From 0fd243a9cc3d8141f523fe1399bf50bdce2ab654 Mon Sep 17 00:00:00 2001 From: Jack Worman Date: Sun, 18 Dec 2022 10:15:15 -0600 Subject: [PATCH] Require trailing commas --- bin/generate_testsuites.php | 10 +- bin/max_used_shortcode.php | 2 +- bin/update-property-map.php | 14 +- examples/TemplateChecker.php | 19 +- examples/TemplateScanner.php | 15 +- examples/plugins/ClassUnqualifier.php | 10 +- examples/plugins/FunctionCasingChecker.php | 16 +- examples/plugins/InternalChecker.php | 8 +- .../plugins/PreventFloatAssignmentChecker.php | 10 +- examples/plugins/SafeArrayKeyChecker.php | 4 +- examples/plugins/StringChecker.php | 20 +- .../echo-checker/EchoChecker.php | 8 +- .../echo-checker/PluginEntryPoint.php | 1 + phpcs.xml | 4 + src/Psalm/CodeLocation.php | 14 +- src/Psalm/CodeLocation/ParseErrorLocation.php | 2 +- src/Psalm/CodeLocation/Raw.php | 2 +- src/Psalm/Codebase.php | 92 ++-- src/Psalm/Config.php | 54 +-- src/Psalm/Config/Creator.php | 24 +- src/Psalm/Config/FileFilter.php | 26 +- src/Psalm/Config/IssueHandler.php | 4 +- src/Psalm/Context.php | 6 +- src/Psalm/DocComment.php | 6 +- src/Psalm/ErrorBaseline.php | 12 +- .../UnpopulatedClasslikeException.php | 2 +- src/Psalm/FileBasedPluginAdapter.php | 2 +- src/Psalm/Internal/Algebra.php | 16 +- .../Internal/Algebra/FormulaGenerator.php | 66 +-- .../Internal/Analyzer/AlgebraAnalyzer.php | 8 +- .../Internal/Analyzer/AttributesAnalyzer.php | 54 +-- src/Psalm/Internal/Analyzer/CanAlias.php | 6 +- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 414 +++++++++--------- .../Internal/Analyzer/ClassLikeAnalyzer.php | 108 ++--- .../Internal/Analyzer/ClosureAnalyzer.php | 28 +- .../Internal/Analyzer/CommentAnalyzer.php | 10 +- src/Psalm/Internal/Analyzer/FileAnalyzer.php | 16 +- .../Internal/Analyzer/FunctionAnalyzer.php | 8 +- .../FunctionLike/ReturnTypeAnalyzer.php | 150 +++---- .../FunctionLike/ReturnTypeCollector.php | 58 +-- .../Analyzer/FunctionLikeAnalyzer.php | 220 +++++----- .../Internal/Analyzer/InterfaceAnalyzer.php | 28 +- .../Internal/Analyzer/MethodAnalyzer.php | 22 +- .../Internal/Analyzer/MethodComparator.php | 182 ++++---- .../Internal/Analyzer/NamespaceAnalyzer.php | 4 +- .../Internal/Analyzer/ProjectAnalyzer.php | 100 ++--- src/Psalm/Internal/Analyzer/ScopeAnalyzer.php | 54 +-- .../Analyzer/Statements/Block/DoAnalyzer.php | 18 +- .../Analyzer/Statements/Block/ForAnalyzer.php | 10 +- .../Statements/Block/ForeachAnalyzer.php | 156 +++---- .../Block/IfConditionalAnalyzer.php | 40 +- .../Statements/Block/IfElse/ElseAnalyzer.php | 30 +- .../Block/IfElse/ElseIfAnalyzer.php | 62 +-- .../Statements/Block/IfElse/IfAnalyzer.php | 60 +-- .../Statements/Block/IfElseAnalyzer.php | 48 +- .../Statements/Block/LoopAnalyzer.php | 62 +-- .../Statements/Block/SwitchAnalyzer.php | 16 +- .../Statements/Block/SwitchCaseAnalyzer.php | 108 ++--- .../Analyzer/Statements/Block/TryAnalyzer.php | 56 +-- .../Statements/Block/WhileAnalyzer.php | 6 +- .../Analyzer/Statements/BreakAnalyzer.php | 8 +- .../Analyzer/Statements/ContinueAnalyzer.php | 10 +- .../Analyzer/Statements/EchoAnalyzer.php | 18 +- .../Statements/Expression/ArrayAnalyzer.php | 68 +-- .../Statements/Expression/AssertionFinder.php | 414 +++++++++--------- .../Assignment/ArrayAssignmentAnalyzer.php | 112 ++--- .../InstancePropertyAssignmentAnalyzer.php | 264 +++++------ .../StaticPropertyAssignmentAnalyzer.php | 64 +-- .../Expression/AssignmentAnalyzer.php | 248 +++++------ .../Expression/BinaryOp/AndAnalyzer.php | 28 +- .../BinaryOp/ArithmeticOpAnalyzer.php | 158 +++---- .../Expression/BinaryOp/CoalesceAnalyzer.php | 6 +- .../Expression/BinaryOp/ConcatAnalyzer.php | 70 +-- .../BinaryOp/NonComparisonOpAnalyzer.php | 12 +- .../Expression/BinaryOp/OrAnalyzer.php | 54 +-- .../Expression/BinaryOpAnalyzer.php | 74 ++-- .../Expression/BitwiseNotAnalyzer.php | 8 +- .../Expression/BooleanNotAnalyzer.php | 2 +- .../Expression/Call/ArgumentAnalyzer.php | 200 ++++----- .../Expression/Call/ArgumentMapPopulator.php | 6 +- .../Expression/Call/ArgumentsAnalyzer.php | 184 ++++---- .../Call/ArrayFunctionArgumentsAnalyzer.php | 112 ++--- .../Call/ClassTemplateParamCollector.php | 32 +- .../Expression/Call/FunctionCallAnalyzer.php | 144 +++--- .../Call/FunctionCallReturnTypeFetcher.php | 98 ++--- .../Call/Method/AtomicMethodCallAnalyzer.php | 92 ++-- .../ExistingAtomicMethodCallAnalyzer.php | 96 ++-- .../Method/MethodCallProhibitionAnalyzer.php | 8 +- .../Call/Method/MethodCallPurityAnalyzer.php | 18 +- .../Method/MethodCallReturnTypeFetcher.php | 106 ++--- .../Call/Method/MethodVisibilityAnalyzer.php | 18 +- .../Call/Method/MissingMethodCallHandler.php | 62 +-- .../Expression/Call/MethodCallAnalyzer.php | 64 +-- .../Call/NamedFunctionCallHandler.php | 70 +-- .../Expression/Call/NewAnalyzer.php | 160 +++---- .../Expression/Call/StaticCallAnalyzer.php | 38 +- .../StaticMethod/AtomicStaticCallAnalyzer.php | 152 +++---- .../ExistingAtomicStaticCallAnalyzer.php | 96 ++-- .../Statements/Expression/CallAnalyzer.php | 126 +++--- .../Statements/Expression/CastAnalyzer.php | 66 +-- .../Expression/ClassConstAnalyzer.php | 146 +++--- .../Statements/Expression/CloneAnalyzer.php | 20 +- .../Statements/Expression/EmptyAnalyzer.php | 8 +- .../Expression/EncapsulatedStringAnalyzer.php | 14 +- .../Statements/Expression/EvalAnalyzer.php | 8 +- .../Statements/Expression/ExitAnalyzer.php | 16 +- .../Expression/ExpressionIdentifier.php | 4 +- .../Expression/Fetch/ArrayFetchAnalyzer.php | 272 ++++++------ .../Fetch/AtomicPropertyFetchAnalyzer.php | 174 ++++---- .../Expression/Fetch/ConstFetchAnalyzer.php | 16 +- .../Fetch/InstancePropertyFetchAnalyzer.php | 62 +-- .../Fetch/StaticPropertyFetchAnalyzer.php | 76 ++-- .../Fetch/VariableFetchAnalyzer.php | 118 ++--- .../Expression/IncDecExpressionAnalyzer.php | 14 +- .../Statements/Expression/IncludeAnalyzer.php | 28 +- .../Expression/InstanceofAnalyzer.php | 8 +- .../Expression/MagicConstAnalyzer.php | 16 +- .../Statements/Expression/MatchAnalyzer.php | 56 +-- .../Expression/NullsafeAnalyzer.php | 10 +- .../Statements/Expression/PrintAnalyzer.php | 14 +- .../Expression/SimpleTypeInferer.php | 64 +-- .../Statements/Expression/TernaryAnalyzer.php | 40 +- .../Expression/UnaryPlusMinusAnalyzer.php | 4 +- .../Statements/Expression/YieldAnalyzer.php | 28 +- .../Expression/YieldFromAnalyzer.php | 2 +- .../Statements/ExpressionAnalyzer.php | 36 +- .../Analyzer/Statements/GlobalAnalyzer.php | 10 +- .../Analyzer/Statements/ReturnAnalyzer.php | 96 ++-- .../Analyzer/Statements/StaticAnalyzer.php | 34 +- .../Analyzer/Statements/ThrowAnalyzer.php | 6 +- .../Analyzer/Statements/UnsetAnalyzer.php | 12 +- .../Statements/UnusedAssignmentRemover.php | 8 +- .../Internal/Analyzer/StatementsAnalyzer.php | 78 ++-- src/Psalm/Internal/Analyzer/TraitAnalyzer.php | 2 +- src/Psalm/Internal/Clause.php | 4 +- src/Psalm/Internal/Cli/LanguageServer.php | 14 +- src/Psalm/Internal/Cli/Psalm.php | 58 +-- src/Psalm/Internal/Cli/Psalter.php | 26 +- src/Psalm/Internal/Cli/Refactor.php | 10 +- src/Psalm/Internal/CliUtils.php | 22 +- src/Psalm/Internal/Codebase/Analyzer.php | 112 ++--- src/Psalm/Internal/Codebase/ClassLikes.php | 204 ++++----- .../Codebase/ConstantTypeResolver.php | 26 +- src/Psalm/Internal/Codebase/Functions.php | 14 +- .../Codebase/InternalCallMapHandler.php | 8 +- src/Psalm/Internal/Codebase/Methods.php | 90 ++-- src/Psalm/Internal/Codebase/Populator.php | 90 ++-- src/Psalm/Internal/Codebase/Properties.php | 26 +- src/Psalm/Internal/Codebase/Reflection.php | 24 +- src/Psalm/Internal/Codebase/Scanner.php | 36 +- .../Internal/Codebase/TaintFlowGraph.php | 44 +- .../Internal/Codebase/VariableUseGraph.php | 6 +- src/Psalm/Internal/DataFlow/DataFlowNode.php | 4 +- src/Psalm/Internal/Diff/AstDiffer.php | 2 +- .../Internal/Diff/ClassStatementsDiffer.php | 4 +- src/Psalm/Internal/Diff/FileDiffer.php | 4 +- .../Internal/Diff/FileStatementsDiffer.php | 8 +- .../Diff/NamespaceStatementsDiffer.php | 4 +- src/Psalm/Internal/ErrorHandler.php | 2 +- .../BuildInfoCollector.php | 2 +- .../ClassDocblockManipulator.php | 2 +- .../FileManipulationBuffer.php | 18 +- .../FunctionDocblockManipulator.php | 18 +- .../PropertyDocblockManipulator.php | 10 +- src/Psalm/Internal/Fork/Pool.php | 4 +- .../LanguageServer/Client/TextDocument.php | 4 +- .../Internal/LanguageServer/ClientHandler.php | 10 +- .../LanguageServer/LanguageClient.php | 4 +- .../LanguageServer/LanguageServer.php | 28 +- .../LanguageServer/ProtocolStreamReader.php | 4 +- .../LanguageServer/Server/TextDocument.php | 22 +- .../Internal/PhpTraverser/CustomTraverser.php | 12 +- .../PhpVisitor/OffsetShifterVisitor.php | 8 +- .../PhpVisitor/ParamReplacementVisitor.php | 10 +- .../PhpVisitor/PartialParserVisitor.php | 20 +- .../Reflector/AttributeResolver.php | 8 +- .../Reflector/ClassLikeDocblockParser.php | 36 +- .../Reflector/ClassLikeNodeScanner.php | 210 ++++----- .../Reflector/ExpressionResolver.php | 36 +- .../Reflector/ExpressionScanner.php | 24 +- .../Reflector/FunctionLikeDocblockParser.php | 48 +- .../Reflector/FunctionLikeDocblockScanner.php | 134 +++--- .../Reflector/FunctionLikeNodeScanner.php | 80 ++-- .../PhpVisitor/Reflector/TypeHintResolver.php | 18 +- .../Internal/PhpVisitor/ReflectorVisitor.php | 26 +- .../PhpVisitor/SimpleNameResolver.php | 6 +- .../PhpVisitor/YieldTypeCollector.php | 4 +- .../PluginManager/Command/DisableCommand.php | 2 +- .../PluginManager/Command/EnableCommand.php | 2 +- .../PluginManager/Command/ShowCommand.php | 8 +- .../Internal/PluginManager/ComposerLock.php | 4 +- .../ClassLikeStorageCacheProvider.php | 2 +- src/Psalm/Internal/Provider/FileProvider.php | 4 +- .../Provider/FileReferenceCacheProvider.php | 8 +- .../Provider/FileReferenceProvider.php | 40 +- .../Provider/FileStorageCacheProvider.php | 2 +- .../Provider/FunctionExistenceProvider.php | 2 +- .../Provider/FunctionParamsProvider.php | 2 +- .../Provider/FunctionReturnTypeProvider.php | 2 +- .../Provider/MethodExistenceProvider.php | 2 +- .../Provider/MethodParamsProvider.php | 2 +- .../Provider/MethodReturnTypeProvider.php | 2 +- .../Provider/MethodVisibilityProvider.php | 2 +- .../Internal/Provider/ParserCacheProvider.php | 6 +- .../Provider/PropertyExistenceProvider.php | 2 +- .../Provider/PropertyTypeProvider.php | 2 +- .../DomDocumentPropertyTypeProvider.php | 2 +- .../Provider/PropertyVisibilityProvider.php | 2 +- src/Psalm/Internal/Provider/Providers.php | 2 +- .../ArrayChunkReturnTypeProvider.php | 4 +- .../ArrayColumnReturnTypeProvider.php | 10 +- .../ArrayCombineReturnTypeProvider.php | 6 +- .../ArrayFillKeysReturnTypeProvider.php | 4 +- .../ArrayFillReturnTypeProvider.php | 14 +- .../ArrayFilterReturnTypeProvider.php | 28 +- .../ArrayMapReturnTypeProvider.php | 62 +-- .../ArrayMergeReturnTypeProvider.php | 20 +- .../ArrayPadReturnTypeProvider.php | 2 +- ...rayPointerAdjustmentReturnTypeProvider.php | 2 +- .../ArrayReduceReturnTypeProvider.php | 34 +- .../ArrayReverseReturnTypeProvider.php | 2 +- .../BasenameReturnTypeProvider.php | 2 +- .../ClosureFromCallableReturnTypeProvider.php | 4 +- .../DirnameReturnTypeProvider.php | 2 +- .../ExplodeReturnTypeProvider.php | 8 +- .../FilterVarReturnTypeProvider.php | 8 +- .../FirstArgStringReturnTypeProvider.php | 2 +- .../GetObjectVarsReturnTypeProvider.php | 8 +- .../ImagickPixelColorReturnTypeProvider.php | 12 +- .../InArrayReturnTypeProvider.php | 2 +- .../IteratorToArrayReturnTypeProvider.php | 4 +- .../MktimeReturnTypeProvider.php | 2 +- .../ParseUrlReturnTypeProvider.php | 10 +- .../PdoStatementReturnTypeProvider.php | 16 +- .../PdoStatementSetFetchMode.php | 12 +- .../StrReplaceReturnTypeProvider.php | 4 +- .../StrTrReturnTypeProvider.php | 6 +- .../VersionCompareReturnTypeProvider.php | 2 +- .../Internal/Provider/StatementsProvider.php | 26 +- src/Psalm/Internal/Scanner/FileScanner.php | 4 +- .../Internal/Scanner/PhpStormMetaScanner.php | 24 +- src/Psalm/Internal/Type/ArrayType.php | 4 +- .../Internal/Type/AssertionReconciler.php | 140 +++--- .../Type/Comparator/ArrayTypeComparator.php | 12 +- .../Type/Comparator/AtomicTypeComparator.php | 68 +-- .../Comparator/CallableTypeComparator.php | 48 +- .../Comparator/ClassLikeStringComparator.php | 6 +- .../Type/Comparator/GenericTypeComparator.php | 8 +- .../Comparator/IntegerRangeComparator.php | 6 +- .../Type/Comparator/KeyedArrayComparator.php | 12 +- .../Type/Comparator/ObjectComparator.php | 22 +- .../Type/Comparator/ScalarTypeComparator.php | 12 +- .../Type/Comparator/UnionTypeComparator.php | 14 +- .../Type/NegatedAssertionReconciler.php | 26 +- src/Psalm/Internal/Type/ParseTreeCreator.php | 36 +- .../Type/SimpleAssertionReconciler.php | 168 +++---- .../Type/SimpleNegatedAssertionReconciler.php | 138 +++--- .../Type/TemplateInferredTypeReplacer.php | 72 +-- .../Type/TemplateStandinTypeReplacer.php | 108 ++--- src/Psalm/Internal/Type/TypeCombiner.php | 88 ++-- src/Psalm/Internal/Type/TypeExpander.php | 70 +-- src/Psalm/Internal/Type/TypeParser.php | 144 +++--- src/Psalm/Internal/Type/TypeTokenizer.php | 4 +- .../TypeVisitor/ClasslikeReplacer.php | 4 +- .../TypeVisitor/TemplateTypeCollector.php | 4 +- .../Internal/TypeVisitor/TypeChecker.php | 48 +- .../Internal/TypeVisitor/TypeLocalizer.php | 6 +- .../Internal/TypeVisitor/TypeScanner.php | 6 +- src/Psalm/Issue/CodeIssue.php | 6 +- src/Psalm/Issue/TaintedInput.php | 2 +- src/Psalm/IssueBuffer.php | 24 +- src/Psalm/Plugin/DynamicFunctionStorage.php | 2 +- src/Psalm/Plugin/Shepherd.php | 6 +- src/Psalm/PluginFileExtensionsSocket.php | 12 +- src/Psalm/Progress/DefaultProgress.php | 2 +- src/Psalm/Progress/LongProgress.php | 2 +- src/Psalm/Report.php | 2 +- src/Psalm/Report/CheckstyleReport.php | 2 +- src/Psalm/Report/CodeClimateReport.php | 2 +- src/Psalm/Report/EmacsReport.php | 2 +- src/Psalm/Report/GithubActionsReport.php | 10 +- src/Psalm/Report/JsonReport.php | 2 +- src/Psalm/Report/PylintReport.php | 4 +- src/Psalm/Report/SarifReport.php | 4 +- src/Psalm/Report/TextReport.php | 2 +- src/Psalm/Report/XmlReport.php | 10 +- src/Psalm/Storage/FunctionLikeStorage.php | 4 +- src/Psalm/Storage/Possibilities.php | 4 +- src/Psalm/Type.php | 42 +- src/Psalm/Type/Atomic.php | 22 +- src/Psalm/Type/Atomic/CallableTrait.php | 10 +- src/Psalm/Type/Atomic/GenericTrait.php | 18 +- .../Type/Atomic/HasIntersectionTrait.php | 12 +- src/Psalm/Type/Atomic/TArray.php | 4 +- src/Psalm/Type/Atomic/TCallable.php | 6 +- src/Psalm/Type/Atomic/TCallableList.php | 6 +- src/Psalm/Type/Atomic/TClassString.php | 4 +- src/Psalm/Type/Atomic/TClassStringMap.php | 14 +- src/Psalm/Type/Atomic/TClosure.php | 8 +- src/Psalm/Type/Atomic/TConditional.php | 4 +- src/Psalm/Type/Atomic/TGenericObject.php | 12 +- src/Psalm/Type/Atomic/TIterable.php | 12 +- src/Psalm/Type/Atomic/TKeyOf.php | 4 +- src/Psalm/Type/Atomic/TKeyedArray.php | 16 +- src/Psalm/Type/Atomic/TList.php | 8 +- src/Psalm/Type/Atomic/TLiteralClassString.php | 2 +- src/Psalm/Type/Atomic/TNamedObject.php | 10 +- src/Psalm/Type/Atomic/TNonEmptyList.php | 4 +- .../Type/Atomic/TObjectWithProperties.php | 24 +- src/Psalm/Type/Atomic/TPropertiesOf.php | 2 +- src/Psalm/Type/Atomic/TTemplateKeyOf.php | 4 +- src/Psalm/Type/Atomic/TTemplateParam.php | 4 +- .../Type/Atomic/TTemplatePropertiesOf.php | 4 +- src/Psalm/Type/Atomic/TTemplateValueOf.php | 4 +- src/Psalm/Type/Atomic/TTypeAlias.php | 6 +- src/Psalm/Type/Atomic/TValueOf.php | 2 +- src/Psalm/Type/MutableUnion.php | 2 +- src/Psalm/Type/Reconciler.php | 80 ++-- src/Psalm/Type/UnionTrait.php | 26 +- tests/AlgebraTest.php | 30 +- tests/AnnotationTest.php | 60 +-- tests/ArgTest.php | 44 +- tests/ArrayAccessTest.php | 72 +-- tests/ArrayAssignmentTest.php | 92 ++-- tests/ArrayFunctionCallTest.php | 108 ++--- tests/ArrayKeysTest.php | 16 +- tests/AssertAnnotationTest.php | 90 ++-- tests/AssignmentTest.php | 2 +- tests/AttributeTest.php | 16 +- tests/BadFormatTest.php | 12 +- tests/BinaryOperationTest.php | 40 +- tests/ByIssueLevelAndTypeReportTest.php | 2 +- tests/CallableTest.php | 34 +- tests/ClassLikeStringTest.php | 20 +- tests/ClassScopeTest.php | 2 +- tests/ClassTest.php | 34 +- tests/ClosureTest.php | 68 +-- tests/CodebaseTest.php | 14 +- .../GetMemoryLimitInBytesTest.php | 2 +- tests/ComposerLockTest.php | 20 +- tests/Config/ConfigFileTest.php | 16 +- tests/Config/ConfigTest.php | 348 +++++++-------- tests/Config/CreatorTest.php | 2 +- .../CustomArrayMapFunctionStorageProvider.php | 14 +- tests/Config/PluginTest.php | 148 +++---- tests/ConstantTest.php | 76 ++-- tests/CoreStubsTest.php | 8 +- tests/DeprecatedAnnotationTest.php | 6 +- tests/DocCommentTest.php | 12 +- tests/DocblockInheritanceTest.php | 8 +- tests/DocumentationTest.php | 10 +- tests/EndToEnd/PsalmEndToEndTest.php | 18 +- tests/EnumTest.php | 26 +- tests/ErrorBaselineTest.php | 54 +-- tests/ExtendsFinalClassTest.php | 4 +- tests/ExtensionRequirementTest.php | 12 +- tests/FileDiffTest.php | 20 +- .../ClassConstantMoveTest.php | 6 +- tests/FileManipulation/ClassMoveTest.php | 6 +- .../FileManipulationTestCase.php | 8 +- tests/FileManipulation/MethodMoveTest.php | 6 +- tests/FileManipulation/NamespaceMoveTest.php | 6 +- tests/FileManipulation/PropertyMoveTest.php | 6 +- .../ReturnTypeManipulationTest.php | 2 +- tests/FileReferenceTest.php | 8 +- tests/FileUpdates/AnalyzedMethodTest.php | 14 +- tests/FileUpdates/CachedStorageTest.php | 4 +- tests/FileUpdates/ErrorAfterUpdateTest.php | 4 +- tests/FileUpdates/ErrorFixTest.php | 14 +- tests/FileUpdates/TemporaryUpdateTest.php | 12 +- tests/ForbiddenCodeTest.php | 64 +-- tests/FunctionCallTest.php | 70 +-- tests/FunctionLikeDocblockParserTest.php | 20 +- tests/GeneratorTest.php | 16 +- tests/IfThisIsTest.php | 20 +- tests/ImmutableAnnotationTest.php | 22 +- tests/ImplementationRequirementTest.php | 14 +- tests/IntRangeTest.php | 46 +- tests/InterfaceTest.php | 8 +- tests/Internal/CallMapTest.php | 36 +- tests/Internal/CliUtilsTest.php | 6 +- .../ClassConstantByWildcardResolverTest.php | 4 +- .../Codebase/InternalCallMapHandlerTest.php | 8 +- tests/InternalAnnotationTest.php | 2 +- tests/IssueBufferTest.php | 12 +- tests/IssueSuppressionTest.php | 22 +- tests/JsonOutputTest.php | 6 +- tests/KeyOfArrayTest.php | 26 +- tests/LanguageServer/CompletionTest.php | 108 ++--- tests/LanguageServer/FileMapTest.php | 26 +- tests/LanguageServer/SymbolLookupTest.php | 32 +- tests/Loop/DoTest.php | 10 +- tests/Loop/ForTest.php | 10 +- tests/Loop/ForeachTest.php | 18 +- tests/Loop/WhileTest.php | 38 +- tests/MagicMethodAnnotationTest.php | 60 +-- tests/MagicPropertyTest.php | 16 +- tests/MatchTest.php | 18 +- tests/MethodCallTest.php | 84 ++-- tests/MethodMutationTest.php | 16 +- tests/MethodSignatureTest.php | 54 +-- tests/MixinAnnotationTest.php | 40 +- tests/NativeIntersectionsTest.php | 14 +- tests/NativeUnionsTest.php | 12 +- tests/ProjectCheckerTest.php | 64 +-- tests/PropertiesOfTest.php | 18 +- tests/PropertyTypeTest.php | 108 ++--- tests/PsalmPluginTest.php | 2 +- tests/PureAnnotationTest.php | 34 +- tests/ReadonlyPropertyTest.php | 16 +- tests/ReferenceConstraintTest.php | 6 +- tests/ReportOutputTest.php | 414 +++++++++--------- .../ReturnTypeProvider/GetObjectVarsTest.php | 16 +- tests/ReturnTypeTest.php | 30 +- tests/StubTest.php | 208 ++++----- tests/SuperGlobalsTest.php | 4 +- tests/SwitchTypeTest.php | 30 +- tests/TaintTest.php | 90 ++-- tests/Template/ClassStringMapTest.php | 6 +- .../Template/ClassTemplateCovarianceTest.php | 16 +- tests/Template/ClassTemplateExtendsTest.php | 174 ++++---- tests/Template/ClassTemplateTest.php | 132 +++--- tests/Template/ConditionalReturnTypeTest.php | 76 ++-- .../FunctionClassStringTemplateTest.php | 12 +- tests/Template/FunctionTemplateAssertTest.php | 26 +- tests/Template/FunctionTemplateTest.php | 98 ++--- tests/Template/KeyOfTemplateTest.php | 16 +- tests/Template/NestedTemplateTest.php | 10 +- tests/Template/PropertiesOfTemplateTest.php | 22 +- tests/Template/TraitTemplateTest.php | 18 +- tests/Template/ValueOfTemplateTest.php | 12 +- tests/TestCase.php | 6 +- tests/TestConfig.php | 2 +- tests/ThisOutTest.php | 6 +- tests/ThrowsAnnotationTest.php | 42 +- tests/ThrowsInGlobalScopeTest.php | 22 +- tests/ToStringTest.php | 24 +- tests/TraceTest.php | 2 +- tests/TraitTest.php | 12 +- tests/TryCatchTest.php | 30 +- tests/TypeAnnotationTest.php | 22 +- tests/TypeCombinationTest.php | 54 +-- tests/TypeComparatorTest.php | 16 +- tests/TypeParseTest.php | 126 +++--- .../TypeReconciliation/ArrayKeyExistsTest.php | 36 +- .../AssignmentInConditionalTest.php | 38 +- tests/TypeReconciliation/ConditionalTest.php | 148 +++---- tests/TypeReconciliation/EmptyTest.php | 14 +- tests/TypeReconciliation/InArrayTest.php | 10 +- tests/TypeReconciliation/IssetTest.php | 38 +- tests/TypeReconciliation/ReconcilerTest.php | 16 +- .../RedundantConditionTest.php | 30 +- tests/TypeReconciliation/TypeAlgebraTest.php | 34 +- tests/TypeReconciliation/TypeTest.php | 46 +- tests/TypeReconciliation/ValueTest.php | 36 +- tests/UnresolvableIncludeTest.php | 4 +- tests/UnusedCodeTest.php | 58 +-- tests/UnusedVariableTest.php | 208 ++++----- tests/ValueOfTest.php | 24 +- tests/VariadicTest.php | 12 +- 460 files changed, 8470 insertions(+), 8445 deletions(-) diff --git a/bin/generate_testsuites.php b/bin/generate_testsuites.php index 195c418137d..0ff6ad8a8ba 100644 --- a/bin/generate_testsuites.php +++ b/bin/generate_testsuites.php @@ -17,12 +17,12 @@ new RecursiveIteratorIterator( new RecursiveDirectoryIterator( 'tests', - FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS + FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS, ), - RecursiveIteratorIterator::LEAVES_ONLY + RecursiveIteratorIterator::LEAVES_ONLY, ), - '/.*Test.php$/' - ) + '/.*Test.php$/', + ), ); mt_srand(4); // chosen by fair dice roll. @@ -31,7 +31,7 @@ $order = array_map( fn(): int => mt_rand(), - $files + $files, ); array_multisort($order, $files); diff --git a/bin/max_used_shortcode.php b/bin/max_used_shortcode.php index ff30f610b84..3a0b07cce4a 100755 --- a/bin/max_used_shortcode.php +++ b/bin/max_used_shortcode.php @@ -13,7 +13,7 @@ function ($issue_type): int { /** @var int */ return $issue_class::SHORTCODE; }, - $issue_types + $issue_types, ); echo 'Max used shortcode: ' . max($shortcodes) . PHP_EOL; diff --git a/bin/update-property-map.php b/bin/update-property-map.php index b26a6e01dbe..1fefe51cfde 100755 --- a/bin/update-property-map.php +++ b/bin/update-property-map.php @@ -25,7 +25,7 @@ $lexer = new PhpParser\Lexer\Emulative(); $parser = (new PhpParser\ParserFactory)->create( PhpParser\ParserFactory::PREFER_PHP7, - $lexer + $lexer, ); $traverser = new PhpParser\NodeTraverser(); $traverser->addVisitor(new PhpParser\NodeVisitor\NameResolver); @@ -48,7 +48,7 @@ function extractClassesFromStatements(array $statements): array $stubbedClasses = []; foreach (new RecursiveDirectoryIterator( __DIR__ . '/../stubs', - FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS + FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS, ) as $file) { if (is_dir($file)) { continue; @@ -72,11 +72,11 @@ function extractClassesFromStatements(array $statements): array new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $docDir, - FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS + FilesystemIterator::CURRENT_AS_PATHNAME|FilesystemIterator::SKIP_DOTS, ), - RecursiveIteratorIterator::LEAVES_ONLY + RecursiveIteratorIterator::LEAVES_ONLY, ), - '/.*.xml$/' + '/.*.xml$/', ); $classes = require_once dirname(__DIR__) . '/dictionaries/ManualPropertyMap.php'; @@ -100,7 +100,7 @@ function extractClassesFromStatements(array $statements): array $file, get_class($exception), $exception->getMessage(), - implode("\n", array_map(fn(LibXMLError $error): string => $error->message, libxml_get_errors())) + implode("\n", array_map(fn(LibXMLError $error): string => $error->message, libxml_get_errors())), ); libxml_clear_errors(); continue; @@ -186,5 +186,5 @@ function serializeArray(array $array, string $prefix): string return $serialized; -EOF +EOF, ); diff --git a/examples/TemplateChecker.php b/examples/TemplateChecker.php index f048d9b1a49..55e65d2300f 100644 --- a/examples/TemplateChecker.php +++ b/examples/TemplateChecker.php @@ -1,4 +1,5 @@ fq_class_name, '__construct'), $this_context, $this->getRootFilePath(), - $this->getRootFileName() + $this->getRootFileName(), ); $this_context->vars_in_scope['$this'] = new Union([new TNamedObject($class_storage->name)]); @@ -119,7 +127,7 @@ private function checkMethod(MethodIdentifier $method_id, PhpParser\Node $stmt, $method_id, $this_context, $this->getRootFilePath(), - $this->getRootFileName() + $this->getRootFileName(), ); $view_context = new Context(); @@ -139,7 +147,6 @@ private function checkMethod(MethodIdentifier $method_id, PhpParser\Node $stmt, /** * @param array $stmts - * */ protected function checkWithViewClass(Context $context, array $stmts): void { @@ -169,7 +176,7 @@ protected function checkWithViewClass(Context $context, array $stmts): void $statements_source = new StatementsAnalyzer( $view_method_analyzer, - new NodeDataProvider() + new NodeDataProvider(), ); $statements_source->analyze($pseudo_method_stmts, $context); diff --git a/examples/TemplateScanner.php b/examples/TemplateScanner.php index 2ed2caae02f..d177f80e6b8 100644 --- a/examples/TemplateScanner.php +++ b/examples/TemplateScanner.php @@ -1,32 +1,33 @@ statements_provider->getStatementsForFile( $file_storage->file_path, 7_04_00, - $progress + $progress, ); if ($stmts === []) { @@ -53,7 +54,7 @@ public function scan( $codebase->scanner->queueClassLikeForScanning( $fq_class_name, - true + true, ); } } diff --git a/examples/plugins/ClassUnqualifier.php b/examples/plugins/ClassUnqualifier.php index c0926ddc55a..3f4f14f517a 100644 --- a/examples/plugins/ClassUnqualifier.php +++ b/examples/plugins/ClassUnqualifier.php @@ -1,14 +1,16 @@ $f[0], - $type_tokens - ) + $type_tokens, + ), ); if ($new_candidate_type !== $candidate_type) { diff --git a/examples/plugins/FunctionCasingChecker.php b/examples/plugins/FunctionCasingChecker.php index 3d8eaa02fb8..9fb1011e1d8 100644 --- a/examples/plugins/FunctionCasingChecker.php +++ b/examples/plugins/FunctionCasingChecker.php @@ -5,18 +5,18 @@ use Exception; use PhpParser; use Psalm\CodeLocation; +use Psalm\Internal\Analyzer\StatementsAnalyzer; +use Psalm\Internal\MethodIdentifier; use Psalm\Issue\PluginIssue; use Psalm\IssueBuffer; use Psalm\Plugin\EventHandler\AfterFunctionCallAnalysisInterface; use Psalm\Plugin\EventHandler\AfterMethodCallAnalysisInterface; use Psalm\Plugin\EventHandler\Event\AfterFunctionCallAnalysisEvent; use Psalm\Plugin\EventHandler\Event\AfterMethodCallAnalysisEvent; -use Psalm\Internal\Analyzer\StatementsAnalyzer; -use Psalm\Internal\MethodIdentifier; +use function end; use function explode; use function strtolower; -use function end; /** * Checks that functions and methods are correctly-cased @@ -50,9 +50,9 @@ public static function afterMethodCallAnalysis(AfterMethodCallAnalysisEvent $eve IssueBuffer::maybeAdd( new IncorrectFunctionCasing( 'Function is incorrectly cased, expecting ' . $function_storage->cased_name, - new CodeLocation($statements_source, $expr->name) + new CodeLocation($statements_source, $expr->name), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } catch (Exception $e) { @@ -75,7 +75,7 @@ public static function afterFunctionCallAnalysis(AfterFunctionCallAnalysisEvent $statements_source instanceof StatementsAnalyzer ? $statements_source : null, - strtolower($function_id) + strtolower($function_id), ); if (!$function_storage->cased_name) { @@ -88,9 +88,9 @@ public static function afterFunctionCallAnalysis(AfterFunctionCallAnalysisEvent IssueBuffer::maybeAdd( new IncorrectFunctionCasing( 'Function is incorrectly cased, expecting ' . $function_storage->cased_name, - new CodeLocation($statements_source, $expr->name) + new CodeLocation($statements_source, $expr->name), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } catch (Exception $e) { diff --git a/examples/plugins/InternalChecker.php b/examples/plugins/InternalChecker.php index d5a701dcc6d..1ae5d8afee9 100644 --- a/examples/plugins/InternalChecker.php +++ b/examples/plugins/InternalChecker.php @@ -15,7 +15,7 @@ class InternalChecker implements AfterClassLikeAnalysisInterface { /** @return null|false */ - public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event) + public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event): ?bool { $storage = $event->getClasslikeStorage(); if (!$storage->internal @@ -26,10 +26,10 @@ public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event new InternalClass( "Class $storage->name must be marked @internal", $storage->location, - $storage->name + $storage->name, ), $event->getStatementsSource()->getSuppressedIssues(), - true + true, ); if (!$event->getCodebase()->alter_code) { @@ -50,7 +50,7 @@ public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event $parsed_docblock->tags['internal'] = ['']; $new_docblock_content = $parsed_docblock->render(''); $event->setFileReplacements([ - new FileManipulation($docblock_start, $docblock_end, $new_docblock_content) + new FileManipulation($docblock_start, $docblock_end, $new_docblock_content), ]); } return null; diff --git a/examples/plugins/PreventFloatAssignmentChecker.php b/examples/plugins/PreventFloatAssignmentChecker.php index 412adb253af..18b5630efbc 100644 --- a/examples/plugins/PreventFloatAssignmentChecker.php +++ b/examples/plugins/PreventFloatAssignmentChecker.php @@ -19,7 +19,8 @@ class PreventFloatAssignmentChecker implements AfterExpressionAnalysisInterface * * @return null */ - public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $event): ?bool { + public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $event): ?bool + { $expr = $event->getExpr(); $statements_source = $event->getStatementsSource(); if ($expr instanceof PhpParser\Node\Expr\Assign @@ -29,9 +30,9 @@ public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $eve IssueBuffer::maybeAdd( new NoFloatAssignment( 'Don’t assign to floats', - new CodeLocation($statements_source, $expr) + new CodeLocation($statements_source, $expr), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } @@ -39,5 +40,6 @@ public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $eve } } -class NoFloatAssignment extends PluginIssue { +class NoFloatAssignment extends PluginIssue +{ } diff --git a/examples/plugins/SafeArrayKeyChecker.php b/examples/plugins/SafeArrayKeyChecker.php index e90759e1aba..5ea69772535 100644 --- a/examples/plugins/SafeArrayKeyChecker.php +++ b/examples/plugins/SafeArrayKeyChecker.php @@ -1,4 +1,5 @@ */ - public static function removeTaints(AddRemoveTaintsEvent $event): array { + public static function removeTaints(AddRemoveTaintsEvent $event): array + { $item = $event->getExpr(); $statements_analyzer = $event->getStatementsSource(); if (!($item instanceof ArrayItem) || !($statements_analyzer instanceof StatementsAnalyzer)) { diff --git a/examples/plugins/StringChecker.php b/examples/plugins/StringChecker.php index 53cdf129949..453a91bad7d 100644 --- a/examples/plugins/StringChecker.php +++ b/examples/plugins/StringChecker.php @@ -1,9 +1,8 @@ getExpr(); $statements_source = $event->getStatementsSource(); $codebase = $event->getCodebase(); @@ -34,9 +40,9 @@ public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $eve new InvalidClass( 'Use ::class constants when representing class names', new CodeLocation($statements_source, $expr), - $absolute_class + $absolute_class, ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } elseif ($expr instanceof PhpParser\Node\Expr\BinaryOp\Concat @@ -57,9 +63,9 @@ public static function afterExpressionAnalysis(AfterExpressionAnalysisEvent $eve new UndefinedMethod( 'Method ' . $method_id . ' does not exist', new CodeLocation($statements_source, $expr), - $method_id + $method_id, ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), )) { return false; } diff --git a/examples/plugins/composer-based/echo-checker/EchoChecker.php b/examples/plugins/composer-based/echo-checker/EchoChecker.php index 3a9ee1d1232..668206c26e3 100644 --- a/examples/plugins/composer-based/echo-checker/EchoChecker.php +++ b/examples/plugins/composer-based/echo-checker/EchoChecker.php @@ -31,9 +31,9 @@ public static function afterStatementAnalysis(AfterStatementAnalysisEvent $event new ArgumentTypeCoercion( 'Echo requires an unescaped string, ' . $expr_type . ' provided', new CodeLocation($statements_source, $expr), - 'echo' + 'echo', ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); continue; } @@ -48,9 +48,9 @@ public static function afterStatementAnalysis(AfterStatementAnalysisEvent $event new ArgumentTypeCoercion( 'Echo requires an unescaped string, ' . $expr_type . ' provided', new CodeLocation($statements_source, $expr), - 'echo' + 'echo', ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } diff --git a/examples/plugins/composer-based/echo-checker/PluginEntryPoint.php b/examples/plugins/composer-based/echo-checker/PluginEntryPoint.php index 075b260d9e6..4d6102281e4 100644 --- a/examples/plugins/composer-based/echo-checker/PluginEntryPoint.php +++ b/examples/plugins/composer-based/echo-checker/PluginEntryPoint.php @@ -1,4 +1,5 @@ src/Psalm/Internal/* tests/* + + + + diff --git a/src/Psalm/CodeLocation.php b/src/Psalm/CodeLocation.php index c962cdb2804..04790dfcc73 100644 --- a/src/Psalm/CodeLocation.php +++ b/src/Psalm/CodeLocation.php @@ -179,7 +179,7 @@ private function calculateRealLocation(): void $preview_end = strpos( $file_contents, "\n", - $search_limit + $search_limit, ); } else { $preview_end = false; @@ -201,8 +201,8 @@ private function calculateRealLocation(): void mb_strcut( $file_contents, $this->preview_start, - $this->selection_start - $this->preview_start - 1 - ) + $this->selection_start - $this->preview_start - 1, + ), ); $preview_offset = 0; @@ -268,7 +268,7 @@ private function calculateRealLocation(): void $preview_snippet = mb_strcut( $file_contents, $this->selection_start, - $this->selection_end - $this->selection_start + $this->selection_end - $this->selection_start, ); if ($this->text) { @@ -279,7 +279,7 @@ private function calculateRealLocation(): void if (!isset($matches[1]) || $matches[1][1] === -1) { throw new LogicException( "Failed to match anything to 1st capturing group, " - . "or regex doesn't contain 1st capturing group, regex type " . $this->regex_type + . "or regex doesn't contain 1st capturing group, regex type " . $this->regex_type, ); } $this->selection_start = $this->selection_start + $matches[1][1]; @@ -291,7 +291,7 @@ private function calculateRealLocation(): void $this->preview_start = (int)strrpos( $file_contents, "\n", - min($this->preview_start, $this->selection_start) - strlen($file_contents) + min($this->preview_start, $this->selection_start) - strlen($file_contents), ) + 1; $this->selection_start = max($this->preview_start, $this->selection_start); @@ -301,7 +301,7 @@ private function calculateRealLocation(): void $this->preview_end = (int)strrpos( $file_contents, "\n", - $this->selection_end + 200 - strlen($file_contents) + $this->selection_end + 200 - strlen($file_contents), ); // if the line is over 200 characters long diff --git a/src/Psalm/CodeLocation/ParseErrorLocation.php b/src/Psalm/CodeLocation/ParseErrorLocation.php index bafe08545fc..1714ff7fead 100644 --- a/src/Psalm/CodeLocation/ParseErrorLocation.php +++ b/src/Psalm/CodeLocation/ParseErrorLocation.php @@ -30,7 +30,7 @@ public function __construct( $this->preview_start = $this->file_start; $this->raw_line_number = substr_count( substr($file_contents, 0, $this->file_start), - "\n" + "\n", ) + 1; } } diff --git a/src/Psalm/CodeLocation/Raw.php b/src/Psalm/CodeLocation/Raw.php index e3569932372..30d68d2f900 100644 --- a/src/Psalm/CodeLocation/Raw.php +++ b/src/Psalm/CodeLocation/Raw.php @@ -28,7 +28,7 @@ public function __construct( $this->preview_start = $this->file_start; $this->raw_line_number = substr_count( substr($file_contents, 0, $this->file_start), - "\n" + "\n", ) + 1; } } diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php index 9af83cd0fa6..2e51cd4975a 100644 --- a/src/Psalm/Codebase.php +++ b/src/Psalm/Codebase.php @@ -339,7 +339,7 @@ public function __construct( $providers->file_provider, $reflection, $providers->file_reference_provider, - $progress + $progress, ); $this->loadAnalyzer(); @@ -351,19 +351,19 @@ public function __construct( $providers->classlike_storage_provider, $providers->file_reference_provider, $providers->statements_provider, - $this->scanner + $this->scanner, ); $this->properties = new Properties( $providers->classlike_storage_provider, $providers->file_reference_provider, - $this->classlikes + $this->classlikes, ); $this->methods = new Methods( $providers->classlike_storage_provider, $providers->file_reference_provider, - $this->classlikes + $this->classlikes, ); $this->populator = new Populator( @@ -371,7 +371,7 @@ public function __construct( $providers->file_storage_provider, $this->classlikes, $providers->file_reference_provider, - $progress + $progress, ); $this->loadAnalyzer(); @@ -383,7 +383,7 @@ private function loadAnalyzer(): void $this->config, $this->file_provider, $this->file_storage_provider, - $this->progress + $this->progress, ); } @@ -514,7 +514,7 @@ public function getStatementsForFile(string $file_path): array return $this->statements_provider->getStatementsForFile( $file_path, $this->analysis_php_version_id, - $this->progress + $this->progress, ); } @@ -538,7 +538,7 @@ public function exhumeClassLikeStorage(string $fq_classlike_name, string $file_p $storage = $this->classlike_storage_provider->exhume( $fq_classlike_name, $file_path, - $file_contents + $file_contents, ); if ($storage->is_trait) { @@ -596,7 +596,7 @@ public function findReferencesToProperty(string $property_id): array [$fq_class_name, $property_name] = explode('::', $property_id); return $this->file_reference_provider->getClassPropertyLocations( - strtolower($fq_class_name) . '::' . $property_name + strtolower($fq_class_name) . '::' . $property_name, ); } @@ -626,7 +626,7 @@ public function getClosureStorage(string $file_path, string $closure_id): Functi } throw new UnexpectedValueException( - 'Expecting ' . $closure_id . ' to have storage in ' . $file_path + 'Expecting ' . $closure_id . ' to have storage in ' . $file_path, ); } @@ -666,7 +666,7 @@ public function classOrInterfaceExists( $fq_class_name, $code_location, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); } @@ -683,7 +683,7 @@ public function classOrInterfaceOrEnumExists( $fq_class_name, $code_location, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); } @@ -706,7 +706,7 @@ public function classExists( $fq_class_name, $code_location, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); } @@ -739,7 +739,7 @@ public function interfaceExists( $fq_interface_name, $code_location, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); } @@ -754,7 +754,7 @@ public function interfaceExtends(string $interface_name, string $possible_parent public function getParentInterfaces(string $fq_interface_name): array { return $this->classlikes->getParentInterfaces( - $this->classlikes->getUnAliasedName($fq_interface_name) + $this->classlikes->getUnAliasedName($fq_interface_name), ); } @@ -826,7 +826,7 @@ public function methodExists( null, $file_path, true, - $is_used + $is_used, ); } @@ -857,7 +857,7 @@ public function getMethodReturnType($method_id, ?string &$self_class, array $cal MethodIdentifier::wrap($method_id), $self_class, null, - $call_args + $call_args, ); } @@ -878,7 +878,7 @@ public function getMethodReturnTypeLocation( ): ?CodeLocation { return $this->methods->getMethodReturnTypeLocation( MethodIdentifier::wrap($method_id), - $defined_location + $defined_location, ); } @@ -1015,7 +1015,7 @@ public function getSymbolInformation(string $file_path, string $symbol): ?array $class_constants = $this->classlikes->getConstantsForClass( $fq_classlike_name, - ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_PRIVATE, ); if (!isset($class_constants[$const_name])) { @@ -1075,7 +1075,7 @@ public function getSymbolInformation(string $file_path, string $symbol): ?array $namespace_constants = NamespaceAnalyzer::getConstantsForNamespace( $namespace_name, - ReflectionProperty::IS_PUBLIC + ReflectionProperty::IS_PUBLIC, ); if (isset($namespace_constants[$const_name])) { $type = $namespace_constants[$const_name]; @@ -1113,7 +1113,7 @@ public function getSymbolLocation(string $file_path, string $symbol): ?CodeLocat $file_path, $this->config->shortenFileName($file_path), (int) $symbol_parts[0], - (int) $symbol_parts[1] + (int) $symbol_parts[1], ); } @@ -1146,7 +1146,7 @@ public function getSymbolLocation(string $file_path, string $symbol): ?CodeLocat $class_constants = $this->classlikes->getConstantsForClass( $fq_classlike_name, - ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_PRIVATE, ); if (!isset($class_constants[$const_name])) { @@ -1229,7 +1229,7 @@ public function getReferenceAtPosition(string $file_path, Position $position): ? $range = new Range( self::getPositionFromOffset($reference_start_pos, $file_contents), - self::getPositionFromOffset($reference_end_pos, $file_contents) + self::getPositionFromOffset($reference_end_pos, $file_contents), ); return [$reference, $range]; @@ -1283,7 +1283,7 @@ public function getFunctionArgumentAtPosition(string $file_path, Position $posit $range = new Range( self::getPositionFromOffset($start_pos, $file_contents), - self::getPositionFromOffset($end_pos, $file_contents) + self::getPositionFromOffset($end_pos, $file_contents), ); return [$reference, $argument_number, $range]; @@ -1319,7 +1319,7 @@ public function getSignatureInformation( null, strtolower($function_symbol), dirname($file_path), - $file_path + $file_path, ); } else { $function_storage = $this->functions->getStorage(null, strtolower($function_symbol)); @@ -1352,7 +1352,7 @@ public function getSignatureInformation( strlen($signature_label), strlen($signature_label) + strlen($parameter_label), ], - $param->description ?? null + $param->description ?? null, ); $signature_label .= $parameter_label; @@ -1367,7 +1367,7 @@ public function getSignatureInformation( return new SignatureInformation( $signature_label, $parameters, - $signature_documentation + $signature_documentation, ); } @@ -1514,7 +1514,7 @@ public function getCompletionItemsForClassishThing(string $type_string, string $ null, new Command('Trigger parameter hints', 'editor.action.triggerParameterHints'), null, - 2 + 2, ); $completion_item->insertTextFormat = InsertTextFormat::SNIPPET; @@ -1525,7 +1525,7 @@ public function getCompletionItemsForClassishThing(string $type_string, string $ foreach ($class_storage->declaring_property_ids as $property_name => $declaring_class) { $property_storage = $this->properties->getStorage( - $declaring_class . '::$' . $property_name + $declaring_class . '::$' . $property_name, ); if ($property_storage->is_static || $gap === '->') { @@ -1536,7 +1536,7 @@ public function getCompletionItemsForClassishThing(string $type_string, string $ $property_storage->description, (string)$property_storage->visibility, $property_name, - ($gap === '::' ? '$' : '') . $property_name + ($gap === '::' ? '$' : '') . $property_name, ); } } @@ -1549,7 +1549,7 @@ public function getCompletionItemsForClassishThing(string $type_string, string $ $const->description, null, $const_name, - $const_name + $const_name, ); } } catch (Exception $e) { @@ -1623,7 +1623,7 @@ public function getCompletionItemsForPartialSymbol( $fq_class_name, $aliases && $aliases->namespace ? $aliases->namespace : null, $aliases->uses_flipped ?? [], - null + null, ); if ($aliases @@ -1641,18 +1641,18 @@ public function getCompletionItemsForPartialSymbol( $extra_edits[] = new TextEdit( new Range( $position, - $position + $position, ), - "\n" . 'use ' . $fq_class_name . ';' + "\n" . 'use ' . $fq_class_name . ';', ); } else { $position = self::getPositionFromOffset($aliases->namespace_first_stmt_start, $file_contents); $extra_edits[] = new TextEdit( new Range( $position, - $position + $position, ), - 'use ' . $fq_class_name . ';' . "\n" . "\n" + 'use ' . $fq_class_name . ';' . "\n" . "\n", ); } @@ -1675,7 +1675,7 @@ public function getCompletionItemsForPartialSymbol( $fq_class_name, $insertion_text, null, - $extra_edits + $extra_edits, ); } @@ -1724,7 +1724,7 @@ public function getCompletionItemsForPartialSymbol( null, new Command('Trigger parameter hints', 'editor.action.triggerParameterHints'), null, - 2 + 2, ); } @@ -1748,7 +1748,7 @@ public function getCompletionItemsForType(Union $type): array null, null, null, - $property_name + $property_name, ); } } elseif ($atomic_type instanceof TLiteralString) { @@ -1759,7 +1759,7 @@ public function getCompletionItemsForType(Union $type): array null, null, null, - "'$atomic_type->value'" + "'$atomic_type->value'", ); } elseif ($atomic_type instanceof TLiteralInt) { $completion_items[] = new CompletionItem( @@ -1769,7 +1769,7 @@ public function getCompletionItemsForType(Union $type): array null, null, null, - (string) $atomic_type->value + (string) $atomic_type->value, ); } elseif ($atomic_type instanceof TClassConstant) { $const = $atomic_type->fq_classlike_name . '::' . $atomic_type->const_name; @@ -1780,7 +1780,7 @@ public function getCompletionItemsForType(Union $type): array null, null, null, - $const + $const, ); } } @@ -1805,7 +1805,7 @@ public function getCompletionItemsForArrayKeys( null, null, null, - "'$property_name'" + "'$property_name'", ); } } @@ -1828,7 +1828,7 @@ private static function getPositionFromOffset(int $offset, string $file_contents return new Position( substr_count($file_contents, "\n"), - $offset - (int)$before_newline_count - 1 + $offset - (int)$before_newline_count - 1, ); } @@ -1940,7 +1940,7 @@ public function addTaintSource( $taint_id, $code_location, null, - $taints + $taints, ); $this->taint_flow_graph->addSource($source); @@ -1966,7 +1966,7 @@ public function addTaintSink( $taint_id, $code_location, null, - $taints + $taints, ); $this->taint_flow_graph->addSink($sink); diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index 45431cc0feb..048b51c53ae 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -701,7 +701,7 @@ public static function loadFromXMLFile(string $file_path, string $current_dir): $config->hash = sha1($file_contents . PSALM_VERSION); } catch (ConfigException $e) { throw new ConfigException( - 'Problem parsing ' . $file_path . ":\n" . ' ' . $e->getMessage() + 'Problem parsing ' . $file_path . ":\n" . ' ' . $e->getMessage(), ); } @@ -781,7 +781,7 @@ private static function validateXmlConfig(string $base_dir, string $file_content if (!$psalm_node) { throw new ConfigException( - 'Missing psalm node' + 'Missing psalm node', ); } @@ -802,7 +802,7 @@ private static function validateXmlConfig(string $base_dir, string $file_content foreach ($errors as $error) { if ($error->level === LIBXML_ERR_FATAL || $error->level === LIBXML_ERR_ERROR) { throw new ConfigException( - 'Error on line ' . $error->line . ":\n" . ' ' . $error->message + 'Error on line ' . $error->line . ":\n" . ' ' . $error->message, ); } } @@ -825,7 +825,7 @@ private static function lineNumberToByteOffset(string $string, int $line_number) $newline_offset = strpos($string, "\n", $offset); if (false === $newline_offset) { throw new OutOfBoundsException( - 'Line ' . $line_number . ' is not found in a string with ' . ($i + 1) . ' lines' + 'Line ' . $line_number . ' is not found in a string with ' . ($i + 1) . ' lines', ); } $offset = $newline_offset + 1; @@ -859,8 +859,8 @@ private static function processDeprecatedAttribute( $config_path, basename($config_path), $attribute_start, - $attribute_end - ) + $attribute_end, + ), ); } @@ -885,8 +885,8 @@ private static function processDeprecatedElement( $config_path, basename($config_path), $element_start, - $element_end - ) + $element_end, + ), ); } @@ -917,7 +917,7 @@ private static function processConfigDeprecations( foreach ($deprecated_elements as $deprecated_element) { $deprecated_elements_xml = $dom_document->getElementsByTagNameNS( self::CONFIG_NAMESPACE, - $deprecated_element + $deprecated_element, ); if ($deprecated_elements_xml->length) { $deprecated_element_xml = $deprecated_elements_xml->item(0); @@ -949,7 +949,7 @@ private static function fromXmlAndPaths( $config, $dom_document, $file_contents, - $config_path + $config_path, ); } @@ -999,7 +999,7 @@ private static function fromXmlAndPaths( $attribute_text = (string) $config_xml[$xmlName]; $config->setBooleanAttribute( $internalName, - $attribute_text === 'true' || $attribute_text === '1' + $attribute_text === 'true' || $attribute_text === '1', ); } } @@ -1102,7 +1102,7 @@ private static function fromXmlAndPaths( if (!in_array($attribute_text, [1, 2, 3, 4, 5, 6, 7, 8], true)) { throw new ConfigException( - 'Invalid error level ' . $config_xml['errorLevel'] + 'Invalid error level ' . $config_xml['errorLevel'], ); } @@ -1159,7 +1159,7 @@ private static function fromXmlAndPaths( $config->taint_analysis_ignored_files = TaintAnalysisFileFilter::loadFromXMLElement( $config_xml->taintAnalysis->ignoreFiles, $base_dir, - false + false, ); } @@ -1231,7 +1231,7 @@ private static function fromXmlAndPaths( 'Cannot resolve stubfile path ' . rtrim($config->base_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR - . $stub_file['name'] + . $stub_file['name'], ); } @@ -1287,13 +1287,13 @@ private static function fromXmlAndPaths( /** @var string $key */ $config->issue_handlers[$custom_class_name] = IssueHandler::loadFromXMLElement( $issue_handler, - $base_dir + $base_dir, ); } else { /** @var string $key */ $config->issue_handlers[$key] = IssueHandler::loadFromXMLElement( $issue_handler, - $base_dir + $base_dir, ); } } @@ -1411,7 +1411,7 @@ public function processPluginFileExtensions(ProjectAnalyzer $projectAnalyzer): v throw new ConfigException( 'Failed to process plugin file extensions ' . $pluginClassName, 1_635_800_581, - $t + $t, ); } $projectAnalyzer->progress->debug('Initialized plugin ' . $pluginClassName . ' successfully' . PHP_EOL); @@ -1454,7 +1454,7 @@ public function initializePlugins(ProjectAnalyzer $project_analyzer): void throw new ConfigException( 'Failed to invoke plugin ' . $plugin_class_name, 1_635_800_582, - $t + $t, ); } @@ -1465,7 +1465,7 @@ public function initializePlugins(ProjectAnalyzer $project_analyzer): void $fq_class_name = $this->getPluginClassForPath( $codebase, $path, - FileScanner::class + FileScanner::class, ); self::requirePath($path); @@ -1477,7 +1477,7 @@ public function initializePlugins(ProjectAnalyzer $project_analyzer): void $fq_class_name = $this->getPluginClassForPath( $codebase, $path, - FileAnalyzer::class + FileAnalyzer::class, ); self::requirePath($path); @@ -1514,7 +1514,7 @@ private function loadPlugin(ProjectAnalyzer $projectAnalyzer, string $pluginClas && ($pluginclas_class_path = $this->composer_class_loader->findFile($pluginClassName)) ) { $projectAnalyzer->progress->debug( - 'Loading plugin ' . $pluginClassName . ' via require' . PHP_EOL + 'Loading plugin ' . $pluginClassName . ' via require' . PHP_EOL, ); self::requirePath($pluginclas_class_path); @@ -1551,7 +1551,7 @@ private function getPluginClassForPath(Codebase $codebase, string $path, string $file_to_scan = new FileScanner($path, $this->shortenFileName($path), true); $file_to_scan->scan( $codebase, - $file_storage + $file_storage, ); $declared_classes = ClassLikeAnalyzer::getClassesForFile($codebase, $path); @@ -1559,7 +1559,7 @@ private function getPluginClassForPath(Codebase $codebase, string $path, string if (!count($declared_classes)) { throw new InvalidArgumentException( 'Plugins must have at least one class in the file - ' . $path . ' has ' . - count($declared_classes) + count($declared_classes), ); } @@ -1567,11 +1567,11 @@ private function getPluginClassForPath(Codebase $codebase, string $path, string if (!$codebase->classlikes->classExtends( $fq_class_name, - $must_extend + $must_extend, ) ) { throw new InvalidArgumentException( - 'This plugin must extend ' . $must_extend . ' - ' . $path . ' does not' + 'This plugin must extend ' . $must_extend . ' - ' . $path . ' does not', ); } @@ -2297,7 +2297,7 @@ public function visitComposerAutoloadFiles(ProjectAnalyzer $project_analyzer, ?P * @psalm-suppress UnresolvableInclude * @var string[] */ - require $vendor_autoload_files_path + require $vendor_autoload_files_path, ); } @@ -2311,7 +2311,7 @@ public function visitComposerAutoloadFiles(ProjectAnalyzer $project_analyzer, ?P $codebase->classlikes->forgetMissingClassLikes(); $this->include_collector->runAndCollect( - [$this, 'requireAutoloader'] + [$this, 'requireAutoloader'], ); } diff --git a/src/Psalm/Config/Creator.php b/src/Psalm/Config/Creator.php index 8748ff42ed5..8b3f102a8ae 100644 --- a/src/Psalm/Config/Creator.php +++ b/src/Psalm/Config/Creator.php @@ -69,20 +69,20 @@ public static function getContents( $template = str_replace( '', implode("\n ", $paths), - self::TEMPLATE + self::TEMPLATE, ); if (is_dir($current_dir . DIRECTORY_SEPARATOR . $vendor_dir)) { $template = str_replace( '', '', - $template + $template, ); } else { $template = str_replace( '', '', - $template + $template, ); } @@ -90,7 +90,7 @@ public static function getContents( return str_replace( 'errorLevel="1"', 'errorLevel="' . $level . '"', - $template + $template, ); } @@ -141,7 +141,7 @@ public static function getLevel(array $issues, int $counted_types): int // remove any issues where < 0.1% of expressions are affected $filtered_issues = array_filter( $issues, - static fn($amount): bool => $amount > 0.1 + static fn($amount): bool => $amount > 0.1, ); if (array_sum($filtered_issues) > 0.5) { @@ -176,7 +176,7 @@ public static function getPaths(string $current_dir, ?string $suggested_dir): ar $bad_dir_path = $current_dir . DIRECTORY_SEPARATOR . $suggested_dir; throw new ConfigCreationException( - 'The given path "' . $bad_dir_path . '" does not appear to be a directory' + 'The given path "' . $bad_dir_path . '" does not appear to be a directory', ); } } elseif (is_dir($current_dir . DIRECTORY_SEPARATOR . 'src')) { @@ -189,7 +189,7 @@ public static function getPaths(string $current_dir, ?string $suggested_dir): ar 'Problem during source autodiscovery - could not find composer.json during initialization. ' . 'If your project doesn\'t use Composer autoloader you will need to run ' . '`psalm --init source_folder`, e.g. `psalm --init library` if your source files ' - . 'reside in `library` folder' + . 'reside in `library` folder', ); } try { @@ -197,11 +197,11 @@ public static function getPaths(string $current_dir, ?string $suggested_dir): ar file_get_contents($composer_json_location), true, 512, - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); } catch (JsonException $e) { throw new ConfigCreationException( - 'Invalid composer.json at ' . $composer_json_location . ': ' . $e->getMessage() + 'Invalid composer.json at ' . $composer_json_location . ': ' . $e->getMessage(), ); } if (!$composer_json) { @@ -216,7 +216,7 @@ public static function getPaths(string $current_dir, ?string $suggested_dir): ar if (!$replacements) { throw new ConfigCreationException( - 'Could not located any PSR-0 or PSR-4-compatible paths in ' . $composer_json_location + 'Could not located any PSR-0 or PSR-4-compatible paths in ' . $composer_json_location, ); } } @@ -233,7 +233,7 @@ private static function getPsr4Or0Paths(string $current_dir, array $composer_jso { $psr_paths = array_merge( $composer_json['autoload']['psr-4'] ?? [], - $composer_json['autoload']['psr-0'] ?? [] + $composer_json['autoload']['psr-0'] ?? [], ); if (!$psr_paths) { @@ -280,7 +280,7 @@ private static function guessPhpFileDirs(string $current_dir): array $php_files = array_merge( glob($current_dir . DIRECTORY_SEPARATOR . '*.php', GLOB_NOSORT), glob($current_dir . DIRECTORY_SEPARATOR . '**/*.php', GLOB_NOSORT), - glob($current_dir . DIRECTORY_SEPARATOR . '**/**/*.php', GLOB_NOSORT) + glob($current_dir . DIRECTORY_SEPARATOR . '**/**/*.php', GLOB_NOSORT), ); foreach ($php_files as $php_file) { diff --git a/src/Psalm/Config/FileFilter.php b/src/Psalm/Config/FileFilter.php index 74b9d25c914..01b1656e6c5 100644 --- a/src/Psalm/Config/FileFilter.php +++ b/src/Psalm/Config/FileFilter.php @@ -130,7 +130,7 @@ public static function loadFromArray( if (strpos($prospective_directory_path, '*') !== false) { $globs = array_map( 'realpath', - glob($prospective_directory_path, GLOB_ONLYDIR) + glob($prospective_directory_path, GLOB_ONLYDIR), ); if (empty($globs)) { @@ -140,7 +140,7 @@ public static function loadFromArray( throw new ConfigException( 'Could not resolve config path to ' . $base_dir - . DIRECTORY_SEPARATOR . $directory_path + . DIRECTORY_SEPARATOR . $directory_path, ); } @@ -152,7 +152,7 @@ public static function loadFromArray( throw new ConfigException( 'Could not resolve config path to ' . $base_dir - . DIRECTORY_SEPARATOR . $directory_path . ':' . $glob_index + . DIRECTORY_SEPARATOR . $directory_path . ':' . $glob_index, ); } @@ -177,21 +177,21 @@ public static function loadFromArray( } throw new ConfigException( - 'Could not resolve config path to ' . $prospective_directory_path + 'Could not resolve config path to ' . $prospective_directory_path, ); } if (!is_dir($directory_path)) { throw new ConfigException( $base_dir . DIRECTORY_SEPARATOR . $directory_path - . ' is not a directory' + . ' is not a directory', ); } if ($resolve_symlinks) { /** @var RecursiveDirectoryIterator */ $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($directory_path, FilesystemIterator::SKIP_DOTS) + new RecursiveDirectoryIterator($directory_path, FilesystemIterator::SKIP_DOTS), ); $iterator->rewind(); @@ -248,8 +248,8 @@ public static function loadFromArray( 'realpath', array_filter( glob($prospective_file_path, GLOB_NOSORT), - 'file_exists' - ) + 'file_exists', + ), ); if (empty($globs)) { @@ -259,7 +259,7 @@ public static function loadFromArray( throw new ConfigException( 'Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR . - $file_path + $file_path, ); } @@ -267,7 +267,7 @@ public static function loadFromArray( if (!$file_path && !$allow_missing_files) { throw new ConfigException( 'Could not resolve config path to ' . $base_dir . DIRECTORY_SEPARATOR . - $file_path . ':' . $glob_index + $file_path . ':' . $glob_index, ); } $filter->addFile($file_path); @@ -279,7 +279,7 @@ public static function loadFromArray( if (!$file_path && !$allow_missing_files) { throw new ConfigException( - 'Could not resolve config path to ' . $prospective_file_path + 'Could not resolve config path to ' . $prospective_file_path, ); } @@ -308,7 +308,7 @@ public static function loadFromArray( if (!preg_match('/^[^:]+::[^:]+$/', $method_id) && !static::isRegularExpression($method_id)) { throw new ConfigException( - 'Invalid referencedMethod ' . $method_id + 'Invalid referencedMethod ' . $method_id, ); } @@ -435,7 +435,7 @@ private static function isRegularExpression(string $string): bool { set_error_handler( static fn(): bool => true, - E_WARNING + E_WARNING, ); $is_regexp = preg_match($string, '') !== false; restore_error_handler(); diff --git a/src/Psalm/Config/IssueHandler.php b/src/Psalm/Config/IssueHandler.php index a35300ca327..258b16d9bf7 100644 --- a/src/Psalm/Config/IssueHandler.php +++ b/src/Psalm/Config/IssueHandler.php @@ -159,7 +159,7 @@ public static function getAllIssueTypes(): array return array_filter( array_map( static fn(string $file_name): string => substr($file_name, 0, -4), - scandir(dirname(__DIR__) . '/Issue', SCANDIR_SORT_NONE) + scandir(dirname(__DIR__) . '/Issue', SCANDIR_SORT_NONE), ), static fn(string $issue_name): bool => $issue_name !== '' && $issue_name !== 'MethodIssue' @@ -174,7 +174,7 @@ public static function getAllIssueTypes(): array && $issue_name !== 'ParseError' && $issue_name !== 'PluginIssue' && $issue_name !== 'MixedIssue' - && $issue_name !== 'MixedIssueTrait' + && $issue_name !== 'MixedIssueTrait', ); } } diff --git a/src/Psalm/Context.php b/src/Psalm/Context.php index 334c405f7b2..fea57cf9fa9 100644 --- a/src/Psalm/Context.php +++ b/src/Psalm/Context.php @@ -531,7 +531,7 @@ public function getRedefinedVars(array $new_vars_in_scope, bool $include_new_var if (!$this_type->equals( $new_type, true, - !($this_type->propagate_parent_nodes || $new_type->propagate_parent_nodes) + !($this_type->propagate_parent_nodes || $new_type->propagate_parent_nodes), ) ) { $redefined_vars[$var_id] = $this_type; @@ -714,7 +714,7 @@ public static function filterClauses( [], null, [], - $failed_reconciliation + $failed_reconciliation, ); if ($result_type->getId() !== $new_type_string) { @@ -757,7 +757,7 @@ public function removeDescendents( || ($new_type && $existing_type->from_docblock !== $new_type->from_docblock) ? null : $new_type, - $statements_analyzer + $statements_analyzer, ); foreach ($this->vars_in_scope as $var_id => &$type) { diff --git a/src/Psalm/DocComment.php b/src/Psalm/DocComment.php index b166f956798..3adb8312e62 100644 --- a/src/Psalm/DocComment.php +++ b/src/Psalm/DocComment.php @@ -42,7 +42,7 @@ public static function parsePreservingLength(Doc $docblock): ParsedDocblock { $parsed_docblock = DocblockParser::parse( $docblock->getText(), - $docblock->getStartFilePos() + $docblock->getStartFilePos(), ); foreach ($parsed_docblock->tags as $special_key => $_) { @@ -52,7 +52,7 @@ public static function parsePreservingLength(Doc $docblock): ParsedDocblock if (!in_array( $special_key, self::PSALM_ANNOTATIONS, - true + true, )) { throw new DocblockParseException('Unrecognised annotation @psalm-' . $special_key); } @@ -80,7 +80,7 @@ public static function parseSuppressList(string $suppress_entry): array ^ (?P (?&issue_list) ) (?P .* ) $ /xm', $suppress_entry, - $matches + $matches, ); if (!isset($matches['issues'])) { diff --git a/src/Psalm/ErrorBaseline.php b/src/Psalm/ErrorBaseline.php index e93b7f14220..75c383e5a4f 100644 --- a/src/Psalm/ErrorBaseline.php +++ b/src/Psalm/ErrorBaseline.php @@ -47,7 +47,7 @@ public static function countTotalIssues(array $existingIssues): int * @param array{o:int, s:array} $existingIssue */ static fn(int $carry, array $existingIssue): int => $carry + $existingIssue['o'], - 0 + 0, ); } @@ -157,11 +157,11 @@ public static function update( $existingIssuesCount[$issueType]['o'] = min( $existingIssueType['o'], - $newIssues[$file][$issueType]['o'] + $newIssues[$file][$issueType]['o'], ); $existingIssuesCount[$issueType]['s'] = array_intersect( $existingIssueType['s'], - $newIssues[$file][$issueType]['s'] + $newIssues[$file][$issueType]['s'], ); } } @@ -213,7 +213,7 @@ static function (array $carry, IssueData $issue): array { return $carry; }, - [] + [], ); // Sort files first @@ -249,7 +249,7 @@ private static function writeToFile( ('php:' . PHP_VERSION), ], ...array_map( static fn(string $extension): string => $extension . ':' . phpversion($extension), - $extensions + $extensions, )])); } @@ -296,7 +296,7 @@ private static function writeToFile( "\n" . $matches[3] . "\n", - $baselineDoc->saveXML() + $baselineDoc->saveXML(), ); if ($xml === null) { diff --git a/src/Psalm/Exception/UnpopulatedClasslikeException.php b/src/Psalm/Exception/UnpopulatedClasslikeException.php index 26096bf9235..7b31cf94495 100644 --- a/src/Psalm/Exception/UnpopulatedClasslikeException.php +++ b/src/Psalm/Exception/UnpopulatedClasslikeException.php @@ -10,7 +10,7 @@ public function __construct(string $fq_classlike_name) { parent::__construct( 'Cannot check inheritance - \'' . $fq_classlike_name . '\' has not been populated yet.' - . ' You may need to defer this check to a later phase.' + . ' You may need to defer this check to a later phase.', ); } } diff --git a/src/Psalm/FileBasedPluginAdapter.php b/src/Psalm/FileBasedPluginAdapter.php index 107ded198ab..d51dd6cbed4 100644 --- a/src/Psalm/FileBasedPluginAdapter.php +++ b/src/Psalm/FileBasedPluginAdapter.php @@ -58,7 +58,7 @@ private function getPluginClassForPath(string $path): string $file_to_scan = new FileScanner($path, $this->config->shortenFileName($path), true); $file_to_scan->scan( $codebase, - $file_storage + $file_storage, ); $declared_classes = ClassLikeAnalyzer::getClassesForFile($codebase, $path); diff --git a/src/Psalm/Internal/Algebra.php b/src/Psalm/Internal/Algebra.php index be967892a0a..09497121f76 100644 --- a/src/Psalm/Internal/Algebra.php +++ b/src/Psalm/Internal/Algebra.php @@ -203,7 +203,7 @@ public static function simplifyCNF(array $clauses): array } else { $updated_clause = $clause_b->addPossibilities( $clause_var, - $clause_var_possibilities + $clause_var_possibilities, ); $cloned_clauses[$updated_clause->hash] = $updated_clause; @@ -251,7 +251,7 @@ public static function simplifyCNF(array $clauses): array for ($k = $i + 1; $k < $clause_count; $k++) { $clause_b = $clauses[$k]; $common_keys = array_keys( - array_intersect_key($clause_a->possibilities, $clause_b->possibilities) + array_intersect_key($clause_a->possibilities, $clause_b->possibilities), ); if ($common_keys) { $common_negated_keys = []; @@ -259,7 +259,7 @@ public static function simplifyCNF(array $clauses): array if (count($clause_a->possibilities[$common_key]) === 1 && count($clause_b->possibilities[$common_key]) === 1 && reset($clause_a->possibilities[$common_key])->isNegationOf( - reset($clause_b->possibilities[$common_key]) + reset($clause_b->possibilities[$common_key]), ) ) { $common_negated_keys[] = $common_key; @@ -307,7 +307,7 @@ public static function simplifyCNF(array $clauses): array false, true, true, - [] + [], )); unset($simplified_clauses[$conflict_clause->hash]); @@ -419,7 +419,7 @@ public static function groupImpossibilities(array $clauses): array $seed_clause = new Clause( [$var => [(string)$impossible_type => $impossible_type]], $clause->creating_conditional_id, - $clause->creating_object_id + $clause->creating_object_id, ); $seed_clauses[] = $seed_clause; @@ -492,7 +492,7 @@ public static function groupImpossibilities(array $clauses): array false, true, true, - [] + [], ); $new_clauses[] = $new_clause; @@ -608,7 +608,7 @@ public static function combineOredClauses( || $left_clause->generated || count($left_clauses) > 1 || count($right_clauses) > 1, - [] + [], ); } } @@ -642,7 +642,7 @@ public static function negateFormula(array $clauses): array { $clauses = array_filter( $clauses, - static fn(Clause $clause): bool => $clause->reconcilable + static fn(Clause $clause): bool => $clause->reconcilable, ); if (!$clauses) { diff --git a/src/Psalm/Internal/Algebra/FormulaGenerator.php b/src/Psalm/Internal/Algebra/FormulaGenerator.php index 5df0a73c84f..c5d75f8829c 100644 --- a/src/Psalm/Internal/Algebra/FormulaGenerator.php +++ b/src/Psalm/Internal/Algebra/FormulaGenerator.php @@ -47,7 +47,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); $right_assertions = self::getFormula( @@ -58,7 +58,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); return [...$left_assertions, ...$right_assertions]; @@ -75,7 +75,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); $right_clauses = self::getFormula( @@ -86,7 +86,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); return Algebra::combineOredClauses($left_clauses, $right_clauses, $conditional_object_id); @@ -97,13 +97,13 @@ public static function getFormula( $and_expr = new VirtualBooleanAnd( new VirtualBooleanNot( $conditional->expr->left, - $conditional->getAttributes() + $conditional->getAttributes(), ), new VirtualBooleanNot( $conditional->expr->right, - $conditional->getAttributes() + $conditional->getAttributes(), ), - $conditional->expr->getAttributes() + $conditional->expr->getAttributes(), ); return self::getFormula( @@ -114,7 +114,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - false + false, ); } @@ -134,7 +134,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); if ($cache && $source instanceof StatementsAnalyzer) { @@ -166,7 +166,7 @@ public static function getFormula( false, true, $orred_types[0]->hasEquality(), - $redefined ? [$var => true] : [] + $redefined ? [$var => true] : [], ); } } @@ -179,13 +179,13 @@ public static function getFormula( $and_expr = new VirtualBooleanOr( new VirtualBooleanNot( $conditional->expr->left, - $conditional->getAttributes() + $conditional->getAttributes(), ), new VirtualBooleanNot( $conditional->expr->right, - $conditional->getAttributes() + $conditional->getAttributes(), ), - $conditional->expr->getAttributes() + $conditional->expr->getAttributes(), ); return self::getFormula( @@ -196,7 +196,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - false + false, ); } @@ -208,8 +208,8 @@ public static function getFormula( $this_class_name, $source, $codebase, - !$inside_negation - ) + !$inside_negation, + ), ); } @@ -234,8 +234,8 @@ public static function getFormula( $source, $codebase, !$inside_negation, - $cache - ) + $cache, + ), ); } @@ -254,8 +254,8 @@ public static function getFormula( $source, $codebase, !$inside_negation, - $cache - ) + $cache, + ), ); } @@ -273,7 +273,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); } @@ -291,7 +291,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); } } @@ -317,8 +317,8 @@ public static function getFormula( $source, $codebase, !$inside_negation, - $cache - ) + $cache, + ), ); } @@ -337,8 +337,8 @@ public static function getFormula( $source, $codebase, !$inside_negation, - $cache - ) + $cache, + ), ); } @@ -356,7 +356,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); } @@ -374,7 +374,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); } } @@ -388,7 +388,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); } @@ -405,7 +405,7 @@ public static function getFormula( $source, $codebase, $inside_negation, - $cache + $cache, ); if ($cache && $source instanceof StatementsAnalyzer) { @@ -437,7 +437,7 @@ public static function getFormula( false, true, $orred_types[0]->hasEquality(), - $redefined ? [$var => true] : [] + $redefined ? [$var => true] : [], ); } } @@ -455,8 +455,8 @@ public static function getFormula( new Clause( [$conditional_ref => ['truthy' => new Truthy()]], $conditional_object_id, - $creating_object_id - ) + $creating_object_id, + ), ]; } } diff --git a/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php b/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php index 7521d71f30d..6fc52514aa3 100644 --- a/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/AlgebraAnalyzer.php @@ -68,9 +68,9 @@ public static function checkForParadox( new RedundantCondition( $formula_2_clause . ' has already been asserted', new CodeLocation($statements_analyzer, $stmt), - 'already asserted ' . $formula_2_clause + 'already asserted ' . $formula_2_clause, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -127,9 +127,9 @@ public static function checkForParadox( IssueBuffer::maybeAdd( new ParadoxicalCondition( $paradox_message, - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; diff --git a/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php b/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php index f1aede90ee8..f5010ecd242 100644 --- a/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php @@ -90,7 +90,7 @@ public static function analyze( $fq_attribute_name, $attribute_name_location, $attribute_class_storage, - $suppressed_issues + $suppressed_issues, ); self::analyzeAttributeConstruction( @@ -99,7 +99,7 @@ public static function analyze( $fq_attribute_name, $attribute, $suppressed_issues, - $storage instanceof ClassLikeStorage ? $storage : null + $storage instanceof ClassLikeStorage ? $storage : null, ); if (($attribute_class_flags & self::IS_REPEATABLE) === 0) { @@ -108,9 +108,9 @@ public static function analyze( IssueBuffer::maybeAdd( new InvalidAttribute( "Attribute {$attribute_name} is not repeatable", - $attribute_name_location + $attribute_name_location, ), - $suppressed_issues + $suppressed_issues, ); } $appearing_non_repeatable_attributes[$fq_attribute_name] = true; @@ -121,9 +121,9 @@ public static function analyze( new InvalidAttribute( "Attribute {$attribute_name} cannot be used on a " . self::TARGET_DESCRIPTIONS[$target], - $attribute_name_location + $attribute_name_location, ), - $suppressed_issues + $suppressed_issues, ); } } @@ -155,8 +155,8 @@ private static function analyzeAttributeConstruction( false, false, false, - true - ) + true, + ), ) === false) { return; } @@ -166,25 +166,25 @@ private static function analyzeAttributeConstruction( IssueBuffer::maybeAdd( new InvalidAttribute( 'Traits cannot act as attribute classes', - $attribute_name_location + $attribute_name_location, ), - $suppressed_issues + $suppressed_issues, ); } elseif ($classlike_storage->is_interface) { IssueBuffer::maybeAdd( new InvalidAttribute( 'Interfaces cannot act as attribute classes', - $attribute_name_location + $attribute_name_location, ), - $suppressed_issues + $suppressed_issues, ); } elseif ($classlike_storage->abstract) { IssueBuffer::maybeAdd( new InvalidAttribute( 'Abstract classes cannot act as attribute classes', - $attribute_name_location + $attribute_name_location, ), - $suppressed_issues + $suppressed_issues, ); } elseif (isset($classlike_storage->methods['__construct']) && $classlike_storage->methods['__construct']->visibility !== ClassLikeAnalyzer::VISIBILITY_PUBLIC @@ -192,24 +192,24 @@ private static function analyzeAttributeConstruction( IssueBuffer::maybeAdd( new InvalidAttribute( 'Classes with protected/private constructors cannot act as attribute classes', - $attribute_name_location + $attribute_name_location, ), - $suppressed_issues + $suppressed_issues, ); } elseif ($classlike_storage->is_enum) { IssueBuffer::maybeAdd( new InvalidAttribute( 'Enums cannot act as attribute classes', - $attribute_name_location + $attribute_name_location, ), - $suppressed_issues + $suppressed_issues, ); } } $statements_analyzer = new StatementsAnalyzer( $source, - new NodeDataProvider() + new NodeDataProvider(), ); $statements_analyzer->addSuppressedIssues(array_values($suppressed_issues)); @@ -220,7 +220,7 @@ private static function analyzeAttributeConstruction( $statements_analyzer->analyze( [new Expression(new New_($attribute->name, $attribute->args, $attribute->getAttributes()))], // Use a new Context for the Attribute attribute so that it can't access `self` - strtolower($fq_attribute_name) === "attribute" ? new Context() : $context + strtolower($fq_attribute_name) === "attribute" ? new Context() : $context, ); $context->has_returned = $had_returned; @@ -271,8 +271,8 @@ private static function getAttributeClassFlags( ConstantTypeResolver::resolve( $source->getCodebase()->classlikes, $first_arg_type, - $source instanceof StatementsAnalyzer ? $source : null - ) + $source instanceof StatementsAnalyzer ? $source : null, + ), ]); } @@ -287,9 +287,9 @@ private static function getAttributeClassFlags( IssueBuffer::maybeAdd( new InvalidAttribute( "The class {$attribute_name} doesn't have the Attribute attribute", - $attribute_name_location + $attribute_name_location, ), - $suppressed_issues + $suppressed_issues, ); return self::TARGET_ALL; // Fall back to default if it's invalid @@ -379,7 +379,7 @@ public static function analyzeGetAttributes( $class_string->value, $arg_location, $class_storage, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); if (($class_attribute_target & $target) === 0) { @@ -387,9 +387,9 @@ public static function analyzeGetAttributes( new InvalidAttribute( "Attribute {$class_string->value} cannot be used on a " . self::TARGET_DESCRIPTIONS[$target], - $arg_location + $arg_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } diff --git a/src/Psalm/Internal/Analyzer/CanAlias.php b/src/Psalm/Internal/Analyzer/CanAlias.php index a91ee0e2293..1e23e08b0a9 100644 --- a/src/Psalm/Internal/Analyzer/CanAlias.php +++ b/src/Psalm/Internal/Analyzer/CanAlias.php @@ -70,7 +70,7 @@ public function visitUse(PhpParser\Node\Stmt\Use_ $stmt): void $this->getFilePath(), (int) $use->getAttribute('startFilePos'), (int) $use->getAttribute('endFilePos'), - $use_path + $use_path, ); if ($codebase->collect_locations) { // register the path @@ -87,7 +87,7 @@ public function visitUse(PhpParser\Node\Stmt\Use_ $stmt): void $file_manipulations[] = new FileManipulation( (int) $use->getAttribute('startFilePos'), (int) $use->getAttribute('endFilePos') + 1, - $new_fq_class_name . ($use->alias ? ' as ' . $use_alias : '') + $new_fq_class_name . ($use->alias ? ' as ' . $use_alias : ''), ); FileManipulationBuffer::add($this->getFilePath(), $file_manipulations); @@ -162,7 +162,7 @@ public function getAliases(): Aliases $this->getNamespace(), $this->aliased_classes, $this->aliased_functions, - $this->aliased_constants + $this->aliased_constants, ); } } diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 7f10f6c9ac3..9c246ddae7b 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -129,7 +129,7 @@ public function __construct(PhpParser\Node\Stmt $class, SourceAnalyzer $source, if ($this->class instanceof PhpParser\Node\Stmt\Class_ && $this->class->extends) { $this->parent_fq_class_name = self::getFQCLNFromNameObject( $this->class->extends, - $this->source->getAliases() + $this->source->getAliases(), ); } } @@ -162,7 +162,7 @@ public function analyze( if ($class->name && (preg_match( '/(^|\\\)(int|float|bool|string|void|null|false|true|object|mixed)$/i', - $fq_class_name + $fq_class_name, ) || strtolower($fq_class_name) === 'resource') ) { $class_name_parts = explode('\\', $fq_class_name); @@ -175,11 +175,11 @@ public function analyze( $this, $class->name, null, - true + true, ), - $class_name + $class_name, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); return; @@ -209,13 +209,13 @@ public function analyze( new FileManipulation( $bounds[0], $bounds[1], - $destination_ns - ) + $destination_ns, + ), ]; FileManipulationBuffer::add( $this->getFilePath(), - $file_manipulations + $file_manipulations, ); } elseif (!$source_ns) { $first_statement_pos = $this->getFileAnalyzer()->getFirstStatementOffset(); @@ -229,13 +229,13 @@ public function analyze( $first_statement_pos, $first_statement_pos, 'namespace ' . $destination_ns . ';' . "\n\n", - true - ) + true, + ), ]; FileManipulationBuffer::add( $this->getFilePath(), - $file_manipulations + $file_manipulations, ); } } @@ -246,7 +246,7 @@ public function analyze( $this, $class->name, $this->fq_class_name, - null + null, ); } @@ -266,7 +266,7 @@ public function analyze( $parent_fq_class_name, $storage, $codebase, - $class_context + $class_context, ); } @@ -275,7 +275,7 @@ public function analyze( foreach ($storage->template_types as $param_name => $_) { $fq_classlike_name = Type::getFQCLNFromString( $param_name, - $this->getAliases() + $this->getAliases(), ); if ($codebase->classOrInterfaceExists($fq_classlike_name)) { @@ -283,9 +283,9 @@ public function analyze( new ReservedWord( 'Cannot use ' . $param_name . ' as template name since the class already exists', new CodeLocation($this, $this->class), - 'resource' + 'resource', ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } } @@ -304,7 +304,7 @@ public function analyze( $union, $storage->name, $static_self, - null + null, ); /** @psalm-suppress UnusedMethodCall This call actually has the side effect of creating issues */ @@ -314,9 +314,9 @@ public function analyze( $this, $class->name ?: $class, null, - true + true, ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } @@ -330,9 +330,9 @@ public function analyze( $this, $class->name ?: $class, null, - true + true, ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } } @@ -352,7 +352,7 @@ public function analyze( $class, $codebase, $fq_class_name, - $storage + $storage, ) === false) { return; } @@ -364,10 +364,10 @@ public function analyze( if ($this->leftover_stmts) { (new StatementsAnalyzer( $this, - new NodeDataProvider() + new NodeDataProvider(), ))->analyze( $this->leftover_stmts, - $class_context + $class_context, ); } @@ -387,10 +387,10 @@ public function analyze( $this, $class->name ?? $class, $class_context->include_location, - true - ) + true, + ), ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), )) { return; } @@ -404,7 +404,7 @@ public function analyze( $storage, $class->attrGroups, AttributesAnalyzer::TARGET_CLASS, - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); self::addContextProperties( @@ -413,7 +413,7 @@ public function analyze( $class_context, $this->fq_class_name, $this->parent_fq_class_name, - $class->stmts + $class->stmts, ); $constructor_analyzer = null; @@ -426,7 +426,7 @@ public function analyze( $storage, $this, $class_context, - $global_context + $global_context, ); if ($stmt->name->name === '__construct') { @@ -440,7 +440,7 @@ public function analyze( $storage, $class_context, $global_context, - $constructor_analyzer + $constructor_analyzer, ) === false) { return; } @@ -450,7 +450,7 @@ public function analyze( IssueBuffer::maybeAdd(new NoEnumProperties( 'Enums cannot have properties', new CodeLocation($this, $prop), - $fq_class_name + $fq_class_name, )); continue; } @@ -472,7 +472,7 @@ public function analyze( $property_storage->type, $this->getFQCLN(), $this->getFQCLN(), - $this->getParentFQCLN() + $this->getParentFQCLN(), ); $codebase->classlikes->handleDocblockTypeInMigration( @@ -480,7 +480,7 @@ public function analyze( $this, $replace_type, $property_storage->type_location, - null + null, ); } @@ -490,13 +490,13 @@ public function analyze( new FileManipulation( (int) $prop->name->getAttribute('startFilePos'), (int) $prop->name->getAttribute('endFilePos') + 1, - '$' . $new_property_name - ) + '$' . $new_property_name, + ), ]; FileManipulationBuffer::add( $this->getFilePath(), - $file_manipulations + $file_manipulations, ); } } @@ -511,8 +511,8 @@ public function analyze( new ReservedWord( 'A class constant cannot be named \'class\'', new CodeLocation($this, $this->class), - $this->fq_class_name - ) + $this->fq_class_name, + ), ); } @@ -524,13 +524,13 @@ public function analyze( new FileManipulation( (int) $const->name->getAttribute('startFilePos'), (int) $const->name->getAttribute('endFilePos') + 1, - $new_const_name - ) + $new_const_name, + ), ]; FileManipulationBuffer::add( $this->getFilePath(), - $file_manipulations + $file_manipulations, ); } } @@ -552,7 +552,7 @@ public function analyze( $storage, $class_context, $global_context, - $constructor_analyzer + $constructor_analyzer, ); } @@ -567,7 +567,7 @@ public function analyze( foreach ($stmt->traits as $trait) { $fq_trait_name = self::getFQCLNFromNameObject( $trait, - $this->source->getAliases() + $this->source->getAliases(), ); try { @@ -588,7 +588,7 @@ public function analyze( $trait_node, $trait_file_analyzer, $fq_trait_name, - $trait_aliases + $trait_aliases, ); $fq_trait_name_lc = strtolower($fq_trait_name); @@ -599,9 +599,9 @@ public function analyze( $trait_storage, new CodeLocation( $this, - $trait + $trait, ), - $storage->template_type_uses_count[$fq_trait_name_lc] ?? 0 + $storage->template_type_uses_count[$fq_trait_name_lc] ?? 0, ); foreach ($trait_node->stmts as $trait_stmt) { @@ -620,7 +620,7 @@ public function analyze( foreach ($pseudo_methods as $pseudo_method_name => $pseudo_method_storage) { $pseudo_method_id = new MethodIdentifier( $this->fq_class_name, - $pseudo_method_name + $pseudo_method_name, ); $overridden_method_ids = $codebase->methods->getOverriddenMethodIds($pseudo_method_id); @@ -648,7 +648,7 @@ public function analyze( $storage->location ?: $pseudo_method_storage->location, $storage->suppressed_issues, true, - false + false, ); } } @@ -659,7 +659,7 @@ public function analyze( $storage, $this, $codebase, - [] + [], ); if ($codebase->config->eventDispatcher->dispatchAfterClassLikeAnalysis($event) === false) { @@ -669,7 +669,7 @@ public function analyze( if ($file_manipulations) { FileManipulationBuffer::add( $this->getFilePath(), - $file_manipulations + $file_manipulations, ); } } @@ -687,7 +687,7 @@ public static function addContextProperties( foreach ($storage->appearing_property_ids as $property_name => $appearing_property_id) { $property_class_name = $codebase->properties->getDeclaringClassForProperty( $appearing_property_id, - true + true, ); if ($property_class_name === null) { @@ -712,8 +712,8 @@ public static function addContextProperties( 'Property ' . $fq_class_name . '::$' . $property_name . ' has different access level than ' . $storage->name . '::$' . $property_name, - $property_storage->location - ) + $property_storage->location, + ), ); } @@ -721,7 +721,7 @@ public static function addContextProperties( || (!$property_storage->signature_type && $guide_property_storage->signature_type) || ($property_storage->signature_type && !$property_storage->signature_type->equals( - $guide_property_storage->signature_type + $guide_property_storage->signature_type, ))) && $property_storage->location ) { @@ -739,9 +739,9 @@ public static function addContextProperties( ? $guide_property_storage->signature_type->getId() : '' ), - $property_storage->location + $property_storage->location, ), - $property_storage->suppressed_issues + $property_storage->suppressed_issues, ); } @@ -772,7 +772,7 @@ public static function addContextProperties( $template_standins, $codebase, null, - $property_type + $property_type, ); // Iterate over parent classes to find template-covariants, and replace the upper bound with the @@ -790,7 +790,7 @@ public static function addContextProperties( $lower_bounds[$pt_name][$parent_class] = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $template_standins->lower_bounds[$pt_name][$parent_class], - $codebase + $codebase, ); } } @@ -803,12 +803,12 @@ public static function addContextProperties( $guide_property_type = TemplateInferredTypeReplacer::replace( $guide_property_type, $template_result, - $codebase + $codebase, ); $property_type = TemplateInferredTypeReplacer::replace( $property_type, $template_result, - $codebase + $codebase, ); if ($property_storage->location @@ -822,9 +822,9 @@ public static function addContextProperties( . ", not invariant with " . $guide_class_name . '::$' . $property_name . ' of type ' . $guide_property_type->getId(), - $property_storage->location + $property_storage->location, ), - $property_storage->suppressed_issues + $property_storage->suppressed_issues, ); } } @@ -841,7 +841,7 @@ public static function addContextProperties( $property_type = $property_type->setProperties([ 'initialized' => false, 'from_property' => true, - 'from_static_property' => $property_storage->is_static === true + 'from_static_property' => $property_storage->is_static === true, ]); } } else { @@ -849,7 +849,7 @@ public static function addContextProperties( $property_type = new Union([new TMixed()], [ 'initialized' => false, 'from_property' => true, - 'from_static_property' => $property_storage->is_static === true + 'from_static_property' => $property_storage->is_static === true, ]); } else { $property_type = Type::getMixed(); @@ -867,7 +867,7 @@ public static function addContextProperties( $parent_fq_class_name, true, false, - $storage->final + $storage->final, ) : $property_type; @@ -877,13 +877,13 @@ public static function addContextProperties( $storage, null, new TNamedObject($fq_class_name), - true + true, ); if ($class_template_params) { $this_object_type = self::getThisObjectType( $storage, - $fq_class_name + $fq_class_name, ); if (!$this_object_type instanceof TGenericObject) { @@ -901,7 +901,7 @@ public static function addContextProperties( $fleshed_out_type, $this_object_type, $storage, - $property_class_storage + $property_class_storage, ); } @@ -934,7 +934,7 @@ public static function addContextProperties( $property_type_location, $storage->suppressed_issues + $statements_source->getSuppressedIssues() + $suppressed, [], - false + false, ); if ($property_storage->signature_type) { @@ -946,7 +946,7 @@ public static function addContextProperties( $property_storage->signature_type, false, false, - $union_comparison_result + $union_comparison_result, ) && !$union_comparison_result->type_coerced_from_mixed ) { IssueBuffer::maybeAdd( @@ -955,8 +955,8 @@ public static function addContextProperties( . $property_class_name . '::$' . $property_name . ' has wrong type \'' . $fleshed_out_type . '\', should be \'' . $property_storage->signature_type . '\'', - $property_type_location - ) + $property_type_location, + ), ); } } @@ -981,7 +981,7 @@ public static function addContextProperties( $property_type, $fq_class_name, $fq_class_name, - $parent_fq_class_name + $parent_fq_class_name, ) : $property_type; @@ -1016,7 +1016,7 @@ private function checkPropertyInitialization( $method_already_analyzed = $codebase->analyzer->isMethodAlreadyAnalyzed( $included_file_path, $fq_class_name_lc . '::__construct', - true + true, ); if ($method_already_analyzed && !$codebase->diff_methods) { @@ -1039,7 +1039,7 @@ private function checkPropertyInitialization( foreach ($storage->appearing_property_ids as $property_name => $appearing_property_id) { $property_class_name = $codebase->properties->getDeclaringClassForProperty( $appearing_property_id, - true + true, ); if ($property_class_name === null) { @@ -1071,7 +1071,7 @@ private function checkPropertyInitialization( $this->getFilePath(), $start, $end, - 'PropertyNotSetInConstructor' + 'PropertyNotSetInConstructor', ); if ($existing_issues) { @@ -1085,13 +1085,13 @@ private function checkPropertyInitialization( $this->getFilePath(), $property->location->raw_file_start, $property->location->raw_file_end, - 'PropertyNotSetInConstructor' + 'PropertyNotSetInConstructor', ); } $codebase->file_reference_provider->addMethodReferenceToMissingClassMember( $fq_class_name_lc . '::__construct', - strtolower($property_class_name) . '::$' . $property_name + strtolower($property_class_name) . '::$' . $property_name, ); if ($property->visibility === ClassLikeAnalyzer::VISIBILITY_PRIVATE) { @@ -1141,7 +1141,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Param { ? [ 'startFilePos' => $param->location->raw_file_start, 'endFilePos' => $param->location->raw_file_end, - 'startLine' => $param->location->raw_line_number + 'startLine' => $param->location->raw_line_number, ] : []; @@ -1149,7 +1149,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Param { return $node; }, - $constructor_storage->params + $constructor_storage->params, ); $fake_constructor_stmt_args = array_map( @@ -1158,7 +1158,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { ? [ 'startFilePos' => $param->location->raw_file_start, 'endFilePos' => $param->location->raw_file_end, - 'startLine' => $param->location->raw_line_number + 'startLine' => $param->location->raw_line_number, ] : []; @@ -1166,10 +1166,10 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { new VirtualVariable($param->name, $attributes), false, $param->is_variadic, - $attributes + $attributes, ); }, - $constructor_storage->params + $constructor_storage->params, ); $fake_constructor_attributes = [ @@ -1183,7 +1183,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { 'comments' => [new PhpParser\Comment\Doc( '/** @psalm-suppress InaccessibleMethod */', $class->extends->getLine(), - (int) $class->extends->getAttribute('startFilePos') + (int) $class->extends->getAttribute('startFilePos'), )], ]; @@ -1193,9 +1193,9 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { new VirtualFullyQualified($constructor_declaring_fqcln), new VirtualIdentifier('__construct', $fake_constructor_attributes), $fake_constructor_stmt_args, - $fake_call_attributes + $fake_call_attributes, ), - $fake_call_attributes + $fake_call_attributes, ), ]; @@ -1206,7 +1206,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { 'params' => $fake_constructor_params, 'stmts' => $fake_constructor_stmts, ], - $fake_constructor_attributes + $fake_constructor_attributes, ); $codebase->analyzer->disableMixedCounts(); @@ -1222,7 +1222,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { $this, $class_context, $global_context, - true + true, ); $class_context->collect_initializations = $was_collecting_initializations; @@ -1247,7 +1247,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { $method_context, new NodeDataProvider(), $global_context, - true + true, ); foreach ($uninitialized_properties as $property_id => $property_storage) { @@ -1271,7 +1271,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { && $property_storage->visibility === ClassLikeAnalyzer::VISIBILITY_PRIVATE ) { $a_class_storage = $classlike_storage_provider->get( - $end_type->initialized_class ?: $constructor_appearing_fqcln + $end_type->initialized_class ?: $constructor_appearing_fqcln, ); if (!isset($a_class_storage->declaring_property_ids[$property_name])) { @@ -1300,9 +1300,9 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { . $this->fq_class_name . ' or in any ' . $expected_visibility . 'methods called in the constructor', $error_location, - $property_id + $property_id, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } elseif (!$property_storage->has_default) { if (isset($this->inferred_property_types[$property_name])) { @@ -1320,7 +1320,7 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { $codebase->analyzer->setAnalyzedMethod( $included_file_path, $fq_class_name_lc . '::__construct', - true + true, ); return; @@ -1334,9 +1334,9 @@ static function (FunctionLikeParameter $param): PhpParser\Node\Arg { $class_storage->name . ' has an uninitialized property ' . $id . ', but no constructor', $uninitialized_property->location, - $class_storage->name . '::' . $uninitialized_variables[0] + $class_storage->name . '::' . $uninitialized_variables[0], ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } } @@ -1366,16 +1366,16 @@ private function analyzeTraitUse( $fq_trait_name = self::getFQCLNFromNameObject( $trait_name, - $aliases + $aliases, ); if (!$codebase->classlikes->hasFullyQualifiedTraitName($fq_trait_name, $trait_location)) { IssueBuffer::maybeAdd( new UndefinedTrait( 'Trait ' . $fq_trait_name . ' does not exist', - new CodeLocation($previous_trait_analyzer ?? $this, $trait_name) + new CodeLocation($previous_trait_analyzer ?? $this, $trait_name), ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); return false; @@ -1385,9 +1385,9 @@ private function analyzeTraitUse( if (IssueBuffer::accepts( new UndefinedTrait( 'Trait ' . $fq_trait_name . ' has wrong casing', - new CodeLocation($previous_trait_analyzer ?? $this, $trait_name) + new CodeLocation($previous_trait_analyzer ?? $this, $trait_name), ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), )) { return false; } @@ -1402,15 +1402,15 @@ private function analyzeTraitUse( IssueBuffer::maybeAdd( new DeprecatedTrait( 'Trait ' . $fq_trait_name . ' is deprecated', - new CodeLocation($previous_trait_analyzer ?? $this, $trait_name) + new CodeLocation($previous_trait_analyzer ?? $this, $trait_name), ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } if ($trait_storage->extension_requirement !== null) { $extension_requirement = $codebase->classlikes->getUnAliasedName( - $trait_storage->extension_requirement + $trait_storage->extension_requirement, ); $extensionRequirementMet = in_array($extension_requirement, $storage->parent_classes); @@ -1419,9 +1419,9 @@ private function analyzeTraitUse( new ExtensionRequirementViolation( $fq_trait_name . ' requires using class to extend ' . $extension_requirement . ', but ' . $storage->name . ' does not', - new CodeLocation($previous_trait_analyzer ?? $this, $trait_name) + new CodeLocation($previous_trait_analyzer ?? $this, $trait_name), ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } } @@ -1435,9 +1435,9 @@ private function analyzeTraitUse( new ImplementationRequirementViolation( $fq_trait_name . ' requires using class to implement ' . $implementation_requirement . ', but ' . $storage->name . ' does not', - new CodeLocation($previous_trait_analyzer ?? $this, $trait_name) + new CodeLocation($previous_trait_analyzer ?? $this, $trait_name), ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } } @@ -1446,9 +1446,9 @@ private function analyzeTraitUse( IssueBuffer::maybeAdd( new MutableDependency( $storage->name . ' is marked @psalm-immutable but ' . $fq_trait_name . ' is not', - new CodeLocation($previous_trait_analyzer ?? $this, $trait_name) + new CodeLocation($previous_trait_analyzer ?? $this, $trait_name), ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -1463,7 +1463,7 @@ private function analyzeTraitUse( $trait_node, $trait_file_analyzer, $fq_trait_name_resolved, - $trait_aliases + $trait_aliases, ); foreach ($trait_node->stmts as $trait_stmt) { @@ -1473,7 +1473,7 @@ private function analyzeTraitUse( $storage, $trait_analyzer, $class_context, - $global_context + $global_context, ); if ($trait_stmt->name->name === '__construct') { @@ -1488,7 +1488,7 @@ private function analyzeTraitUse( $class_context, $global_context, $constructor_analyzer, - $trait_analyzer + $trait_analyzer, ) === false) { return false; } @@ -1517,7 +1517,7 @@ private function analyzeProperty( $declaring_property_class = $codebase->properties->getDeclaringClassForProperty( $property_id, - true + true, ); if (!$declaring_property_class) { @@ -1539,7 +1539,7 @@ private function analyzeProperty( $property_storage, $stmt->attrGroups, AttributesAnalyzer::TARGET_PROPERTY, - $property_storage->suppressed_issues + $this->getSuppressedIssues() + $property_storage->suppressed_issues + $this->getSuppressedIssues(), ); if ($class_property_type && ($property_storage->type_location || !$codebase->alter_code)) { @@ -1554,7 +1554,7 @@ private function analyzeProperty( $suggested_type = Type::combineUnionTypes( $suggested_type, $this->inferred_property_types[$property_name] ?? null, - $codebase + $codebase, ); } @@ -1566,7 +1566,7 @@ private function analyzeProperty( $message .= ' - consider ' . str_replace( ['', ''], '', - $suggested_type->getId(false) + $suggested_type->getId(false), ); } @@ -1587,7 +1587,7 @@ private function analyzeProperty( $stmt, $suggested_type, $this, - $suggested_type->from_docblock + $suggested_type->from_docblock, ); return; @@ -1597,9 +1597,9 @@ private function analyzeProperty( new MissingPropertyType( $message, new CodeLocation($source, $stmt->props[0]->name), - $property_id + $property_id, ), - $this->source->getSuppressedIssues() + $property_storage->suppressed_issues + $this->source->getSuppressedIssues() + $property_storage->suppressed_issues, ); } @@ -1613,7 +1613,7 @@ private static function addOrUpdatePropertyType( $manipulator = PropertyDocblockManipulator::getForProperty( $project_analyzer, $source->getFilePath(), - $property + $property, ); $codebase = $project_analyzer->getCodebase(); @@ -1628,21 +1628,21 @@ private static function addOrUpdatePropertyType( $source->getNamespace(), $source->getAliasedClassesFlipped(), $source->getFQCLN(), - $codebase->analysis_php_version_id + $codebase->analysis_php_version_id, ) : null, $inferred_type->toNamespacedString( $source->getNamespace(), $source->getAliasedClassesFlipped(), $source->getFQCLN(), - false + false, ), $inferred_type->toNamespacedString( $source->getNamespace(), $source->getAliasedClassesFlipped(), $source->getFQCLN(), - true + true, ), - $inferred_type->canBeFullyExpressedInPhp($codebase->analysis_php_version_id) + $inferred_type->canBeFullyExpressedInPhp($codebase->analysis_php_version_id), ); } @@ -1660,8 +1660,8 @@ private function analyzeClassMethod( IssueBuffer::maybeAdd( new ParseError( 'Non-abstract class method must have statements', - new CodeLocation($this, $stmt) - ) + new CodeLocation($this, $stmt), + ), ); return null; @@ -1673,8 +1673,8 @@ private function analyzeClassMethod( IssueBuffer::maybeAdd( new ParseError( 'Problem loading method: ' . $e->getMessage(), - new CodeLocation($this, $stmt) - ) + new CodeLocation($this, $stmt), + ), ); return null; @@ -1706,7 +1706,7 @@ private function analyzeClassMethod( if ($declaring_method_id && $declaring_method_storage->abstract) { $implementer_method_storage = $codebase->methods->getStorage($declaring_method_id); $declaring_storage = $codebase->classlike_storage_provider->get( - $actual_method_id->fq_class_name + $actual_method_id->fq_class_name, ); MethodComparator::compare( @@ -1720,7 +1720,7 @@ private function analyzeClassMethod( $implementer_method_storage->visibility, new CodeLocation($source, $stmt), $implementer_method_storage->suppressed_issues, - false + false, ); } @@ -1738,7 +1738,7 @@ private function analyzeClassMethod( $method_already_analyzed = $codebase->analyzer->isMethodAlreadyAnalyzed( $included_file_path, - $trait_safe_method_id + $trait_safe_method_id, ); $start = (int)$stmt->getAttribute('startFilePos'); @@ -1757,13 +1757,13 @@ private function analyzeClassMethod( && !$is_fake ) { $project_analyzer->progress->debug( - 'Skipping analysis of pre-analyzed method ' . $analyzed_method_id . "\n" + 'Skipping analysis of pre-analyzed method ' . $analyzed_method_id . "\n", ); $existing_issues = $codebase->analyzer->getExistingIssuesForFile( $source->getFilePath(), $start, - $end + $end, ); IssueBuffer::addIssues([$source->getFilePath() => $existing_issues]); @@ -1774,7 +1774,7 @@ private function analyzeClassMethod( $codebase->analyzer->removeExistingDataForFile( $source->getFilePath(), $start, - $end + $end, ); $method_context = clone $class_context; @@ -1795,7 +1795,7 @@ private function analyzeClassMethod( $method_analyzer->analyze( $method_context, $type_provider, - $global_context ? clone $global_context : null + $global_context ? clone $global_context : null, ); if ($stmt->name->name !== '__construct' @@ -1812,7 +1812,7 @@ private function analyzeClassMethod( $class_context->self, $analyzed_method_id, $actual_method_id, - $method_context->has_returned + $method_context->has_returned, ); } @@ -1841,14 +1841,14 @@ private static function getThisObjectType( new TTemplateParam( $param_name, reset($template_map), - $key - ) + $key, + ), ]); } return new TGenericObject( $original_fq_classlike_name, - $template_params + $template_params, ); } @@ -1873,7 +1873,7 @@ public static function analyzeClassMethodReturnType( $return_type_location = $codebase->methods->getMethodReturnTypeLocation( $actual_method_id, - $secondary_return_type_location + $secondary_return_type_location, ); $original_fq_classlike_name = $fq_classlike_name; @@ -1881,7 +1881,7 @@ public static function analyzeClassMethodReturnType( $return_type = $codebase->methods->getMethodReturnType( $analyzed_method_id, $fq_classlike_name, - $method_analyzer + $method_analyzer, ); if ($return_type && $class_storage->template_extended_params) { @@ -1895,7 +1895,7 @@ public static function analyzeClassMethodReturnType( $this_object_type = self::getThisObjectType( $class_storage, - $original_fq_classlike_name + $original_fq_classlike_name, ); $class_template_params = ClassTemplateParamCollector::collect( @@ -1903,12 +1903,12 @@ public static function analyzeClassMethodReturnType( $class_storage, $codebase->classlike_storage_provider->get($original_fq_classlike_name), strtolower($stmt->name->name), - $this_object_type + $this_object_type, ) ?: []; $template_result = new TemplateResult( $class_template_params ?: [], - [] + [], ); $return_type = TemplateStandinTypeReplacer::replace( @@ -1918,7 +1918,7 @@ public static function analyzeClassMethodReturnType( null, null, null, - $original_fq_classlike_name + $original_fq_classlike_name, ); } @@ -1937,11 +1937,11 @@ public static function analyzeClassMethodReturnType( $interface_return_type = $codebase->methods->getMethodReturnType( $interface_method_id, - $interface_class + $interface_class, ); $interface_return_type_location = $codebase->methods->getMethodReturnTypeLocation( - $interface_method_id + $interface_method_id, ); ReturnTypeAnalyzer::verifyReturnType( @@ -1955,14 +1955,14 @@ public static function analyzeClassMethodReturnType( $original_fq_classlike_name, $interface_return_type_location, [$analyzed_method_id->__toString()], - $did_explicitly_return + $did_explicitly_return, ); } } $overridden_method_ids = array_map( static fn($method_id): string => $method_id->__toString(), - $overridden_method_ids + $overridden_method_ids, ); if ($actual_method_storage->overridden_downstream) { @@ -1981,7 +1981,7 @@ public static function analyzeClassMethodReturnType( $original_fq_classlike_name, $return_type_location, $overridden_method_ids, - $did_explicitly_return + $did_explicitly_return, ); } @@ -2000,7 +2000,7 @@ private function checkImplementedInterfaces( foreach ($class->implements as $interface_name) { $fq_interface_name = self::getFQCLNFromNameObject( $interface_name, - $this->source->getAliases() + $this->source->getAliases(), ); $fq_interface_name_lc = strtolower($fq_interface_name); @@ -2014,7 +2014,7 @@ private function checkImplementedInterfaces( . ($interface_name instanceof PhpParser\Node\Name\FullyQualified ? '\\' : $this->getNamespace() . '-') - . implode('\\', $interface_name->parts) + . implode('\\', $interface_name->parts), ); $interface_location = new CodeLocation($this, $interface_name); @@ -2025,7 +2025,7 @@ private function checkImplementedInterfaces( $interface_location, null, null, - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ) === false) { return false; } @@ -2037,7 +2037,7 @@ private function checkImplementedInterfaces( $this->getFilePath(), $bounds[0], $bounds[1], - $fq_interface_name + $fq_interface_name, ); } @@ -2046,7 +2046,7 @@ private function checkImplementedInterfaces( $this, $interface_name, $fq_interface_name, - null + null, ); try { @@ -2059,7 +2059,7 @@ private function checkImplementedInterfaces( $this, $interface_name, $class_context->include_location, - true + true, ); if (!$interface_storage->is_interface) { @@ -2067,9 +2067,9 @@ private function checkImplementedInterfaces( new UndefinedInterface( $fq_interface_name . ' is not an interface', $code_location, - $fq_interface_name + $fq_interface_name, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2078,7 +2078,7 @@ private function checkImplementedInterfaces( $storage, $interface_storage, $code_location, - $storage->template_type_implements_count[$fq_interface_name_lc] ?? 0 + $storage->template_type_implements_count[$fq_interface_name_lc] ?? 0, ); } @@ -2093,7 +2093,7 @@ private function checkImplementedInterfaces( $this, $class->name ?? $class, $class_context->include_location, - true + true, ); if ($fq_interface_name_lc === 'traversable' @@ -2109,8 +2109,8 @@ private function checkImplementedInterfaces( new InvalidTraversableImplementation( 'Traversable should be implemented by implementing IteratorAggregate or Iterator', $code_location, - $fq_class_name - ) + $fq_class_name, + ), ); } @@ -2119,9 +2119,9 @@ private function checkImplementedInterfaces( new DeprecatedInterface( $fq_interface_name . ' is marked deprecated', $code_location, - $fq_interface_name + $fq_interface_name, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2132,9 +2132,9 @@ private function checkImplementedInterfaces( new MissingImmutableAnnotation( $fq_interface_name . ' is marked @psalm-immutable, but ' . $fq_class_name . ' is not marked @psalm-immutable', - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2143,8 +2143,8 @@ private function checkImplementedInterfaces( $implementer_declaring_method_id = $codebase->methods->getDeclaringMethodId( new MethodIdentifier( $this->fq_class_name, - $interface_method_name_lc - ) + $interface_method_name_lc, + ), ); $implementer_method_storage = null; @@ -2153,10 +2153,10 @@ private function checkImplementedInterfaces( if ($implementer_declaring_method_id) { $implementer_fq_class_name = $implementer_declaring_method_id->fq_class_name; $implementer_method_storage = $codebase->methods->getStorage( - $implementer_declaring_method_id + $implementer_declaring_method_id, ); $implementer_classlike_storage = $classlike_storage_provider->get( - $implementer_fq_class_name + $implementer_fq_class_name, ); } @@ -2176,9 +2176,9 @@ private function checkImplementedInterfaces( new UnimplementedInterfaceMethod( 'Method ' . $interface_method_name_lc . ' is not defined on class ' . $storage->name, - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); return true; @@ -2187,8 +2187,8 @@ private function checkImplementedInterfaces( $implementer_appearing_method_id = $codebase->methods->getAppearingMethodId( new MethodIdentifier( $this->fq_class_name, - $interface_method_name_lc - ) + $interface_method_name_lc, + ), ); $implementer_visibility = $implementer_method_storage->visibility; @@ -2200,7 +2200,7 @@ private function checkImplementedInterfaces( $appearing_method_name = $implementer_appearing_method_id->method_name; $appearing_class_storage = $classlike_storage_provider->get( - $appearing_fq_class_name + $appearing_fq_class_name, ); if (isset($appearing_class_storage->trait_visibility_map[$appearing_method_name])) { @@ -2214,9 +2214,9 @@ private function checkImplementedInterfaces( new InaccessibleMethod( 'Interface-defined method ' . $implementer_method_storage->cased_name . ' must be public in ' . $storage->name, - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); return true; @@ -2228,9 +2228,9 @@ private function checkImplementedInterfaces( 'Method ' . $implementer_method_storage->cased_name . ' should be static like ' . $storage->name . '::' . $interface_method_storage->cased_name, - $code_location + $code_location, ), - $implementer_method_storage->suppressed_issues + $implementer_method_storage->suppressed_issues, ); return true; @@ -2251,7 +2251,7 @@ private function checkImplementedInterfaces( $implementer_visibility, $code_location, $implementer_method_storage->suppressed_issues, - false + false, ); } } @@ -2283,7 +2283,7 @@ private function checkParentClass( $parent_reference_location, null, null, - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ) === false) { return; } @@ -2294,7 +2294,7 @@ private function checkParentClass( $this, $extended_class, $parent_fq_class_name, - null + null, ); } @@ -2305,7 +2305,7 @@ private function checkParentClass( $this, $extended_class, $class_context->include_location ?? null, - true + true, ); if ($parent_class_storage->is_trait || $parent_class_storage->is_interface) { @@ -2313,9 +2313,9 @@ private function checkParentClass( new UndefinedClass( $parent_fq_class_name . ' is not a class', $code_location, - $parent_fq_class_name . ' as class' + $parent_fq_class_name . ' as class', ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2324,9 +2324,9 @@ private function checkParentClass( new InvalidExtendClass( 'Class ' . $fq_class_name . ' may not inherit from final class ' . $parent_fq_class_name, $code_location, - $fq_class_name + $fq_class_name, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2335,9 +2335,9 @@ private function checkParentClass( new DeprecatedClass( $parent_fq_class_name . ' is marked deprecated', $code_location, - $parent_fq_class_name + $parent_fq_class_name, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2348,9 +2348,9 @@ private function checkParentClass( . InternalClass::listToPhrase($parent_class_storage->internal) . ' but called from ' . $fq_class_name, $code_location, - $parent_fq_class_name + $parent_fq_class_name, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2361,9 +2361,9 @@ private function checkParentClass( new MissingImmutableAnnotation( $parent_fq_class_name . ' is marked @psalm-immutable, but ' . $fq_class_name . ' is not marked @psalm-immutable', - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2373,9 +2373,9 @@ private function checkParentClass( IssueBuffer::maybeAdd( new MutableDependency( $fq_class_name . ' is marked @psalm-immutable but ' . $parent_fq_class_name . ' is not', - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -2389,7 +2389,7 @@ private function checkParentClass( . ($extended_class instanceof PhpParser\Node\Name\FullyQualified ? '\\' : $this->getNamespace() . '-') - . implode('\\', $extended_class->parts) + . implode('\\', $extended_class->parts), ); } @@ -2397,7 +2397,7 @@ private function checkParentClass( $this, $class->name ?: $class, $class_context->include_location ?? null, - true + true, ); $this->checkTemplateParams( @@ -2405,7 +2405,7 @@ private function checkParentClass( $storage, $parent_class_storage, $code_location, - $storage->template_type_extends_count[$parent_fq_class_name] ?? 0 + $storage->template_type_extends_count[$parent_fq_class_name] ?? 0, ); } catch (InvalidArgumentException $e) { // do nothing @@ -2423,16 +2423,16 @@ private function checkEnum(): void new InvalidEnumCaseValue( 'Case of a non-backed enum should not have a value', $case_storage->stmt_location, - $storage->name - ) + $storage->name, + ), ); } elseif ($case_storage->value === null && $storage->enum_type !== null) { IssueBuffer::maybeAdd( new InvalidEnumCaseValue( 'Case of a backed enum should have a value', $case_storage->stmt_location, - $storage->name - ) + $storage->name, + ), ); } elseif ($case_storage->value !== null && $storage->enum_type !== null) { if ((is_int($case_storage->value) && $storage->enum_type === 'string') @@ -2442,8 +2442,8 @@ private function checkEnum(): void new InvalidEnumCaseValue( 'Enum case value type should be ' . $storage->enum_type, $case_storage->stmt_location, - $storage->name - ) + $storage->name, + ), ); } } @@ -2454,8 +2454,8 @@ private function checkEnum(): void new DuplicateEnumCaseValue( 'Enum case values should be unique', $case_storage->stmt_location, - $storage->name - ) + $storage->name, + ), ); } else { $seen_values[] = $case_storage->value; diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php index f3cc7a81b13..60491a78b6f 100644 --- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php @@ -135,7 +135,7 @@ public function getMethodMutations( foreach ($stmt->traits as $trait) { $fq_trait_name = self::getFQCLNFromNameObject( $trait, - $this->source->getAliases() + $this->source->getAliases(), ); $trait_file_analyzer = $project_analyzer->getFileAnalyzerForClassLike($fq_trait_name); @@ -151,7 +151,7 @@ public function getMethodMutations( $trait_node, $trait_file_analyzer, $fq_trait_name, - $trait_aliases + $trait_aliases, ); foreach ($trait_node->stmts as $trait_stmt) { @@ -175,7 +175,7 @@ public function getMethodMutations( $context, new NodeDataProvider(), null, - true + true, ); } } @@ -221,9 +221,9 @@ public static function checkFullyQualifiedClassLikeName( new UndefinedClass( 'Class or interface does not exist', $code_location, - 'empty string' + 'empty string', ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -239,7 +239,7 @@ public static function checkFullyQualifiedClassLikeName( if (preg_match( '/(^|\\\)(int|float|bool|string|void|null|false|true|object|mixed)$/i', - $fq_class_name + $fq_class_name, ) || strtolower($fq_class_name) === 'resource' ) { $class_name_parts = explode('\\', $fq_class_name); @@ -249,9 +249,9 @@ public static function checkFullyQualifiedClassLikeName( new ReservedWord( $class_name . ' is a reserved word', $code_location, - $class_name + $class_name, ), - $suppressed_issues + $suppressed_issues, ); return null; @@ -261,21 +261,21 @@ public static function checkFullyQualifiedClassLikeName( $fq_class_name, !$options->inferred ? $code_location : null, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); $interface_exists = $codebase->classlikes->interfaceExists( $fq_class_name, !$options->inferred ? $code_location : null, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); $enum_exists = $codebase->classlikes->enumExists( $fq_class_name, !$options->inferred ? $code_location : null, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); if (!$class_exists @@ -288,9 +288,9 @@ public static function checkFullyQualifiedClassLikeName( new UndefinedDocblockClass( 'Docblock-defined class, interface or enum named ' . $fq_class_name . ' does not exist', $code_location, - $fq_class_name + $fq_class_name, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -299,9 +299,9 @@ public static function checkFullyQualifiedClassLikeName( new UndefinedAttributeClass( 'Attribute class ' . $fq_class_name . ' does not exist', $code_location, - $fq_class_name + $fq_class_name, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -310,9 +310,9 @@ public static function checkFullyQualifiedClassLikeName( new UndefinedClass( 'Class, interface or enum named ' . $fq_class_name . ' does not exist', $code_location, - $fq_class_name + $fq_class_name, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -323,7 +323,7 @@ public static function checkFullyQualifiedClassLikeName( } $aliased_name = $codebase->classlikes->getUnAliasedName( - $fq_class_name + $fq_class_name, ); try { @@ -348,9 +348,9 @@ public static function checkFullyQualifiedClassLikeName( $fq_class_name . ' depends on class or interface ' . $dependency_class_name . ' that does not exist', $code_location, - $fq_class_name + $fq_class_name, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -365,9 +365,9 @@ public static function checkFullyQualifiedClassLikeName( new InvalidClass( 'Class, interface or enum ' . $fq_class_name . ' has wrong casing', $code_location, - $fq_class_name + $fq_class_name, ), - $suppressed_issues + $suppressed_issues, ); } } @@ -378,7 +378,7 @@ public static function checkFullyQualifiedClassLikeName( $code_location, $statements_source, $codebase, - [] + [], ); $codebase->config->eventDispatcher->dispatchAfterClassLikeExistenceCheck($event); @@ -416,7 +416,7 @@ public static function getFQCLNFromNameObject( return Type::getFQCLNFromString( implode('\\', $class_name->parts), - $aliases + $aliases, ); } @@ -536,7 +536,7 @@ public static function checkPropertyVisibility( $property_name, true, $context, - $code_location + $code_location, ); if ($property_visible !== null) { @@ -546,16 +546,16 @@ public static function checkPropertyVisibility( $declaring_property_class = $codebase->properties->getDeclaringClassForProperty( $property_id, - true + true, ); $appearing_property_class = $codebase->properties->getAppearingClassForProperty( $property_id, - true + true, ); if (!$declaring_property_class || !$appearing_property_class) { throw new UnexpectedValueException( - 'Appearing/Declaring classes are not defined for ' . $property_id + 'Appearing/Declaring classes are not defined for ' . $property_id, ); } @@ -587,9 +587,9 @@ public static function checkPropertyVisibility( IssueBuffer::maybeAdd( new InaccessibleProperty( 'Cannot access private property ' . $property_id . ' from context ' . $context->self, - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, ); } @@ -600,9 +600,9 @@ public static function checkPropertyVisibility( IssueBuffer::maybeAdd( new InaccessibleProperty( 'Cannot access protected property ' . $property_id, - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, ); } @@ -618,9 +618,9 @@ public static function checkPropertyVisibility( IssueBuffer::maybeAdd( new InaccessibleProperty( 'Cannot access protected property ' . $property_id . ' from context ' . $context->self, - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, ); } @@ -647,18 +647,18 @@ protected function checkTemplateParams( new MissingTemplateParam( $storage->name . ' has missing template params when extending ' . $parent_storage->name . ', expecting ' . $expected_param_count, - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } elseif ($expected_param_count < $given_param_count) { IssueBuffer::maybeAdd( new TooManyTemplateParams( $storage->name . ' has too many template params when extending ' . $parent_storage->name . ', expecting ' . $expected_param_count, - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } @@ -672,18 +672,18 @@ protected function checkTemplateParams( new MissingTemplateParam( $storage->name . ' requires the same number of template params as ' . $parent_storage->name . ' but saw ' . $storage_param_count, - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TooManyTemplateParams( $storage->name . ' requires the same number of template params as ' . $parent_storage->name . ' but saw ' . $storage_param_count, - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } } @@ -717,9 +717,9 @@ protected function checkTemplateParams( new InvalidTemplateParam( 'Cannot extend an invariant template param ' . $template_name . ' into a covariant context', - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } } @@ -735,9 +735,9 @@ protected function checkTemplateParams( 'Cannot extend a strictly-enforced parent template param ' . $template_name . ' with a non-template type', - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } elseif ($storage->template_types[$t->param_name][$storage->name]->getId() !== $template_type->getId() @@ -750,9 +750,9 @@ protected function checkTemplateParams( . ' with a child template param ' . $t->param_name . ' with different constraint ' . $storage->template_types[$t->param_name][$storage->name]->getId(), - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } } @@ -761,7 +761,7 @@ protected function checkTemplateParams( if (!$template_type->isMixed()) { $template_result = new TemplateResult( $previous_extended ?: [], - [] + [], ); $template_type_copy = TemplateStandinTypeReplacer::replace( @@ -771,7 +771,7 @@ protected function checkTemplateParams( null, $extended_type, null, - null + null, ); if (!UnionTypeComparator::isContainedBy($codebase, $extended_type, $template_type_copy)) { @@ -780,18 +780,18 @@ protected function checkTemplateParams( 'Extended template param ' . $template_name . ' expects type ' . $template_type_copy->getId() . ', type ' . $extended_type->getId() . ' given', - $code_location + $code_location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } else { $previous_extended[$template_name] = [ - $declaring_class => $extended_type + $declaring_class => $extended_type, ]; } } else { $previous_extended[$template_name] = [ - $declaring_class => $extended_type + $declaring_class => $extended_type, ]; } } diff --git a/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php b/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php index 7d6fae0fc85..97930b24e0e 100644 --- a/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php @@ -89,7 +89,7 @@ public static function analyzeExpression( $context->self && $codebase->classExtends( $context->self, - (string)$statements_analyzer->getFQCLN() + (string)$statements_analyzer->getFQCLN(), ) ) { /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ @@ -115,7 +115,7 @@ public static function analyzeExpression( $self_class_storage, $use_context, $context->self, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); } @@ -148,7 +148,7 @@ public static function analyzeExpression( $statements_analyzer->data_flow_graph->addPath( $parent_node, new DataFlowNode('closure-use', 'closure use', null), - 'closure-use' + 'closure-use', ); } } @@ -192,7 +192,7 @@ public static function analyzeExpression( $statements_analyzer->data_flow_graph->addPath( $parent_node, new DataFlowNode('closure-use', 'closure use', null), - 'closure-use' + 'closure-use', ); } } @@ -254,9 +254,9 @@ public static function analyzeClosureUses( if (IssueBuffer::accepts( new DuplicateParam( 'Closure use duplicates param name ' . $use_var_id, - new CodeLocation($statements_analyzer->getSource(), $use->var) + new CodeLocation($statements_analyzer->getSource(), $use->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -275,7 +275,7 @@ public static function analyzeClosureUses( $statements_analyzer->registerVariable( $use_var_id, new CodeLocation($statements_analyzer, $use->var), - null + null, ); } @@ -287,9 +287,9 @@ public static function analyzeClosureUses( if (IssueBuffer::accepts( new UndefinedVariable( 'Cannot find referenced variable ' . $use_var_id, - new CodeLocation($statements_analyzer->getSource(), $use->var) + new CodeLocation($statements_analyzer->getSource(), $use->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -305,9 +305,9 @@ public static function analyzeClosureUses( new PossiblyUndefinedVariable( 'Possibly undefined variable ' . $use_var_id . ', first seen on line ' . $first_appearance->getLineNumber(), - new CodeLocation($statements_analyzer->getSource(), $use->var) + new CodeLocation($statements_analyzer->getSource(), $use->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -319,9 +319,9 @@ public static function analyzeClosureUses( if (IssueBuffer::accepts( new UndefinedVariable( 'Cannot find referenced variable ' . $use_var_id, - new CodeLocation($statements_analyzer->getSource(), $use->var) + new CodeLocation($statements_analyzer->getSource(), $use->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -330,7 +330,7 @@ public static function analyzeClosureUses( } } elseif ($use->byRef) { $new_type = new Union([new TMixed()], [ - 'parent_nodes' => $context->vars_in_scope[$use_var_id]->parent_nodes + 'parent_nodes' => $context->vars_in_scope[$use_var_id]->parent_nodes, ]); $context->remove($use_var_id); diff --git a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php index 02a5e91b3b9..805da934070 100644 --- a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php @@ -57,7 +57,7 @@ public static function getTypeFromComment( $source, $aliases, $template_type_map, - $type_aliases + $type_aliases, ); } @@ -103,7 +103,7 @@ public static function arrayToDocblocks( $comment_text, "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ); $description = $parsed_docblock->description; @@ -125,7 +125,7 @@ public static function arrayToDocblocks( $line_parts[0], $aliases, $template_type_map, - $type_aliases + $type_aliases, ); } catch (TypeParseTreeException $e) { throw new DocblockParseException($line_parts[0] . ' is not a valid type'); @@ -156,7 +156,7 @@ public static function arrayToDocblocks( null, $template_type_map ?: [], $type_aliases ?: [], - true + true, ); } catch (TypeParseTreeException $e) { throw new DocblockParseException( @@ -166,7 +166,7 @@ public static function arrayToDocblocks( $source->getFilePath() . ':' . $comment->getStartLine() . - ')' + ')', ); } diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php index 7fb1fb01eda..7f6ce4cee76 100644 --- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php @@ -211,8 +211,8 @@ public function analyze( IssueBuffer::maybeAdd( new UncaughtThrowInGlobalScope( $possibly_thrown_exception . ' is thrown but not caught in global scope', - $codelocation - ) + $codelocation, + ), ); } } @@ -226,7 +226,7 @@ public function analyze( $this->getSource(), $alias->start_offset, $alias->end_offset, - $alias->line_number + $alias->line_number, ); $fq_source_classlike = $alias->declaring_fq_classlike_name; if (ClassLikeAnalyzer::checkFullyQualifiedClassLikeName( @@ -241,8 +241,8 @@ public function analyze( false, true, true, - true - ) + true, + ), ) === false) { continue; } @@ -254,8 +254,8 @@ public function analyze( 'Type alias ' . $alias->alias_name . ' imported from ' . $fq_source_classlike . ' is not defined on the source class', - $location - ) + $location, + ), ); } } @@ -378,7 +378,7 @@ public function getMethodMutations( $method_id, $this_context, $this->getRootFilePath(), - $this->getRootFileName() + $this->getRootFileName(), ); } diff --git a/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php index c11aa47c376..f22e09cf29f 100644 --- a/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php @@ -30,7 +30,7 @@ public function __construct(PhpParser\Node\Stmt\Function_ $function, SourceAnaly if (!isset($file_storage->functions[$function_id])) { throw new UnexpectedValueException( - 'Function ' . $function_id . ' should be defined in ' . $source->getFilePath() + 'Function ' . $function_id . ' should be defined in ' . $source->getFilePath(), ); } @@ -95,7 +95,7 @@ public static function analyzeStatement( $function_analyzer->analyze( $function_context, $statements_analyzer->node_data, - $context + $context, ); if ($config->reportIssueInFile('InvalidReturnType', $statements_analyzer->getFilePath())) { @@ -103,7 +103,7 @@ public static function analyzeStatement( $function_storage = $codebase->functions->getStorage( $statements_analyzer, - strtolower($method_id) + strtolower($method_id), ); $return_type = $function_storage->return_type; @@ -115,7 +115,7 @@ public static function analyzeStatement( $return_type, $statements_analyzer->getFQCLN(), $return_type_location, - $function_context->has_returned + $function_context->has_returned, ); } } diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php index 860af43801c..eb6c4000f9e 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php @@ -111,9 +111,9 @@ public static function verifyReturnType( IssueBuffer::maybeAdd( new MissingReturnType( 'Method ' . $cased_method_id . ' does not have a return type', - new CodeLocation($function_like_analyzer, $function->name, null, true) + new CodeLocation($function_like_analyzer, $function->name, null, true), ), - $suppressed_issues + $suppressed_issues, ); } @@ -134,7 +134,7 @@ public static function verifyReturnType( if (!$return_type_location) { $return_type_location = new CodeLocation( $function_like_analyzer, - $function instanceof Closure || $function instanceof ArrowFunction ? $function : $function->name + $function instanceof Closure || $function instanceof ArrowFunction ? $function : $function->name, ); } @@ -145,7 +145,7 @@ public static function verifyReturnType( $type_provider, $function_stmts, $inferred_yield_types, - true + true, ); if (!$inferred_return_type_parts) { @@ -156,7 +156,7 @@ public static function verifyReturnType( && ScopeAnalyzer::getControlActions( $function_stmts, $type_provider, - [] + [], ) !== [ScopeAnalyzer::ACTION_END] && !$inferred_yield_types && count($inferred_return_type_parts) @@ -176,14 +176,14 @@ public static function verifyReturnType( $function_stmts, $type_provider, [], - false + false, ); $function_always_exits = $control_actions === [ScopeAnalyzer::ACTION_END]; $function_returns_implicitly = (bool) array_diff( $control_actions, - [ScopeAnalyzer::ACTION_END, ScopeAnalyzer::ACTION_RETURN] + [ScopeAnalyzer::ACTION_END, ScopeAnalyzer::ACTION_RETURN], ); /** @psalm-suppress PossiblyUndefinedStringArrayOffset */ @@ -203,9 +203,9 @@ public static function verifyReturnType( new InvalidReturnType( 'Not all code paths of ' . $cased_method_id . ' end in a return statement, return type ' . $return_type . ' expected', - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -223,9 +223,9 @@ public static function verifyReturnType( new InvalidReturnType( $cased_method_id . ' is not expected to return any values but it does, ' . 'either implicitly or explicitly', - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -269,7 +269,7 @@ public static function verifyReturnType( $inferred_return_type, $source->getFQCLN(), $source->getFQCLN(), - $source->getParentFQCLN() + $source->getParentFQCLN(), ); // hack until we have proper yield type collection @@ -290,15 +290,15 @@ public static function verifyReturnType( Type::getString(), $inferred_return_type->ignore_nullable_issues, $inferred_return_type->ignore_falsable_issues, - $union_comparison_results + $union_comparison_results, ) ) { if (IssueBuffer::accepts( new InvalidToString( '__toString methods must return a string, ' . $inferred_return_type . ' returned', - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -309,9 +309,9 @@ public static function verifyReturnType( new ImplicitToStringCast( 'The declared return type for ' . $cased_method_id . ' expects string, ' . '\'' . $inferred_return_type . '\' provided with a __toString method', - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, ); } @@ -337,7 +337,7 @@ public static function verifyReturnType( ($project_analyzer->only_replace_php_types_with_non_docblock_types || $unsafe_return_type) && $inferred_return_type->from_docblock, - $function_like_storage + $function_like_storage, ); return null; @@ -346,10 +346,10 @@ public static function verifyReturnType( IssueBuffer::maybeAdd( new MissingClosureReturnType( 'Closure does not have a return type, expecting ' . $inferred_return_type->getId(), - new CodeLocation($function_like_analyzer, $function, null, true) + new CodeLocation($function_like_analyzer, $function, null, true), ), $suppressed_issues, - !$inferred_return_type->hasMixed() && !$inferred_return_type->isNull() + !$inferred_return_type->hasMixed() && !$inferred_return_type->isNull(), ); } @@ -374,7 +374,7 @@ public static function verifyReturnType( || (($project_analyzer->only_replace_php_types_with_non_docblock_types || $unsafe_return_type) && $inferred_return_type->from_docblock), - $function_like_storage + $function_like_storage, ); return null; @@ -384,10 +384,10 @@ public static function verifyReturnType( new MissingReturnType( 'Method ' . $cased_method_id . ' does not have a return type' . (!$inferred_return_type->hasMixed() ? ', expecting ' . $inferred_return_type->getId() : ''), - new CodeLocation($function_like_analyzer, $function->name, null, true) + new CodeLocation($function_like_analyzer, $function->name, null, true), ), $suppressed_issues, - !$inferred_return_type->hasMixed() && !$inferred_return_type->isNull() + !$inferred_return_type->hasMixed() && !$inferred_return_type->isNull(), ); return null; @@ -414,7 +414,7 @@ public static function verifyReturnType( true, true, ($function_like_storage instanceof MethodStorage && $function_like_storage->final) - || ($classlike_storage && $classlike_storage->final) + || ($classlike_storage && $classlike_storage->final), ); if (!$inferred_return_type_parts @@ -444,7 +444,7 @@ public static function verifyReturnType( $compatible_method_ids || (($project_analyzer->only_replace_php_types_with_non_docblock_types || $unsafe_return_type) - && $inferred_return_type->from_docblock) + && $inferred_return_type->from_docblock), ); return null; @@ -455,10 +455,10 @@ public static function verifyReturnType( new InvalidReturnType( 'No return statements were found for method ' . $cased_method_id . ' but return type \'' . $declared_return_type . '\' was expected', - $return_type_location + $return_type_location, ), $suppressed_issues, - true + true, )) { return false; } @@ -479,9 +479,9 @@ public static function verifyReturnType( new MixedInferredReturnType( 'Could not verify return type \'' . $declared_return_type . '\' for ' . $cased_method_id, - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -497,9 +497,9 @@ public static function verifyReturnType( 'The declared return type \'' . $declared_return_type->getId() . '|never\' for ' . $cased_method_id . ' is more specific than the inferred return type ' . '\'' . $inferred_return_type->getId() . '\'', - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -525,7 +525,7 @@ public static function verifyReturnType( ($project_analyzer->only_replace_php_types_with_non_docblock_types || $unsafe_return_type) && $inferred_return_type->from_docblock, - $function_like_storage + $function_like_storage, ); return null; @@ -537,10 +537,10 @@ public static function verifyReturnType( . $declared_return_type->getId() . '\' for ' . $cased_method_id . ' is incorrect, got \'never\'', - $return_type_location + $return_type_location, ), $suppressed_issues, - true + true, )) { return false; } @@ -552,7 +552,7 @@ public static function verifyReturnType( $declared_return_type, true, true, - $union_comparison_results + $union_comparison_results, )) { // is the declared return type more specific than the inferred one? if ($union_comparison_results->type_coerced) { @@ -563,9 +563,9 @@ public static function verifyReturnType( 'The declared return type \'' . $declared_return_type->getId() . '\' for ' . $cased_method_id . ' is more specific than the inferred return type ' . '\'' . $inferred_return_type->getId() . '\'', - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -576,9 +576,9 @@ public static function verifyReturnType( 'The declared return type \'' . $declared_return_type->getId() . '\' for ' . $cased_method_id . ' is more specific than the inferred return type ' . '\'' . $inferred_return_type->getId() . '\'', - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -596,7 +596,7 @@ public static function verifyReturnType( ($project_analyzer->only_replace_php_types_with_non_docblock_types || $unsafe_return_type) && $inferred_return_type->from_docblock, - $function_like_storage + $function_like_storage, ); return null; @@ -615,10 +615,10 @@ public static function verifyReturnType( . implode(', ', $union_comparison_results->missing_shape_fields) . ')' : ''), - $return_type_location + $return_type_location, ), $suppressed_issues, - true + true, )) { return false; } @@ -628,7 +628,7 @@ public static function verifyReturnType( $declared_return_type, $inferred_return_type, false, - false + false, )) { if ($codebase->alter_code) { if (isset($project_analyzer->getIssuesToFix()['LessSpecificReturnType']) @@ -644,7 +644,7 @@ public static function verifyReturnType( || (($project_analyzer->only_replace_php_types_with_non_docblock_types || $unsafe_return_type) && $inferred_return_type->from_docblock), - $function_like_storage + $function_like_storage, ); } } else { @@ -676,10 +676,10 @@ public static function verifyReturnType( . '\' for ' . $cased_method_id . ' is more specific than the declared return type \'' . $declared_return_type->getId() . '\'', - $return_type_location + $return_type_location, ), $suppressed_issues, - !($function_like_storage instanceof MethodStorage && $function_like_storage->inheritdoc) + !($function_like_storage instanceof MethodStorage && $function_like_storage->inheritdoc), )) { return false; } @@ -693,9 +693,9 @@ public static function verifyReturnType( 'The declared return type for ' . $cased_method_id . ' expects \'' . $declared_return_type . '\', ' . '\'' . $inferred_return_type . '\' provided with a __toString method', - $return_type_location + $return_type_location, ), - $suppressed_issues + $suppressed_issues, ); } @@ -718,7 +718,7 @@ public static function verifyReturnType( ($project_analyzer->only_replace_php_types_with_non_docblock_types || $unsafe_return_type) && $inferred_return_type->from_docblock, - $function_like_storage + $function_like_storage, ); return null; @@ -728,10 +728,10 @@ public static function verifyReturnType( new InvalidNullableReturnType( 'The declared return type \'' . $declared_return_type . '\' for ' . $cased_method_id . ' is not nullable, but \'' . $inferred_return_type . '\' contains null', - $return_type_location + $return_type_location, ), $suppressed_issues, - !$inferred_return_type->isNull() + !$inferred_return_type->isNull(), )) { return false; } @@ -754,7 +754,7 @@ public static function verifyReturnType( ($project_analyzer->only_replace_php_types_with_non_docblock_types || $unsafe_return_type) && $inferred_return_type->from_docblock, - $function_like_storage + $function_like_storage, ); return null; @@ -764,10 +764,10 @@ public static function verifyReturnType( new InvalidFalsableReturnType( 'The declared return type \'' . $declared_return_type . '\' for ' . $cased_method_id . ' does not allow false, but \'' . $inferred_return_type . '\' contains false', - $return_type_location + $return_type_location, ), $suppressed_issues, - true + true, )) { return false; } @@ -812,9 +812,9 @@ public static function checkReturnType( if (IssueBuffer::accepts( new InvalidParent( 'Cannot use parent as a return type when class has no parent', - $storage->return_type_location + $storage->return_type_location, ), - $storage->suppressed_issues + $storage->suppressed_issues, )) { return false; } @@ -827,7 +827,7 @@ public static function checkReturnType( $storage->return_type, $classlike_storage->name ?? null, $classlike_storage->name ?? null, - $parent_class + $parent_class, ); /** @psalm-suppress UnusedMethodCall This call actually has the side effect of creating issues */ @@ -839,7 +839,7 @@ public static function checkReturnType( false, false, false, - $context->calling_method_id + $context->calling_method_id, ); return null; @@ -850,7 +850,7 @@ public static function checkReturnType( $storage->signature_return_type, $classlike_storage->name ?? null, $classlike_storage->name ?? null, - $parent_class + $parent_class, ); if ($fleshed_out_signature_type->check( @@ -858,7 +858,7 @@ public static function checkReturnType( $storage->signature_return_type_location ?: $storage->return_type_location, $storage->suppressed_issues, [], - false + false, ) === false) { return false; } @@ -885,10 +885,10 @@ public static function checkReturnType( IssueBuffer::maybeAdd( new UnresolvableConstant( "Could not resolve constant {$e->class_name}::{$e->const_name}", - $storage->return_type_location + $storage->return_type_location, ), $storage->suppressed_issues, - true + true, ); $fleshed_out_return_type = $storage->return_type; } @@ -899,7 +899,7 @@ public static function checkReturnType( $storage->suppressed_issues, [], false, - $storage instanceof MethodStorage && $storage->inherited_return_type + $storage instanceof MethodStorage && $storage->inherited_return_type, ) === false) { return false; } @@ -911,7 +911,7 @@ public static function checkReturnType( $codebase->classlike_storage_provider->get($context->self), strtolower($function->name->name), new TNamedObject($context->self), - true + true, ); $class_template_params = $class_template_params ?: []; @@ -919,7 +919,7 @@ public static function checkReturnType( if ($class_template_params) { $template_result = new TemplateResult( $class_template_params, - [] + [], ); $fleshed_out_return_type = TemplateStandinTypeReplacer::replace( @@ -928,7 +928,7 @@ public static function checkReturnType( $codebase, null, null, - null + null, ); } } @@ -941,7 +941,7 @@ public static function checkReturnType( $fleshed_out_signature_type, false, false, - $union_comparison_result + $union_comparison_result, ) && !$union_comparison_result->type_coerced_from_mixed ) { if ($codebase->alter_code @@ -951,7 +951,7 @@ public static function checkReturnType( $function, $project_analyzer, $storage->signature_return_type, - $function_like_analyzer->getSource() + $function_like_analyzer->getSource(), ); return null; @@ -961,10 +961,10 @@ public static function checkReturnType( new MismatchingDocblockReturnType( 'Docblock has incorrect return type \'' . $storage->return_type->getId() . '\', should be \'' . $storage->signature_return_type->getId() . '\'', - $storage->return_type_location + $storage->return_type_location, ), $storage->suppressed_issues, - true + true, )) { return false; } @@ -987,7 +987,7 @@ private static function addOrUpdateReturnType( $manipulator = FunctionDocblockManipulator::getForFunction( $project_analyzer, $source->getFilePath(), - $function + $function, ); $codebase = $project_analyzer->getCodebase(); @@ -1013,22 +1013,22 @@ private static function addOrUpdateReturnType( $source->getNamespace(), $source->getAliasedClassesFlipped(), $source->getFQCLN(), - $codebase->analysis_php_version_id + $codebase->analysis_php_version_id, ) : null, $inferred_return_type->toNamespacedString( $source->getNamespace(), $source->getAliasedClassesFlipped(), $source->getFQCLN(), - false + false, ), $inferred_return_type->toNamespacedString( $source->getNamespace(), $source->getAliasedClassesFlipped(), $source->getFQCLN(), - true + true, ), $inferred_return_type->canBeFullyExpressedInPhp($codebase->analysis_php_version_id), - $function_like_storage->return_type_description ?? null + $function_like_storage->return_type_description ?? null, ); } } diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php index 07dbf8145fd..fe6c5774f3f 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php @@ -106,8 +106,8 @@ public static function getReturnTypes( $codebase, $nodes, [$stmt->expr->expr], - $yield_types - ) + $yield_types, + ), ]; } @@ -119,8 +119,8 @@ public static function getReturnTypes( $codebase, $nodes, $stmt->stmts, - $yield_types - ) + $yield_types, + ), ]; foreach ($stmt->elseifs as $elseif) { @@ -130,8 +130,8 @@ public static function getReturnTypes( $codebase, $nodes, $elseif->stmts, - $yield_types - ) + $yield_types, + ), ]; } @@ -142,8 +142,8 @@ public static function getReturnTypes( $codebase, $nodes, $stmt->else->stmts, - $yield_types - ) + $yield_types, + ), ]; } } elseif ($stmt instanceof PhpParser\Node\Stmt\TryCatch) { @@ -153,8 +153,8 @@ public static function getReturnTypes( $codebase, $nodes, $stmt->stmts, - $yield_types - ) + $yield_types, + ), ]; foreach ($stmt->catches as $catch) { @@ -164,8 +164,8 @@ public static function getReturnTypes( $codebase, $nodes, $catch->stmts, - $yield_types - ) + $yield_types, + ), ]; } @@ -176,8 +176,8 @@ public static function getReturnTypes( $codebase, $nodes, $stmt->finally->stmts, - $yield_types - ) + $yield_types, + ), ]; } } elseif ($stmt instanceof PhpParser\Node\Stmt\For_) { @@ -187,8 +187,8 @@ public static function getReturnTypes( $codebase, $nodes, $stmt->stmts, - $yield_types - ) + $yield_types, + ), ]; } elseif ($stmt instanceof PhpParser\Node\Stmt\Foreach_) { $return_types = [ @@ -197,8 +197,8 @@ public static function getReturnTypes( $codebase, $nodes, $stmt->stmts, - $yield_types - ) + $yield_types, + ), ]; } elseif ($stmt instanceof PhpParser\Node\Stmt\While_) { $yield_types = array_merge($yield_types, self::getYieldTypeFromExpression($stmt->cond, $nodes)); @@ -208,8 +208,8 @@ public static function getReturnTypes( $codebase, $nodes, $stmt->stmts, - $yield_types - ) + $yield_types, + ), ]; } elseif ($stmt instanceof PhpParser\Node\Stmt\Do_) { $return_types = [ @@ -218,8 +218,8 @@ public static function getReturnTypes( $codebase, $nodes, $stmt->stmts, - $yield_types - ) + $yield_types, + ), ]; } elseif ($stmt instanceof PhpParser\Node\Stmt\Switch_) { foreach ($stmt->cases as $case) { @@ -229,8 +229,8 @@ public static function getReturnTypes( $codebase, $nodes, $case->stmts, - $yield_types - ) + $yield_types, + ), ]; } } @@ -283,7 +283,7 @@ private static function processYieldTypes( $type, $codebase, $key_type, - $value_type + $value_type, ); } } @@ -296,10 +296,10 @@ private static function processYieldTypes( $key_type ?? Type::getMixed(), $value_type ?? Type::getMixed(), Type::getMixed(), - $return_types ? Type::combineUnionTypeArray($return_types, null) : Type::getVoid() - ] + $return_types ? Type::combineUnionTypeArray($return_types, null) : Type::getVoid(), + ], ), - ]) + ]), ]; } @@ -313,7 +313,7 @@ private static function getYieldTypeFromExpression( $collector = new YieldTypeCollector($nodes); $traverser = new NodeTraverser(); $traverser->addVisitor( - $collector + $collector, ); $traverser->traverse([$stmt]); diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 4d0c29aee16..d86a5422dae 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -196,7 +196,7 @@ public function analyze( $codebase, $type_provider, $storage, - $add_mutations + $add_mutations, ); if ($function_information === null) { @@ -209,7 +209,7 @@ public function analyze( $appearing_class_storage, $hash, $cased_method_id, - $overridden_method_ids + $overridden_method_ids, ] = $function_information; $this->suppressed_issues = $this->getSource()->getSuppressedIssues() + $storage->suppressed_issues; @@ -240,14 +240,14 @@ public function analyze( if ($statements_analyzer->data_flow_graph) { $use_assignment = DataFlowNode::getForAssignment( $use_var_id, - $use_location + $use_location, ); $statements_analyzer->data_flow_graph->addNode($use_assignment); $context->vars_in_scope[$use_var_id] = $context->vars_in_scope[$use_var_id]->addParentNodes( - [$use_assignment->id => $use_assignment] + [$use_assignment->id => $use_assignment], ); } @@ -258,7 +258,7 @@ public function analyze( $statements_analyzer->data_flow_graph->addPath( $use_assignment, new DataFlowNode('closure-use', 'closure use', null), - 'closure-use' + 'closure-use', ); } } else { @@ -273,7 +273,7 @@ public function analyze( foreach ($storage->template_types as $param_name => $_) { $fq_classlike_name = Type::getFQCLNFromString( $param_name, - $this->getAliases() + $this->getAliases(), ); if ($codebase->classOrInterfaceExists($fq_classlike_name)) { @@ -281,9 +281,9 @@ public function analyze( new ReservedWord( 'Cannot use ' . $param_name . ' as template name since the class already exists', new CodeLocation($this, $this->function), - 'resource' + 'resource', ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } } @@ -309,13 +309,13 @@ public function analyze( new FileManipulation( (int) $this->function->name->getAttribute('startFilePos'), (int) $this->function->name->getAttribute('endFilePos') + 1, - $new_method_name - ) + $new_method_name, + ), ]; FileManipulationBuffer::add( $this->getFilePath(), - $file_manipulations + $file_manipulations, ); } } @@ -326,7 +326,7 @@ public function analyze( ) { $params = $codebase->methods->getMethodParams( $method_id, - $this + $this, ); } @@ -337,7 +337,7 @@ public function analyze( $params, array_values($this->function->params), $context, - (bool) $template_types + (bool) $template_types, ); if ($storage->pure) { @@ -364,8 +364,8 @@ public function analyze( IssueBuffer::maybeAdd( new InvalidDocblockParamName( 'Incorrect param name $' . $param_name . ' in docblock for ' . $cased_method_id, - $param_location - ) + $param_location, + ), ); } } @@ -377,7 +377,7 @@ public function analyze( $this->getFilePath(), $start, $end, - (string) $storage->signature_return_type + (string) $storage->signature_return_type, ); } @@ -388,7 +388,7 @@ public function analyze( IssueBuffer::maybeAdd(new MethodSignatureMismatch( 'Method ' . (string) $method_id . ' should accept named arguments ' . ' as ' . (string) $overridden_method_id . ' does', - $storage->location + $storage->location, )); } } @@ -399,7 +399,7 @@ public function analyze( $project_analyzer, $this, $storage, - $context + $context, ) === false) { $check_stmts = false; } @@ -467,7 +467,7 @@ public function analyze( $manipulator = FunctionDocblockManipulator::getForFunction( $project_analyzer, $this->source->getFilePath(), - $this->function + $this->function, ); $yield_types = []; @@ -477,13 +477,13 @@ public function analyze( $type_provider, $function_stmts, $yield_types, - true + true, ); $inferred_return_type = $inferred_return_types ? Type::combineUnionTypeArray( $inferred_return_types, - $codebase + $codebase, ) : Type::getVoid(); @@ -523,7 +523,7 @@ public function analyze( $final_actions = ScopeAnalyzer::getControlActions( $this->function->getStmts() ?: [], null, - [] + [], ); if ($final_actions !== [ScopeAnalyzer::ACTION_END]) { @@ -541,17 +541,17 @@ public function analyze( IssueBuffer::maybeAdd( new MissingClosureParamType( 'Parameter $' . $function_param->name . ' has no provided type', - $function_param->location + $function_param->location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new MissingParamType( 'Parameter $' . $function_param->name . ' has no provided type', - $function_param->location + $function_param->location, ), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } } @@ -567,7 +567,7 @@ public function analyze( $this->source->getFQCLN(), $storage->return_type_location, $context->has_returned, - $global_context && ($global_context->inside_call || $global_context->inside_return) + $global_context && ($global_context->inside_call || $global_context->inside_return), ); $closure_yield_types = []; @@ -577,20 +577,20 @@ public function analyze( $type_provider, $function_stmts, $closure_yield_types, - true + true, ); $closure_return_type = $closure_return_types ? Type::combineUnionTypeArray( $closure_return_types, - $codebase + $codebase, ) : Type::getVoid(); $closure_yield_type = $closure_yield_types ? Type::combineUnionTypeArray( $closure_yield_types, - $codebase + $codebase, ) : null; @@ -611,7 +611,7 @@ public function analyze( || UnionTypeComparator::isContainedBy( $codebase, $closure_return_type, - $storage->return_type + $storage->return_type, )) ) { $new_closure_return_type = $closure_return_type; @@ -630,8 +630,8 @@ public function analyze( $closure_atomic->byref_uses, $closure_atomic->extra_types, $closure_atomic->from_docblock, - ) - ]) + ), + ]), ); } } @@ -646,7 +646,7 @@ public function analyze( $statements_analyzer, $storage, $appearing_class_storage, - $context + $context, ); } @@ -671,8 +671,8 @@ public function analyze( false, true, true, - true - ) + true, + ), )) { $input_type = new Union([new TNamedObject($expected_exception)]); $container_type = new Union([new TNamedObject('Exception'), new TNamedObject('Throwable')]); @@ -683,9 +683,9 @@ public function analyze( 'Class supplied for @throws ' . $expected_exception . ' does not implement Throwable', $storage->throw_locations[$expected_exception], - $expected_exception + $expected_exception, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -695,7 +695,7 @@ public function analyze( $this, $input_type, $storage->throw_locations[$expected_exception], - $context->calling_method_id + $context->calling_method_id, ); } } @@ -721,7 +721,7 @@ public function analyze( $this->source->getNamespace(), $this->source->getAliasedClassesFlipped(), $this->source->getFQCLN(), - true + true, ); foreach ($codelocations as $codelocation) { @@ -730,8 +730,8 @@ public function analyze( new MissingThrowsDocblock( $possibly_thrown_exception . ' is thrown but not caught - please either catch' . ' or add a @throws annotation', - $codelocation - ) + $codelocation, + ), ); } } @@ -743,7 +743,7 @@ public function analyze( $manipulator = FunctionDocblockManipulator::getForFunction( $project_analyzer, $this->source->getFilePath(), - $this->function + $this->function, ); $manipulator->addThrowsDocblock($missingThrowsDocblockErrors); } @@ -758,7 +758,7 @@ public function analyze( $method_source = DataFlowNode::getForMethodReturn( (string) $method_id, $cased_method_id, - $storage->location + $storage->location, ); $codebase->taint_flow_graph->addNode($method_source); @@ -767,7 +767,7 @@ public function analyze( $codebase->taint_flow_graph->addPath( $parent_node, $method_source, - '$this' + '$this', ); } } @@ -776,14 +776,14 @@ public function analyze( if ($this->return_vars_in_scope !== null) { $context->vars_in_scope = TypeAnalyzer::combineKeyedTypes( $context->vars_in_scope, - $this->return_vars_in_scope + $this->return_vars_in_scope, ); } if ($this->return_vars_possibly_in_scope !== null) { $context->vars_possibly_in_scope = array_merge( $context->vars_possibly_in_scope, - $this->return_vars_possibly_in_scope + $this->return_vars_possibly_in_scope, ); } @@ -819,7 +819,7 @@ public function analyze( $codebase, [], $type_provider, - $context + $context, ); if ($codebase->config->eventDispatcher->dispatchAfterFunctionLikeAnalysis($event) === false) { @@ -831,7 +831,7 @@ public function analyze( if ($file_manipulations) { FileManipulationBuffer::add( $this->getFilePath(), - $file_manipulations + $file_manipulations, ); } @@ -841,7 +841,7 @@ public function analyze( $storage, $this->function->attrGroups, $storage instanceof MethodStorage ? AttributesAnalyzer::TARGET_METHOD : AttributesAnalyzer::TARGET_FUNCTION, - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); return null; @@ -905,17 +905,17 @@ private function checkParamReferences( IssueBuffer::maybeAdd( new UnusedClosureParam( 'Param ' . $var_name . ' is never referenced in this method', - $original_location + $original_location, ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new UnusedParam( 'Param ' . $var_name . ' is never referenced in this method', - $original_location + $original_location, ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } } else { @@ -961,7 +961,7 @@ private function checkParamReferences( $codebase->file_reference_provider->addMethodParamUse( $method_id_lc, $i, - $method_id_lc + $method_id_lc, ); $method_name_lc = strtolower($storage->cased_name); @@ -974,7 +974,7 @@ private function checkParamReferences( $codebase->file_reference_provider->addMethodParamUse( strtolower((string) $parent_method_id), $i, - $method_id_lc + $method_id_lc, ); } } @@ -1016,7 +1016,7 @@ private function processParams( $this->getFilePath(), $start, $end, - (string) $referenced_type + (string) $referenced_type, ); } @@ -1026,7 +1026,7 @@ private function processParams( $signature_type, $context->self, $context->self, - $this->getParentFQCLN() + $this->getParentFQCLN(), ); } @@ -1045,7 +1045,7 @@ private function processParams( ) { $param_assignment = DataFlowNode::getForAssignment( $function_param_id, - $function_param->location + $function_param->location, ); $statements_analyzer->data_flow_graph->addNode($param_assignment); @@ -1056,7 +1056,7 @@ private function processParams( $cased_method_id, $offset, $function_param->location, - null + null, ); $statements_analyzer->data_flow_graph->addPath($type_source, $param_assignment, 'param'); @@ -1092,10 +1092,10 @@ private function processParams( IssueBuffer::maybeAdd( new UnresolvableConstant( "Could not resolve constant {$e->class_name}::{$e->const_name}", - $function_param->type_location + $function_param->type_location, ), $storage->suppressed_issues, - true + true, ); } } @@ -1110,7 +1110,7 @@ private function processParams( false, $this->function instanceof ClassMethod && strtolower($this->function->name->name) !== '__construct', - $context->calling_method_id + $context->calling_method_id, ) === false) { $check_stmts = false; } @@ -1120,7 +1120,7 @@ private function processParams( } else { $param_type = new Union([new TMixed()], [ 'by_ref' => $function_param->by_ref, - 'parent_nodes' => $parent_nodes + 'parent_nodes' => $parent_nodes, ]); } @@ -1132,14 +1132,14 @@ private function processParams( new TArray([Type::getArrayKey(), $param_type]), ], [ 'by_ref' => $function_param->by_ref, - 'parent_nodes' => $parent_nodes + 'parent_nodes' => $parent_nodes, ]); } else { $var_type = new Union([ Type::getListAtomic($param_type), ], [ 'by_ref' => $function_param->by_ref, - 'parent_nodes' => $parent_nodes + 'parent_nodes' => $parent_nodes, ]); } } @@ -1159,7 +1159,7 @@ private function processParams( $statements_analyzer->registerVariable( $function_param_id, $function_param->location, - null + null, ); } @@ -1180,7 +1180,7 @@ private function processParams( $signature_type, false, false, - $union_comparison_result + $union_comparison_result, ) && !$union_comparison_result->type_coerced_from_mixed ) { if ($codebase->alter_code @@ -1195,10 +1195,10 @@ private function processParams( new MismatchingDocblockParamType( 'Parameter ' . $function_param_id . ' has wrong type \'' . $param_type . '\', should be \'' . $signature_type . '\'', - $function_param->type_location + $function_param->type_location, ), $storage->suppressed_issues, - true + true, ); if ($signature_type->check( @@ -1206,7 +1206,7 @@ private function processParams( $function_param->type_location, $storage->suppressed_issues, [], - false + false, ) === false) { $check_stmts = false; } @@ -1229,7 +1229,7 @@ private function processParams( false, false, null, - true + true, ) ) { IssueBuffer::maybeAdd( @@ -1237,8 +1237,8 @@ private function processParams( 'Default value type ' . $default_type->getId() . ' for argument ' . ($offset + 1) . ' of method ' . $cased_method_id . ' does not match the given type ' . $param_type->getId(), - $function_param->type_location - ) + $function_param->type_location, + ), ); } } @@ -1249,7 +1249,7 @@ private function processParams( $function_param->type_location, $this->suppressed_issues, [], - false + false, ) === false) { $check_stmts = false; } @@ -1259,9 +1259,9 @@ private function processParams( new ReservedWord( 'Parameter cannot be void', $function_param->type_location, - 'void' + 'void', ), - $this->suppressed_issues + $this->suppressed_issues, ); } @@ -1270,7 +1270,7 @@ private function processParams( $function_param->type_location, $this->suppressed_issues, [], - false + false, ) === false) { $check_stmts = false; } @@ -1286,7 +1286,7 @@ private function processParams( $function_param->signature_type_location, $this->suppressed_issues, [], - false + false, ) === false) { $check_stmts = false; } @@ -1308,7 +1308,7 @@ private function processParams( $param_stmts[$offset]->attrGroups, AttributesAnalyzer::TARGET_PARAMETER | ($function_param->promoted_property ? AttributesAnalyzer::TARGET_PROPERTY : 0), - $storage->suppressed_issues + $this->getSuppressedIssues() + $storage->suppressed_issues + $this->getSuppressedIssues(), ); } } @@ -1354,7 +1354,7 @@ private function alterParams( $resolved_name, $context->calling_method_id, false, - true + true, ); } } @@ -1388,7 +1388,7 @@ private function alterParams( $resolved_name, $context->calling_method_id, false, - true + true, ); } } @@ -1403,7 +1403,7 @@ private function alterParams( $context->self, 'static', $this->getParentFQCLN(), - false + false, ); $codebase->classlikes->handleDocblockTypeInMigration( @@ -1411,7 +1411,7 @@ private function alterParams( $this, $replace_type, $storage->return_type_location, - $context->calling_method_id + $context->calling_method_id, ); } @@ -1427,7 +1427,7 @@ private function alterParams( $context->self, 'static', $this->getParentFQCLN(), - false + false, ); $codebase->classlikes->handleDocblockTypeInMigration( @@ -1435,7 +1435,7 @@ private function alterParams( $this, $replace_type, $function_param->type_location, - $context->calling_method_id + $context->calling_method_id, ); } } @@ -1465,7 +1465,7 @@ public function verifyReturnType( $return_type_location, [], $did_explicitly_return, - $closure_inside_call + $closure_inside_call, ); } @@ -1478,7 +1478,7 @@ public function addOrUpdateParamType( $manipulator = FunctionDocblockManipulator::getForFunction( $project_analyzer, $this->source->getFilePath(), - $this->function + $this->function, ); $codebase = $project_analyzer->getCodebase(); @@ -1505,20 +1505,20 @@ public function addOrUpdateParamType( $this->source->getNamespace(), $this->source->getAliasedClassesFlipped(), $this->source->getFQCLN(), - $project_analyzer->getCodebase()->analysis_php_version_id + $project_analyzer->getCodebase()->analysis_php_version_id, ) : null, $inferred_return_type->toNamespacedString( $this->source->getNamespace(), $this->source->getAliasedClassesFlipped(), $this->source->getFQCLN(), - false + false, ), $inferred_return_type->toNamespacedString( $this->source->getNamespace(), $this->source->getAliasedClassesFlipped(), $this->source->getFQCLN(), - true - ) + true, + ), ); } @@ -1530,7 +1530,7 @@ public function addReturnTypes(Context $context): void if ($this->return_vars_in_scope !== null) { $this->return_vars_in_scope = TypeAnalyzer::combineKeyedTypes( $context->vars_in_scope, - $this->return_vars_in_scope + $this->return_vars_in_scope, ); } else { $this->return_vars_in_scope = $context->vars_in_scope; @@ -1539,7 +1539,7 @@ public function addReturnTypes(Context $context): void if ($this->return_vars_possibly_in_scope !== null) { $this->return_vars_possibly_in_scope = array_merge( $context->vars_possibly_in_scope, - $this->return_vars_possibly_in_scope + $this->return_vars_possibly_in_scope, ); } else { $this->return_vars_possibly_in_scope = $context->vars_possibly_in_scope; @@ -1565,7 +1565,7 @@ public function examineParamTypes( $actual_type, $param_out_type, $actual_type->ignore_nullable_issues, - $actual_type->ignore_falsable_issues + $actual_type->ignore_falsable_issues, ) ) { IssueBuffer::maybeAdd( @@ -1577,9 +1577,9 @@ public function examineParamTypes( . 'a different output type', $stmt ? new CodeLocation($this, $stmt) - : $param->location + : $param->location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1785,7 +1785,7 @@ public function getLocalReturnType(Union $storage_return_type, bool $final = fal $this->getParentFQCLN(), true, true, - $final + $final, ); return $this->local_return_type; @@ -1849,8 +1849,8 @@ private function getFunctionInformation( new TTemplateParam( $param_name, reset($template_map), - $key - ) + $key, + ), ]); } @@ -1858,12 +1858,12 @@ private function getFunctionInformation( $context->self, $template_params, false, - !$storage->final + !$storage->final, ); } else { $this_object_type = new TNamedObject( $context->self, - !$storage->final + !$storage->final, ); } @@ -1895,7 +1895,7 @@ private function getFunctionInformation( $template_result, $codebase, null, - $this->storage->if_this_is_type + $this->storage->if_this_is_type, ); foreach ($context->vars_in_scope as $var_name => &$var_type) { @@ -1925,7 +1925,7 @@ private function getFunctionInformation( $this, $this->function, null, - true + true, ); if ($overridden_method_ids @@ -1961,11 +1961,11 @@ private function getFunctionInformation( $declaring_fq_class_name = $implementer_declaring_method_id->fq_class_name; $appearing_class_storage = $classlike_storage_provider->get( - $appearing_fq_class_name + $appearing_fq_class_name, ); $declaring_class_storage = $classlike_storage_provider->get( - $declaring_fq_class_name + $declaring_fq_class_name, ); if (isset($appearing_class_storage->trait_visibility_map[$appearing_method_name])) { @@ -1986,7 +1986,7 @@ private function getFunctionInformation( $fq_class_name, $implementer_visibility, $codeLocation, - $storage->suppressed_issues + $storage->suppressed_issues, ); } } @@ -2013,7 +2013,7 @@ private function getFunctionInformation( $storage->return_type, $context->self, $context->self, - $this->getParentFQCLN() + $this->getParentFQCLN(), ); } else { $closure_return_type = Type::getMixed(); @@ -2031,7 +2031,7 @@ private function getFunctionInformation( $this->function, new Union([ $closure_type, - ]) + ]), ); } else { throw new UnexpectedValueException('Impossible'); @@ -2043,7 +2043,7 @@ private function getFunctionInformation( $appearing_class_storage, $hash, $cased_method_id, - $overridden_method_ids + $overridden_method_ids, ]; } } diff --git a/src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php b/src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php index c714fa51b63..827a997897d 100644 --- a/src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/InterfaceAnalyzer.php @@ -53,14 +53,14 @@ public function analyze(): void foreach ($this->class->extends as $extended_interface) { $extended_interface_name = self::getFQCLNFromNameObject( $extended_interface, - $this->getAliases() + $this->getAliases(), ); $parent_reference_location = new CodeLocation($this, $extended_interface); if (!$codebase->classOrInterfaceExists( $extended_interface_name, - $parent_reference_location + $parent_reference_location, )) { // we should not normally get here return; @@ -74,7 +74,7 @@ public function analyze(): void $code_location = new CodeLocation( $this, - $extended_interface + $extended_interface, ); if (!$extended_interface_storage->is_interface) { @@ -82,9 +82,9 @@ public function analyze(): void new UndefinedInterface( $extended_interface_name . ' is not an interface', $code_location, - $extended_interface_name + $extended_interface_name, ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } @@ -95,7 +95,7 @@ public function analyze(): void $this->getFilePath(), $bounds[0], $bounds[1], - $extended_interface_name + $extended_interface_name, ); } @@ -104,7 +104,7 @@ public function analyze(): void $class_storage, $extended_interface_storage, $code_location, - $class_storage->template_type_extends_count[$extended_interface_name] ?? 0 + $class_storage->template_type_extends_count[$extended_interface_name] ?? 0, ); } } @@ -124,7 +124,7 @@ public function analyze(): void $class_storage, $this->class->attrGroups, AttributesAnalyzer::TARGET_CLASS, - $class_storage->suppressed_issues + $this->getSuppressedIssues() + $class_storage->suppressed_issues + $this->getSuppressedIssues(), ); $member_stmts = []; @@ -151,15 +151,15 @@ public function analyze(): void $fq_interface_name, $actual_method_id, $actual_method_id, - false + false, ); } } elseif ($stmt instanceof PhpParser\Node\Stmt\Property) { IssueBuffer::maybeAdd( new ParseError( 'Interfaces cannot have properties', - new CodeLocation($this, $stmt) - ) + new CodeLocation($this, $stmt), + ), ); return; @@ -175,13 +175,13 @@ public function analyze(): void new FileManipulation( (int) $const->name->getAttribute('startFilePos'), (int) $const->name->getAttribute('endFilePos') + 1, - $new_const_name - ) + $new_const_name, + ), ]; FileManipulationBuffer::add( $this->getFilePath(), - $file_manipulations + $file_manipulations, ); } } diff --git a/src/Psalm/Internal/Analyzer/MethodAnalyzer.php b/src/Psalm/Internal/Analyzer/MethodAnalyzer.php index 8bfb54e4184..0a5077c1414 100644 --- a/src/Psalm/Internal/Analyzer/MethodAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/MethodAnalyzer.php @@ -130,9 +130,9 @@ public static function checkStatic( 'Method ' . $codebase_methods->getCasedMethodId($method_id) . ' is not static, but is called ' . 'using self::', - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, )) { return; } @@ -145,9 +145,9 @@ public static function checkStatic( 'Method ' . $codebase_methods->getCasedMethodId($method_id) . ' is not static, but is called ' . 'statically', - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, )) { return; } @@ -174,14 +174,14 @@ public static function checkMethodExists( ? $code_location : null, null, - $code_location->file_path + $code_location->file_path, )) { return true; } if (IssueBuffer::accepts( new UndefinedMethod('Method ' . $method_id . ' does not exist', $code_location, (string) $method_id), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -205,7 +205,7 @@ public static function isMethodVisible( $fq_classlike_name, $method_name, $context, - null + null, ); if ($method_visible !== null) { @@ -294,8 +294,8 @@ public static function checkMethodSignatureMustOmitReturnType( IssueBuffer::maybeAdd( new MethodSignatureMustOmitReturnType( 'Method ' . $method_storage->cased_name . ' must not declare a return type', - $code_location - ) + $code_location, + ), ); } } @@ -306,7 +306,7 @@ public function getMethodId(?string $context_self = null): MethodIdentifier return new MethodIdentifier( $context_self ?: (string) $this->source->getFQCLN(), - strtolower($function_name) + strtolower($function_name), ); } @@ -321,7 +321,7 @@ public static function checkForbiddenEnumMethod(MethodStorage $method_storage): IssueBuffer::maybeAdd(new InvalidEnumMethod( 'Enums cannot define ' . $method_storage->cased_name, $method_storage->location, - $method_storage->defining_fqcln . '::' . $method_storage->cased_name + $method_storage->defining_fqcln . '::' . $method_storage->cased_name, )); } } diff --git a/src/Psalm/Internal/Analyzer/MethodComparator.php b/src/Psalm/Internal/Analyzer/MethodComparator.php index 9349545e160..ed56927f874 100644 --- a/src/Psalm/Internal/Analyzer/MethodComparator.php +++ b/src/Psalm/Internal/Analyzer/MethodComparator.php @@ -67,11 +67,11 @@ public static function compare( ): ?bool { $implementer_method_id = new MethodIdentifier( $implementer_classlike_storage->name, - strtolower($guide_method_storage->cased_name ?: '') + strtolower($guide_method_storage->cased_name ?: ''), ); $implementer_declaring_method_id = $codebase->methods->getDeclaringMethodId( - $implementer_method_id + $implementer_method_id, ); $cased_implementer_method_id = $implementer_classlike_storage->name . '::' @@ -81,7 +81,7 @@ public static function compare( $codebase->methods->file_reference_provider->addMethodDependencyToClassMember( strtolower((string)($implementer_declaring_method_id ?? $implementer_method_id)), - strtolower($guide_classlike_storage->name . '::' . $guide_method_storage->cased_name) + strtolower($guide_classlike_storage->name . '::' . $guide_method_storage->cased_name), ); self::checkForObviousMethodMismatches( @@ -97,7 +97,7 @@ public static function compare( $prevent_abstract_override, $codebase->analysis_php_version_id >= 8_00_00, $code_location, - $suppressed_issues + $suppressed_issues, ); if ($guide_method_storage->signature_return_type && $prevent_method_signature_mismatch) { @@ -112,7 +112,7 @@ public static function compare( $implementer_called_class_name, $cased_implementer_method_id, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -125,15 +125,15 @@ public static function compare( && !$implementer_method_storage->signature_return_type && !array_filter( $implementer_method_storage->attributes, - static fn(AttributeStorage $s): bool => $s->fq_class_name === 'ReturnTypeWillChange' + static fn(AttributeStorage $s): bool => $s->fq_class_name === 'ReturnTypeWillChange', ) ) { IssueBuffer::maybeAdd( new MethodSignatureMustProvideReturnType( 'Method ' . $cased_implementer_method_id . ' must have a return type signature!', - $implementer_method_storage->location ?: $code_location + $implementer_method_storage->location ?: $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } @@ -156,7 +156,7 @@ public static function compare( $implementer_called_class_name, $implementer_declaring_method_id, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -170,9 +170,9 @@ public static function compare( new MethodSignatureMismatch( 'Method ' . $cased_implementer_method_id . ' has fewer parameters than parent method ' . $cased_guide_method_id, - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, )) { return false; } @@ -195,7 +195,7 @@ public static function compare( $cased_implementer_method_id, $prevent_method_signature_mismatch, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -210,9 +210,9 @@ public static function compare( new MethodSignatureMismatch( 'Method ' . $cased_implementer_method_id . ' has more required parameters than parent method ' . $cased_guide_method_id, - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, )) { return false; } @@ -221,9 +221,9 @@ public static function compare( new ConstructorSignatureMismatch( 'Method ' . $cased_implementer_method_id . ' has more required parameters than parent method ' . $cased_guide_method_id, - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, )) { return false; } @@ -266,18 +266,18 @@ private static function checkForObviousMethodMismatches( new OverriddenMethodAccess( 'Method ' . $cased_implementer_method_id . ' has different access level than ' . $cased_guide_method_id, - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } else { IssueBuffer::maybeAdd( new TraitMethodSignatureMismatch( 'Method ' . $cased_implementer_method_id . ' has different access level than ' . $cased_guide_method_id, - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } @@ -289,11 +289,11 @@ private static function checkForObviousMethodMismatches( IssueBuffer::maybeAdd( new MethodSignatureMismatch( 'Method ' . $cased_guide_method_id . ' is declared final and cannot be overridden', - $code_location + $code_location, ), $guide_method_storage->final_from_docblock ? $suppressed_issues + $implementer_classlike_storage->suppressed_issues : - [] + [], ); } @@ -307,9 +307,9 @@ private static function checkForObviousMethodMismatches( new MethodSignatureMismatch( 'Method ' . $cased_implementer_method_id . ' cannot be abstract when inherited method ' . $cased_guide_method_id . ' is non-abstract', - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } @@ -324,9 +324,9 @@ private static function checkForObviousMethodMismatches( . $implementer_classlike_storage->name . '::' . ($guide_method_storage->cased_name ?: '') . ' is not marked @psalm-immutable', - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } @@ -396,12 +396,12 @@ private static function compareMethodParams( . $cased_guide_method_id, $implementer_param->location && $config->isInProjectDirs( - $implementer_param->location->file_path + $implementer_param->location->file_path, ) ? $implementer_param->location - : $code_location + : $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -413,12 +413,12 @@ private static function compareMethodParams( . $cased_guide_method_id, $implementer_param->location && $config->isInProjectDirs( - $implementer_param->location->file_path + $implementer_param->location->file_path, ) ? $implementer_param->location - : $code_location + : $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } @@ -438,7 +438,7 @@ private static function compareMethodParams( && $guide_method_storage->cased_name && strpos($guide_method_storage->cased_name, '__') !== 0 && $config->isInProjectDirs( - $implementer_param->location->file_path + $implementer_param->location->file_path, ) ) { if ($config->allow_named_arg_calls @@ -452,7 +452,7 @@ private static function compareMethodParams( if ($stmt && isset($project_analyzer->getIssuesToFix()['ParamNameMismatch'])) { $param_replacer = new ParamReplacementVisitor( $implementer_param->name, - $guide_param->name + $guide_param->name, ); $traverser = new NodeTraverser(); @@ -462,7 +462,7 @@ private static function compareMethodParams( if ($replacements = $param_replacer->getReplacements()) { FileManipulationBuffer::add( $implementer_param->location->file_path, - $replacements + $replacements, ); } } @@ -473,9 +473,9 @@ private static function compareMethodParams( . $implementer_param->name . ', expecting $' . $guide_param->name . ' as defined by ' . $cased_guide_method_id, - $implementer_param->location + $implementer_param->location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } @@ -496,7 +496,7 @@ private static function compareMethodParams( $cased_guide_method_id, $cased_implementer_method_id, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -518,7 +518,7 @@ private static function compareMethodParams( $guide_param->type, $implementer_param->type, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -532,12 +532,12 @@ private static function compareMethodParams( ($i + 1) . ' of ' . $cased_guide_method_id . ' is' . ($guide_param->by_ref ? '' : ' not'), $implementer_param->location && $config->isInProjectDirs( - $implementer_param->location->file_path + $implementer_param->location->file_path, ) ? $implementer_param->location - : $code_location + : $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } @@ -571,7 +571,7 @@ private static function compareMethodSignatureParams( : $guide_classlike_storage->name, $guide_classlike_storage->is_trait && $guide_method_storage->abstract ? $implementer_classlike_storage->parent_class - : $guide_classlike_storage->parent_class + : $guide_classlike_storage->parent_class, ) : null; @@ -580,7 +580,7 @@ private static function compareMethodSignatureParams( $implementer_param_signature_type, $implementer_classlike_storage->name, $implementer_classlike_storage->name, - $implementer_classlike_storage->parent_class + $implementer_classlike_storage->parent_class, ); $is_contained_by = $codebase->analysis_php_version_id >= 7_04_00 @@ -588,11 +588,11 @@ private static function compareMethodSignatureParams( ? UnionTypeComparator::isContainedBy( $codebase, $guide_param_signature_type, - $implementer_param_signature_type + $implementer_param_signature_type, ) : UnionTypeComparator::isContainedByInPhp( $guide_param_signature_type, - $implementer_param_signature_type + $implementer_param_signature_type, ); if (!$is_contained_by) { $config = Config::getInstance(); @@ -615,12 +615,12 @@ private static function compareMethodSignatureParams( . $cased_guide_method_id, $implementer_method_storage->params[$i]->location && $config->isInProjectDirs( - $implementer_method_storage->params[$i]->location->file_path + $implementer_method_storage->params[$i]->location->file_path, ) ? $implementer_method_storage->params[$i]->location - : $code_location + : $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -633,12 +633,12 @@ private static function compareMethodSignatureParams( . $cased_guide_method_id, $implementer_method_storage->params[$i]->location && $config->isInProjectDirs( - $implementer_method_storage->params[$i]->location->file_path + $implementer_method_storage->params[$i]->location->file_path, ) ? $implementer_method_storage->params[$i]->location - : $code_location + : $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } else { @@ -650,12 +650,12 @@ private static function compareMethodSignatureParams( $cased_guide_method_id, $implementer_method_storage->params[$i]->location && $config->isInProjectDirs( - $implementer_method_storage->params[$i]->location->file_path + $implementer_method_storage->params[$i]->location->file_path, ) ? $implementer_method_storage->params[$i]->location - : $code_location + : $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } @@ -684,7 +684,7 @@ private static function compareMethodDocblockParams( $implementer_param_type, $implementer_classlike_storage->name, $implementer_called_class_name, - $implementer_classlike_storage->parent_class + $implementer_classlike_storage->parent_class, ); $guide_method_storage_param_type = TypeExpander::expandUnion( @@ -698,31 +698,31 @@ private static function compareMethodDocblockParams( : $guide_classlike_storage->name, $guide_classlike_storage->is_trait && $guide_method_storage->abstract ? $implementer_classlike_storage->parent_class - : $guide_classlike_storage->parent_class + : $guide_classlike_storage->parent_class, ); $guide_class_name = $guide_classlike_storage->name; if ($implementer_classlike_storage->is_trait) { $implementer_called_class_storage = $codebase->classlike_storage_provider->get( - $implementer_called_class_name + $implementer_called_class_name, ); if (isset( - $implementer_called_class_storage->template_extended_params[$implementer_classlike_storage->name] + $implementer_called_class_storage->template_extended_params[$implementer_classlike_storage->name], )) { self::transformTemplates( $implementer_called_class_storage->template_extended_params, $implementer_classlike_storage->name, $implementer_method_storage_param_type, - $codebase + $codebase, ); self::transformTemplates( $implementer_called_class_storage->template_extended_params, $guide_class_name, $guide_method_storage_param_type, - $codebase + $codebase, ); } } @@ -761,7 +761,7 @@ private static function compareMethodDocblockParams( $implementer_classlike_storage->template_extended_params, $guide_class_name, $guide_method_storage_param_type, - $codebase + $codebase, ); } @@ -773,7 +773,7 @@ private static function compareMethodDocblockParams( $implementer_method_storage_param_type, !$guide_classlike_storage->user_defined, !$guide_classlike_storage->user_defined, - $union_comparison_results + $union_comparison_results, )) { // is the declared return type more specific than the inferred one? if ($union_comparison_results->type_coerced) { @@ -786,9 +786,9 @@ private static function compareMethodDocblockParams( $guide_method_storage_param_type->getId() . '\' as defined by ' . $cased_guide_method_id, $implementer_method_storage->params[$i]->location - ?: $code_location + ?: $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } else { @@ -797,7 +797,7 @@ private static function compareMethodDocblockParams( $implementer_method_storage_param_type, $guide_method_storage_param_type, !$guide_classlike_storage->user_defined, - !$guide_classlike_storage->user_defined + !$guide_classlike_storage->user_defined, )) { IssueBuffer::maybeAdd( new MoreSpecificImplementedParamType( @@ -807,9 +807,9 @@ private static function compareMethodDocblockParams( $guide_method_storage_param_type->getId() . '\' as defined by ' . $cased_guide_method_id, $implementer_method_storage->params[$i]->location - ?: $code_location + ?: $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -820,9 +820,9 @@ private static function compareMethodDocblockParams( $guide_method_storage_param_type->getId() . '\' as defined by ' . $cased_guide_method_id, $implementer_method_storage->params[$i]->location - ?: $code_location + ?: $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } @@ -860,7 +860,7 @@ private static function compareMethodSignatureReturnTypes( : $guide_classlike_storage->parent_class, true, true, - $implementer_method_storage->final + $implementer_method_storage->final, ); $implementer_signature_return_type = $implementer_method_storage->signature_return_type @@ -873,7 +873,7 @@ private static function compareMethodSignatureReturnTypes( $implementer_classlike_storage->is_trait ? $implementer_called_class_name : $implementer_classlike_storage->name, - $implementer_classlike_storage->parent_class + $implementer_classlike_storage->parent_class, ) : null; $is_contained_by = $codebase->analysis_php_version_id >= 7_04_00 @@ -881,7 +881,7 @@ private static function compareMethodSignatureReturnTypes( ? UnionTypeComparator::isContainedBy( $codebase, $implementer_signature_return_type, - $guide_signature_return_type + $guide_signature_return_type, ) : UnionTypeComparator::isContainedByInPhp($implementer_signature_return_type, $guide_signature_return_type); @@ -898,9 +898,9 @@ private static function compareMethodSignatureReturnTypes( 'Method ' . $cased_implementer_method_id . ' with return type \'' . $implementer_signature_return_type . '\' is different to return type \'' . $guide_signature_return_type . '\' of inherited method ' . $cased_guide_method_id, - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -908,9 +908,9 @@ private static function compareMethodSignatureReturnTypes( 'Method ' . $cased_implementer_method_id . ' with return type \'' . $implementer_signature_return_type . '\' is different to return type \'' . $guide_signature_return_type . '\' of inherited method ' . $cased_guide_method_id, - $code_location + $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } @@ -939,7 +939,7 @@ private static function compareMethodDocblockReturnTypes( ? $implementer_called_class_name : $implementer_classlike_storage->name, $implementer_called_class_name, - $implementer_classlike_storage->parent_class + $implementer_classlike_storage->parent_class, ); $guide_method_storage_return_type = TypeExpander::expandUnion( @@ -955,7 +955,7 @@ private static function compareMethodDocblockReturnTypes( $guide_classlike_storage->parent_class, true, true, - $implementer_method_storage->final + $implementer_method_storage->final, ); $guide_class_name = $guide_classlike_storage->name; @@ -965,7 +965,7 @@ private static function compareMethodDocblockReturnTypes( $implementer_classlike_storage->template_extended_params, $guide_class_name, $guide_method_storage_return_type, - $codebase + $codebase, ); if ($implementer_method_storage->defining_fqcln) { @@ -973,14 +973,14 @@ private static function compareMethodDocblockReturnTypes( $implementer_classlike_storage->template_extended_params, $implementer_method_storage->defining_fqcln, $implementer_method_storage_return_type, - $codebase + $codebase, ); } } if ($implementer_classlike_storage->is_trait) { $implementer_called_class_storage = $codebase->classlike_storage_provider->get( - $implementer_called_class_name + $implementer_called_class_name, ); if ($implementer_called_class_storage->template_extended_params) { @@ -988,14 +988,14 @@ private static function compareMethodDocblockReturnTypes( $implementer_called_class_storage->template_extended_params, $implementer_classlike_storage->name, $implementer_method_storage_return_type, - $codebase + $codebase, ); self::transformTemplates( $implementer_called_class_storage->template_extended_params, $guide_class_name, $guide_method_storage_return_type, - $codebase + $codebase, ); } } @@ -1017,7 +1017,7 @@ private static function compareMethodDocblockReturnTypes( $guide_method_storage_return_type, false, false, - $union_comparison_results + $union_comparison_results, )) { // is the declared return type more specific than the inferred one? if ($union_comparison_results->type_coerced) { @@ -1028,9 +1028,9 @@ private static function compareMethodDocblockReturnTypes( . 'return type for ' . $implementer_declaring_method_id . ' \'' . $implementer_method_storage_return_type->getId() . '\'', $implementer_method_storage->return_type_location - ?: $code_location + ?: $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -1040,9 +1040,9 @@ private static function compareMethodDocblockReturnTypes( . 'return type for ' . $implementer_declaring_method_id . ' \'' . $implementer_method_storage_return_type->getId() . '\'', $implementer_method_storage->return_type_location - ?: $code_location + ?: $code_location, ), - $suppressed_issues + $implementer_classlike_storage->suppressed_issues + $suppressed_issues + $implementer_classlike_storage->suppressed_issues, ); } } @@ -1079,7 +1079,7 @@ private static function transformTemplates( $template_extended_params, $new_base_class_name, $mapped_type, - $codebase + $codebase, ); } } @@ -1092,7 +1092,7 @@ private static function transformTemplates( $templated_type = TemplateInferredTypeReplacer::replace( $templated_type, $template_result, - $codebase + $codebase, ); } } diff --git a/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php b/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php index e0d412cbfc6..9187b76cd8b 100644 --- a/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php @@ -106,12 +106,12 @@ public function collectAnalyzableClassLike(PhpParser\Node\Stmt\ClassLike $stmt): if ($stmt instanceof PhpParser\Node\Stmt\Class_ || $stmt instanceof PhpParser\Node\Stmt\Enum_) { $this->source->addNamespacedClassAnalyzer( $fq_class_name, - new ClassAnalyzer($stmt, $this, $fq_class_name) + new ClassAnalyzer($stmt, $this, $fq_class_name), ); } elseif ($stmt instanceof PhpParser\Node\Stmt\Interface_) { $this->source->addNamespacedInterfaceAnalyzer( $fq_class_name, - new InterfaceAnalyzer($stmt, $this, $fq_class_name) + new InterfaceAnalyzer($stmt, $this, $fq_class_name), ); } } diff --git a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php index 38696dbbb08..d256db9ffbf 100644 --- a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php @@ -250,7 +250,7 @@ public function __construct( $this->codebase = new Codebase( $config, $providers, - $progress + $progress, ); $this->stdout_report_options = $stdout_report_options; @@ -263,7 +263,7 @@ public function __construct( $file_paths = $this->file_provider->getFilesInDir( $dir_name, $file_extensions, - [$this->config, 'isInProjectDirs'] + [$this->config, 'isInProjectDirs'], ); foreach ($file_paths as $file_path) { @@ -275,7 +275,7 @@ public function __construct( $file_paths = $this->file_provider->getFilesInDir( $dir_name, $file_extensions, - [$this->config, 'isInExtraDirs'] + [$this->config, 'isInExtraDirs'], ); foreach ($file_paths as $file_path) { @@ -305,7 +305,7 @@ private function clearCacheDirectoryIfConfigOrComposerLockfileChanged(): void clearstatcache(true, $cache_directory); if (is_dir($cache_directory)) { $this->progress->debug( - 'Composer lockfile change detected, clearing cache directory ' . $cache_directory . "\n" + 'Composer lockfile change detected, clearing cache directory ' . $cache_directory . "\n", ); Config::removeCacheDirectory($cache_directory); @@ -322,7 +322,7 @@ private function clearCacheDirectoryIfConfigOrComposerLockfileChanged(): void clearstatcache(true, $cache_directory); if (is_dir($cache_directory)) { $this->progress->debug( - 'Config change detected, clearing cache directory ' . $cache_directory . "\n" + 'Config change detected, clearing cache directory ' . $cache_directory . "\n", ); Config::removeCacheDirectory($cache_directory); @@ -389,7 +389,7 @@ private function visitAutoloadFiles(): void $now_time = microtime(true); $this->progress->debug( - 'Visiting autoload files took ' . number_format($now_time - $start_time, 3) . 's' . "\n" + 'Visiting autoload files took ' . number_format($now_time - $start_time, 3) . 's' . "\n", ); } @@ -436,7 +436,7 @@ public function server(?string $address = '127.0.0.1:12345', bool $socket_server new LanguageServer( new ProtocolStreamReader($socket), new ProtocolStreamWriter($socket), - $this + $this, ); Loop::run(); } elseif ($socket_server_mode && $address) { @@ -459,7 +459,7 @@ public function server(?string $address = '127.0.0.1:12345', bool $socket_server fwrite( STDERR, "pcntl_fork() is disabled by php configuration (disable_functions directive)." - . " Only a single connection will be accepted\n" + . " Only a single connection will be accepted\n", ); $fork_available = false; } @@ -483,12 +483,12 @@ public function server(?string $address = '127.0.0.1:12345', bool $socket_server 'close', static function (): void { fwrite(STDOUT, "Connection closed\n"); - } + }, ); new LanguageServer( $reader, new ProtocolStreamWriter($socket), - $this + $this, ); // Just for safety exit(0); @@ -499,7 +499,7 @@ static function (): void { new LanguageServer( new ProtocolStreamReader($socket), new ProtocolStreamWriter($socket), - $this + $this, ); Loop::run(); } @@ -510,7 +510,7 @@ static function (): void { new LanguageServer( new ProtocolStreamReader(STDIN), new ProtocolStreamWriter(STDOUT), - $this + $this, ); Loop::run(); } @@ -648,7 +648,7 @@ public function check(string $base_dir, bool $is_diff = false): void $this, $this->threads, $this->codebase->alter_code, - true + true, ); if ($this->parser_cache_provider && !$is_diff) { @@ -665,7 +665,7 @@ public function consolidateAnalyzedData(): void $this->codebase->classlikes->consolidateAnalyzedData( $this->codebase->methods, $this->progress, - (bool)$this->codebase->find_unused_code + (bool)$this->codebase->find_unused_code, ); } @@ -709,14 +709,14 @@ public function interpretRefactors(): void if (!$this->codebase->classlikes->hasFullyQualifiedClassName($source_parts[0])) { throw new RefactorException( - 'Source class ' . $source_parts[0] . ' doesn’t exist' + 'Source class ' . $source_parts[0] . ' doesn’t exist', ); } if (count($source_parts) === 1 && count($destination_parts) === 1) { if ($this->codebase->classlikes->hasFullyQualifiedClassName($destination_parts[0])) { throw new RefactorException( - 'Destination class ' . $destination_parts[0] . ' already exists' + 'Destination class ' . $destination_parts[0] . ' already exists', ); } @@ -747,24 +747,24 @@ public function interpretRefactors(): void $source_method_id = new MethodIdentifier( $source_parts[0], - strtolower($source_parts[1]) + strtolower($source_parts[1]), ); if ($this->codebase->methods->methodExists($source_method_id)) { if ($this->codebase->methods->methodExists( new MethodIdentifier( $destination_parts[0], - strtolower($destination_parts[1]) - ) + strtolower($destination_parts[1]), + ), )) { throw new RefactorException( - 'Destination method ' . $destination . ' already exists' + 'Destination method ' . $destination . ' already exists', ); } if (!$this->codebase->classlikes->classExists($destination_parts[0])) { throw new RefactorException( - 'Destination class ' . $destination_parts[0] . ' doesn’t exist' + 'Destination class ' . $destination_parts[0] . ' doesn’t exist', ); } @@ -776,12 +776,12 @@ public function interpretRefactors(): void if (!$source_method_storage->is_static && !isset( - $destination_class_storage->parent_classes[strtolower($source_method_id->fq_class_name)] + $destination_class_storage->parent_classes[strtolower($source_method_id->fq_class_name)], ) ) { throw new RefactorException( 'Cannot move non-static method ' . $source - . ' into unrelated class ' . $destination_parts[0] + . ' into unrelated class ' . $destination_parts[0], ); } @@ -797,25 +797,25 @@ public function interpretRefactors(): void if ($source_parts[1][0] === '$') { if ($destination_parts[1][0] !== '$') { throw new RefactorException( - 'Destination property must be of the form Foo::$bar' + 'Destination property must be of the form Foo::$bar', ); } if (!$this->codebase->properties->propertyExists($source, true)) { throw new RefactorException( - 'Property ' . $source . ' does not exist' + 'Property ' . $source . ' does not exist', ); } if ($this->codebase->properties->propertyExists($destination, true)) { throw new RefactorException( - 'Destination property ' . $destination . ' already exists' + 'Destination property ' . $destination . ' already exists', ); } if (!$this->codebase->classlikes->classExists($destination_parts[0])) { throw new RefactorException( - 'Destination class ' . $destination_parts[0] . ' doesn’t exist' + 'Destination class ' . $destination_parts[0] . ' doesn’t exist', ); } @@ -826,7 +826,7 @@ public function interpretRefactors(): void if (!$source_storage->is_static) { throw new RefactorException( - 'Cannot move non-static property ' . $source + 'Cannot move non-static property ' . $source, ); } @@ -841,24 +841,24 @@ public function interpretRefactors(): void $source_class_constants = $this->codebase->classlikes->getConstantsForClass( $source_parts[0], - ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_PRIVATE, ); if (isset($source_class_constants[$source_parts[1]])) { if (!$this->codebase->classlikes->hasFullyQualifiedClassName($destination_parts[0])) { throw new RefactorException( - 'Destination class ' . $destination_parts[0] . ' doesn’t exist' + 'Destination class ' . $destination_parts[0] . ' doesn’t exist', ); } $destination_class_constants = $this->codebase->classlikes->getConstantsForClass( $destination_parts[0], - ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_PRIVATE, ); if (isset($destination_class_constants[$destination_parts[1]])) { throw new RefactorException( - 'Destination constant ' . $destination . ' already exists' + 'Destination constant ' . $destination . ' already exists', ); } @@ -875,7 +875,7 @@ public function interpretRefactors(): void } throw new RefactorException( - 'Psalm cannot locate ' . $source + 'Psalm cannot locate ' . $source, ); } } @@ -888,16 +888,16 @@ public function prepareMigration(): void $this->codebase->classlikes->moveMethods( $this->codebase->methods, - $this->progress + $this->progress, ); $this->codebase->classlikes->moveProperties( $this->codebase->properties, - $this->progress + $this->progress, ); $this->codebase->classlikes->moveClassConstants( - $this->progress + $this->progress, ); } @@ -908,7 +908,7 @@ public function migrateCode(): void } $migration_manipulations = FileManipulationBuffer::getMigrationManipulations( - $this->codebase->file_provider + $this->codebase->file_provider, ); if ($migration_manipulations) { @@ -925,7 +925,7 @@ static function (FileManipulation $a, FileManipulation $b): int { } return $b->start > $a->start ? 1 : -1; - } + }, ); $existing_contents = $this->codebase->file_provider->getContents($file_path); @@ -1012,7 +1012,7 @@ public function checkDir(string $dir_name): void $this, $this->threads, $this->codebase->alter_code, - $this->codebase->find_unused_code === 'always' + $this->codebase->find_unused_code === 'always', ); } @@ -1024,7 +1024,7 @@ private function checkDirWithConfig(string $dir_name, Config $config, bool $allo $file_paths = $this->file_provider->getFilesInDir( $dir_name, $file_extensions, - $filter + $filter, ); $files_to_scan = []; @@ -1122,7 +1122,7 @@ public function checkFile(string $file_path): void $this, $this->threads, $this->codebase->alter_code, - $this->codebase->find_unused_code === 'always' + $this->codebase->find_unused_code === 'always', ); } @@ -1166,13 +1166,13 @@ public function checkPaths(array $paths_to_check): void $this, $this->threads, $this->codebase->alter_code, - $this->codebase->find_unused_code === 'always' + $this->codebase->find_unused_code === 'always', ); if ($this->stdout_report_options && in_array( $this->stdout_report_options->format, - [Report::TYPE_CONSOLE, Report::TYPE_PHP_STORM] + [Report::TYPE_CONSOLE, Report::TYPE_PHP_STORM], ) && $this->codebase->collect_references ) { @@ -1180,7 +1180,7 @@ public function checkPaths(array $paths_to_check): void STDERR, PHP_EOL . 'To whom it may concern: Psalm cannot detect unused classes, methods and properties' . PHP_EOL . 'when analyzing individual files and folders. Run on the full project to enable' - . PHP_EOL . 'complete unused code detection.' . PHP_EOL + . PHP_EOL . 'complete unused code detection.' . PHP_EOL, ); } } @@ -1290,7 +1290,7 @@ public function setIssuesToFix(array $issues): void if (! empty($unsupportedIssues)) { throw new UnsupportedIssueToFixException( 'Psalm doesn\'t know how to fix issue(s): ' . implode(', ', $unsupportedIssues) . PHP_EOL - . 'Supported issues to fix are: ' . implode(',', $supported_issues_to_fix) + . 'Supported issues to fix are: ' . implode(',', $supported_issues_to_fix), ); } @@ -1326,7 +1326,7 @@ public function getFileAnalyzerForClassLike(string $fq_class_name): FileAnalyzer return new FileAnalyzer( $this, $file_path, - $this->config->shortenFileName($file_path) + $this->config->shortenFileName($file_path), ); } @@ -1362,7 +1362,7 @@ public function getMethodMutations( } $stmts = $this->codebase->getStatementsForFile( - $file_analyzer->getFilePath() + $file_analyzer->getFilePath(), ); $file_analyzer->populateCheckers($stmts); @@ -1386,11 +1386,11 @@ public function getFunctionLikeAnalyzer( $file_analyzer = new FileAnalyzer( $this, $file_path, - $this->config->shortenFileName($file_path) + $this->config->shortenFileName($file_path), ); $stmts = $this->codebase->getStatementsForFile( - $file_analyzer->getFilePath() + $file_analyzer->getFilePath(), ); $file_analyzer->populateCheckers($stmts); @@ -1446,7 +1446,7 @@ static function (string $issue_class): string { $parts = explode('\\', $issue_class); return end($parts); }, - self::SUPPORTED_ISSUES_TO_FIX + self::SUPPORTED_ISSUES_TO_FIX, ); } } diff --git a/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php b/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php index 72af912397a..4b6a7491b3b 100644 --- a/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ScopeAnalyzer.php @@ -124,12 +124,12 @@ public static function getControlActions( $stmt->stmts, $nodes, $break_types, - $return_is_exit + $return_is_exit, ); $all_leave = !array_filter( $if_statement_actions, - static fn(string $action): bool => $action === self::ACTION_NONE + static fn(string $action): bool => $action === self::ACTION_NONE, ); $else_statement_actions = $stmt->else @@ -137,14 +137,14 @@ public static function getControlActions( $stmt->else->stmts, $nodes, $break_types, - $return_is_exit + $return_is_exit, ) : []; $all_leave = $all_leave && $else_statement_actions && !array_filter( $else_statement_actions, - static fn(string $action): bool => $action === self::ACTION_NONE + static fn(string $action): bool => $action === self::ACTION_NONE, ); $all_elseif_actions = []; @@ -155,13 +155,13 @@ public static function getControlActions( $elseif->stmts, $nodes, $break_types, - $return_is_exit + $return_is_exit, ); $all_leave = $all_leave && !array_filter( $elseif_control_actions, - static fn(string $action): bool => $action === self::ACTION_NONE + static fn(string $action): bool => $action === self::ACTION_NONE, ); $all_elseif_actions = [...$elseif_control_actions, ...$all_elseif_actions]; @@ -174,14 +174,14 @@ public static function getControlActions( ...$control_actions, ...$if_statement_actions, ...$else_statement_actions, - ...$all_elseif_actions - ]) + ...$all_elseif_actions, + ]), ); } $control_actions = array_filter( [...$control_actions, ...$if_statement_actions, ...$else_statement_actions, ...$all_elseif_actions], - static fn(string $action): bool => $action !== self::ACTION_NONE + static fn(string $action): bool => $action !== self::ACTION_NONE, ); } @@ -200,13 +200,13 @@ public static function getControlActions( $case->stmts, $nodes, [...$break_types, ...['switch']], - $return_is_exit + $return_is_exit, ); if (array_intersect([ self::ACTION_LEAVE_SWITCH, self::ACTION_BREAK, - self::ACTION_CONTINUE + self::ACTION_CONTINUE, ], $case_actions) ) { continue 2; @@ -218,7 +218,7 @@ public static function getControlActions( $case_does_end = !array_diff( $control_actions, - [self::ACTION_END, self::ACTION_RETURN] + [self::ACTION_END, self::ACTION_RETURN], ); if ($case_does_end) { @@ -238,7 +238,7 @@ public static function getControlActions( $all_case_actions = array_filter( $all_case_actions, - static fn(string $action): bool => $action !== self::ACTION_NONE + static fn(string $action): bool => $action !== self::ACTION_NONE, ); if ($has_default_terminator || $stmt->getAttribute('allMatched', false)) { @@ -257,12 +257,12 @@ public static function getControlActions( $stmt->stmts, $nodes, [...$break_types, ...['loop']], - $return_is_exit + $return_is_exit, ); $control_actions = array_filter( [...$control_actions, ...$loop_actions], - static fn(string $action): bool => $action !== self::ACTION_NONE + static fn(string $action): bool => $action !== self::ACTION_NONE, ); if ($stmt instanceof PhpParser\Node\Stmt\While_ @@ -274,7 +274,7 @@ public static function getControlActions( //infinite while loop that only return don't have an exit path $have_exit_path = (bool)array_diff( $control_actions, - [self::ACTION_END, self::ACTION_RETURN] + [self::ACTION_END, self::ACTION_RETURN], ); if (!$have_exit_path) { @@ -300,7 +300,7 @@ public static function getControlActions( //infinite while loop that only return don't have an exit path $have_exit_path = (bool)array_diff( $control_actions, - [self::ACTION_END, self::ACTION_RETURN] + [self::ACTION_END, self::ACTION_RETURN], ); if (!$have_exit_path) { @@ -311,7 +311,7 @@ public static function getControlActions( $control_actions = array_filter( $control_actions, - static fn(string $action): bool => $action !== self::ACTION_LEAVE_LOOP + static fn(string $action): bool => $action !== self::ACTION_LEAVE_LOOP, ); } @@ -320,12 +320,12 @@ public static function getControlActions( $stmt->stmts, $nodes, $break_types, - $return_is_exit + $return_is_exit, ); $try_leaves = !array_filter( $try_statement_actions, - static fn(string $action): bool => $action === self::ACTION_NONE + static fn(string $action): bool => $action === self::ACTION_NONE, ); $all_catch_actions = []; @@ -338,13 +338,13 @@ public static function getControlActions( $catch->stmts, $nodes, $break_types, - $return_is_exit + $return_is_exit, ); $all_leave = $all_leave && !array_filter( $catch_actions, - static fn(string $action): bool => $action === self::ACTION_NONE + static fn(string $action): bool => $action === self::ACTION_NONE, ); if (!$all_leave) { @@ -357,8 +357,8 @@ public static function getControlActions( if ($all_leave && $try_statement_actions !== [self::ACTION_NONE]) { return array_values( array_unique( - [...$control_actions, ...$try_statement_actions, ...$all_catch_actions] - ) + [...$control_actions, ...$try_statement_actions, ...$all_catch_actions], + ), ); } } elseif ($try_leaves) { @@ -370,20 +370,20 @@ public static function getControlActions( $stmt->finally->stmts, $nodes, $break_types, - $return_is_exit + $return_is_exit, ); if (!in_array(self::ACTION_NONE, $finally_statement_actions, true)) { return [...array_filter( $control_actions, - static fn(string $action): bool => $action !== self::ACTION_NONE + static fn(string $action): bool => $action !== self::ACTION_NONE, ), ...$finally_statement_actions]; } } $control_actions = array_filter( [...$control_actions, ...$try_statement_actions], - static fn(string $action): bool => $action !== self::ACTION_NONE + static fn(string $action): bool => $action !== self::ACTION_NONE, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/DoAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/DoAnalyzer.php index e55434fa258..228f0b9e05e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/DoAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/DoAnalyzer.php @@ -66,7 +66,7 @@ public static function analyze( $stmt->cond, $context->self, $statements_analyzer, - $codebase + $codebase, ); $while_clauses = array_values( @@ -86,8 +86,8 @@ static function (Clause $c) use ($mixed_var_ids): bool { } return true; - } - ) + }, + ), ); if (!$while_clauses) { @@ -102,7 +102,7 @@ static function (Clause $c) use ($mixed_var_ids): bool { $loop_scope, $inner_loop_context, true, - true + true, ) === false) { return false; } @@ -116,8 +116,8 @@ static function (Clause $c) use ($mixed_var_ids): bool { $negated_while_types = Algebra::getTruthsFromFormula( Algebra::simplifyCNF( - [...$context->clauses, ...$negated_while_clauses] - ) + [...$context->clauses, ...$negated_while_clauses], + ), ); if ($negated_while_types) { @@ -134,7 +134,7 @@ static function (Clause $c) use ($mixed_var_ids): bool { $statements_analyzer, [], true, - new CodeLocation($statements_analyzer->getSource(), $stmt->cond) + new CodeLocation($statements_analyzer->getSource(), $stmt->cond), ); } @@ -146,7 +146,7 @@ static function (Clause $c) use ($mixed_var_ids): bool { if (isset($loop_scope->possibly_defined_loop_parent_vars[$var_id])) { $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, - $loop_scope->possibly_defined_loop_parent_vars[$var_id] + $loop_scope->possibly_defined_loop_parent_vars[$var_id], ); } } else { @@ -158,7 +158,7 @@ static function (Clause $c) use ($mixed_var_ids): bool { $context->vars_possibly_in_scope = array_merge( $context->vars_possibly_in_scope, - $do_context->vars_possibly_in_scope + $do_context->vars_possibly_in_scope, ); if ($context->collect_exceptions) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForAnalyzer.php index c1293774b17..598f0a305da 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/ForAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForAnalyzer.php @@ -52,7 +52,7 @@ public static function analyze( $context->assigned_var_ids = array_merge( $pre_assigned_var_ids, - $assigned_var_ids + $assigned_var_ids, ); $while_true = !$stmt->cond && !$stmt->init && !$stmt->loop; @@ -78,7 +78,7 @@ public static function analyze( $loop_scope->protected_var_ids = array_merge( $assigned_var_ids, - $context->protected_var_ids + $context->protected_var_ids, ); if (LoopAnalyzer::analyze( @@ -87,7 +87,7 @@ public static function analyze( $stmt->cond, $stmt->loop, $loop_scope, - $inner_loop_context + $inner_loop_context, ) === false) { return false; } @@ -155,7 +155,7 @@ public static function analyze( if (isset($loop_scope->possibly_defined_loop_parent_vars[$var_id])) { $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, - $loop_scope->possibly_defined_loop_parent_vars[$var_id] + $loop_scope->possibly_defined_loop_parent_vars[$var_id], ); } } else { @@ -169,7 +169,7 @@ public static function analyze( if ($can_leave_loop) { $context->vars_possibly_in_scope = array_merge( $context->vars_possibly_in_scope, - $for_context->vars_possibly_in_scope + $for_context->vars_possibly_in_scope, ); } elseif ($pre_context) { $context->vars_possibly_in_scope = $pre_context->vars_possibly_in_scope; diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php index 8f92df08164..6a6439991e0 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php @@ -96,14 +96,14 @@ public static function analyze( $statements_analyzer->getSource(), $statements_analyzer->getSource()->getAliases(), $statements_analyzer->getTemplateTypeMap() ?: [], - $type_aliases + $type_aliases, ); } catch (DocblockParseException $e) { IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer, $stmt) - ) + new CodeLocation($statements_analyzer, $stmt), + ), ); } } @@ -118,7 +118,7 @@ public static function analyze( $safe_var_ids['$' . $stmt->valueVar->name] = true; $statements_analyzer->foreach_var_locations['$' . $stmt->valueVar->name][] = new CodeLocation( $statements_analyzer, - $stmt->valueVar + $stmt->valueVar, ); } elseif ($stmt->valueVar instanceof PhpParser\Node\Expr\List_) { foreach ($stmt->valueVar->items as $list_item) { @@ -153,7 +153,7 @@ public static function analyze( $var_comment->type, $context->self, $context->self, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); $type_location = null; @@ -166,7 +166,7 @@ public static function analyze( $statements_analyzer, $var_comment->type_start, $var_comment->type_end, - $var_comment->line_number + $var_comment->line_number, ); if ($codebase->alter_code) { @@ -175,7 +175,7 @@ public static function analyze( $statements_analyzer, $comment_type, $type_location, - $context->calling_method_id + $context->calling_method_id, ); } } @@ -201,10 +201,10 @@ public static function analyze( new UnnecessaryVarAnnotation( 'The @var ' . $comment_type . ' annotation for ' . $var_comment->var_id . ' is unnecessary', - $type_location + $type_location, ), $statements_analyzer->getSuppressedIssues(), - true + true, ); } } @@ -234,7 +234,7 @@ public static function analyze( $var_id = ExpressionIdentifier::getVarId( $stmt->expr, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($stmt_expr_type = $statements_analyzer->node_data->getType($stmt->expr)) { @@ -255,7 +255,7 @@ public static function analyze( $context, $key_type, $value_type, - $always_non_empty_array + $always_non_empty_array, ) === false ) { return false; @@ -286,7 +286,7 @@ public static function analyze( $key_type, $foreach_context, $doc_comment, - ['$' . $stmt->keyVar->name => true] + ['$' . $stmt->keyVar->name => true], ); } @@ -315,7 +315,7 @@ public static function analyze( $stmt->valueVar instanceof PhpParser\Node\Expr\Variable && is_string($stmt->valueVar->name) ? ['$' . $stmt->valueVar->name => true] - : [] + : [], ); if ($stmt->byRef @@ -336,7 +336,7 @@ public static function analyze( $var_comment->type, $context->self, $context->self, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); if (isset($foreach_context->vars_in_scope[$var_comment->var_id])) { @@ -362,7 +362,7 @@ public static function analyze( $loop_scope, $inner_loop_context, false, - $always_non_empty_array + $always_non_empty_array, ) === false) { return false; } @@ -375,7 +375,7 @@ public static function analyze( $context->vars_possibly_in_scope = array_merge( $foreach_context->vars_possibly_in_scope, - $context->vars_possibly_in_scope + $context->vars_possibly_in_scope, ); if ($context->collect_exceptions) { @@ -404,9 +404,9 @@ public static function checkIteratorType( IssueBuffer::maybeAdd( new NullIterator( 'Cannot iterate over null', - new CodeLocation($statements_analyzer->getSource(), $expr) + new CodeLocation($statements_analyzer->getSource(), $expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return false; } @@ -415,9 +415,9 @@ public static function checkIteratorType( IssueBuffer::maybeAdd( new PossiblyNullIterator( 'Cannot iterate over nullable var ' . $iterator_type, - new CodeLocation($statements_analyzer->getSource(), $expr) + new CodeLocation($statements_analyzer->getSource(), $expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return null; @@ -427,9 +427,9 @@ public static function checkIteratorType( IssueBuffer::maybeAdd( new PossiblyFalseIterator( 'Cannot iterate over falsable var ' . $iterator_type, - new CodeLocation($statements_analyzer->getSource(), $expr) + new CodeLocation($statements_analyzer->getSource(), $expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return null; @@ -475,8 +475,8 @@ public static function checkIteratorType( ExpressionIdentifier::getExtendedVarId( $expr, $statements_analyzer->getFQCLN(), - $statements_analyzer - ) + $statements_analyzer, + ), ); } elseif (!$iterator_atomic_type instanceof TNonEmptyArray) { $always_non_empty_array = false; @@ -493,7 +493,7 @@ public static function checkIteratorType( $expr, null, $value_type, - $key_type + $key_type, ); $has_valid_iterator = true; @@ -519,7 +519,7 @@ public static function checkIteratorType( $expr, null, $value_type, - $key_type + $key_type, ); if (!$context->pure) { @@ -534,16 +534,16 @@ public static function checkIteratorType( IssueBuffer::maybeAdd( new ImpureMethodCall( 'Cannot call a possibly-mutating iterator from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } elseif ($iterator_atomic_type instanceof TIterable) { if ($iterator_atomic_type->extra_types) { $iterator_atomic_types = array_merge( [$iterator_atomic_type->setIntersectionTypes([])], - $iterator_atomic_type->extra_types + $iterator_atomic_type->extra_types, ); } else { $iterator_atomic_types = [$iterator_atomic_type]; @@ -565,7 +565,7 @@ public static function checkIteratorType( $intersection_value_type = Type::intersectUnionTypes( $intersection_value_type, $value_type_part, - $codebase + $codebase, ) ?? Type::getMixed(); } @@ -575,7 +575,7 @@ public static function checkIteratorType( $intersection_key_type = Type::intersectUnionTypes( $intersection_key_type, $key_type_part, - $codebase + $codebase, ) ?? Type::getMixed(); } } @@ -592,7 +592,7 @@ public static function checkIteratorType( $expr, null, $value_type, - $key_type + $key_type, ); $has_valid_iterator = true; @@ -609,9 +609,9 @@ public static function checkIteratorType( IssueBuffer::maybeAdd( new ImpureMethodCall( 'Cannot call a possibly-mutating Traversable::getIterator from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } elseif ($iterator_atomic_type instanceof TNamedObject) { @@ -625,7 +625,7 @@ public static function checkIteratorType( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(true) + new ClassLikeNameOptions(true), ) === false) { return false; } @@ -634,7 +634,7 @@ public static function checkIteratorType( if (AtomicTypeComparator::isContainedBy( $codebase, $iterator_atomic_type, - new TIterable([Type::getMixed(), Type::getMixed()]) + new TIterable([Type::getMixed(), Type::getMixed()]), )) { self::handleIterable( $statements_analyzer, @@ -644,7 +644,7 @@ public static function checkIteratorType( $context, $key_type, $value_type, - $has_valid_iterator + $has_valid_iterator, ); } else { $raw_object_types[] = $iterator_atomic_type->value; @@ -662,9 +662,9 @@ public static function checkIteratorType( IssueBuffer::maybeAdd( new ImpureMethodCall( 'Cannot call a possibly-mutating iterator from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -675,17 +675,17 @@ public static function checkIteratorType( IssueBuffer::maybeAdd( new PossibleRawObjectIteration( 'Possibly undesired iteration over regular object ' . reset($raw_object_types), - new CodeLocation($statements_analyzer->getSource(), $expr) + new CodeLocation($statements_analyzer->getSource(), $expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RawObjectIteration( 'Possibly undesired iteration over regular object ' . reset($raw_object_types), - new CodeLocation($statements_analyzer->getSource(), $expr) + new CodeLocation($statements_analyzer->getSource(), $expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -695,17 +695,17 @@ public static function checkIteratorType( IssueBuffer::maybeAdd( new PossiblyInvalidIterator( 'Cannot iterate over ' . $invalid_iterator_types[0], - new CodeLocation($statements_analyzer->getSource(), $expr) + new CodeLocation($statements_analyzer->getSource(), $expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidIterator( 'Cannot iterate over ' . $invalid_iterator_types[0], - new CodeLocation($statements_analyzer->getSource(), $expr) + new CodeLocation($statements_analyzer->getSource(), $expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -726,7 +726,7 @@ public static function handleIterable( if ($iterator_atomic_type->extra_types) { $iterator_atomic_types = array_merge( [$iterator_atomic_type->setIntersectionTypes([])], - $iterator_atomic_type->extra_types + $iterator_atomic_type->extra_types, ); } else { $iterator_atomic_types = [$iterator_atomic_type]; @@ -747,12 +747,12 @@ public static function handleIterable( ) { $value_type = Type::combineUnionTypes( $value_type, - new Union([$iterator_atomic_type]) + new Union([$iterator_atomic_type]), ); $key_type = Type::combineUnionTypes( $key_type, - Type::getString() + Type::getString(), ); } @@ -760,25 +760,25 @@ public static function handleIterable( || (strtolower($iterator_atomic_type->value) === 'traversable' || $codebase->classImplements( $iterator_atomic_type->value, - 'Traversable' + 'Traversable', ) || ( $codebase->interfaceExists($iterator_atomic_type->value) && $codebase->interfaceExtends( $iterator_atomic_type->value, - 'Traversable' + 'Traversable', ) )) ) { if (strtolower($iterator_atomic_type->value) === 'iteratoraggregate' || $codebase->classImplements( $iterator_atomic_type->value, - 'IteratorAggregate' + 'IteratorAggregate', ) || ($codebase->interfaceExists($iterator_atomic_type->value) && $codebase->interfaceExtends( $iterator_atomic_type->value, - 'IteratorAggregate' + 'IteratorAggregate', ) ) ) { @@ -788,7 +788,7 @@ public static function handleIterable( $fake_method_call = new VirtualMethodCall( $foreach_expr, - new VirtualIdentifier('getIterator', $foreach_expr->getAttributes()) + new VirtualIdentifier('getIterator', $foreach_expr->getAttributes()), ); $suppressed_issues = $statements_analyzer->getSuppressedIssues(); @@ -808,7 +808,7 @@ public static function handleIterable( MethodCallAnalyzer::analyze( $statements_analyzer, $fake_method_call, - $context + $context, ); $context->inside_call = $was_inside_call; @@ -843,11 +843,11 @@ public static function handleIterable( && $codebase->classExists($array_atomic_type->value) && $codebase->classImplements( $array_atomic_type->value, - 'Traversable' + 'Traversable', ) ) { $generic_storage = $codebase->classlike_storage_provider->get( - $array_atomic_type->value + $array_atomic_type->value, ); // The collection might be an iterator, in which case @@ -867,7 +867,7 @@ public static function handleIterable( $context, $key_type, $value_type, - $has_valid_iterator + $has_valid_iterator, ); continue; @@ -880,14 +880,14 @@ public static function handleIterable( || ($codebase->classOrInterfaceExists($array_atomic_type->value) && $codebase->classImplements( $array_atomic_type->value, - 'Traversable' + 'Traversable', )))) ) { self::getKeyValueParamsForTraversableObject( $array_atomic_type, $codebase, $key_type_part, - $value_type_part + $value_type_part, ); } } @@ -902,13 +902,13 @@ public static function handleIterable( } } elseif ($codebase->classImplements( $iterator_atomic_type->value, - 'Iterator' + 'Iterator', ) || ( $codebase->interfaceExists($iterator_atomic_type->value) && $codebase->interfaceExtends( $iterator_atomic_type->value, - 'Iterator' + 'Iterator', ) ) ) { @@ -916,14 +916,14 @@ public static function handleIterable( $statements_analyzer, $foreach_expr, $context, - 'current' + 'current', ); $iterator_key_type = self::getFakeMethodCallType( $statements_analyzer, $foreach_expr, $context, - 'key' + 'key', ); if ($iterator_value_type && !$iterator_value_type->isMixed()) { @@ -940,7 +940,7 @@ public static function handleIterable( $iterator_atomic_type, $codebase, $key_type, - $value_type + $value_type, ); } @@ -974,16 +974,16 @@ public static function getKeyValueParamsForTraversableObject( && ( $codebase->classImplements( $iterator_atomic_type->value, - 'Traversable' + 'Traversable', ) || $codebase->interfaceExtends( $iterator_atomic_type->value, - 'Traversable' + 'Traversable', ) ) ) { $generic_storage = $codebase->classlike_storage_provider->get( - $iterator_atomic_type->value + $iterator_atomic_type->value, ); if (!isset($generic_storage->template_extended_params['Traversable'])) { @@ -1001,8 +1001,8 @@ public static function getKeyValueParamsForTraversableObject( array_map( /** @param array $arr */ static fn(array $arr): Union => $arr[$iterator_atomic_type->value] ?? Type::getMixed(), - $generic_storage->template_types - ) + $generic_storage->template_types, + ), ); } else { $passed_type_params = null; @@ -1014,7 +1014,7 @@ public static function getKeyValueParamsForTraversableObject( $generic_storage->name, $generic_storage->template_extended_params, $generic_storage->template_types, - $passed_type_params + $passed_type_params, ); $value_type = self::getExtendedType( @@ -1023,7 +1023,7 @@ public static function getKeyValueParamsForTraversableObject( $generic_storage->name, $generic_storage->template_extended_params, $generic_storage->template_types, - $passed_type_params + $passed_type_params, ); return; @@ -1042,7 +1042,7 @@ private static function getFakeMethodCallType( $fake_method_call = new VirtualMethodCall( $foreach_expr, - new VirtualIdentifier($method_name, $foreach_expr->getAttributes()) + new VirtualIdentifier($method_name, $foreach_expr->getAttributes()), ); $suppressed_issues = $statements_analyzer->getSuppressedIssues(); @@ -1062,7 +1062,7 @@ private static function getFakeMethodCallType( MethodCallAnalyzer::analyze( $statements_analyzer, $fake_method_call, - $context + $context, ); $context->inside_call = $was_inside_call; @@ -1116,7 +1116,7 @@ private static function getExtendedType( if (!$extended_atomic_type instanceof TTemplateParam) { $return_type = Type::combineUnionTypes( $return_type, - $extended_type + $extended_type, ); continue; @@ -1128,13 +1128,13 @@ private static function getExtendedType( $calling_class, $template_extended_params, $class_template_types, - $calling_type_params + $calling_type_params, ); if ($candidate_type) { $return_type = Type::combineUnionTypes( $return_type, - $candidate_type + $candidate_type, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php index c64ebaa0d58..ea9e450f81e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfConditionalAnalyzer.php @@ -64,8 +64,8 @@ public static function analyze( ? $cond->expr : $cond, $outer_context->include_location, - false - ) + false, + ), ); if ($changed_var_ids) { @@ -79,7 +79,7 @@ public static function analyze( static fn(Clause $c): bool => count($c->possibilities) > 1 || $c->wedge || !isset($changed_var_ids[array_keys($c->possibilities)[0]]) - ) + ), ); } } @@ -116,7 +116,7 @@ public static function analyze( if (ExpressionAnalyzer::analyze( $statements_analyzer, $externally_applied_if_cond_expr, - $outer_context + $outer_context, ) === false) { throw new ScopeAnalysisException(); } @@ -124,13 +124,13 @@ public static function analyze( $first_cond_assigned_var_ids = $outer_context->assigned_var_ids; $outer_context->assigned_var_ids = array_merge( $pre_assigned_var_ids, - $first_cond_assigned_var_ids + $first_cond_assigned_var_ids, ); $first_cond_referenced_var_ids = $outer_context->cond_referenced_var_ids; $outer_context->cond_referenced_var_ids = array_merge( $referenced_var_ids, - $first_cond_referenced_var_ids + $first_cond_referenced_var_ids, ); $outer_context->inside_conditional = $was_inside_conditional; @@ -176,24 +176,24 @@ public static function analyze( $more_cond_referenced_var_ids = $if_conditional_context->cond_referenced_var_ids; $if_conditional_context->cond_referenced_var_ids = array_merge( $more_cond_referenced_var_ids, - $referenced_var_ids + $referenced_var_ids, ); $cond_referenced_var_ids = array_merge( $first_cond_referenced_var_ids, - $more_cond_referenced_var_ids + $more_cond_referenced_var_ids, ); /** @var array */ $more_cond_assigned_var_ids = $if_conditional_context->assigned_var_ids; $if_conditional_context->assigned_var_ids = array_merge( $more_cond_assigned_var_ids, - $assigned_var_ids + $assigned_var_ids, ); $assigned_in_conditional_var_ids = array_merge( $first_cond_assigned_var_ids, - $more_cond_assigned_var_ids + $more_cond_assigned_var_ids, ); } else { $cond_referenced_var_ids = $first_cond_referenced_var_ids; @@ -207,7 +207,7 @@ public static function analyze( $if_conditional_context->vars_in_scope, $pre_condition_vars_in_scope, $cond_referenced_var_ids, - $assigned_in_conditional_var_ids + $assigned_in_conditional_var_ids, ) as $name => $_value) { $newish_var_ids[$name] = true; } @@ -224,7 +224,7 @@ public static function analyze( $post_if_context, $cond_referenced_var_ids, $assigned_in_conditional_var_ids, - $entry_clauses + $entry_clauses, ); } @@ -330,18 +330,18 @@ public static function handleParadoxicalCondition( new DocblockTypeContradiction( 'Operand of type ' . $type->getId() . ' is always falsy', new CodeLocation($statements_analyzer, $stmt), - $type->getId() . ' falsy' + $type->getId() . ' falsy', ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TypeDoesNotContainType( 'Operand of type ' . $type->getId() . ' is always falsy', new CodeLocation($statements_analyzer, $stmt), - $type->getId() . ' falsy' + $type->getId() . ' falsy', ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } elseif ($type->isAlwaysTruthy() && @@ -352,18 +352,18 @@ public static function handleParadoxicalCondition( new RedundantConditionGivenDocblockType( 'Operand of type ' . $type->getId() . ' is always truthy', new CodeLocation($statements_analyzer, $stmt), - $type->getId() . ' falsy' + $type->getId() . ' falsy', ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantCondition( 'Operand of type ' . $type->getId() . ' is always truthy', new CodeLocation($statements_analyzer, $stmt), - $type->getId() . ' falsy' + $type->getId() . ' falsy', ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php index 057bc064745..094b3fcaeaa 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseAnalyzer.php @@ -51,7 +51,7 @@ public static function analyze( } $else_context->clauses = Algebra::simplifyCNF( - [...$else_context->clauses, ...$if_scope->negated_clauses] + [...$else_context->clauses, ...$if_scope->negated_clauses], ); $else_types = Algebra::getTruthsFromFormula($else_context->clauses); @@ -73,7 +73,7 @@ public static function analyze( $else_context->inside_loop, $else ? new CodeLocation($statements_analyzer->getSource(), $else, $outer_context->include_location) - : null + : null, ); $else_context->clauses = Context::removeReconciledClauses($else_context->clauses, $changed_var_ids)[0]; @@ -100,7 +100,7 @@ public static function analyze( if ($else) { if ($statements_analyzer->analyze( $else->stmts, - $else_context + $else_context, ) === false ) { return false; @@ -127,15 +127,15 @@ public static function analyze( && !UnionTypeComparator::isContainedBy( $codebase, $byref_constraint->type, - $outer_constraint_type + $outer_constraint_type, ) ) { IssueBuffer::maybeAdd( new ConflictingReferenceConstraint( 'There is more than one pass-by-reference constraint on ' . $var_id, - new CodeLocation($statements_analyzer, $else, $outer_context->include_location, true) + new CodeLocation($statements_analyzer, $else, $outer_context->include_location, true), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { $outer_context->byref_constraints[$var_id] = $byref_constraint; @@ -147,7 +147,7 @@ public static function analyze( ? ScopeAnalyzer::getControlActions( $else->stmts, $statements_analyzer->node_data, - [] + [], ) : [ScopeAnalyzer::ACTION_NONE]; // has a return/throw at end @@ -170,7 +170,7 @@ public static function analyze( $new_assigned_var_ids, $new_possibly_assigned_var_ids, [], - true + true, ); $if_scope->reasonable_clauses = []; @@ -183,14 +183,14 @@ public static function analyze( $else_context, $has_leaving_statements, array_keys($if_scope->negatable_if_types), - $if_scope->updated_vars + $if_scope->updated_vars, ); } if (!$has_ending_statements) { $vars_possibly_in_scope = array_diff_key( $else_context->vars_possibly_in_scope, - $outer_context->vars_possibly_in_scope + $outer_context->vars_possibly_in_scope, ); $possibly_assigned_var_ids = $new_possibly_assigned_var_ids; @@ -200,24 +200,24 @@ public static function analyze( if (!$has_continue_statement && !$has_break_statement) { $if_scope->new_vars_possibly_in_scope = array_merge( $vars_possibly_in_scope, - $if_scope->new_vars_possibly_in_scope + $if_scope->new_vars_possibly_in_scope, ); } $else_context->loop_scope->vars_possibly_in_scope = array_merge( $vars_possibly_in_scope, - $else_context->loop_scope->vars_possibly_in_scope + $else_context->loop_scope->vars_possibly_in_scope, ); } } else { $if_scope->new_vars_possibly_in_scope = array_merge( $vars_possibly_in_scope, - $if_scope->new_vars_possibly_in_scope + $if_scope->new_vars_possibly_in_scope, ); $if_scope->possibly_assigned_var_ids = array_merge( $possibly_assigned_var_ids, - $if_scope->possibly_assigned_var_ids + $if_scope->possibly_assigned_var_ids, ); } } @@ -229,7 +229,7 @@ public static function analyze( // Track references set in the else to make sure they aren't reused later $outer_context->updateReferencesPossiblyFromConfusingScope( $else_context, - $statements_analyzer + $statements_analyzer, ); return null; diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php index 1c816846647..4ff32acc88f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/ElseIfAnalyzer.php @@ -63,7 +63,7 @@ public static function analyze( $else_context, $codebase, $if_scope, - $branch_point + $branch_point, ); $elseif_context = $if_conditional_scope->if_context; @@ -89,7 +89,7 @@ public static function analyze( $elseif->cond, $else_context->self, $statements_analyzer, - $codebase + $codebase, ); $elseif_clauses_handled = []; @@ -133,7 +133,7 @@ public static function analyze( $elseif_clauses, $statements_analyzer, $elseif->cond, - $assigned_in_conditional_var_ids + $assigned_in_conditional_var_ids, ); $elseif_context_clauses = [...$entry_clauses, ...$elseif_clauses]; @@ -145,7 +145,7 @@ public static function analyze( array_filter( $elseif_context_clauses, static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true) - ) + ), ); } @@ -156,7 +156,7 @@ public static function analyze( try { if (array_filter( $entry_clauses, - static fn(Clause $clause): bool => (bool) $clause->possibilities + static fn(Clause $clause): bool => (bool) $clause->possibilities, )) { $omit_keys = array_reduce( $entry_clauses, @@ -166,7 +166,7 @@ public static function analyze( */ static fn(array $carry, Clause $clause): array => array_merge($carry, array_keys($clause->possibilities)), - [] + [], ); $omit_keys = array_combine($omit_keys, $omit_keys); @@ -174,17 +174,17 @@ public static function analyze( $cond_referenced_var_ids = array_diff_key( $cond_referenced_var_ids, - $omit_keys + $omit_keys, ); } $reconcilable_elseif_types = Algebra::getTruthsFromFormula( $elseif_context->clauses, spl_object_id($elseif->cond), $cond_referenced_var_ids, - $active_elseif_types + $active_elseif_types, ); $negated_elseif_types = Algebra::getTruthsFromFormula( - Algebra::negateFormula($elseif_clauses) + Algebra::negateFormula($elseif_clauses), ); } catch (ComplicatedExpressionException $e) { $reconcilable_elseif_types = []; @@ -192,7 +192,7 @@ public static function analyze( } $all_negated_vars = array_unique( - [...array_keys($negated_elseif_types), ...array_keys($if_scope->negated_types)] + [...array_keys($negated_elseif_types), ...array_keys($if_scope->negated_types)], ); foreach ($all_negated_vars as $var_id) { @@ -200,7 +200,7 @@ public static function analyze( if (isset($if_scope->negated_types[$var_id])) { $if_scope->negated_types[$var_id] = [ ...$if_scope->negated_types[$var_id], - ...$negated_elseif_types[$var_id] + ...$negated_elseif_types[$var_id], ]; } else { $if_scope->negated_types[$var_id] = $negated_elseif_types[$var_id]; @@ -227,14 +227,14 @@ public static function analyze( $elseif->cond instanceof PhpParser\Node\Expr\BooleanNot ? $elseif->cond->expr : $elseif->cond, - $outer_context->include_location - ) + $outer_context->include_location, + ), ); if ($newly_reconciled_var_ids) { $elseif_context->clauses = Context::removeReconciledClauses( $elseif_context->clauses, - $newly_reconciled_var_ids + $newly_reconciled_var_ids, )[0]; foreach ($newly_reconciled_var_ids as $changed_var_id => $_) { @@ -257,7 +257,7 @@ public static function analyze( if ($statements_analyzer->analyze( $elseif->stmts, - $elseif_context + $elseif_context, ) === false ) { return false; @@ -283,15 +283,15 @@ public static function analyze( && !UnionTypeComparator::isContainedBy( $codebase, $byref_constraint->type, - $outer_constraint_type + $outer_constraint_type, ) ) { IssueBuffer::maybeAdd( new ConflictingReferenceConstraint( 'There is more than one pass-by-reference constraint on ' . $var_id, - new CodeLocation($statements_analyzer, $elseif, $outer_context->include_location, true) + new CodeLocation($statements_analyzer, $elseif, $outer_context->include_location, true), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { $outer_context->byref_constraints[$var_id] = $byref_constraint; @@ -301,7 +301,7 @@ public static function analyze( $final_actions = ScopeAnalyzer::getControlActions( $elseif->stmts, $statements_analyzer->node_data, - [] + [], ); // has a return/throw at end $has_ending_statements = $final_actions === [ScopeAnalyzer::ACTION_END]; @@ -322,7 +322,7 @@ public static function analyze( $outer_context, array_merge($new_stmts_assigned_var_ids, $assigned_in_conditional_var_ids), $new_stmts_possibly_assigned_var_ids, - $newly_reconciled_var_ids + $newly_reconciled_var_ids, ); $reasonable_clause_count = count($if_scope->reasonable_clauses); @@ -331,7 +331,7 @@ public static function analyze( $if_scope->reasonable_clauses = Algebra::combineOredClauses( $if_scope->reasonable_clauses, $elseif_clauses, - $elseif_cond_id + $elseif_cond_id, ); } else { $if_scope->reasonable_clauses = []; @@ -356,7 +356,7 @@ public static function analyze( $statements_analyzer, $statements_analyzer->getTemplateTypeMap() ?: [], $elseif_context->inside_loop, - new CodeLocation($statements_analyzer->getSource(), $elseif, $outer_context->include_location) + new CodeLocation($statements_analyzer->getSource(), $elseif, $outer_context->include_location), ); $updated_vars = []; @@ -366,7 +366,7 @@ public static function analyze( $implied_outer_context, false, array_keys($negated_elseif_types), - $updated_vars + $updated_vars, ); } } @@ -374,7 +374,7 @@ public static function analyze( if (!$has_ending_statements) { $vars_possibly_in_scope = array_diff_key( $elseif_context->vars_possibly_in_scope, - $outer_context->vars_possibly_in_scope + $outer_context->vars_possibly_in_scope, ); $possibly_assigned_var_ids = $new_stmts_possibly_assigned_var_ids; @@ -383,26 +383,26 @@ public static function analyze( if (!$has_continue_statement && !$has_break_statement) { $if_scope->new_vars_possibly_in_scope = array_merge( $vars_possibly_in_scope, - $if_scope->new_vars_possibly_in_scope + $if_scope->new_vars_possibly_in_scope, ); $if_scope->possibly_assigned_var_ids = array_merge( $possibly_assigned_var_ids, - $if_scope->possibly_assigned_var_ids + $if_scope->possibly_assigned_var_ids, ); } $elseif_context->loop_scope->vars_possibly_in_scope = array_merge( $vars_possibly_in_scope, - $elseif_context->loop_scope->vars_possibly_in_scope + $elseif_context->loop_scope->vars_possibly_in_scope, ); } elseif (!$has_leaving_statements) { $if_scope->new_vars_possibly_in_scope = array_merge( $vars_possibly_in_scope, - $if_scope->new_vars_possibly_in_scope + $if_scope->new_vars_possibly_in_scope, ); $if_scope->possibly_assigned_var_ids = array_merge( $possibly_assigned_var_ids, - $if_scope->possibly_assigned_var_ids + $if_scope->possibly_assigned_var_ids, ); } } @@ -413,7 +413,7 @@ public static function analyze( try { $if_scope->negated_clauses = Algebra::simplifyCNF( - [...$if_scope->negated_clauses, ...Algebra::negateFormula($elseif_clauses)] + [...$if_scope->negated_clauses, ...Algebra::negateFormula($elseif_clauses)], ); } catch (ComplicatedExpressionException $e) { $if_scope->negated_clauses = []; @@ -422,7 +422,7 @@ public static function analyze( // Track references set in the elseif to make sure they aren't reused later $outer_context->updateReferencesPossiblyFromConfusingScope( $elseif_context, - $statements_analyzer + $statements_analyzer, ); return null; diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php index 2fbc984da60..dd2e0989402 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php @@ -69,12 +69,12 @@ public static function analyze( $if_context->clauses, spl_object_id($stmt->cond), $cond_referenced_var_ids, - $active_if_types + $active_if_types, ); if (array_filter( $outer_context->clauses, - static fn(Clause $clause): bool => (bool) $clause->possibilities + static fn(Clause $clause): bool => (bool) $clause->possibilities, )) { $omit_keys = array_reduce( $outer_context->clauses, @@ -84,7 +84,7 @@ public static function analyze( */ static fn(array $carry, Clause $clause): array => array_merge($carry, array_keys($clause->possibilities)), - [] + [], ); $omit_keys = array_combine($omit_keys, $omit_keys); @@ -92,7 +92,7 @@ public static function analyze( $cond_referenced_var_ids = array_diff_key( $cond_referenced_var_ids, - $omit_keys + $omit_keys, ); } @@ -116,8 +116,8 @@ public static function analyze( $stmt->cond instanceof PhpParser\Node\Expr\BooleanNot ? $stmt->cond->expr : $stmt->cond, - $outer_context->include_location - ) : null + $outer_context->include_location, + ) : null, ); foreach ($reconcilable_if_types as $var_id => $_) { @@ -146,7 +146,7 @@ public static function analyze( $outer_context->vars_possibly_in_scope = array_merge( $if_context->vars_possibly_in_scope, - $outer_context->vars_possibly_in_scope + $outer_context->vars_possibly_in_scope, ); $old_if_context = clone $if_context; @@ -160,7 +160,7 @@ public static function analyze( if ($statements_analyzer->analyze( $stmt->stmts, - $if_context + $if_context, ) === false ) { return false; @@ -173,7 +173,7 @@ public static function analyze( $if_scope->if_actions = $final_actions = ScopeAnalyzer::getControlActions( $stmt->stmts, $statements_analyzer->node_data, - [] + [], ); $has_ending_statements = $final_actions === [ScopeAnalyzer::ACTION_END]; @@ -195,7 +195,7 @@ public static function analyze( $if_context->assigned_var_ids = array_merge($assigned_var_ids, $new_assigned_var_ids); $if_context->possibly_assigned_var_ids = array_merge( $possibly_assigned_var_ids, - $new_possibly_assigned_var_ids + $new_possibly_assigned_var_ids, ); foreach ($if_context->byref_constraints as $var_id => $byref_constraint) { @@ -205,7 +205,7 @@ public static function analyze( && !UnionTypeComparator::isContainedBy( $codebase, $byref_constraint->type, - $outer_constraint_type + $outer_constraint_type, ) ) { IssueBuffer::maybeAdd( @@ -213,9 +213,9 @@ public static function analyze( 'There is more than one pass-by-reference constraint on ' . $var_id . ' between ' . $byref_constraint->type->getId() . ' and ' . $outer_constraint_type->getId(), - new CodeLocation($statements_analyzer, $stmt, $outer_context->include_location, true) + new CodeLocation($statements_analyzer, $stmt, $outer_context->include_location, true), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { $outer_context->byref_constraints[$var_id] = $byref_constraint; @@ -230,7 +230,7 @@ public static function analyze( $outer_context, $new_assigned_var_ids, $new_possibly_assigned_var_ids, - $if_scope->if_cond_changed_var_ids + $if_scope->if_cond_changed_var_ids, ); if ($if_scope->reasonable_clauses) { @@ -240,7 +240,7 @@ public static function analyze( $var_id, $if_scope->reasonable_clauses, $if_context->vars_in_scope[$var_id] ?? null, - $statements_analyzer + $statements_analyzer, ); } } @@ -257,7 +257,7 @@ public static function analyze( $stmt->cond, $if_scope->post_leaving_if_context, $outer_context, - $if_conditional_scope->assigned_in_conditional_var_ids + $if_conditional_scope->assigned_in_conditional_var_ids, ); } } @@ -269,7 +269,7 @@ public static function analyze( if ($if_scope->negated_types) { $vars_to_update = array_intersect( array_keys($pre_assignment_else_redefined_vars), - array_keys($if_scope->negated_types) + array_keys($if_scope->negated_types), ); $extra_vars_to_update = []; @@ -291,14 +291,14 @@ public static function analyze( $if_context, $has_leaving_statements, $vars_to_update, - $if_scope->updated_vars + $if_scope->updated_vars, ); } if (!$has_ending_statements) { $vars_possibly_in_scope = array_diff_key( $if_context->vars_possibly_in_scope, - $outer_context->vars_possibly_in_scope + $outer_context->vars_possibly_in_scope, ); if ($if_context->loop_scope) { @@ -308,7 +308,7 @@ public static function analyze( $if_context->loop_scope->vars_possibly_in_scope = array_merge( $vars_possibly_in_scope, - $if_context->loop_scope->vars_possibly_in_scope + $if_context->loop_scope->vars_possibly_in_scope, ); } elseif (!$has_leaving_statements) { $if_scope->new_vars_possibly_in_scope = $vars_possibly_in_scope; @@ -322,7 +322,7 @@ public static function analyze( // Track references set in the if to make sure they aren't reused later $outer_context->updateReferencesPossiblyFromConfusingScope( $if_context, - $statements_analyzer + $statements_analyzer, ); return null; @@ -358,7 +358,7 @@ public static function addConditionallyAssignedVarsToContext( $fake_not = new VirtualBooleanOr( self::negateExpr($expr->left), self::negateExpr($expr->right), - $expr->getAttributes() + $expr->getAttributes(), ); } else { $fake_not = self::negateExpr($expr); @@ -370,9 +370,9 @@ public static function addConditionallyAssignedVarsToContext( $fake_not, false, false, - $expr->getAttributes() + $expr->getAttributes(), )], - $expr->getAttributes() + $expr->getAttributes(), ); $post_leaving_if_context->inside_negation = !$post_leaving_if_context->inside_negation; @@ -380,7 +380,7 @@ public static function addConditionallyAssignedVarsToContext( ExpressionAnalyzer::analyze( $statements_analyzer, $fake_negated_expr, - $post_leaving_if_context + $post_leaving_if_context, ); $post_leaving_if_context->inside_negation = !$post_leaving_if_context->inside_negation; @@ -411,7 +411,7 @@ private static function getDefinitelyEvaluatedOredExpressions(PhpParser\Node\Exp ) { return [ ...self::getDefinitelyEvaluatedOredExpressions($stmt->left), - ...self::getDefinitelyEvaluatedOredExpressions($stmt->right) + ...self::getDefinitelyEvaluatedOredExpressions($stmt->right), ]; } @@ -456,7 +456,7 @@ public static function updateIfScope( $if_scope->new_vars[$new_var] = Type::combineUnionTypes( $type, $if_context->vars_in_scope[$new_var], - $codebase + $codebase, ); } } @@ -491,12 +491,12 @@ public static function updateIfScope( $if_scope->redefined_vars[$redefined_var] = Type::combineUnionTypes( $redefined_vars[$redefined_var], $type, - $codebase + $codebase, ); if (isset($outer_context->vars_in_scope[$redefined_var]) && $if_scope->redefined_vars[$redefined_var]->equals( - $outer_context->vars_in_scope[$redefined_var] + $outer_context->vars_in_scope[$redefined_var], ) ) { unset($if_scope->redefined_vars[$redefined_var]); @@ -508,7 +508,7 @@ public static function updateIfScope( $if_scope->possibly_redefined_vars[$var] = Type::combineUnionTypes( $type, $if_scope->possibly_redefined_vars[$var] ?? null, - $codebase + $codebase, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php index 3a87d9e8f9f..1abf90ffca9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElseAnalyzer.php @@ -83,7 +83,7 @@ public static function analyze( $final_actions = ScopeAnalyzer::getControlActions( $stmt->stmts, null, - [] + [], ); $has_leaving_statements = $final_actions === [ScopeAnalyzer::ACTION_END] @@ -101,7 +101,7 @@ public static function analyze( $context, $codebase, $if_scope, - $context->branch_point ?: (int) $stmt->getAttribute('startFilePos') + $context->branch_point ?: (int) $stmt->getAttribute('startFilePos'), ); // this is the context for stuff that happens within the `if` block @@ -130,7 +130,7 @@ public static function analyze( $stmt->cond, $context->self, $statements_analyzer, - $codebase + $codebase, ); if (count($if_clauses) > 200) { @@ -165,7 +165,7 @@ public static function analyze( $if_clauses, $statements_analyzer, $stmt->cond, - $assigned_in_conditional_var_ids + $assigned_in_conditional_var_ids, ); $if_clauses = Algebra::simplifyCNF($if_clauses); @@ -183,7 +183,7 @@ public static function analyze( array_filter( $if_context->clauses, static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses) - ) + ), ); if (count($if_context->clauses) === 1 @@ -209,7 +209,7 @@ public static function analyze( $context->self, $statements_analyzer, $codebase, - false + false, ); } catch (ComplicatedExpressionException $e) { $if_scope->negated_clauses = []; @@ -218,8 +218,8 @@ public static function analyze( $if_scope->negated_types = Algebra::getTruthsFromFormula( Algebra::simplifyCNF( - [...$context->clauses, ...$if_scope->negated_clauses] - ) + [...$context->clauses, ...$if_scope->negated_clauses], + ), ); $temp_else_context = clone $post_if_context; @@ -244,8 +244,8 @@ public static function analyze( $stmt->cond instanceof PhpParser\Node\Expr\BooleanNot ? $stmt->cond->expr : $stmt->cond, - $context->include_location - ) : null + $context->include_location, + ) : null, ); } @@ -253,7 +253,7 @@ public static function analyze( // which vars of the if we can safely change $pre_assignment_else_redefined_vars = array_intersect_key( $temp_else_context->getRedefinedVars($context->vars_in_scope, true), - $changed_var_ids + $changed_var_ids, ); // check the if @@ -264,7 +264,7 @@ public static function analyze( $if_conditional_scope, $if_context, $context, - $pre_assignment_else_redefined_vars + $pre_assignment_else_redefined_vars, ) === false) { return false; } @@ -282,7 +282,7 @@ public static function analyze( $else_context, $context, $codebase, - $else_context->branch_point ?: (int) $stmt->getAttribute('startFilePos') + $else_context->branch_point ?: (int) $stmt->getAttribute('startFilePos'), ) === false) { return false; } @@ -300,7 +300,7 @@ public static function analyze( $stmt->else, $if_scope, $else_context, - $context + $context, ) === false) { return false; } @@ -343,7 +343,7 @@ public static function analyze( IssueBuffer::remove( $statements_analyzer->getFilePath(), 'MixedAssignment', - $first_appearance->raw_file_start + $first_appearance->raw_file_start, ); } } @@ -353,25 +353,25 @@ public static function analyze( $context->loop_scope->final_actions = array_unique( array_merge( $context->loop_scope->final_actions, - $if_scope->final_actions - ) + $if_scope->final_actions, + ), ); } $context->vars_possibly_in_scope = array_merge( $context->vars_possibly_in_scope, - $if_scope->new_vars_possibly_in_scope + $if_scope->new_vars_possibly_in_scope, ); $context->possibly_assigned_var_ids = array_merge( $context->possibly_assigned_var_ids, - $if_scope->possibly_assigned_var_ids ?: [] + $if_scope->possibly_assigned_var_ids ?: [], ); // vars can only be defined/redefined if there was an else (defined in every block) $context->assigned_var_ids = array_merge( $context->assigned_var_ids, - $if_scope->assigned_var_ids ?: [] + $if_scope->assigned_var_ids ?: [], ); if ($if_scope->new_vars) { @@ -380,7 +380,7 @@ public static function analyze( && $statements_analyzer->data_flow_graph ) { $type = $type->addParentNodes( - $statements_analyzer->getParentNodesForPossiblyUndefinedVariable($var_id) + $statements_analyzer->getParentNodesForPossiblyUndefinedVariable($var_id), ); } @@ -399,7 +399,7 @@ public static function analyze( $var_id, $if_scope->reasonable_clauses, $context->vars_in_scope[$var_id] ?? null, - $statements_analyzer + $statements_analyzer, ); } } @@ -409,7 +409,7 @@ public static function analyze( && (count($if_scope->reasonable_clauses) > 1 || !$if_scope->reasonable_clauses[0]->wedge) ) { $context->clauses = Algebra::simplifyCNF( - [...$if_scope->reasonable_clauses, ...$context->clauses] + [...$if_scope->reasonable_clauses, ...$context->clauses], ); } @@ -422,7 +422,7 @@ public static function analyze( $combined_type = Type::combineUnionTypes( $context->vars_in_scope[$var_id], $type, - $codebase + $codebase, ); if (!$combined_type->equals($context->vars_in_scope[$var_id])) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php index 79ac5bda923..969af175130 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/LoopAnalyzer.php @@ -82,20 +82,20 @@ public static function analyze( $pre_condition, $loop_context->self, $statements_analyzer, - $codebase + $codebase, ); } } else { $always_assigned_before_loop_body_vars = Context::getNewOrUpdatedVarIds( $loop_parent_context, - $loop_context + $loop_context, ); } $final_actions = ScopeAnalyzer::getControlActions( $stmts, $statements_analyzer->node_data, - [] + [], ); $does_always_break = $final_actions === [ScopeAnalyzer::ACTION_BREAK]; @@ -122,7 +122,7 @@ public static function analyze( $pre_condition_clauses[$condition_offset], $continue_context, $loop_parent_context, - $is_do + $is_do, ); } @@ -135,7 +135,7 @@ public static function analyze( if (ExpressionAnalyzer::analyze( $statements_analyzer, $post_expression, - $loop_context + $loop_context, ) === false ) { return false; @@ -144,7 +144,7 @@ public static function analyze( $loop_parent_context->vars_possibly_in_scope = array_merge( $continue_context->vars_possibly_in_scope, - $loop_parent_context->vars_possibly_in_scope + $loop_parent_context->vars_possibly_in_scope, ); } else { $original_parent_context = clone $loop_parent_context; @@ -166,7 +166,7 @@ public static function analyze( $pre_condition_clauses[$condition_offset], $loop_context, $loop_parent_context, - $is_do + $is_do, ); } } @@ -193,7 +193,7 @@ public static function analyze( $pre_condition_clauses[$condition_offset], $continue_context, $loop_parent_context, - $is_do + $is_do, ), ...$always_assigned_before_loop_body_vars]; } } @@ -234,7 +234,7 @@ public static function analyze( // widen the foreach context type with the initial context type $continue_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $continue_context->vars_in_scope[$var_id], - $original_parent_context->vars_in_scope[$var_id] + $original_parent_context->vars_in_scope[$var_id], ); // if there's a change, invalidate related clauses @@ -251,7 +251,7 @@ public static function analyze( // widen the foreach context type with the initial context type $continue_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $continue_context->vars_in_scope[$var_id], - $loop_context->vars_in_scope[$var_id] + $loop_context->vars_in_scope[$var_id], ); // if there's a change, invalidate related clauses @@ -275,7 +275,7 @@ public static function analyze( $loop_parent_context->vars_possibly_in_scope = array_merge( $continue_context->vars_possibly_in_scope, - $loop_parent_context->vars_possibly_in_scope + $loop_parent_context->vars_possibly_in_scope, ); // if there are no changes to the types, no need to re-examine @@ -302,7 +302,7 @@ public static function analyze( $pre_condition_clauses[$condition_offset], $continue_context, $loop_parent_context, - false + false, ); } } @@ -331,8 +331,8 @@ public static function analyze( $traverser->addVisitor( new NodeCleanerVisitor( - $statements_analyzer->node_data - ) + $statements_analyzer->node_data, + ), ); $traverser->traverse($stmts); @@ -352,7 +352,7 @@ public static function analyze( $pre_condition_clauses[$condition_offset], $continue_context, $loop_parent_context, - $is_do + $is_do, ); } } @@ -361,7 +361,7 @@ public static function analyze( if (ExpressionAnalyzer::analyze( $statements_analyzer, $post_expression, - $continue_context + $continue_context, ) === false) { return false; } @@ -387,7 +387,7 @@ public static function analyze( foreach ($loop_scope->possibly_redefined_loop_parent_vars as $var => $type) { $loop_parent_context->vars_in_scope[$var] = Type::combineUnionTypes( $type, - $loop_parent_context->vars_in_scope[$var] + $loop_parent_context->vars_in_scope[$var], ); $loop_parent_context->possibly_assigned_var_ids[$var] = true; @@ -402,14 +402,14 @@ public static function analyze( if ($loop_context->vars_in_scope[$var_id]->getId() !== $type->getId()) { $loop_parent_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $loop_parent_context->vars_in_scope[$var_id], - $loop_context->vars_in_scope[$var_id] + $loop_context->vars_in_scope[$var_id], ); $loop_parent_context->removeVarFromConflictingClauses($var_id); } else { $loop_parent_context->vars_in_scope[$var_id] = $loop_parent_context->vars_in_scope[$var_id]->addParentNodes( - $loop_context->vars_in_scope[$var_id]->parent_nodes + $loop_context->vars_in_scope[$var_id]->parent_nodes, ) ; } @@ -425,7 +425,7 @@ public static function analyze( if ($continue_context->vars_in_scope[$var_id]->hasMixed()) { $continue_context->vars_in_scope[$var_id] = $continue_context->vars_in_scope[$var_id]->addParentNodes( - $loop_parent_context->vars_in_scope[$var_id]->parent_nodes + $loop_parent_context->vars_in_scope[$var_id]->parent_nodes, ) ; @@ -439,7 +439,7 @@ public static function analyze( if ($continue_context->vars_in_scope[$var_id]->getId() !== $type->getId()) { $loop_parent_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $loop_parent_context->vars_in_scope[$var_id], - $continue_context->vars_in_scope[$var_id] + $continue_context->vars_in_scope[$var_id], ); $loop_parent_context->removeVarFromConflictingClauses($var_id); @@ -447,7 +447,7 @@ public static function analyze( $loop_parent_context->vars_in_scope[$var_id] = $loop_parent_context->vars_in_scope[$var_id]->setParentNodes(array_merge( $loop_parent_context->vars_in_scope[$var_id]->parent_nodes, - $continue_context->vars_in_scope[$var_id]->parent_nodes + $continue_context->vars_in_scope[$var_id]->parent_nodes, )) ; } @@ -479,7 +479,7 @@ public static function analyze( $statements_analyzer, [], true, - new CodeLocation($statements_analyzer->getSource(), $pre_conditions[0]) + new CodeLocation($statements_analyzer->getSource(), $pre_conditions[0]), ); foreach ($changed_var_ids as $var_id => $_) { @@ -505,7 +505,7 @@ public static function analyze( if (isset($loop_scope->possibly_defined_loop_parent_vars[$var_id])) { $loop_parent_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, - $loop_scope->possibly_defined_loop_parent_vars[$var_id] + $loop_scope->possibly_defined_loop_parent_vars[$var_id], ); } } else { @@ -521,7 +521,7 @@ public static function analyze( // Track references set in the loop to make sure they aren't reused later $loop_parent_context->updateReferencesPossiblyFromConfusingScope( $continue_context, - $statements_analyzer + $statements_analyzer, ); return null; @@ -548,7 +548,7 @@ private static function updateLoopScopeContexts( if (!isset($updated_loop_vars[$var])) { $continue_context->vars_in_scope[$var] = Type::combineUnionTypes( $continue_context->vars_in_scope[$var], - $type + $type, ); } else { $continue_context->vars_in_scope[$var] = @@ -561,7 +561,7 @@ private static function updateLoopScopeContexts( // merge vars possibly in scope at the end of each loop $loop_context->vars_possibly_in_scope = array_merge( $loop_context->vars_possibly_in_scope, - $loop_scope->vars_possibly_in_scope + $loop_scope->vars_possibly_in_scope, ); } @@ -598,7 +598,7 @@ private static function applyPreConditionToLoopContext( $always_assigned_before_loop_body_vars = Context::getNewOrUpdatedVarIds($outer_context, $loop_context); $loop_context->clauses = Algebra::simplifyCNF( - [...$outer_context->clauses, ...$pre_condition_clauses] + [...$outer_context->clauses, ...$pre_condition_clauses], ); $active_while_types = []; @@ -607,7 +607,7 @@ private static function applyPreConditionToLoopContext( $loop_context->clauses, spl_object_id($pre_condition), $new_referenced_var_ids, - $active_while_types + $active_while_types, ); $changed_var_ids = []; @@ -623,7 +623,7 @@ private static function applyPreConditionToLoopContext( $statements_analyzer, [], true, - new CodeLocation($statements_analyzer->getSource(), $pre_condition) + new CodeLocation($statements_analyzer->getSource(), $pre_condition), ); } @@ -636,7 +636,7 @@ private static function applyPreConditionToLoopContext( $var_id, $loop_context->clauses, null, - $statements_analyzer + $statements_analyzer, ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php index 8f1b1b47107..a0d9d48200c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchAnalyzer.php @@ -45,7 +45,7 @@ public static function analyze( $switch_var_id = ExpressionIdentifier::getExtendedVarId( $stmt->cond, null, - $statements_analyzer + $statements_analyzer, ); if (!$switch_var_id @@ -79,7 +79,7 @@ public static function analyze( $case_actions = $case_action_map[$i] = ScopeAnalyzer::getControlActions( $case->stmts, $statements_analyzer->node_data, - ['switch'] + ['switch'], ); if (!in_array(ScopeAnalyzer::ACTION_NONE, $case_actions, true)) { @@ -131,7 +131,7 @@ public static function analyze( $case_exit_type, $case_actions, $i === $l - 1, - $switch_scope + $switch_scope, ) === false ) { return; @@ -142,7 +142,7 @@ public static function analyze( if (!$has_default && $switch_scope->negated_clauses && $switch_var_id) { $entry_clauses = Algebra::simplifyCNF( - [...$original_context->clauses, ...$switch_scope->negated_clauses] + [...$original_context->clauses, ...$switch_scope->negated_clauses], ); $reconcilable_if_types = Algebra::getTruthsFromFormula($entry_clauses); @@ -161,7 +161,7 @@ public static function analyze( [], $statements_analyzer, [], - $original_context->inside_loop + $original_context->inside_loop, ); if (isset($case_vars_in_scope_reconciled[$switch_var_id]) @@ -195,7 +195,7 @@ public static function analyze( ) { $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, - $context->vars_in_scope[$var_id] + $context->vars_in_scope[$var_id], ); } } @@ -207,7 +207,7 @@ public static function analyze( if (isset($context->vars_in_scope[$var_id])) { $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, - $context->vars_in_scope[$var_id] + $context->vars_in_scope[$var_id], ); } } @@ -219,7 +219,7 @@ public static function analyze( $context->vars_possibly_in_scope = array_merge( $context->vars_possibly_in_scope, - $switch_scope->new_vars_possibly_in_scope + $switch_scope->new_vars_possibly_in_scope, ); //a switch can't return in all options without a default diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php index 0831552fddc..5fd9b4b1483 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php @@ -93,7 +93,7 @@ public static function analyze( if ($switch_var_id && strpos($switch_var_id, '$__tmp_switch__') === 0) { $switch_condition = new VirtualVariable( substr($switch_var_id, 1), - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ); $fake_switch_condition = true; @@ -119,8 +119,8 @@ public static function analyze( $traverser = new PhpParser\NodeTraverser; $traverser->addVisitor( new ConditionCloningVisitor( - $statements_analyzer->node_data - ) + $statements_analyzer->node_data, + ), ); /** @var PhpParser\Node\Expr */ @@ -129,7 +129,7 @@ public static function analyze( if ($fake_switch_condition) { $statements_analyzer->node_data->setType( $switch_condition, - $case_context->vars_in_scope[$switch_var_id] ?? Type::getMixed() + $case_context->vars_in_scope[$switch_var_id] ?? Type::getMixed(), ); } @@ -149,14 +149,14 @@ public static function analyze( new VirtualArg( new VirtualVariable( substr($type->typeof, 1), - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ), false, false, - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ), ], - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ); } elseif ($type instanceof TDependentGetType) { $type_statements[] = new VirtualFuncCall( @@ -165,14 +165,14 @@ public static function analyze( new VirtualArg( new VirtualVariable( substr($type->typeof, 1), - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ), false, false, - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ), ], - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ); } elseif ($type instanceof TDependentGetDebugType) { $type_statements[] = new VirtualFuncCall( @@ -181,14 +181,14 @@ public static function analyze( new VirtualArg( new VirtualVariable( substr($type->typeof, 1), - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ), false, false, - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ), ], - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ); } else { $type_statements = null; @@ -202,7 +202,7 @@ public static function analyze( if ($fake_switch_condition) { $statements_analyzer->node_data->setType( $switch_condition, - $case_context->vars_in_scope[$switch_var_id] ?? Type::getMixed() + $case_context->vars_in_scope[$switch_var_id] ?? Type::getMixed(), ); } } @@ -222,13 +222,13 @@ public static function analyze( $case_equality_expr = new VirtualIdentical( $switch_condition, $case->cond, - $case->cond->getAttributes() + $case->cond->getAttributes(), ); } else { $case_equality_expr = new VirtualEqual( $switch_condition, $case->cond, - $case->cond->getAttributes() + $case->cond->getAttributes(), ); } } @@ -250,7 +250,7 @@ public static function analyze( new VirtualArg(new VirtualLNumber(0)), new VirtualArg(new VirtualLNumber(1)), ], - $case->getAttributes() + $case->getAttributes(), ); } @@ -258,7 +258,7 @@ public static function analyze( ? new VirtualBooleanOr( $switch_scope->leftover_case_equality_expr, $case_equality_expr, - $case->cond ? $case->cond->getAttributes() : $case->getAttributes() + $case->cond ? $case->cond->getAttributes() : $case->getAttributes(), ) : $case_equality_expr; @@ -271,7 +271,7 @@ public static function analyze( $case_if_stmt = new VirtualIf( $switch_scope->leftover_case_equality_expr, ['stmts' => $case_stmts], - $case->getAttributes() + $case->getAttributes(), ); $switch_scope->leftover_statements = [$case_if_stmt]; @@ -295,14 +295,14 @@ public static function analyze( new VirtualArg(new VirtualLNumber(0)), new VirtualArg(new VirtualLNumber(1)), ], - $case->getAttributes() + $case->getAttributes(), ); } $case_equality_expr = new VirtualBooleanOr( $switch_scope->leftover_case_equality_expr, $case_or_default_equality_expr, - $case_or_default_equality_expr->getAttributes() + $case_or_default_equality_expr->getAttributes(), ); } @@ -313,7 +313,7 @@ public static function analyze( ) { $new_case_equality_expr = self::simplifyCaseEqualityExpression( $case_equality_expr, - $switch_condition + $switch_condition, ); if ($new_case_equality_expr) { @@ -324,7 +324,7 @@ public static function analyze( ExpressionAnalyzer::analyze( $statements_analyzer, $new_case_equality_expr->getArgs()[1]->value, - $case_context + $case_context, ); $case_context->inside_conditional = $was_inside_conditional; @@ -350,13 +350,13 @@ public static function analyze( $statements_analyzer, $codebase, false, - false + false, ); } if ($switch_scope->negated_clauses && count($switch_scope->negated_clauses) < 50) { $entry_clauses = Algebra::simplifyCNF( - [...$original_context->clauses, ...$switch_scope->negated_clauses] + [...$original_context->clauses, ...$switch_scope->negated_clauses], ); } else { $entry_clauses = $original_context->clauses; @@ -369,7 +369,7 @@ public static function analyze( $case_clauses, $statements_analyzer, $case->cond, - [] + [], ); if (count($entry_clauses) + count($case_clauses) < 50) { @@ -411,8 +411,8 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $case->cond ?? $case, - $context->include_location - ) + $context->include_location, + ), ); if (!in_array('RedundantCondition', $suppressed_issues, true)) { @@ -449,7 +449,7 @@ public static function analyze( $statements_analyzer, $codebase, false, - false + false, ); } catch (ComplicatedExpressionException $e) { $negated_case_clauses = []; @@ -465,8 +465,8 @@ public static function analyze( $traverser->addVisitor( new TypeMappingVisitor( $statements_analyzer->node_data, - $old_node_data - ) + $old_node_data, + ), ); $traverser->traverse([$case]); @@ -482,7 +482,7 @@ public static function analyze( $case_context, $original_context, $case_exit_type, - $switch_scope + $switch_scope, ) === false) { unset($case_scope->parent_context); unset($case_context->case_scope); @@ -496,14 +496,14 @@ public static function analyze( if ($switch_scope->possibly_redefined_vars === null) { $switch_scope->possibly_redefined_vars = array_intersect_key( $case_scope->break_vars, - $context->vars_in_scope + $context->vars_in_scope, ); } else { foreach ($case_scope->break_vars as $var_id => $type) { if (isset($context->vars_in_scope[$var_id])) { $switch_scope->possibly_redefined_vars[$var_id] = Type::combineUnionTypes( $type, - $switch_scope->possibly_redefined_vars[$var_id] ?? null + $switch_scope->possibly_redefined_vars[$var_id] ?? null, ); } } @@ -517,7 +517,7 @@ public static function analyze( } else { $switch_scope->new_vars_in_scope[$var_id] = Type::combineUnionTypes( $case_scope->break_vars[$var_id], - $type + $type, ); } } else { @@ -531,7 +531,7 @@ public static function analyze( if (isset($case_scope->break_vars[$var_id])) { $switch_scope->redefined_vars[$var_id] = Type::combineUnionTypes( $case_scope->break_vars[$var_id], - $type + $type, ); } else { unset($switch_scope->redefined_vars[$var_id]); @@ -567,9 +567,9 @@ private static function handleNonReturningCase( if (IssueBuffer::accepts( new ParadoxicalCondition( 'All possible case statements have been met, default is impossible here', - new CodeLocation($statements_analyzer->getSource(), $case) + new CodeLocation($statements_analyzer->getSource(), $case), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -581,8 +581,8 @@ private static function handleNonReturningCase( if (IssueBuffer::accepts( new ContinueOutsideLoop( 'Continue called when not in loop', - new CodeLocation($statements_analyzer->getSource(), $case) - ) + new CodeLocation($statements_analyzer->getSource(), $case), + ), )) { return false; } @@ -596,7 +596,7 @@ private static function handleNonReturningCase( foreach ($case_redefined_vars as $var_id => $type) { $switch_scope->possibly_redefined_vars[$var_id] = Type::combineUnionTypes( $type, - $switch_scope->possibly_redefined_vars[$var_id] ?? null + $switch_scope->possibly_redefined_vars[$var_id] ?? null, ); } } @@ -610,7 +610,7 @@ private static function handleNonReturningCase( } else { $switch_scope->redefined_vars[$var_id] = Type::combineUnionTypes( $type, - $case_redefined_vars[$var_id] + $case_redefined_vars[$var_id], ); } } @@ -622,7 +622,7 @@ private static function handleNonReturningCase( $switch_scope->new_vars_in_scope = $context_new_vars; $switch_scope->new_vars_possibly_in_scope = array_diff_key( $case_context->vars_possibly_in_scope, - $context->vars_possibly_in_scope + $context->vars_possibly_in_scope, ); } else { foreach ($switch_scope->new_vars_in_scope as $new_var => $type) { @@ -637,9 +637,9 @@ private static function handleNonReturningCase( $switch_scope->new_vars_possibly_in_scope = array_merge( array_diff_key( $case_context->vars_possibly_in_scope, - $context->vars_possibly_in_scope + $context->vars_possibly_in_scope, ), - $switch_scope->new_vars_possibly_in_scope + $switch_scope->new_vars_possibly_in_scope, ); } } @@ -666,23 +666,23 @@ private static function simplifyCaseEqualityExpression( $var, false, false, - $var->getAttributes() + $var->getAttributes(), ), new VirtualArg( new VirtualArray( $nested_or_options, - $case_equality_expr->getAttributes() + $case_equality_expr->getAttributes(), ), false, false, - $case_equality_expr->getAttributes() + $case_equality_expr->getAttributes(), ), new VirtualArg( new VirtualConstFetch( - new VirtualFullyQualified(['true']) - ) + new VirtualFullyQualified(['true']), + ), ), - ] + ], ); } } @@ -707,7 +707,7 @@ private static function getOptionsFromNestedOr( $case_equality_expr->right, null, false, - $case_equality_expr->right->getAttributes() + $case_equality_expr->right->getAttributes(), ); return $in_array_values; @@ -728,13 +728,13 @@ private static function getOptionsFromNestedOr( $case_equality_expr->right->right, null, false, - $case_equality_expr->right->right->getAttributes() + $case_equality_expr->right->right->getAttributes(), ); return self::getOptionsFromNestedOr( $case_equality_expr->left, $var, - $in_array_values + $in_array_values, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php index 50ce7bca8cd..18536b49394 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php @@ -52,7 +52,7 @@ public static function analyze( $catch_actions[$i] = ScopeAnalyzer::getControlActions( $catch->stmts, $statements_analyzer->node_data, - [] + [], ); $all_catches_leave = $all_catches_leave && !in_array(ScopeAnalyzer::ACTION_NONE, $catch_actions[$i], true); } @@ -91,7 +91,7 @@ public static function analyze( $try_block_control_actions = ScopeAnalyzer::getControlActions( $stmt->stmts, $statements_analyzer->node_data, - [] + [], ); /** @var array */ @@ -99,7 +99,7 @@ public static function analyze( $context->assigned_var_ids = array_merge( $assigned_var_ids, - $newly_assigned_var_ids + $newly_assigned_var_ids, ); foreach ($context->vars_in_scope as $var_id => $type) { @@ -110,7 +110,7 @@ public static function analyze( } else { $try_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $try_context->vars_in_scope[$var_id], - $type + $type, ); } } @@ -120,7 +120,7 @@ public static function analyze( $try_context->finally_scope->vars_in_scope[$var_id] = Type::combineUnionTypes( $try_context->finally_scope->vars_in_scope[$var_id] ?? null, $type, - $statements_analyzer->getCodebase() + $statements_analyzer->getCodebase(), ); } } @@ -165,12 +165,12 @@ public static function analyze( if (!isset($old_context->vars_in_scope[$var_id])) { $catch_context->vars_in_scope[$var_id] = $type->setPossiblyUndefined( $catch_context->vars_in_scope[$var_id]->possibly_undefined, - true + true, ); } else { $catch_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, - $old_context->vars_in_scope[$var_id] + $old_context->vars_in_scope[$var_id], ); } } @@ -184,7 +184,7 @@ public static function analyze( foreach ($catch->types as $catch_type) { $fq_catch_class = ClassLikeAnalyzer::getFQCLNFromNameObject( $catch_type, - $statements_analyzer->getAliases() + $statements_analyzer->getAliases(), ); $fq_catch_class = $codebase->classlikes->getUnAliasedName($fq_catch_class); @@ -195,7 +195,7 @@ public static function analyze( $statements_analyzer, $catch_type, $fq_catch_class, - $context->calling_method_id + $context->calling_method_id, ); } @@ -207,7 +207,7 @@ public static function analyze( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(true) + new ClassLikeNameOptions(true), ); } @@ -223,9 +223,9 @@ public static function analyze( new InvalidCatch( 'Class/interface ' . $fq_catch_class . ' cannot be caught', new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_catch_class + $fq_catch_class, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -274,8 +274,8 @@ public static function analyze( ? ['Throwable' => new TNamedObject('Throwable')] : [], ), - $fq_catch_classes - ) + $fq_catch_classes, + ), ); // removes dependent vars from $context @@ -283,7 +283,7 @@ public static function analyze( $catch_var_id, $catch_context->vars_in_scope[$catch_var_id], $catch_context->vars_in_scope[$catch_var_id], - $statements_analyzer + $statements_analyzer, ); $catch_context->vars_possibly_in_scope[$catch_var_id] = true; @@ -294,12 +294,12 @@ public static function analyze( $statements_analyzer->registerVariable( $catch_var_id, $location, - $catch_context->branch_point + $catch_context->branch_point, ); } else { $statements_analyzer->registerVariableAssignment( $catch_var_id, - $location + $location, ); } @@ -308,7 +308,7 @@ public static function analyze( $catch_context->vars_in_scope[$catch_var_id] = $catch_context->vars_in_scope[$catch_var_id]->addParentNodes([ - $catch_var_node->id => $catch_var_node + $catch_var_node->id => $catch_var_node, ]) ; @@ -316,7 +316,7 @@ public static function analyze( $statements_analyzer->data_flow_graph->addPath( $catch_var_node, new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } } @@ -340,7 +340,7 @@ public static function analyze( $catch_actions[$i] = ScopeAnalyzer::getControlActions( $catch->stmts, $statements_analyzer->node_data, - [] + [], ); foreach ($issues_to_suppress as $issue_to_suppress) { @@ -365,7 +365,7 @@ public static function analyze( if ($catch_doesnt_leave_parent_scope) { $definitely_newly_assigned_var_ids = array_intersect_key( $new_catch_assigned_var_ids, - $definitely_newly_assigned_var_ids + $definitely_newly_assigned_var_ids, ); foreach ($catch_context->vars_in_scope as $var_id => $type) { @@ -374,20 +374,20 @@ public static function analyze( } elseif (isset($context->vars_in_scope[$var_id])) { $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $context->vars_in_scope[$var_id], - $type + $type, ); } } $context->vars_possibly_in_scope = array_merge( $catch_context->vars_possibly_in_scope, - $context->vars_possibly_in_scope + $context->vars_possibly_in_scope, ); } else { if ($stmt->finally) { $context->vars_possibly_in_scope = array_merge( $catch_context->vars_possibly_in_scope, - $context->vars_possibly_in_scope + $context->vars_possibly_in_scope, ); } } @@ -399,13 +399,13 @@ public static function analyze( $try_context->finally_scope->vars_in_scope[$var_id] = Type::combineUnionTypes( $try_context->finally_scope->vars_in_scope[$var_id], $type, - $statements_analyzer->getCodebase() + $statements_analyzer->getCodebase(), ); } } else { $try_context->finally_scope->vars_in_scope[$var_id] = $type->setPossiblyUndefined( true, - true + true, ); } } @@ -445,7 +445,7 @@ public static function analyze( $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $context->vars_in_scope[$var_id], $finally_context->vars_in_scope[$var_id], - $codebase + $codebase, ); if ($possibly_undefined) { /** @psalm-suppress InaccessibleProperty We just created this type */ @@ -466,7 +466,7 @@ public static function analyze( $context->vars_in_scope[$var_id] = $context->vars_in_scope[$var_id]->setPossiblyUndefined( false, - false + false, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/WhileAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/WhileAnalyzer.php index 6a4e8eab3c8..e3a52f67e76 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/WhileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/WhileAnalyzer.php @@ -55,7 +55,7 @@ public static function analyze( self::getAndExpressions($stmt->cond), [], $loop_scope, - $inner_loop_context + $inner_loop_context, ) === false) { return false; } @@ -88,7 +88,7 @@ public static function analyze( if (isset($loop_scope->possibly_defined_loop_parent_vars[$var_id])) { $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, - $loop_scope->possibly_defined_loop_parent_vars[$var_id] + $loop_scope->possibly_defined_loop_parent_vars[$var_id], ); } } else { @@ -102,7 +102,7 @@ public static function analyze( if ($can_leave_loop) { $context->vars_possibly_in_scope = array_merge( $context->vars_possibly_in_scope, - $while_context->vars_possibly_in_scope + $while_context->vars_possibly_in_scope, ); } elseif ($pre_context) { $context->vars_possibly_in_scope = $pre_context->vars_possibly_in_scope; diff --git a/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php index 1b220288fc5..cbf9be6c0ea 100644 --- a/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php @@ -41,7 +41,7 @@ public static function analyze( foreach ($redefined_vars as $var => $type) { $loop_scope->possibly_redefined_loop_parent_vars[$var] = Type::combineUnionTypes( $type, - $loop_scope->possibly_redefined_loop_parent_vars[$var] ?? null + $loop_scope->possibly_redefined_loop_parent_vars[$var] ?? null, ); } @@ -50,7 +50,7 @@ public static function analyze( if (!isset($loop_scope->loop_parent_context->vars_in_scope[$var_id])) { $loop_scope->possibly_defined_loop_parent_vars[$var_id] = Type::combineUnionTypes( $type, - $loop_scope->possibly_defined_loop_parent_vars[$var_id] ?? null + $loop_scope->possibly_defined_loop_parent_vars[$var_id] ?? null, ); } } @@ -62,7 +62,7 @@ public static function analyze( $context->finally_scope->vars_in_scope[$var_id] = Type::combineUnionTypes( $context->finally_scope->vars_in_scope[$var_id], $type, - $statements_analyzer->getCodebase() + $statements_analyzer->getCodebase(), ); } else { $type = $type->setPossiblyUndefined(true, true); @@ -82,7 +82,7 @@ public static function analyze( $case_scope->break_vars[$var_id] = Type::combineUnionTypes( $type, - $case_scope->break_vars[$var_id] ?? null + $case_scope->break_vars[$var_id] ?? null, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/ContinueAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ContinueAnalyzer.php index 7466d720e4e..9e04d165440 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ContinueAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ContinueAnalyzer.php @@ -40,9 +40,9 @@ public static function analyze( if (IssueBuffer::accepts( new ContinueOutsideLoop( 'Continue call outside loop context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSource()->getSuppressedIssues() + $statements_analyzer->getSource()->getSuppressedIssues(), )) { return; } @@ -65,7 +65,7 @@ public static function analyze( } else { $loop_scope->redefined_loop_vars[$redefined_var] = Type::combineUnionTypes( $redefined_vars[$redefined_var], - $type + $type, ); } } @@ -73,7 +73,7 @@ public static function analyze( foreach ($redefined_vars as $var => $type) { $loop_scope->possibly_redefined_loop_vars[$var] = Type::combineUnionTypes( $type, - $loop_scope->possibly_redefined_loop_vars[$var] ?? null + $loop_scope->possibly_redefined_loop_vars[$var] ?? null, ); } @@ -83,7 +83,7 @@ public static function analyze( $context->finally_scope->vars_in_scope[$var_id] = Type::combineUnionTypes( $context->finally_scope->vars_in_scope[$var_id], $type, - $statements_analyzer->getCodebase() + $statements_analyzer->getCodebase(), ); } else { $type = $type->setPossiblyUndefined(true, true); diff --git a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php index 441f6a50d18..300b8fe02aa 100644 --- a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php @@ -30,7 +30,7 @@ public static function analyze( ): bool { $echo_param = new FunctionLikeParameter( 'var', - false + false, ); $codebase = $statements_analyzer->getCodebase(); @@ -49,7 +49,7 @@ public static function analyze( $context, $expr_type, $expr, - false + false, ); } @@ -60,14 +60,14 @@ public static function analyze( 'echo', (int) $i, null, - $call_location + $call_location, ); $echo_param_sink->taints = [ TaintKind::INPUT_HTML, TaintKind::INPUT_HAS_QUOTES, TaintKind::USER_SECRET, - TaintKind::SYSTEM_SECRET + TaintKind::SYSTEM_SECRET, ]; $statements_analyzer->data_flow_graph->addSink($echo_param_sink); @@ -89,7 +89,7 @@ public static function analyze( null, true, true, - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ) === false) { return false; } @@ -99,9 +99,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ForbiddenCode( 'Use of echo', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSource()->getSuppressedIssues() + $statements_analyzer->getSource()->getSuppressedIssues(), ); } @@ -110,9 +110,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureFunctionCall( 'Cannot call echo from a mutation-free context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php index 32ffd4a5d0f..84eb22f4323 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php @@ -77,8 +77,8 @@ public static function analyze( IssueBuffer::maybeAdd( new ParseError( 'Array element cannot be empty', - new CodeLocation($statements_analyzer, $stmt) - ) + new CodeLocation($statements_analyzer, $stmt), + ), ); return false; @@ -89,7 +89,7 @@ public static function analyze( $context, $array_creation_info, $item, - $codebase + $codebase, ); } @@ -99,7 +99,7 @@ public static function analyze( $codebase, false, true, - 30 + 30, ); } else { $item_key_type = null; @@ -111,7 +111,7 @@ public static function analyze( $codebase, false, true, - 30 + 30, ); } else { $item_value_type = null; @@ -125,11 +125,11 @@ public static function analyze( $array_creation_info->can_create_objectlike ? null : [$item_key_type ?? Type::getArrayKey(), $item_value_type ?? Type::getMixed()], - $array_creation_info->all_list + $array_creation_info->all_list, ); $stmt_type = new Union([$atomic_type], [ - 'parent_nodes' => $array_creation_info->parent_taint_nodes + 'parent_nodes' => $array_creation_info->parent_taint_nodes, ]); $statements_analyzer->node_data->setType($stmt, $stmt_type); @@ -153,7 +153,7 @@ public static function analyze( $stmt_type = new Union([ $array_type, ], [ - 'parent_nodes' => $array_creation_info->parent_taint_nodes + 'parent_nodes' => $array_creation_info->parent_taint_nodes, ]); $statements_analyzer->node_data->setType($stmt, $stmt_type); @@ -170,9 +170,9 @@ public static function analyze( IssueBuffer::maybeAdd( new MixedArrayOffset( 'Cannot create mixed offset – expecting array-key', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $bad_types[] = $atomic_key_type; @@ -195,9 +195,9 @@ public static function analyze( IssueBuffer::maybeAdd( new InvalidArrayOffset( 'Cannot create offset of type ' . $item_key_type->getKey() . ', expecting array-key', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $bad_types[] = $atomic_key_type; @@ -222,7 +222,7 @@ public static function analyze( if ($bad_types && $good_types) { $item_key_type = $item_key_type->getBuilder()->substitute( TypeCombiner::combine($bad_types, $codebase), - TypeCombiner::combine($good_types, $codebase) + TypeCombiner::combine($good_types, $codebase), )->freeze(); } } @@ -236,7 +236,7 @@ public static function analyze( $stmt_type = new Union([ $array_type, ], [ - 'parent_nodes' => $array_creation_info->parent_taint_nodes + 'parent_nodes' => $array_creation_info->parent_taint_nodes, ]); $statements_analyzer->node_data->setType($stmt, $stmt_type); @@ -267,7 +267,7 @@ private static function analyzeArrayItem( $array_creation_info, $item, $unpacked_array_type, - $codebase + $codebase, ); if (($data_flow_graph = $statements_analyzer->data_flow_graph) @@ -278,7 +278,7 @@ private static function analyzeArrayItem( $new_parent_node = DataFlowNode::getForAssignment( 'array', - $var_location + $var_location, ); $data_flow_graph->addNode($new_parent_node); @@ -287,7 +287,7 @@ private static function analyzeArrayItem( $data_flow_graph->addPath( $parent_node, $new_parent_node, - 'arrayvalue-assignment' + 'arrayvalue-assignment', ); } @@ -369,9 +369,9 @@ private static function analyzeArrayItem( IssueBuffer::maybeAdd( new DuplicateArrayKey( 'Key \'' . $item_key_value . '\' already exists on array', - new CodeLocation($statements_analyzer->getSource(), $item) + new CodeLocation($statements_analyzer->getSource(), $item), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -394,7 +394,7 @@ private static function analyzeArrayItem( $new_parent_node = DataFlowNode::getForAssignment( 'array' . ($item_key_value !== null ? '[\'' . $item_key_value . '\']' : ''), - $var_location + $var_location, ); $data_flow_graph->addNode($new_parent_node); @@ -411,7 +411,7 @@ private static function analyzeArrayItem( 'arrayvalue-assignment' . ($item_key_value !== null ? '-\'' . $item_key_value . '\'' : ''), $added_taints, - $removed_taints + $removed_taints, ); } @@ -429,7 +429,7 @@ private static function analyzeArrayItem( $new_parent_node = DataFlowNode::getForAssignment( 'array', - $var_location + $var_location, ); $data_flow_graph->addNode($new_parent_node); @@ -445,7 +445,7 @@ private static function analyzeArrayItem( $new_parent_node, 'arraykey-assignment', $added_taints, - $removed_taints + $removed_taints, ); } @@ -458,7 +458,7 @@ private static function analyzeArrayItem( $var_id = ExpressionIdentifier::getExtendedVarId( $item->value, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($var_id) { @@ -467,7 +467,7 @@ private static function analyzeArrayItem( $var_id, $context->vars_in_scope[$var_id], null, - $statements_analyzer + $statements_analyzer, ); } @@ -486,11 +486,11 @@ private static function analyzeArrayItem( $array_creation_info->can_create_objectlike = false; $array_creation_info->item_key_atomic_types = array_merge( $array_creation_info->item_key_atomic_types, - array_values($key_type->getAtomicTypes()) + array_values($key_type->getAtomicTypes()), ); $array_creation_info->item_value_atomic_types = array_merge( $array_creation_info->item_value_atomic_types, - array_values($item_value_type->getAtomicTypes()) + array_values($item_value_type->getAtomicTypes()), ); } } else { @@ -502,7 +502,7 @@ private static function analyzeArrayItem( $array_creation_info->can_create_objectlike = false; $array_creation_info->item_key_atomic_types = array_merge( $array_creation_info->item_key_atomic_types, - array_values($key_type->getAtomicTypes()) + array_values($key_type->getAtomicTypes()), ); $array_creation_info->item_value_atomic_types[] = new TMixed(); } @@ -534,9 +534,9 @@ private static function handleUnpackedArray( IssueBuffer::maybeAdd( new DuplicateArrayKey( 'String keys are not supported in unpacked arrays', - new CodeLocation($statements_analyzer->getSource(), $item->value) + new CodeLocation($statements_analyzer->getSource(), $item->value), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); continue 2; @@ -611,9 +611,9 @@ private static function handleUnpackedArray( IssueBuffer::maybeAdd( new DuplicateArrayKey( 'String keys are not supported in unpacked arrays', - new CodeLocation($statements_analyzer->getSource(), $item->value) + new CodeLocation($statements_analyzer->getSource(), $item->value), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); continue; @@ -634,11 +634,11 @@ private static function handleUnpackedArray( $array_creation_info->item_key_atomic_types = array_merge( $array_creation_info->item_key_atomic_types, - array_values($iterable_type->type_params[0]->getAtomicTypes()) + array_values($iterable_type->type_params[0]->getAtomicTypes()), ); $array_creation_info->item_value_atomic_types = array_merge( $array_creation_info->item_value_atomic_types, - array_values($iterable_type->type_params[1]->getAtomicTypes()) + array_values($iterable_type->type_params[1]->getAtomicTypes()), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php index a5f830f3f9c..3733053cf0e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php @@ -147,7 +147,7 @@ public static function scrapeAssertions( $codebase, $source, $this_class_name, - $inside_negation + $inside_negation, ); } @@ -155,7 +155,7 @@ public static function scrapeAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->var, $this_class_name, - $source + $source, ); $candidate_if_types = $inside_conditional @@ -166,7 +166,7 @@ public static function scrapeAssertions( $codebase, $inside_negation, $cache, - $inside_conditional + $inside_conditional, ) : []; @@ -184,7 +184,7 @@ public static function scrapeAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional, $this_class_name, - $source + $source, ); if ($var_name) { @@ -210,7 +210,7 @@ public static function scrapeAssertions( $source, $codebase, $cache, - $inside_conditional + $inside_conditional, ); } @@ -223,7 +223,7 @@ public static function scrapeAssertions( $source, $codebase, $cache, - $inside_conditional + $inside_conditional, ); } @@ -234,7 +234,7 @@ public static function scrapeAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->var, $this_class_name, - $source + $source, ); if ($var_name) { @@ -252,7 +252,7 @@ public static function scrapeAssertions( return self::getGreaterAssertions( $conditional, $source, - $this_class_name + $this_class_name, ); } @@ -262,7 +262,7 @@ public static function scrapeAssertions( return self::getSmallerAssertions( $conditional, $source, - $this_class_name + $this_class_name, ); } @@ -272,7 +272,7 @@ public static function scrapeAssertions( $this_class_name, $source, $codebase, - $inside_negation + $inside_negation, ); } @@ -293,7 +293,7 @@ public static function scrapeAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->expr, $this_class_name, - $source + $source, ); if ($var_name) { @@ -317,7 +317,7 @@ public static function scrapeAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $isset_var, $this_class_name, - $source + $source, ); if ($var_name) { @@ -342,7 +342,7 @@ public static function scrapeAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $array_root, $this_class_name, - $source + $source, ); } @@ -378,7 +378,7 @@ private static function scrapeEqualityAssertions( $this_class_name, $source, $codebase, - $null_position + $null_position, ); } @@ -392,7 +392,7 @@ private static function scrapeEqualityAssertions( $codebase, $false_position, $cache, - $inside_conditional + $inside_conditional, ); } @@ -406,7 +406,7 @@ private static function scrapeEqualityAssertions( $codebase, $true_position, $cache, - $inside_conditional + $inside_conditional, ); } @@ -418,7 +418,7 @@ private static function scrapeEqualityAssertions( $this_class_name, $source, $codebase, - $empty_array_position + $empty_array_position, ); } @@ -429,7 +429,7 @@ private static function scrapeEqualityAssertions( $conditional, $this_class_name, $source, - $gettype_position + $gettype_position, ); } @@ -440,7 +440,7 @@ private static function scrapeEqualityAssertions( $conditional, $this_class_name, $source, - $get_debug_type_position + $get_debug_type_position, ); } @@ -464,7 +464,7 @@ private static function scrapeEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $count_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($source instanceof StatementsAnalyzer) { @@ -482,7 +482,7 @@ private static function scrapeEqualityAssertions( $this_class_name, $other_type, $codebase, - $conditional + $conditional, ); } } @@ -509,7 +509,7 @@ private static function scrapeEqualityAssertions( $conditional, $this_class_name, $source, - $getclass_position + $getclass_position, ); } @@ -521,7 +521,7 @@ private static function scrapeEqualityAssertions( $this_class_name, $source, $codebase, - $typed_value_position + $typed_value_position, ); } @@ -538,9 +538,9 @@ private static function scrapeEqualityAssertions( new TypeDoesNotContainType( $var_type->getId() . ' cannot be identical to ' . $other_type->getId(), new CodeLocation($source, $conditional), - $var_type->getId() . ' ' . $other_type->getId() + $var_type->getId() . ' ' . $other_type->getId(), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { // both side of the Identical can be asserted to the intersection of both @@ -552,7 +552,7 @@ private static function scrapeEqualityAssertions( $var_name_left = ExpressionIdentifier::getExtendedVarId( $conditional->left, $this_class_name, - $source + $source, ); $var_assertion_different = $var_type->getId() !== $intersection_type->getId(); @@ -564,7 +564,7 @@ private static function scrapeEqualityAssertions( $var_name_right = ExpressionIdentifier::getExtendedVarId( $conditional->right, $this_class_name, - $source + $source, ); $other_assertion_different = $other_type->getId() !== $intersection_type->getId(); @@ -601,7 +601,7 @@ private static function scrapeInequalityAssertions( $source, $this_class_name, $codebase, - $null_position + $null_position, ); } @@ -615,7 +615,7 @@ private static function scrapeInequalityAssertions( $codebase, $false_position, $cache, - $inside_conditional + $inside_conditional, ); } @@ -629,7 +629,7 @@ private static function scrapeInequalityAssertions( $codebase, $true_position, $cache, - $inside_conditional + $inside_conditional, ); } @@ -641,7 +641,7 @@ private static function scrapeInequalityAssertions( $this_class_name, $source, $codebase, - $empty_array_position + $empty_array_position, ); } @@ -652,7 +652,7 @@ private static function scrapeInequalityAssertions( $conditional, $this_class_name, $source, - $gettype_position + $gettype_position, ); } @@ -663,7 +663,7 @@ private static function scrapeInequalityAssertions( $conditional, $this_class_name, $source, - $get_debug_type_position + $get_debug_type_position, ); } @@ -685,7 +685,7 @@ private static function scrapeInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $count_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($source instanceof StatementsAnalyzer) { @@ -703,7 +703,7 @@ private static function scrapeInequalityAssertions( $this_class_name, $other_type, $codebase, - $conditional + $conditional, ); } } @@ -730,7 +730,7 @@ private static function scrapeInequalityAssertions( $conditional, $this_class_name, $source, - $getclass_position + $getclass_position, ); } @@ -742,7 +742,7 @@ private static function scrapeInequalityAssertions( $this_class_name, $source, $codebase, - $typed_value_position + $typed_value_position, ); } @@ -763,7 +763,7 @@ public static function processFunctionCall( ? ExpressionIdentifier::getExtendedVarId( $expr->getArgs()[0]->value, $this_class_name, - $source + $source, ) : null; @@ -781,7 +781,7 @@ public static function processFunctionCall( $first_var_name, $first_var_type, $expr, - $negate + $negate, )) { $if_types = $tmp_if_types; } elseif ($source instanceof StatementsAnalyzer && self::hasIsACheck($expr, $source)) { @@ -796,11 +796,11 @@ public static function processFunctionCall( $first_var_name_in_array_argument = ExpressionIdentifier::getExtendedVarId( $expr->getArgs()[0]->value->items[0]->value, $this_class_name, - $source + $source, ); if ($first_var_name_in_array_argument) { $if_types[$first_var_name_in_array_argument] = [ - [new HasMethod($expr->getArgs()[0]->value->items[1]->value->value)] + [new HasMethod($expr->getArgs()[0]->value->items[1]->value->value)], ]; } } @@ -847,7 +847,7 @@ public static function processFunctionCall( $first_var_type, $first_var_name, $source, - $this_class_name + $this_class_name, ); } elseif (self::hasNonEmptyCountCheck($expr)) { if ($first_var_name) { @@ -875,7 +875,7 @@ private static function processIrreconcilableFunctionCall( if (!UnionTypeComparator::isContainedBy( $codebase, $first_var_type, - $expected_type + $expected_type, )) { return; } @@ -886,18 +886,18 @@ private static function processIrreconcilableFunctionCall( new RedundantConditionGivenDocblockType( 'Docblock type ' . $first_var_type . ' always contains ' . $expected_type, new CodeLocation($source, $expr), - $first_var_type . ' ' . $expected_type + $first_var_type . ' ' . $expected_type, ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantCondition( $first_var_type . ' always contains ' . $expected_type, new CodeLocation($source, $expr), - $first_var_type . ' ' . $expected_type + $first_var_type . ' ' . $expected_type, ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } else { @@ -906,18 +906,18 @@ private static function processIrreconcilableFunctionCall( new DocblockTypeContradiction( 'Docblock type !' . $first_var_type . ' does not contain ' . $expected_type, new CodeLocation($source, $expr), - $first_var_type . ' ' . $expected_type + $first_var_type . ' ' . $expected_type, ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TypeDoesNotContainType( '!' . $first_var_type . ' does not contain ' . $expected_type, new CodeLocation($source, $expr), - $first_var_type . ' ' . $expected_type + $first_var_type . ' ' . $expected_type, ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -947,7 +947,7 @@ protected static function processCustomAssertion( ? ExpressionIdentifier::getExtendedVarId( $expr->getArgs()[0]->value, $this_class_name, - $source + $source, ) : null; @@ -971,8 +971,8 @@ protected static function processCustomAssertion( $rule_type, null, null, - null - )[0] + null, + )[0], ); } else { $newRules []= $rule; @@ -988,7 +988,7 @@ protected static function processCustomAssertion( $var_name = ExpressionIdentifier::getExtendedVarId( $expr->getArgs()[$assertion->var_id]->value, $this_class_name, - $source + $source, ); } @@ -1000,8 +1000,8 @@ protected static function processCustomAssertion( IssueBuffer::maybeAdd( new InvalidDocblock( 'Assertion of $this can be done only on method of a class', - new CodeLocation($source, $expr) - ) + new CodeLocation($source, $expr), + ), ); continue; } @@ -1009,7 +1009,7 @@ protected static function processCustomAssertion( $var_id = ExpressionIdentifier::getExtendedVarId( $expr->var, $this_class_name, - $source + $source, ); if ($var_id) { @@ -1030,8 +1030,8 @@ protected static function processCustomAssertion( IssueBuffer::maybeAdd( new InvalidDocblock( 'Variable '.$var_id.' is not an argument so cannot be asserted', - new CodeLocation($source, $expr) - ) + new CodeLocation($source, $expr), + ), ); continue; } @@ -1046,8 +1046,8 @@ protected static function processCustomAssertion( new InvalidDocblock( 'Variable being asserted as argument ' . ($var_id+1) . ' cannot be found in local scope', - new CodeLocation($source, $expr) - ) + new CodeLocation($source, $expr), + ), ); continue; } @@ -1057,12 +1057,12 @@ protected static function processCustomAssertion( $property, $source->getNodeTypeProvider(), $source->getCodebase()->classlike_storage_provider, - $arg_value + $arg_value, ); if (null !== $failedMessage) { IssueBuffer::maybeAdd( - new InvalidDocblock($failedMessage, new CodeLocation($source, $expr)) + new InvalidDocblock($failedMessage, new CodeLocation($source, $expr)), ); continue; } @@ -1079,8 +1079,8 @@ protected static function processCustomAssertion( IssueBuffer::maybeAdd( new InvalidDocblock( sprintf('Assertion of variable "%s" cannot be recognized', $assertion->var_id), - new CodeLocation($source, $expr) - ) + new CodeLocation($source, $expr), + ), ); continue; } @@ -1111,8 +1111,8 @@ protected static function processCustomAssertion( $rule_type, null, null, - null - )[0] + null, + )[0], ); } else { $newRules []= $rule; @@ -1128,7 +1128,7 @@ protected static function processCustomAssertion( $var_name = ExpressionIdentifier::getExtendedVarId( $expr->getArgs()[$assertion->var_id]->value, $this_class_name, - $source + $source, ); } @@ -1139,7 +1139,7 @@ protected static function processCustomAssertion( $var_id = ExpressionIdentifier::getExtendedVarId( $expr->var, $this_class_name, - $source + $source, ); if ($var_id) { @@ -1159,8 +1159,8 @@ protected static function processCustomAssertion( IssueBuffer::maybeAdd( new InvalidDocblock( 'Variable '.$var_id.' is not an argument so cannot be asserted', - new CodeLocation($source, $expr) - ) + new CodeLocation($source, $expr), + ), ); continue; } @@ -1174,8 +1174,8 @@ protected static function processCustomAssertion( new InvalidDocblock( 'Variable being asserted as argument ' . ($var_id+1) . ' cannot be found in local scope', - new CodeLocation($source, $expr) - ) + new CodeLocation($source, $expr), + ), ); continue; } @@ -1185,12 +1185,12 @@ protected static function processCustomAssertion( $property, $source->getNodeTypeProvider(), $source->getCodebase()->classlike_storage_provider, - $arg_value + $arg_value, ); if (null !== $failedMessage) { IssueBuffer::maybeAdd( - new InvalidDocblock($failedMessage, new CodeLocation($source, $expr)) + new InvalidDocblock($failedMessage, new CodeLocation($source, $expr)), ); continue; } @@ -1211,8 +1211,8 @@ protected static function processCustomAssertion( IssueBuffer::maybeAdd( new InvalidDocblock( sprintf('Assertion of variable "%s" cannot be recognized', $assertion->var_id), - new CodeLocation($source, $expr) - ) + new CodeLocation($source, $expr), + ), ); } } @@ -1238,7 +1238,7 @@ protected static function getInstanceOfAssertions( if (!in_array(strtolower($stmt->class->parts[0]), ['self', 'static', 'parent'], true)) { $instanceof_class = ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $source->getAliases() + $source->getAliases(), ); if ($source instanceof StatementsAnalyzer) { @@ -1274,12 +1274,12 @@ protected static function getInstanceOfAssertions( new TTemplateParam( $atomic_type->param_name, new Union([$atomic_type->as_type ?: new TObject()]), - $atomic_type->defining_class - ) + $atomic_type->defining_class, + ), ); } elseif ($atomic_type instanceof TClassString && $atomic_type->as !== 'object') { $literal_class_strings[] = new IsType( - $atomic_type->as_type ?: new TNamedObject($atomic_type->as) + $atomic_type->as_type ?: new TNamedObject($atomic_type->as), ); } } @@ -1930,7 +1930,7 @@ private static function handleIsTypeCheck( || isset($source->getAliases()->functions[$function_name]) //or it is imported || ($codebase && !$codebase->functions->functionExists( $source, - strtolower($source->getNamespace()."\\".$function_name) + strtolower($source->getNamespace()."\\".$function_name), )) //or this function name does not exist in current namespace ) ) { @@ -1946,7 +1946,7 @@ private static function handleIsTypeCheck( $expr, $source, $codebase, - $negate + $negate, ); } } @@ -2078,7 +2078,7 @@ private static function getNullInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $base_conditional, $this_class_name, - $source + $source, ); if ($var_name) { @@ -2103,29 +2103,29 @@ private static function getNullInequalityAssertions( if (!UnionTypeComparator::isContainedBy( $codebase, $var_type, - $null_type + $null_type, ) && !UnionTypeComparator::isContainedBy( $codebase, $null_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( new RedundantConditionGivenDocblockType( 'Docblock-defined type ' . $var_type . ' can never contain null', new CodeLocation($source, $conditional), - $var_type->getId() . ' null' + $var_type->getId() . ' null', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantCondition( $var_type . ' can never contain null', new CodeLocation($source, $conditional), - $var_type->getId() . ' null' + $var_type->getId() . ' null', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -2161,7 +2161,7 @@ private static function getFalseInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $base_conditional, $this_class_name, - $source + $source, ); if ($var_name) { @@ -2187,7 +2187,7 @@ private static function getFalseInequalityAssertions( $codebase, false, $cache, - $inside_conditional + $inside_conditional, ); if ($source instanceof StatementsAnalyzer && $cache) { @@ -2212,9 +2212,9 @@ private static function getFalseInequalityAssertions( IssueBuffer::maybeAdd( new RedundantIdentityWithTrue( 'The "!== false" part of this comparison is redundant', - new CodeLocation($source, $conditional) + new CodeLocation($source, $conditional), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } @@ -2223,29 +2223,29 @@ private static function getFalseInequalityAssertions( if (!UnionTypeComparator::isContainedBy( $codebase, $var_type, - $false_type + $false_type, ) && !UnionTypeComparator::isContainedBy( $codebase, $false_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( new RedundantConditionGivenDocblockType( 'Docblock-defined type ' . $var_type . ' can never contain false', new CodeLocation($source, $conditional), - $var_type->getId() . ' false' + $var_type->getId() . ' false', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantCondition( $var_type . ' can never contain false', new CodeLocation($source, $conditional), - $var_type->getId() . ' false' + $var_type->getId() . ' false', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -2283,13 +2283,13 @@ private static function getTrueInequalityAssertions( $this_class_name, $source, $codebase, - true + true, ); } else { $var_name = ExpressionIdentifier::getExtendedVarId( $base_conditional, $this_class_name, - $source + $source, ); if ($var_name) { @@ -2315,7 +2315,7 @@ private static function getTrueInequalityAssertions( $codebase, false, $cache, - $inside_conditional + $inside_conditional, ); if ($source instanceof StatementsAnalyzer && $cache) { @@ -2345,29 +2345,29 @@ private static function getTrueInequalityAssertions( if (!UnionTypeComparator::isContainedBy( $codebase, $var_type, - $true_type + $true_type, ) && !UnionTypeComparator::isContainedBy( $codebase, $true_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( new RedundantConditionGivenDocblockType( 'Docblock-defined type ' . $var_type . ' can never contain true', new CodeLocation($source, $conditional), - $var_type->getId() . ' true' + $var_type->getId() . ' true', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantCondition( $var_type . ' can never contain ' . $true_type, new CodeLocation($source, $conditional), - $var_type->getId() . ' true' + $var_type->getId() . ' true', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -2401,7 +2401,7 @@ private static function getEmptyInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $base_conditional, $this_class_name, - $source + $source, ); if ($var_name) { @@ -2422,29 +2422,29 @@ private static function getEmptyInequalityAssertions( if (!UnionTypeComparator::isContainedBy( $codebase, $var_type, - $empty_array_type + $empty_array_type, ) && !UnionTypeComparator::isContainedBy( $codebase, $empty_array_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( new RedundantConditionGivenDocblockType( 'Docblock-defined type ' . $var_type->getId() . ' can never contain null', new CodeLocation($source, $conditional), - $var_type->getId() . ' null' + $var_type->getId() . ' null', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantCondition( $var_type->getId() . ' can never contain null', new CodeLocation($source, $conditional), - $var_type->getId() . ' null' + $var_type->getId() . ' null', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -2480,7 +2480,7 @@ private static function getGettypeInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $gettype_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($whichclass_expr instanceof PhpParser\Node\Scalar\String_) { @@ -2490,7 +2490,7 @@ private static function getGettypeInequalityAssertions( ) { $var_type = ClassLikeAnalyzer::getFQCLNFromNameObject( $whichclass_expr->class, - $source->getAliases() + $source->getAliases(), ); } else { throw new UnexpectedValueException('Shouldn’t get here'); @@ -2500,8 +2500,8 @@ private static function getGettypeInequalityAssertions( IssueBuffer::maybeAdd( new UnevaluatedCode( 'gettype cannot return this value', - new CodeLocation($source, $whichclass_expr) - ) + new CodeLocation($source, $whichclass_expr), + ), ); } else { if ($var_name && $var_type) { @@ -2546,7 +2546,7 @@ private static function getGetdebugTypeInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $get_debug_type_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($whichclass_expr instanceof PhpParser\Node\Scalar\String_) { @@ -2556,7 +2556,7 @@ private static function getGetdebugTypeInequalityAssertions( ) { $var_type = ClassLikeAnalyzer::getFQCLNFromNameObject( $whichclass_expr->class, - $source->getAliases() + $source->getAliases(), ); } else { throw new UnexpectedValueException('Shouldn’t get here'); @@ -2603,7 +2603,7 @@ private static function getGetclassInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $getclass_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); } elseif ($getclass_expr instanceof PhpParser\Node\Expr\ClassConstFetch && $getclass_expr->class instanceof PhpParser\Node\Expr @@ -2611,7 +2611,7 @@ private static function getGetclassInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $getclass_expr->class, $this_class_name, - $source + $source, ); } else { $var_name = '$this'; @@ -2624,7 +2624,7 @@ private static function getGetclassInequalityAssertions( ) { $var_type = ClassLikeAnalyzer::getFQCLNFromNameObject( $whichclass_expr->class, - $source->getAliases() + $source->getAliases(), ); if ($var_type === 'self' || $var_type === 'static') { @@ -2642,8 +2642,8 @@ private static function getGetclassInequalityAssertions( new TTemplateParam( $type_part->param_name, new Union([$type_part->as_type ?: new TObject()]), - $type_part->defining_class - ) + $type_part->defining_class, + ), )]]; } } @@ -2659,7 +2659,7 @@ private static function getGetclassInequalityAssertions( new CodeLocation($source, $whichclass_expr), null, null, - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ) !== false ) { if ($var_name && $var_type) { @@ -2687,7 +2687,7 @@ private static function getTypedValueInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->left, $this_class_name, - $source + $source, ); $other_type = $source->node_data->getType($conditional->left); @@ -2696,7 +2696,7 @@ private static function getTypedValueInequalityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->right, $this_class_name, - $source + $source, ); $var_type = $source->node_data->getType($conditional->left); @@ -2736,7 +2736,7 @@ private static function getTypedValueInequalityAssertions( $this_class_name, $other_type, $codebase, - $conditional + $conditional, ); } } @@ -2768,7 +2768,7 @@ private static function getNullEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $base_conditional, $this_class_name, - $source + $source, ); if ($var_name && $base_conditional instanceof PhpParser\Node\Expr\Assign) { @@ -2793,29 +2793,29 @@ private static function getNullEqualityAssertions( if (!UnionTypeComparator::isContainedBy( $codebase, $var_type, - $null_type + $null_type, ) && !UnionTypeComparator::isContainedBy( $codebase, $null_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( new DocblockTypeContradiction( $var_type . ' does not contain null', new CodeLocation($source, $conditional), - $var_type . ' null' + $var_type . ' null', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TypeDoesNotContainNull( $var_type . ' does not contain null', new CodeLocation($source, $conditional), - $var_type->getId() + $var_type->getId(), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -2853,13 +2853,13 @@ private static function getTrueEqualityAssertions( $this_class_name, $source, $codebase, - false + false, ); } else { $var_name = ExpressionIdentifier::getExtendedVarId( $base_conditional, $this_class_name, - $source + $source, ); if ($var_name) { @@ -2885,7 +2885,7 @@ private static function getTrueEqualityAssertions( $codebase, false, $cache, - $inside_conditional + $inside_conditional, ); if ($source instanceof StatementsAnalyzer && $cache) { @@ -2913,9 +2913,9 @@ private static function getTrueEqualityAssertions( IssueBuffer::maybeAdd( new RedundantIdentityWithTrue( 'The "=== true" part of this comparison is redundant', - new CodeLocation($source, $conditional) + new CodeLocation($source, $conditional), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } @@ -2924,25 +2924,25 @@ private static function getTrueEqualityAssertions( if (!UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $true_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( new DocblockTypeContradiction( $var_type . ' does not contain true', new CodeLocation($source, $conditional), - $var_type . ' true' + $var_type . ' true', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TypeDoesNotContainType( $var_type . ' does not contain true', new CodeLocation($source, $conditional), - $var_type . ' true' + $var_type . ' true', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -2980,13 +2980,13 @@ private static function getFalseEqualityAssertions( $this_class_name, $source, $codebase, - true + true, ); } else { $var_name = ExpressionIdentifier::getExtendedVarId( $base_conditional, $this_class_name, - $source + $source, ); if ($var_name) { @@ -3012,7 +3012,7 @@ private static function getFalseEqualityAssertions( $codebase, false, $cache, - $inside_conditional + $inside_conditional, ); if ($source instanceof StatementsAnalyzer && $cache) { @@ -3042,25 +3042,25 @@ private static function getFalseEqualityAssertions( if (!UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $false_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( new DocblockTypeContradiction( $var_type . ' does not contain false', new CodeLocation($source, $conditional), - $var_type . ' false' + $var_type . ' false', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TypeDoesNotContainType( $var_type . ' does not contain false', new CodeLocation($source, $conditional), - $var_type . ' false' + $var_type . ' false', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -3094,7 +3094,7 @@ private static function getEmptyArrayEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $base_conditional, $this_class_name, - $source + $source, ); if ($var_name) { @@ -3115,25 +3115,25 @@ private static function getEmptyArrayEqualityAssertions( if (!UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $empty_array_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( new DocblockTypeContradiction( $var_type . ' does not contain an empty array', new CodeLocation($source, $conditional), - $var_type . ' !== []' + $var_type . ' !== []', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TypeDoesNotContainType( $var_type . ' does not contain empty array', new CodeLocation($source, $conditional), - $var_type . ' !== []' + $var_type . ' !== []', ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -3168,7 +3168,7 @@ private static function getGettypeEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $gettype_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); /** @var PhpParser\Node\Scalar\String_ $string_expr */ @@ -3178,8 +3178,8 @@ private static function getGettypeEqualityAssertions( IssueBuffer::maybeAdd( new UnevaluatedCode( 'gettype cannot return this value', - new CodeLocation($source, $string_expr) - ) + new CodeLocation($source, $string_expr), + ), ); } else { if ($var_name && $var_type) { @@ -3230,7 +3230,7 @@ private static function getGetdebugtypeEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $get_debug_type_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($whichclass_expr instanceof PhpParser\Node\Scalar\String_) { @@ -3240,7 +3240,7 @@ private static function getGetdebugtypeEqualityAssertions( ) { $var_type = ClassLikeAnalyzer::getFQCLNFromNameObject( $whichclass_expr->class, - $source->getAliases() + $source->getAliases(), ); } else { throw new UnexpectedValueException('Shouldn’t get here'); @@ -3293,7 +3293,7 @@ private static function getGetclassEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $getclass_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); } elseif ($getclass_expr instanceof PhpParser\Node\Expr\ClassConstFetch && $getclass_expr->class instanceof PhpParser\Node\Expr @@ -3301,7 +3301,7 @@ private static function getGetclassEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $getclass_expr->class, $this_class_name, - $source + $source, ); } else { $var_name = '$this'; @@ -3312,7 +3312,7 @@ private static function getGetclassEqualityAssertions( ) { $var_type = ClassLikeAnalyzer::getFQCLNFromNameObject( $whichclass_expr->class, - $source->getAliases() + $source->getAliases(), ); if ($var_type === 'self' || $var_type === 'static') { @@ -3329,7 +3329,7 @@ private static function getGetclassEqualityAssertions( null, null, $source->getSuppressedIssues(), - new ClassLikeNameOptions(true) + new ClassLikeNameOptions(true), ) === false ) { return []; @@ -3351,8 +3351,8 @@ private static function getGetclassEqualityAssertions( $type_part->as_type ? new Union([$type_part->as_type]) : Type::getObject(), - $type_part->defining_class - )) + $type_part->defining_class, + )), ]]; } } @@ -3379,13 +3379,13 @@ private static function getTypedValueEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->left, $this_class_name, - $source + $source, ); $other_var_name = ExpressionIdentifier::getExtendedVarId( $conditional->right, $this_class_name, - $source + $source, ); $other_type = $source->node_data->getType($conditional->left); @@ -3394,13 +3394,13 @@ private static function getTypedValueEqualityAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->right, $this_class_name, - $source + $source, ); $other_var_name = ExpressionIdentifier::getExtendedVarId( $conditional->left, $this_class_name, - $source + $source, ); $var_type = $source->node_data->getType($conditional->left); @@ -3465,7 +3465,7 @@ private static function getTypedValueEqualityAssertions( $this_class_name, $other_type, $codebase, - $conditional + $conditional, ); } @@ -3550,8 +3550,8 @@ private static function getIsaAssertions( $object = new TNamedObject( ClassLikeAnalyzer::getFQCLNFromNameObject( $class_node, - $source->getAliases() - ) + $source->getAliases(), + ), ); $if_types[$first_var_name] = [[new IsAClass($object, $third_arg_value === 'true')]]; } @@ -3687,7 +3687,7 @@ private static function getArrayKeyExistsAssertions( ) { if ($atomic_type instanceof TKeyedArray) { $key_type = $atomic_type->getGenericKeyType( - !$atomic_type->allShapeKeysAlwaysDefined() + !$atomic_type->allShapeKeysAlwaysDefined(), ); } else { $key_type = $atomic_type->type_params[0]; @@ -3715,7 +3715,7 @@ private static function getArrayKeyExistsAssertions( ? ExpressionIdentifier::getExtendedVarId( $expr->getArgs()[1]->value, $this_class_name, - $source + $source, ) : null; @@ -3797,7 +3797,7 @@ private static function getGreaterAssertions( $superior_value_position = self::hasSuperiorNumberCheck( $source, $conditional, - $superior_value_comparison + $superior_value_comparison, ); if ($count_equality_position) { @@ -3811,7 +3811,7 @@ private static function getGreaterAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $counted_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($var_name) { @@ -3840,7 +3840,7 @@ private static function getGreaterAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $count_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($var_name) { @@ -3859,13 +3859,13 @@ private static function getGreaterAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->left, $this_class_name, - $source + $source, ); } else { $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->right, $this_class_name, - $source + $source, ); } @@ -3909,7 +3909,7 @@ private static function getSmallerAssertions( $inferior_value_position = self::hasInferiorNumberCheck( $source, $conditional, - $inferior_value_comparison + $inferior_value_comparison, ); if ($count_equality_position) { @@ -3923,7 +3923,7 @@ private static function getSmallerAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $count_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($var_name) { @@ -3948,7 +3948,7 @@ private static function getSmallerAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $count_expr->getArgs()[0]->value, $this_class_name, - $source + $source, ); if ($var_name) { @@ -3967,13 +3967,13 @@ private static function getSmallerAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->left, $this_class_name, - $source + $source, ); } else { $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->right, $this_class_name, - $source + $source, ); } @@ -4018,7 +4018,7 @@ private static function getAndCheckInstanceofAssertions( $var_name = ExpressionIdentifier::getExtendedVarId( $conditional->expr, $this_class_name, - $source + $source, ); if ($var_name) { @@ -4049,7 +4049,7 @@ private static function getAndCheckInstanceofAssertions( if (!UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $instanceof_type, - $var_type + $var_type, )) { if ($var_type->from_docblock) { IssueBuffer::maybeAdd( @@ -4057,9 +4057,9 @@ private static function getAndCheckInstanceofAssertions( $var_type->getId() . ' does not contain ' . $instanceof_type->getId(), new CodeLocation($source, $conditional), - $var_type->getId() . ' ' . $instanceof_type->getId() + $var_type->getId() . ' ' . $instanceof_type->getId(), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -4067,9 +4067,9 @@ private static function getAndCheckInstanceofAssertions( $var_type->getId() . ' cannot be identical to ' . $instanceof_type->getId(), new CodeLocation($source, $conditional), - $var_type->getId() . ' ' . $instanceof_type->getId() + $var_type->getId() . ' ' . $instanceof_type->getId(), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -4104,16 +4104,16 @@ private static function handleParadoxicalAssertions( } elseif (!UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $other_type, - $var_type + $var_type, )) { if ($var_type->from_docblock || $other_type->from_docblock) { IssueBuffer::maybeAdd( new DocblockTypeContradiction( $var_type->getId() . ' does not contain ' . $other_type->getId(), new CodeLocation($source, $conditional), - $var_type->getId() . ' ' . $other_type->getId() + $var_type->getId() . ' ' . $other_type->getId(), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { if ($conditional instanceof NotEqual || $conditional instanceof NotIdentical) { @@ -4121,18 +4121,18 @@ private static function handleParadoxicalAssertions( new RedundantCondition( $var_type->getId() . ' can never contain ' . $other_type->getId(), new CodeLocation($source, $conditional), - $var_type->getId() . ' ' . $other_type->getId() + $var_type->getId() . ' ' . $other_type->getId(), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TypeDoesNotContainType( $var_type->getId() . ' cannot be identical to ' . $other_type->getId(), new CodeLocation($source, $conditional), - $var_type->getId() . ' ' . $other_type->getId() + $var_type->getId() . ' ' . $other_type->getId(), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -4167,7 +4167,7 @@ public static function isPropertyImmutableOnArgument( return sprintf( 'Property %s is not defined on variable %s so the assertion cannot be applied', $property, - $name + $name, ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php index 64fe24e2772..1b64ce3805f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php @@ -69,7 +69,7 @@ public static function analyze( $stmt->var, $statements_analyzer->getFQCLN(), $statements_analyzer, - $nesting + $nesting, ); self::updateArrayType( @@ -77,7 +77,7 @@ public static function analyze( $stmt, $assign_value, $assignment_value_type, - $context + $context, ); if (!$statements_analyzer->node_data->getType($stmt->var) && $var_id) { @@ -112,7 +112,7 @@ public static function updateArrayType( $statements_analyzer, $root_array_expr, $context, - true + true, ); $codebase = $statements_analyzer->getCodebase(); @@ -124,14 +124,14 @@ public static function updateArrayType( $statements_analyzer, $stmt->var, $context, - true + true, ); if ($stmt->dim) { ExpressionAnalyzer::analyze( $statements_analyzer, $stmt->dim, - $context + $context, ); } } @@ -144,7 +144,7 @@ public static function updateArrayType( $root_var_id = ExpressionIdentifier::getExtendedVarId( $root_array_expr, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $parent_var_id = null; @@ -163,7 +163,7 @@ public static function updateArrayType( $root_type, $current_type, $current_dim, - $offset_already_existed + $offset_already_existed, ); $root_is_string = $root_type->isString(); @@ -198,7 +198,7 @@ public static function updateArrayType( $codebase, $root_type, $current_type, - $key_values + $key_values, ); } elseif (!$root_is_string) { $new_child_type = self::updateArrayAssignmentChildType( @@ -209,7 +209,7 @@ public static function updateArrayType( $current_type, $root_type, $offset_already_existed, - $parent_var_id + $parent_var_id, ); } else { $new_child_type = $root_type; @@ -234,7 +234,7 @@ public static function updateArrayType( null, $root_type, $context, - false + false, ); } else { if (ExpressionAnalyzer::analyze($statements_analyzer, $root_array_expr->name, $context) === false) { @@ -253,7 +253,7 @@ public static function updateArrayType( $root_array_expr, null, $root_type, - $context + $context, ) === false) { return false; } @@ -269,9 +269,9 @@ public static function updateArrayType( IssueBuffer::maybeAdd( new InvalidArrayAssignment( 'Assigning to the output of a function has no effect', - new CodeLocation($statements_analyzer->getSource(), $root_array_expr) + new CodeLocation($statements_analyzer->getSource(), $root_array_expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -303,7 +303,7 @@ private static function updateTypeWithKeyValues( $codebase, $type->as, $current_type, - $key_values + $key_values, )); $has_matching_objectlike_property = true; } elseif ($type instanceof TKeyedArray) { @@ -353,7 +353,7 @@ private static function updateTypeWithKeyValues( [$key_value->value => $current_type], $key_value instanceof TLiteralClassString ? [$key_value->value => true] - : null + : null, ); $array_assignment_type = new Union([ @@ -365,8 +365,8 @@ private static function updateTypeWithKeyValues( $array_assignment_type = new Union([ new TNonEmptyArray([ new Union($array_assignment_literals), - $current_type - ]) + $current_type, + ]), ]); } @@ -375,7 +375,7 @@ private static function updateTypeWithKeyValues( $array_assignment_type, $codebase, true, - false + false, ); } @@ -401,7 +401,7 @@ private static function taintArrayAssignment( $parent_node = DataFlowNode::getForAssignment( $var_var_id ?: 'assignment', - $var_location + $var_location, ); $statements_analyzer->data_flow_graph->addNode($parent_node); @@ -414,14 +414,14 @@ private static function taintArrayAssignment( $statements_analyzer->data_flow_graph->addPath( $old_parent_node, $parent_node, - '=' + '=', ); if ($stmt_type->by_ref) { $statements_analyzer->data_flow_graph->addPath( $parent_node, $old_parent_node, - '=' + '=', ); } } @@ -433,14 +433,14 @@ private static function taintArrayAssignment( $statements_analyzer->data_flow_graph->addPath( $child_parent_node, $parent_node, - 'arrayvalue-assignment-\'' . $key_value->value . '\'' + 'arrayvalue-assignment-\'' . $key_value->value . '\'', ); } } else { $statements_analyzer->data_flow_graph->addPath( $child_parent_node, $parent_node, - 'arrayvalue-assignment' + 'arrayvalue-assignment', ); } } @@ -540,23 +540,23 @@ private static function updateArrayAssignmentChildType( $offset_type_part->as_type ? new Union([$offset_type_part->as_type]) : Type::getObject(), - 'class-string-map' - ) - ]) - ] - ] + 'class-string-map', + ), + ]), + ], + ], ); $value_type = TemplateInferredTypeReplacer::replace( $value_type, $template_result, - $codebase + $codebase, ); $array_atomic_type_class_string = new TClassStringMap( $class_string_map->param_name, $class_string_map->as_type, - $value_type + $value_type, ); } else { $array_atomic_type_array = [ @@ -591,7 +591,7 @@ private static function updateArrayAssignmentChildType( if ($array_atomic_type_class_string) { $array_atomic_type = new TNonEmptyArray([ $array_atomic_type_class_string->getStandinKeyParam(), - $array_atomic_type_class_string->value_param + $array_atomic_type_class_string->value_param, ]); } elseif ($atomic_root_type_array instanceof TKeyedArray && $atomic_root_type_array->is_list @@ -616,7 +616,7 @@ private static function updateArrayAssignmentChildType( if ($array_atomic_type_array) { $array_atomic_type = new TNonEmptyArray( $array_atomic_type_array, - $prop_count + $prop_count, ); } elseif ($prop_count !== null) { assert($array_atomic_type_list !== null); @@ -624,14 +624,14 @@ private static function updateArrayAssignmentChildType( array_fill( 0, $prop_count, - $array_atomic_type_list + $array_atomic_type_list, ), null, [ Type::getListKey(), - $array_atomic_type_list + $array_atomic_type_list, ], - true + true, ); } } elseif ($atomic_root_type_array instanceof TKeyedArray @@ -640,12 +640,12 @@ private static function updateArrayAssignmentChildType( if ($array_atomic_type_array) { $array_atomic_type = new TNonEmptyArray( $array_atomic_type_array, - count($atomic_root_type_array->properties) + count($atomic_root_type_array->properties), ); } elseif ($atomic_root_type_array->is_list) { $array_atomic_type = $atomic_root_type_array; $new_child_type = new Union([$array_atomic_type], [ - 'parent_nodes' => $root_type->parent_nodes + 'parent_nodes' => $root_type->parent_nodes, ]); } else { assert($array_atomic_type_list !== null); @@ -653,25 +653,25 @@ private static function updateArrayAssignmentChildType( array_fill( 0, count($atomic_root_type_array->properties), - $array_atomic_type_list + $array_atomic_type_list, ), null, [ Type::getListKey(), - $array_atomic_type_list + $array_atomic_type_list, ], - true + true, ); } $from_countable_object_like = true; } elseif ($array_atomic_type_list) { $array_atomic_type = Type::getNonEmptyListAtomic( - $array_atomic_type_list + $array_atomic_type_list, ); } else { assert($array_atomic_type_array !== null); $array_atomic_type = new TNonEmptyArray( - $array_atomic_type_array + $array_atomic_type_array, ); } } @@ -699,7 +699,7 @@ private static function updateArrayAssignmentChildType( $array_assignment_type, $codebase, true, - true + true, ); } } @@ -782,7 +782,7 @@ private static function analyzeNestedArrayAssignment( if (ExpressionAnalyzer::analyze( $statements_analyzer, $child_stmt->dim, - $context + $context, ) === false) { $context->inside_general_use = $was_inside_general_use; @@ -798,7 +798,7 @@ private static function analyzeNestedArrayAssignment( [$offset_type, $var_id_addition, $full_var_id] = self::getArrayAssignmentOffsetType( $statements_analyzer, $child_stmt, - $child_stmt_dim_type + $child_stmt_dim_type, ); $var_id_additions[] = $var_id_addition; @@ -835,18 +835,18 @@ private static function analyzeNestedArrayAssignment( $extended_var_id, $context, $assign_value, - !$is_last ? null : $assignment_type + !$is_last ? null : $assignment_type, ); if ($child_stmt->dim) { $statements_analyzer->node_data->setType( $child_stmt->dim, - $child_stmt_dim_type_or_int + $child_stmt_dim_type_or_int, ); } $statements_analyzer->node_data->setType( $child_stmt, - $child_stmt_type + $child_stmt_type, ); if ($is_last) { @@ -868,9 +868,9 @@ private static function analyzeNestedArrayAssignment( ExpressionIdentifier::getExtendedVarId( $child_stmt->var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ), - $offset_type !== null ? [$offset_type] : [] + $offset_type !== null ? [$offset_type] : [], ); } } @@ -905,10 +905,10 @@ private static function analyzeNestedArrayAssignment( $statements_analyzer->data_flow_graph->addPath( DataFlowNode::getForAssignment( $root_var_id, - new CodeLocation($statements_analyzer->getSource(), $root_var) + new CodeLocation($statements_analyzer->getSource(), $root_var), ), new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } @@ -947,7 +947,7 @@ private static function analyzeNestedArrayAssignment( $codebase, $child_stmt_type, $current_type, - $key_values + $key_values, ); } else { if (!$current_dim) { @@ -970,7 +970,7 @@ private static function analyzeNestedArrayAssignment( $array_assignment_type, $codebase, true, - true + true, ); } if ($new_child_type->hasNull() || $new_child_type->possibly_undefined) { @@ -1122,7 +1122,7 @@ private static function getArrayAssignmentOffsetType( $object_id = ExpressionIdentifier::getExtendedVarId( $child_stmt->dim->var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($object_id) { @@ -1140,7 +1140,7 @@ private static function getArrayAssignmentOffsetType( ) { $object_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $child_stmt->dim->class, - $statements_analyzer->getAliases() + $statements_analyzer->getAliases(), ); $var_id_addition = '[' . $object_name . '::' . $child_stmt->dim->name->name . ']'; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php index e4752554384..9435ea9ed81 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php @@ -118,7 +118,7 @@ public static function analyze( $property_id, true, $statements_analyzer, - $context + $context, ); } catch (UnexpectedValueException $e) { // do nothing @@ -131,7 +131,7 @@ public static function analyze( $codebase, $context->self, $prop_name, - $class_storage + $class_storage, ); } @@ -141,8 +141,8 @@ public static function analyze( new AssignedProperty( $class_property_type ?? Type::getMixed(), $property_id, - $assignment_value_type - ) + $assignment_value_type, + ), ]; } else { $assigned_properties = self::analyzeRegularAssignment( @@ -154,7 +154,7 @@ public static function analyze( $codebase, $assignment_value_type, $prop_name, - $var_id + $var_id, ); } @@ -178,7 +178,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt->name, - $assigned_properties[0]->property_type->getId() + $assigned_properties[0]->property_type->getId(), ); } @@ -198,7 +198,7 @@ public static function analyze( $class_property_type, true, true, - $union_comparison_results + $union_comparison_results, ); if ($type_match_found && $union_comparison_results->replacement_union_type) { @@ -216,11 +216,11 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location + $context->include_location, ), - $assigned_property->id + $assigned_property->id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -230,11 +230,11 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location + $context->include_location, ), - $assigned_property->id + $assigned_property->id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -247,10 +247,10 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location - ) + $context->include_location, + ), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -260,7 +260,7 @@ public static function analyze( $assignment_type, $class_property_type, true, - true + true, )) { $has_valid_assignment_value_type = true; } @@ -282,11 +282,11 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location + $context->include_location, ), - $assigned_property->id + $assigned_property->id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -304,11 +304,11 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location + $context->include_location, ), - $assigned_property->id + $assigned_property->id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -325,11 +325,11 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location + $context->include_location, ), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -342,11 +342,11 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location + $context->include_location, ), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -372,7 +372,7 @@ public static function trackPropertyImpurity( $appearing_property_class = $codebase->properties->getAppearingClassForProperty( $property_id, - true + true, ); $project_analyzer = $statements_analyzer->getProjectAnalyzer(); @@ -394,9 +394,9 @@ public static function trackPropertyImpurity( IssueBuffer::maybeAdd( new InaccessibleProperty( $property_id . ' is marked readonly', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif (!$declaring_class_storage->mutation_free && isset($project_analyzer->getIssuesToFix()['MissingImmutableAnnotation']) @@ -421,8 +421,8 @@ public static function analyzeStatement( new InvalidPropertyAssignment( 'Readonly property ' . $context->self . '::$' . $prop->name->name . ' cannot have a default', - new CodeLocation($statements_analyzer->getSource(), $prop->default) - ) + new CodeLocation($statements_analyzer->getSource(), $prop->default), + ), ); } @@ -435,7 +435,7 @@ public static function analyzeStatement( $prop->name->name, $prop->default, $prop_default_type, - $context + $context, ); } } @@ -462,13 +462,13 @@ private static function taintProperty( $var_id = ExpressionIdentifier::getExtendedVarId( $stmt->var, null, - $statements_analyzer + $statements_analyzer, ); $var_property_id = ExpressionIdentifier::getExtendedVarId( $stmt, null, - $statements_analyzer + $statements_analyzer, ); if ($var_id) { @@ -484,7 +484,7 @@ private static function taintProperty( $var_node = DataFlowNode::getForAssignment( $var_id, - $var_location + $var_location, ); $data_flow_graph->addNode($var_node); @@ -493,7 +493,7 @@ private static function taintProperty( $property_node = DataFlowNode::getForAssignment( $var_property_id ?: $var_id . '->$property', - $property_location + $property_location, ); $data_flow_graph->addNode($property_node); @@ -509,7 +509,7 @@ private static function taintProperty( 'property-assignment' . ($stmt->name instanceof PhpParser\Node\Identifier ? '-' . $stmt->name : ''), $added_taints, - $removed_taints + $removed_taints, ); if ($assignment_value_type->parent_nodes) { @@ -520,7 +520,7 @@ private static function taintProperty( if (isset($context->vars_in_scope[$var_id])) { $stmt_var_type = $context->vars_in_scope[$var_id]->setParentNodes( - [$var_node->id => $var_node] + [$var_node->id => $var_node], ); if ($context->vars_in_scope[$var_id]->parent_nodes) { @@ -543,7 +543,7 @@ private static function taintProperty( $var_property_id = ExpressionIdentifier::getExtendedVarId( $stmt, null, - $statements_analyzer + $statements_analyzer, ); self::taintUnspecializedProperty( @@ -553,7 +553,7 @@ private static function taintProperty( $class_storage, $assignment_value_type, $context, - $var_property_id + $var_property_id, ); } } @@ -579,7 +579,7 @@ public static function taintUnspecializedProperty( $localized_property_node = DataFlowNode::getForAssignment( $var_property_id ?: $property_id, - $property_location + $property_location, ); $data_flow_graph->addNode($localized_property_node); @@ -588,7 +588,7 @@ public static function taintUnspecializedProperty( $property_id, $property_id, null, - null + null, ); $data_flow_graph->addNode($property_node); @@ -603,7 +603,7 @@ public static function taintUnspecializedProperty( $property_node, 'property-assignment', $added_taints, - $removed_taints + $removed_taints, ); if ($assignment_value_type->parent_nodes) { @@ -613,7 +613,7 @@ public static function taintUnspecializedProperty( $localized_property_node, '=', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -621,7 +621,7 @@ public static function taintUnspecializedProperty( $declaring_property_class = $codebase->properties->getDeclaringClassForProperty( $property_id, false, - $statements_analyzer + $statements_analyzer, ); if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph @@ -635,7 +635,7 @@ public static function taintUnspecializedProperty( $declaring_property_class . '::$' . $stmt->name, $declaring_property_class . '::$' . $stmt->name, null, - null + null, ); $data_flow_graph->addNode($declaring_property_node); @@ -645,7 +645,7 @@ public static function taintUnspecializedProperty( $declaring_property_node, 'property-assignment', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -680,13 +680,13 @@ private static function analyzeRegularAssignment( $lhs_var_id = ExpressionIdentifier::getVarId( $stmt->var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $var_id = ExpressionIdentifier::getVarId( $stmt, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($var_id) { @@ -696,9 +696,9 @@ private static function analyzeRegularAssignment( IssueBuffer::maybeAdd( new LoopInvalidation( 'Variable ' . $var_id . ' has already been assigned in a for/foreach loop', - new CodeLocation($statements_analyzer->getSource(), $stmt->var) + new CodeLocation($statements_analyzer->getSource(), $stmt->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -717,16 +717,16 @@ private static function analyzeRegularAssignment( if ($stmt->name instanceof PhpParser\Node\Identifier) { $codebase->analyzer->addMixedMemberName( '$' . $stmt->name->name, - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } IssueBuffer::maybeAdd( new MixedPropertyAssignment( $lhs_var_id . ' of type mixed cannot be assigned to', - new CodeLocation($statements_analyzer->getSource(), $stmt->var) + new CodeLocation($statements_analyzer->getSource(), $stmt->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return []; @@ -746,9 +746,9 @@ private static function analyzeRegularAssignment( IssueBuffer::maybeAdd( new NullPropertyAssignment( $lhs_var_id . ' of type null cannot be assigned to', - new CodeLocation($statements_analyzer->getSource(), $stmt->var) + new CodeLocation($statements_analyzer->getSource(), $stmt->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return []; @@ -758,9 +758,9 @@ private static function analyzeRegularAssignment( IssueBuffer::maybeAdd( new PossiblyNullPropertyAssignment( $lhs_var_id . ' with possibly null type \'' . $lhs_type . '\' cannot be assigned to', - new CodeLocation($statements_analyzer->getSource(), $stmt->var) + new CodeLocation($statements_analyzer->getSource(), $stmt->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -782,7 +782,7 @@ private static function analyzeRegularAssignment( if ($lhs_type_part instanceof TTemplateParam) { $lhs_atomic_types = array_merge( $lhs_atomic_types, - $lhs_type_part->as->getAtomicTypes() + $lhs_type_part->as->getAtomicTypes(), ); continue; @@ -802,7 +802,7 @@ private static function analyzeRegularAssignment( $assignment_value_type, $lhs_var_id, $has_valid_assignment_type, - $has_regular_setter + $has_regular_setter, ); if ($assigned_property) { @@ -812,7 +812,7 @@ private static function analyzeRegularAssignment( $context_type = Type::combineUnionTypes( $context_type, $assigned_property->assignment_type, - $codebase + $codebase, ); } else { $context_type = $assigned_property->assignment_type; @@ -828,18 +828,18 @@ private static function analyzeRegularAssignment( new InvalidPropertyAssignment( $lhs_var_id . ' with non-object type \'' . $invalid_assignment_type . '\' cannot treated as an object', - new CodeLocation($statements_analyzer->getSource(), $stmt->var) + new CodeLocation($statements_analyzer->getSource(), $stmt->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new PossiblyInvalidPropertyAssignment( $lhs_var_id . ' with possible non-object type \'' . $invalid_assignment_type . '\' cannot treated as an object', - new CodeLocation($statements_analyzer->getSource(), $stmt->var) + new CodeLocation($statements_analyzer->getSource(), $stmt->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -913,9 +913,9 @@ private static function analyzeAtomicAssignment( Config::getInstance()->getUniversalObjectCrates() + [ 'dateinterval', 'domdocument', - 'domnode' + 'domnode', ], - true + true, ) ) ) { @@ -953,7 +953,7 @@ private static function analyzeAtomicAssignment( if ($codebase->interfaceExists($lhs_type_part->value)) { $interface_exists = true; $interface_storage = $codebase->classlike_storage_provider->get( - strtolower($lhs_type_part->value) + strtolower($lhs_type_part->value), ); $override_property_visibility = $interface_storage->override_property_visibility; @@ -973,9 +973,9 @@ private static function analyzeAtomicAssignment( new NoInterfaceProperties( 'Interfaces cannot have properties', new CodeLocation($statements_analyzer->getSource(), $stmt), - $lhs_type_part->value + $lhs_type_part->value, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return null; } @@ -983,8 +983,8 @@ private static function analyzeAtomicAssignment( if (!$codebase->methods->methodExists( new MethodIdentifier( $fq_class_name, - '__set' - ) + '__set', + ), )) { return null; } @@ -996,9 +996,9 @@ private static function analyzeAtomicAssignment( new UndefinedClass( 'Cannot set properties of undefined class ' . $lhs_type_part->value, new CodeLocation($statements_analyzer->getSource(), $stmt), - $lhs_type_part->value + $lhs_type_part->value, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return null; @@ -1022,7 +1022,7 @@ private static function analyzeAtomicAssignment( $statements_analyzer, new CodeLocation($statements_analyzer->getSource(), $stmt), $statements_analyzer->getSuppressedIssues(), - false + false, ) !== true) ) && $codebase->methods->methodExists( @@ -1035,7 +1035,7 @@ private static function analyzeAtomicAssignment( && !$context->collect_mutations ? $statements_analyzer : null, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), ) ) { $has_magic_setter = true; @@ -1048,7 +1048,7 @@ private static function analyzeAtomicAssignment( $class_storage->pseudo_property_set_types['$' . $prop_name], $fq_class_name, $fq_class_name, - $class_storage->parent_class + $class_storage->parent_class, ); $has_regular_setter = true; @@ -1060,14 +1060,14 @@ private static function analyzeAtomicAssignment( $property_id, $class_storage, $assignment_value_type, - $context + $context, ); } return new AssignedProperty( $class_property_type, $property_id, - $assignment_value_type + $assignment_value_type, ); } } @@ -1079,7 +1079,7 @@ private static function analyzeAtomicAssignment( $statements_analyzer, $stmt, $prop_name, - $assignment_value + $assignment_value, ); } @@ -1095,7 +1095,7 @@ private static function analyzeAtomicAssignment( $property_id, $class_storage, $assignment_value_type, - $context + $context, ); } @@ -1107,9 +1107,9 @@ private static function analyzeAtomicAssignment( new UndefinedMagicPropertyAssignment( 'Magic instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1131,7 +1131,7 @@ private static function analyzeAtomicAssignment( $self_property_id, false, $statements_analyzer, - $context + $context, ) ) { $property_id = $self_property_id; @@ -1150,7 +1150,7 @@ private static function analyzeAtomicAssignment( $property_id, $class_storage, $assignment_value_type, - $context + $context, ); } @@ -1159,7 +1159,7 @@ private static function analyzeAtomicAssignment( false, $statements_analyzer, $context, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ) // when property existence is asserted by a plugin it doesn't necessarily has storage || ($codebase->properties->hasStorage($property_id) @@ -1176,9 +1176,9 @@ private static function analyzeAtomicAssignment( new UndefinedThisPropertyAssignment( 'Instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { if ($has_magic_setter) { @@ -1186,18 +1186,18 @@ private static function analyzeAtomicAssignment( new UndefinedMagicPropertyAssignment( 'Magic instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new UndefinedPropertyAssignment( 'Instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1212,7 +1212,7 @@ private static function analyzeAtomicAssignment( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->name, - $property_id + $property_id, ); } @@ -1223,7 +1223,7 @@ private static function analyzeAtomicAssignment( $context, $statements_analyzer, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false) { return null; } @@ -1234,7 +1234,7 @@ private static function analyzeAtomicAssignment( $statements_analyzer, new CodeLocation($statements_analyzer->getSource(), $stmt), $statements_analyzer->getSuppressedIssues(), - false + false, ) !== true) { return null; } @@ -1243,7 +1243,7 @@ private static function analyzeAtomicAssignment( $declaring_property_class = (string)$codebase->properties->getDeclaringClassForProperty( $property_id, - false + false, ); self::handlePropertyRenames( @@ -1251,7 +1251,7 @@ private static function analyzeAtomicAssignment( $declaring_property_class, $prop_name, $stmt, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), ); $declaring_class_storage = $codebase->classlike_storage_provider->get($declaring_property_class); @@ -1264,9 +1264,9 @@ private static function analyzeAtomicAssignment( new DeprecatedProperty( $property_id . ' is marked deprecated', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1276,9 +1276,9 @@ private static function analyzeAtomicAssignment( $property_id . ' is internal to ' . InternalClass::listToPhrase($property_storage->internal) . ' but called from ' . $context->self, new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1288,7 +1288,7 @@ private static function analyzeAtomicAssignment( $property_id, $property_storage, $declaring_class_storage, - $context + $context, ); if (!$property_storage->readonly @@ -1301,9 +1301,9 @@ private static function analyzeAtomicAssignment( IssueBuffer::maybeAdd( new ImpurePropertyAssignment( 'Cannot assign to a property from a mutation-free context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer @@ -1324,7 +1324,7 @@ private static function analyzeAtomicAssignment( $property_id, true, $statements_analyzer, - $context + $context, ); if (!$class_property_type @@ -1342,7 +1342,7 @@ private static function analyzeAtomicAssignment( ) { $source_analyzer->inferred_property_types[$prop_name] = Type::combineUnionTypes( $assignment_value_type, - $source_analyzer->inferred_property_types[$prop_name] ?? null + $source_analyzer->inferred_property_types[$prop_name] ?? null, ); } } @@ -1358,14 +1358,14 @@ private static function analyzeAtomicAssignment( $declaring_class_storage->parent_class, true, false, - $class_storage->final + $class_storage->final, ); $class_property_type = Methods::localizeType( $codebase, $class_property_type, $fq_class_name, - $declaring_property_class + $declaring_property_class, ); if ($lhs_type_part instanceof TGenericObject) { @@ -1374,7 +1374,7 @@ private static function analyzeAtomicAssignment( $class_property_type, $lhs_type_part, $class_storage, - $declaring_class_storage + $declaring_class_storage, ); } @@ -1382,7 +1382,7 @@ private static function analyzeAtomicAssignment( $codebase, $assignment_value_type, $fq_class_name, - $declaring_property_class + $declaring_property_class, ); if (!$class_property_type->hasMixed() && $assignment_value_type->hasMixed()) { @@ -1392,7 +1392,7 @@ private static function analyzeAtomicAssignment( foreach ($assignment_value_type->parent_nodes as $parent_node) { $origin_locations = [ ...$origin_locations, - ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node) + ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node), ]; } } @@ -1411,9 +1411,9 @@ private static function analyzeAtomicAssignment( new MixedAssignment( $message, new CodeLocation($statements_analyzer->getSource(), $stmt), - $origin_location + $origin_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1421,7 +1421,7 @@ private static function analyzeAtomicAssignment( return new AssignedProperty( $class_property_type, $property_id, - $assignment_value_type + $assignment_value_type, ); } @@ -1444,13 +1444,13 @@ private static function handlePropertyRenames( new FileManipulation( (int)$stmt->name->getAttribute('startFilePos'), (int)$stmt->name->getAttribute('endFilePos') + 1, - $new_property_name - ) + $new_property_name, + ), ]; FileManipulationBuffer::add( $file_path, - $file_manipulations + $file_manipulations, ); } } @@ -1464,7 +1464,7 @@ public static function getExpandedPropertyType( ): ?Union { $property_class_name = $codebase->properties->getDeclaringClassForProperty( $fq_class_name . '::$' . $property_name, - true + true, ); if ($property_class_name === null) { @@ -1490,7 +1490,7 @@ public static function getExpandedPropertyType( $storage->parent_class, true, false, - $storage->final + $storage->final, ) : $property_type; @@ -1500,12 +1500,12 @@ public static function getExpandedPropertyType( $storage, null, new TNamedObject($fq_class_name), - true + true, ); $template_result = new TemplateResult( $class_template_params ?: [], - [] + [], ); if ($class_template_params) { @@ -1515,7 +1515,7 @@ public static function getExpandedPropertyType( $codebase, null, null, - null + null, ); } @@ -1534,7 +1534,7 @@ private static function analyzeSetCall( $context->removeVarFromConflictingClauses( $var_id, Type::getMixed(), - $statements_analyzer + $statements_analyzer, ); $context->removePossibleReference($var_id); @@ -1551,13 +1551,13 @@ private static function analyzeSetCall( new VirtualArg( new VirtualString( $prop_name, - $stmt->name->getAttributes() - ) + $stmt->name->getAttributes(), + ), ), new VirtualArg( - $assignment_value - ) - ] + $assignment_value, + ), + ], ); $suppressed_issues = $statements_analyzer->getSuppressedIssues(); @@ -1570,7 +1570,7 @@ private static function analyzeSetCall( $statements_analyzer, $fake_method_call, $context, - false + false, ); if (!in_array('PossiblyNullReference', $suppressed_issues, true)) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php index 8d303408d6a..e307f514644 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/StaticPropertyAssignmentAnalyzer.php @@ -48,7 +48,7 @@ public static function analyze( $var_id = ExpressionIdentifier::getExtendedVarId( $stmt, $context->self, - $statements_analyzer + $statements_analyzer, ); $lhs_type = $statements_analyzer->node_data->getType($stmt->class); @@ -92,7 +92,7 @@ public static function analyze( if (!$context->ignore_variable_property) { $codebase->analyzer->addMixedMemberName( strtolower($fq_class_name) . '::$', - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } @@ -108,13 +108,13 @@ public static function analyze( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->class, - $fq_class_name + $fq_class_name, ); $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->name, - $property_id + $property_id, ); } @@ -123,9 +123,9 @@ public static function analyze( new UndefinedPropertyAssignment( 'Static property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return null; @@ -136,14 +136,14 @@ public static function analyze( $context, $statements_analyzer, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false) { return false; } $declaring_property_class = (string) $codebase->properties->getDeclaringClassForProperty( $fq_class_name . '::$' . $prop_name->name, - false + false, ); $declaring_property_id = strtolower($declaring_property_class) . '::$' . $prop_name; @@ -154,7 +154,7 @@ public static function analyze( $statements_analyzer, $stmt->class, $fq_class_name, - $context->calling_method_id + $context->calling_method_id, ); if (!$moved_class) { @@ -173,15 +173,15 @@ public static function analyze( $new_fq_class_name, $statements_analyzer->getNamespace(), $statements_analyzer->getAliasedClassesFlipped(), - null - ) + null, + ), ); } $file_manipulations[] = new FileManipulation( (int) $stmt->name->getAttribute('startFilePos'), (int) $stmt->name->getAttribute('endFilePos') + 1, - '$' . $new_property_name + '$' . $new_property_name, ); FileManipulationBuffer::add($statements_analyzer->getFilePath(), $file_manipulations); @@ -203,14 +203,14 @@ public static function analyze( $class_storage, $assignment_value_type, $context, - null + null, ); $class_property_type = $codebase->properties->getPropertyType( $property_id, true, $statements_analyzer, - $context + $context, ); if (!$class_property_type) { @@ -225,7 +225,7 @@ public static function analyze( ) { $source_analyzer->inferred_property_types[$prop_name_name] = Type::combineUnionTypes( $assignment_value_type, - $source_analyzer->inferred_property_types[$prop_name_name] ?? null + $source_analyzer->inferred_property_types[$prop_name_name] ?? null, ); } } @@ -243,7 +243,7 @@ public static function analyze( $class_property_type, $fq_class_name, $fq_class_name, - $class_storage->parent_class + $class_storage->parent_class, ); $union_comparison_results = new TypeComparisonResult(); @@ -254,7 +254,7 @@ public static function analyze( $class_property_type, true, true, - $union_comparison_results + $union_comparison_results, ); if ($union_comparison_results->type_coerced) { @@ -266,11 +266,11 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location + $context->include_location, ), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -280,11 +280,11 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location + $context->include_location, ), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -297,10 +297,10 @@ public static function analyze( new CodeLocation( $statements_analyzer->getSource(), $assignment_value ?? $stmt, - $context->include_location - ) + $context->include_location, + ), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -313,11 +313,11 @@ public static function analyze( . $assignment_value_type->getId() . '\'', new CodeLocation( $statements_analyzer->getSource(), - $assignment_value ?? $stmt + $assignment_value ?? $stmt, ), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -329,11 +329,11 @@ public static function analyze( . $assignment_value_type->getId() . '\'', new CodeLocation( $statements_analyzer->getSource(), - $assignment_value ?? $stmt + $assignment_value ?? $stmt, ), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index 34f4525687d..95b2adf3411 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -115,14 +115,14 @@ public static function analyze( $var_id = ExpressionIdentifier::getVarId( $assign_var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); // gets a variable id that *may* contain array keys $extended_var_id = ExpressionIdentifier::getExtendedVarId( $assign_var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $var_comments = []; @@ -166,21 +166,21 @@ public static function analyze( $statements_analyzer->getSource(), $statements_analyzer->getAliases(), $template_type_map, - $file_storage->type_aliases + $file_storage->type_aliases, ); } catch (IncorrectDocblockException $e) { IssueBuffer::maybeAdd( new MissingDocblockType( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $assign_var) - ) + new CodeLocation($statements_analyzer->getSource(), $assign_var), + ), ); } catch (DocblockParseException $e) { IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $assign_var) - ) + new CodeLocation($statements_analyzer->getSource(), $assign_var), + ), ); } @@ -199,7 +199,7 @@ public static function analyze( $comment_type_location, $not_ignored_docblock_var_ids, $var_id === $var_comment->var_id - && $assign_value_type && $comment_type && $assign_value_type->by_ref + && $assign_value_type && $comment_type && $assign_value_type->by_ref, ); } } @@ -247,7 +247,7 @@ public static function analyze( $context->removeDescendents( $extended_var_id, $context->vars_in_scope[$extended_var_id], - $assign_value_type + $assign_value_type, ); } @@ -281,10 +281,10 @@ public static function analyze( new UnnecessaryVarAnnotation( 'The @var ' . $comment_type . ' annotation for ' . $extended_var_id . ' is unnecessary', - $comment_type_location + $comment_type_location, ), $statements_analyzer->getSuppressedIssues(), - true + true, ); } } @@ -314,14 +314,14 @@ public static function analyze( if ($extended_var_id) { $assignment_node = DataFlowNode::getForAssignment( $extended_var_id, - new CodeLocation($statements_analyzer->getSource(), $assign_var) + new CodeLocation($statements_analyzer->getSource(), $assign_var), ); } else { $assignment_node = new DataFlowNode('unknown-origin', 'unknown origin', null); } $parent_nodes = [ - $assignment_node->id => $assignment_node + $assignment_node->id => $assignment_node, ]; if ($context->inside_try) { @@ -341,8 +341,8 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureByReferenceAssignment( 'Variable ' . $extended_var_id . ' cannot be assigned to as it is passed by reference', - new CodeLocation($statements_analyzer->getSource(), $assign_var) - ) + new CodeLocation($statements_analyzer->getSource(), $assign_var), + ), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations @@ -359,20 +359,20 @@ public static function analyze( $extended_var_id, $context->vars_in_scope[$extended_var_id], $assign_value_type, - $statements_analyzer + $statements_analyzer, ); } else { $root_var_id = ExpressionIdentifier::getRootVarId( $assign_var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($root_var_id && isset($context->vars_in_scope[$root_var_id])) { $context->removeVarFromConflictingClauses( $root_var_id, $context->vars_in_scope[$root_var_id], - $statements_analyzer + $statements_analyzer, ); } } @@ -383,7 +383,7 @@ public static function analyze( $root_var_id = ExpressionIdentifier::getRootVarId( $assign_var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if (!$context->collect_initializations @@ -407,7 +407,7 @@ public static function analyze( foreach ($assign_value_type->parent_nodes as $parent_node) { $origin_locations = [ ...$origin_locations, - ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node) + ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node), ]; } } @@ -428,9 +428,9 @@ public static function analyze( new MixedAssignment( $message, $issue_location, - $origin_location + $origin_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { @@ -453,7 +453,7 @@ public static function analyze( $assign_value_type, $outer_constraint_type, $assign_value_type->ignore_nullable_issues, - $assign_value_type->ignore_falsable_issues + $assign_value_type->ignore_falsable_issues, ) ) { IssueBuffer::maybeAdd( @@ -462,9 +462,9 @@ public static function analyze( . $context->byref_constraints[$var_id]->type . ' because it is passed by reference, ' . $assign_value_type->getId() . ' type found', - new CodeLocation($statements_analyzer->getSource(), $assign_var) + new CodeLocation($statements_analyzer->getSource(), $assign_var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -473,9 +473,9 @@ public static function analyze( if ($var_id === '$this' && IssueBuffer::accepts( new InvalidScope( 'Cannot re-assign ' . $var_id, - new CodeLocation($statements_analyzer->getSource(), $assign_var) + new CodeLocation($statements_analyzer->getSource(), $assign_var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -486,9 +486,9 @@ public static function analyze( IssueBuffer::maybeAdd( new LoopInvalidation( 'Variable ' . $var_id . ' has already been assigned in a for/foreach loop', - new CodeLocation($statements_analyzer->getSource(), $assign_var) + new CodeLocation($statements_analyzer->getSource(), $assign_var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -503,7 +503,7 @@ public static function analyze( $doc_comment, $extended_var_id, $var_comments, - $removed_taints + $removed_taints, ) === false ) { return false; @@ -514,9 +514,9 @@ public static function analyze( IssueBuffer::maybeAdd( new AssignmentToVoid( 'Cannot assign ' . $var_id . ' to type void', - new CodeLocation($statements_analyzer->getSource(), $assign_var) + new CodeLocation($statements_analyzer->getSource(), $assign_var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $context->vars_in_scope[$var_id] = Type::getNull(); @@ -530,9 +530,9 @@ public static function analyze( if (IssueBuffer::accepts( new NoValue( 'All possible types for this assignment were invalidated - This may be dead code', - new CodeLocation($statements_analyzer->getSource(), $assign_var) + new CodeLocation($statements_analyzer->getSource(), $assign_var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -560,7 +560,7 @@ public static function analyze( $added_taints = $codebase->config->eventDispatcher->dispatchAddTaints($event); $removed_taints = [ ...$removed_taints, - ...$codebase->config->eventDispatcher->dispatchRemoveTaints($event) + ...$codebase->config->eventDispatcher->dispatchRemoveTaints($event), ]; self::taintAssignment( @@ -569,14 +569,14 @@ public static function analyze( $var_id, $var_location, $removed_taints, - $added_taints + $added_taints, ); } if ($assign_expr) { $new_parent_node = DataFlowNode::getForAssignment( 'assignment_expr', - new CodeLocation($statements_analyzer->getSource(), $assign_expr) + new CodeLocation($statements_analyzer->getSource(), $assign_expr), ); $data_flow_graph->addNode($new_parent_node); @@ -590,7 +590,7 @@ public static function analyze( } $assign_value_type = $assign_value_type->setParentNodes( - [$new_parent_node->id => $new_parent_node] + [$new_parent_node->id => $new_parent_node], ); } } @@ -628,7 +628,7 @@ private static function analyzeAssignment( $assign_value, $assign_value_type, $var_id, - $context + $context, ); } elseif ($assign_var instanceof PhpParser\Node\Expr\List_ || $assign_var instanceof PhpParser\Node\Expr\Array_ @@ -643,7 +643,7 @@ private static function analyzeAssignment( $doc_comment, $extended_var_id, $var_comments, - $removed_taints + $removed_taints, ); } elseif ($assign_var instanceof PhpParser\Node\Expr\ArrayDimFetch) { ArrayAssignmentAnalyzer::analyze( @@ -651,7 +651,7 @@ private static function analyzeAssignment( $assign_var, $context, $assign_value, - $assign_value_type + $assign_value_type, ); } elseif ($assign_var instanceof PhpParser\Node\Expr\PropertyFetch) { self::analyzePropertyAssignment( @@ -661,7 +661,7 @@ private static function analyzeAssignment( $context, $assign_value, $assign_value_type, - $var_id + $var_id, ); } elseif ($assign_var instanceof PhpParser\Node\Expr\StaticPropertyFetch && $assign_var->class instanceof PhpParser\Node\Name @@ -676,7 +676,7 @@ private static function analyzeAssignment( $assign_var, $assign_value, $assign_value_type, - $context + $context, ) === false) { return false; } @@ -712,12 +712,12 @@ public static function assignTypeFromVarDocblock( $var_comment->type, $context->self, $context->self, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); $var_comment_type = $var_comment_type->setProperties([ 'from_docblock' => true, - 'by_ref' => $by_ref + 'by_ref' => $by_ref, ]); /** @psalm-suppress UnusedMethodCall This actually has the side effect of generating issues */ @@ -729,7 +729,7 @@ public static function assignTypeFromVarDocblock( false, false, false, - $context->calling_method_id + $context->calling_method_id, ); $type_location = null; @@ -742,7 +742,7 @@ public static function assignTypeFromVarDocblock( $statements_analyzer, $var_comment->type_start, $var_comment->type_end, - $var_comment->line_number + $var_comment->line_number, ); if ($codebase->alter_code) { @@ -751,7 +751,7 @@ public static function assignTypeFromVarDocblock( $statements_analyzer, $var_comment_type, $type_location, - $context->calling_method_id + $context->calling_method_id, ); } } @@ -780,10 +780,10 @@ public static function assignTypeFromVarDocblock( new UnnecessaryVarAnnotation( 'The @var ' . $var_comment_type . ' annotation for ' . $var_comment->var_id . ' is unnecessary', - $type_location + $type_location, ), $statements_analyzer->getSuppressedIssues(), - true + true, ); } } @@ -796,8 +796,8 @@ public static function assignTypeFromVarDocblock( IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $stmt) - ) + new CodeLocation($statements_analyzer->getSource(), $stmt), + ), ); } } @@ -826,7 +826,7 @@ private static function taintAssignment( $new_parent_node, '=', $added_taints, - $removed_taints + $removed_taints, ); } @@ -871,7 +871,7 @@ public static function analyzeAssignmentOperation( $fake_assignment = new VirtualAssign( $stmt->var, $operation, - $stmt->getAttributes() + $stmt->getAttributes(), ); $old_node_data = $statements_analyzer->node_data; @@ -884,7 +884,7 @@ public static function analyzeAssignmentOperation( $old_node_data->setType( $stmt, - $statements_analyzer->node_data->getType($operation) ?? Type::getMixed() + $statements_analyzer->node_data->getType($operation) ?? Type::getMixed(), ); $statements_analyzer->node_data = $old_node_data; @@ -902,13 +902,13 @@ public static function analyzeAssignmentRef( $lhs_var_id = ExpressionIdentifier::getExtendedVarId( $stmt->var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $rhs_var_id = ExpressionIdentifier::getExtendedVarId( $stmt->expr, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $doc_comment = $stmt->getDocComment(); @@ -923,23 +923,23 @@ public static function analyzeAssignmentRef( IssueBuffer::maybeAdd( new MissingDocblockType( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $stmt) - ) + new CodeLocation($statements_analyzer->getSource(), $stmt), + ), ); } catch (DocblockParseException $e) { IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $stmt) - ) + new CodeLocation($statements_analyzer->getSource(), $stmt), + ), ); } if (!empty($var_comments) && $var_comments[0]->type !== null && $var_comments[0]->var_id === null) { IssueBuffer::maybeAdd( new InvalidDocblock( "Docblock type cannot be used for reference assignment", - new CodeLocation($statements_analyzer->getSource(), $stmt) - ) + new CodeLocation($statements_analyzer->getSource(), $stmt), + ), ); } } @@ -991,7 +991,7 @@ public static function analyzeAssignmentRef( // so it's not registered as an unused variable (this mirrors behavior for non-references). $statements_analyzer->registerVariableAssignment( $lhs_var_id, - $lhs_location + $lhs_location, ); } @@ -1029,7 +1029,7 @@ public static function assignByRefParam( $prop_name, null, $by_ref_out_type, - $context + $context, ); return; @@ -1038,7 +1038,7 @@ public static function assignByRefParam( $var_id = ExpressionIdentifier::getVarId( $stmt, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($var_id) { @@ -1064,9 +1064,9 @@ public static function assignByRefParam( IssueBuffer::maybeAdd( new NullReference( 'Not expecting null argument passed by reference', - $location + $location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1074,7 +1074,7 @@ public static function assignByRefParam( $statements_analyzer->registerVariable( $var_id, $location, - $context->branch_point + $context->branch_point, ); if ($statements_analyzer->data_flow_graph instanceof VariableUseGraph) { @@ -1083,7 +1083,7 @@ public static function assignByRefParam( $statements_analyzer->data_flow_graph->addPath( $byref_node, new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } } @@ -1103,11 +1103,11 @@ public static function assignByRefParam( $var_id, $existing_type, $by_ref_type, - $statements_analyzer + $statements_analyzer, ); $by_ref_out_type = $by_ref_out_type->addParentNodes( - $existing_type->parent_nodes + $existing_type->parent_nodes, ); if (!$context->inside_conditional) { @@ -1163,9 +1163,9 @@ private static function analyzeDestructuringAssignment( IssueBuffer::maybeAdd( new InvalidArrayOffset( 'Cannot destructure non-array of type ' . $assign_value_type->getId(), - new CodeLocation($statements_analyzer->getSource(), $assign_var) + new CodeLocation($statements_analyzer->getSource(), $assign_var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1188,7 +1188,7 @@ private static function analyzeDestructuringAssignment( $assign_var_item->value, null, $context, - $doc_comment + $doc_comment, ); continue; @@ -1205,7 +1205,7 @@ private static function analyzeDestructuringAssignment( $list_var_id = ExpressionIdentifier::getExtendedVarId( $var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $new_assign_type = null; @@ -1229,9 +1229,9 @@ private static function analyzeDestructuringAssignment( IssueBuffer::maybeAdd( new PossiblyUndefinedArrayOffset( 'Possibly undefined array key', - new CodeLocation($statements_analyzer->getSource(), $var) + new CodeLocation($statements_analyzer->getSource(), $var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $value_type = $value_type->setPossiblyUndefined(false); @@ -1245,7 +1245,7 @@ private static function analyzeDestructuringAssignment( $assign_value_id = ExpressionIdentifier::getExtendedVarId( $assign_value, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $keyed_array_var_id = null; @@ -1260,7 +1260,7 @@ private static function analyzeDestructuringAssignment( $assign_value, $keyed_array_var_id, $value_type, - $temp + $temp, ); } @@ -1270,7 +1270,7 @@ private static function analyzeDestructuringAssignment( null, $value_type, $context, - $doc_comment + $doc_comment, ); $assigned = true; @@ -1282,9 +1282,9 @@ private static function analyzeDestructuringAssignment( IssueBuffer::maybeAdd( new InvalidArrayOffset( 'Cannot access value with offset ' . $offset, - new CodeLocation($statements_analyzer->getSource(), $var) + new CodeLocation($statements_analyzer->getSource(), $var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1293,9 +1293,9 @@ private static function analyzeDestructuringAssignment( IssueBuffer::maybeAdd( new MixedArrayAccess( 'Cannot access array value on mixed variable ' . $extended_var_id, - new CodeLocation($statements_analyzer->getSource(), $var) + new CodeLocation($statements_analyzer->getSource(), $var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($assign_value_atomic_type instanceof TNull) { $has_null = true; @@ -1311,9 +1311,9 @@ private static function analyzeDestructuringAssignment( new PossiblyInvalidArrayAccess( 'Cannot access array value on non-array variable ' . $extended_var_id . ' of type ' . $assign_value_atomic_type->getId(), - new CodeLocation($statements_analyzer->getSource(), $var) + new CodeLocation($statements_analyzer->getSource(), $var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { @@ -1321,9 +1321,9 @@ private static function analyzeDestructuringAssignment( new InvalidArrayAccess( 'Cannot access array value on non-array variable ' . $extended_var_id . ' of type ' . $assign_value_atomic_type->getId(), - new CodeLocation($statements_analyzer->getSource(), $var) + new CodeLocation($statements_analyzer->getSource(), $var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1345,7 +1345,7 @@ private static function analyzeDestructuringAssignment( null, $array_value_type, $context, - $doc_comment + $doc_comment, ); continue; @@ -1365,12 +1365,12 @@ private static function analyzeDestructuringAssignment( $statements_analyzer->registerVariable( $list_var_id, $location, - $context->branch_point + $context->branch_point, ); } else { $statements_analyzer->registerVariableAssignment( $list_var_id, - $location + $location, ); } @@ -1391,7 +1391,7 @@ private static function analyzeDestructuringAssignment( $assign_value, null, $new_assign_type, - $temp + $temp, ); } @@ -1408,9 +1408,9 @@ private static function analyzeDestructuringAssignment( IssueBuffer::maybeAdd( new PossiblyUndefinedArrayOffset( 'Possibly undefined array key', - new CodeLocation($statements_analyzer->getSource(), $var) + new CodeLocation($statements_analyzer->getSource(), $var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $new_assign_type = $new_assign_type->setPossiblyUndefined(false); @@ -1425,9 +1425,9 @@ private static function analyzeDestructuringAssignment( IssueBuffer::maybeAdd( new PossiblyUndefinedIntArrayOffset( 'Possibly undefined array key', - new CodeLocation($statements_analyzer->getSource(), $var) + new CodeLocation($statements_analyzer->getSource(), $var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1442,7 +1442,7 @@ private static function analyzeDestructuringAssignment( $assign_value, null, $new_assign_type, - $temp + $temp, ); } } elseif ($assign_value_atomic_type->hasArrayAccessInterface($codebase)) { @@ -1450,7 +1450,7 @@ private static function analyzeDestructuringAssignment( $assign_value_atomic_type, $codebase, $array_access_key_type, - $array_access_value_type + $array_access_value_type, ); $new_assign_type = $array_access_value_type; @@ -1462,7 +1462,7 @@ private static function analyzeDestructuringAssignment( $list_var_id, $context->vars_in_scope[$list_var_id], $new_assign_type, - $statements_analyzer + $statements_analyzer, ); } } @@ -1475,9 +1475,9 @@ private static function analyzeDestructuringAssignment( IssueBuffer::maybeAdd( new PossiblyNullArrayAccess( 'Cannot access array value on null variable ' . $extended_var_id, - new CodeLocation($statements_analyzer->getSource(), $var) + new CodeLocation($statements_analyzer->getSource(), $var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1493,7 +1493,7 @@ private static function analyzeDestructuringAssignment( $var_comment->type, $context->self, $context->self, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); $var_comment_type = $var_comment_type->setFromDocblock(); @@ -1505,8 +1505,8 @@ private static function analyzeDestructuringAssignment( IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $assign_var) - ) + new CodeLocation($statements_analyzer->getSource(), $assign_var), + ), ); } } @@ -1522,12 +1522,12 @@ private static function analyzeDestructuringAssignment( if (!$context->vars_in_scope[$list_var_id]->parent_nodes) { $assignment_node = DataFlowNode::getForAssignment( $list_var_id, - $var_location + $var_location, ); $context->vars_in_scope[$list_var_id] = $context->vars_in_scope[$list_var_id]->setParentNodes([ - $assignment_node->id => $assignment_node + $assignment_node->id => $assignment_node, ]) ; } else { @@ -1542,7 +1542,7 @@ private static function analyzeDestructuringAssignment( $added_taints = $codebase->config->eventDispatcher->dispatchAddTaints($event); $removed_taints = [ ...$removed_taints, - ...$codebase->config->eventDispatcher->dispatchRemoveTaints($event) + ...$codebase->config->eventDispatcher->dispatchRemoveTaints($event), ]; self::taintAssignment( @@ -1551,7 +1551,7 @@ private static function analyzeDestructuringAssignment( $list_var_id, $var_location, $removed_taints, - $added_taints + $added_taints, ); } } @@ -1619,7 +1619,7 @@ private static function analyzePropertyAssignment( $prop_name, $assign_value, $assign_value_type, - $context + $context, ); } else { if (ExpressionAnalyzer::analyze($statements_analyzer, $assign_var->var, $context) === false) { @@ -1636,7 +1636,7 @@ private static function analyzePropertyAssignment( if ($type instanceof TNamedObject) { $codebase->analyzer->addMixedMemberName( strtolower($type->value) . '::$', - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } } @@ -1659,9 +1659,9 @@ private static function analyzePropertyAssignment( IssueBuffer::maybeAdd( new ImpurePropertyAssignment( 'Cannot assign to a property from a mutation-free context', - new CodeLocation($statements_analyzer, $assign_var) + new CodeLocation($statements_analyzer, $assign_var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations @@ -1698,12 +1698,12 @@ private static function analyzeAssignmentToVariable( $statements_analyzer->registerVariable( $var_id, $location, - $context->branch_point + $context->branch_point, ); } elseif (!$context->inside_isset) { $statements_analyzer->registerVariableAssignment( $var_id, - $location + $location, ); } @@ -1717,7 +1717,7 @@ private static function analyzeAssignmentToVariable( $assign_var, $location->raw_file_start . '-' . $location->raw_file_end - . ':' . $assign_value_type->getId() + . ':' . $assign_value_type->getId(), ); } @@ -1742,7 +1742,7 @@ private static function analyzeAssignmentToVariable( $statements_analyzer->data_flow_graph->addPath( $parent_node, $assignment_node, - '&=' // Normal assignment to reference/referenced variable + '&=', // Normal assignment to reference/referenced variable ); } @@ -1751,7 +1751,7 @@ private static function analyzeAssignmentToVariable( $statements_analyzer->data_flow_graph->addPath( $assignment_node, new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } } @@ -1763,9 +1763,9 @@ private static function analyzeAssignmentToVariable( "$var_id is possibly a reference defined at" . " {$context->references_possibly_from_confusing_scope[$var_id]->getShortSummary()}." . " Reusing this variable may cause the referenced value to change.", - new CodeLocation($statements_analyzer, $assign_var) + new CodeLocation($statements_analyzer, $assign_var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1783,18 +1783,18 @@ private static function analyzeAssignmentToVariable( $assign_value, $context->self, $statements_analyzer, - $codebase + $codebase, ); $right_clauses = Context::filterClauses( $var_id, - $right_clauses + $right_clauses, ); $assignment_clauses = Algebra::combineOredClauses( [new Clause([$var_id => ['falsy' => new Falsy()]], $var_object_id, $var_object_id)], $right_clauses, - $cond_object_id + $cond_object_id, ); $context->clauses = [...$context->clauses, ...$assignment_clauses]; @@ -1819,7 +1819,7 @@ private static function analyzeAssignmentToVariable( $statements_analyzer->data_flow_graph->addPath( $parent_node, new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php index cad1020fecc..5732707b92c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php @@ -42,11 +42,11 @@ public static function analyze( [ 'stmts' => [ new VirtualExpression( - $stmt->right - ) - ] + $stmt->right, + ), + ], ], - $stmt->getAttributes() + $stmt->getAttributes(), ); return IfElseAnalyzer::analyze($statements_analyzer, $fake_if_stmt, $context) !== false; @@ -80,7 +80,7 @@ public static function analyze( $stmt->left, $context->self, $statements_analyzer, - $codebase + $codebase, ); foreach ($left_context->vars_in_scope as $var_id => $type) { @@ -106,7 +106,7 @@ public static function analyze( array_filter( $context_clauses, static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses, true) - ) + ), ); if (count($context_clauses) === 1 @@ -125,7 +125,7 @@ public static function analyze( $simplified_clauses, $left_cond_id, $left_referenced_var_ids, - $active_left_assertions + $active_left_assertions, ); $changed_var_ids = []; @@ -145,7 +145,7 @@ public static function analyze( $statements_analyzer->getTemplateTypeMap() ?: [], $context->inside_loop, new CodeLocation($statements_analyzer->getSource(), $stmt->left), - $context->inside_negation + $context->inside_negation, ); } else { $right_context = clone $left_context; @@ -163,7 +163,7 @@ public static function analyze( $context->cond_referenced_var_ids = array_merge( $right_context->cond_referenced_var_ids, - $left_context->cond_referenced_var_ids + $left_context->cond_referenced_var_ids, ); if ($context->inside_conditional) { @@ -171,12 +171,12 @@ public static function analyze( $context->vars_possibly_in_scope = array_merge( $right_context->vars_possibly_in_scope, - $left_context->vars_possibly_in_scope + $left_context->vars_possibly_in_scope, ); $context->assigned_var_ids = array_merge( $left_context->assigned_var_ids, - $right_context->assigned_var_ids + $right_context->assigned_var_ids, ); } @@ -185,7 +185,7 @@ public static function analyze( $context->vars_in_scope = $right_context->vars_in_scope; $if_body_context->vars_in_scope = array_merge( $if_body_context->vars_in_scope, - $context->vars_in_scope + $context->vars_in_scope, ); $if_body_context->cond_referenced_var_ids = array_merge( @@ -203,8 +203,8 @@ public static function analyze( ...array_map( /** @return string|int */ static fn(Clause $c) => $c->hash, - $partitioned_clauses[1] - ) + $partitioned_clauses[1], + ), ]; $if_body_context->vars_possibly_in_scope = array_merge( diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php index 11a1468af31..1712c8a5485 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php @@ -87,9 +87,9 @@ public static function analyze( IssueBuffer::maybeAdd( new NullOperand( 'Left operand cannot be null', - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } $result_type = Type::getMixed(); @@ -102,9 +102,9 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyNullOperand( 'Left operand cannot be nullable, got ' . $left_type, - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -114,9 +114,9 @@ public static function analyze( IssueBuffer::maybeAdd( new NullOperand( 'Right operand cannot be null', - new CodeLocation($statements_source, $right) + new CodeLocation($statements_source, $right), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } $result_type = Type::getMixed(); @@ -129,9 +129,9 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyNullOperand( 'Right operand cannot be nullable, got ' . $right_type, - new CodeLocation($statements_source, $right) + new CodeLocation($statements_source, $right), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -141,9 +141,9 @@ public static function analyze( IssueBuffer::maybeAdd( new FalseOperand( 'Left operand cannot be false', - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } @@ -155,9 +155,9 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyFalseOperand( 'Left operand cannot be falsable, got ' . $left_type, - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -167,9 +167,9 @@ public static function analyze( IssueBuffer::maybeAdd( new FalseOperand( 'Right operand cannot be false', - new CodeLocation($statements_source, $right) + new CodeLocation($statements_source, $right), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } @@ -181,9 +181,9 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyFalseOperand( 'Right operand cannot be falsable, got ' . $right_type, - new CodeLocation($statements_source, $right) + new CodeLocation($statements_source, $right), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -211,7 +211,7 @@ public static function analyze( $has_valid_left_operand, $has_valid_right_operand, $has_string_increment, - $result_type + $result_type, ); if ($candidate_result_type) { @@ -228,17 +228,17 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyInvalidOperand( $first_left_message, - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidOperand( $first_left_message, - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -250,17 +250,17 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyInvalidOperand( $first_right_message, - new CodeLocation($statements_source, $right) + new CodeLocation($statements_source, $right), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidOperand( $first_right_message, - new CodeLocation($statements_source, $right) + new CodeLocation($statements_source, $right), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -269,9 +269,9 @@ public static function analyze( IssueBuffer::maybeAdd( new StringIncrement( 'Possibly unintended string increment', - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -329,9 +329,9 @@ private static function analyzeOperands( new InvalidOperand( 'Cannot process numeric types together in strict operands mode, '. 'please cast explicitly', - new CodeLocation($statements_source, $parent) + new CodeLocation($statements_source, $parent), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } @@ -340,13 +340,13 @@ private static function analyzeOperands( $parent, $left_type_part->value, $right_type_part->value, - true + true, ); if ($calculated_type) { $result_type = Type::combineUnionTypes( $calculated_type, - $result_type + $result_type, ); $has_valid_left_operand = true; @@ -378,7 +378,7 @@ private static function analyzeOperands( ) { $new_result_type = new Union( [new TFloat(), new TInt()], - ['from_calculation' => true] + ['from_calculation' => true], ); } else { $new_result_type = Type::getNonEmptyString(); @@ -398,7 +398,7 @@ private static function analyzeOperands( ) { $combined_type = Type::combineUnionTypes( $left_type_part->as, - $right_type_part->as + $right_type_part->as, ); $combined_atomic_types = array_values($combined_type->getAtomicTypes()); @@ -427,9 +427,9 @@ private static function analyzeOperands( IssueBuffer::maybeAdd( new MixedOperand( 'Left operand cannot be mixed', - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } else { @@ -437,9 +437,9 @@ private static function analyzeOperands( IssueBuffer::maybeAdd( new MixedOperand( 'Right operand cannot be mixed', - new CodeLocation($statements_source, $right) + new CodeLocation($statements_source, $right), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -471,9 +471,9 @@ private static function analyzeOperands( IssueBuffer::maybeAdd( new MixedOperand( 'Left operand cannot be a non-numeric template', - new CodeLocation($statements_source, $left) + new CodeLocation($statements_source, $left), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } elseif ($right_type_part instanceof TTemplateParam @@ -484,9 +484,9 @@ private static function analyzeOperands( IssueBuffer::maybeAdd( new MixedOperand( 'Right operand cannot be a non-numeric template', - new CodeLocation($statements_source, $right) + new CodeLocation($statements_source, $right), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -555,7 +555,7 @@ private static function analyzeOperands( ) { $definitely_existing_mixed_right_properties = array_diff_key( $right_type_part->properties, - $left_type_part->properties + $left_type_part->properties, ); $properties = $left_type_part->properties; @@ -571,7 +571,7 @@ private static function analyzeOperands( false, true, 500, - $type->possibly_undefined + $type->possibly_undefined, ); } } @@ -592,11 +592,11 @@ private static function analyzeOperands( $fallback_params = [ Type::combineUnionTypes( $left_type_part->fallback_params[0], - $right_type_part->fallback_params[0] + $right_type_part->fallback_params[0], ), Type::combineUnionTypes( $left_type_part->fallback_params[1], - $right_type_part->fallback_params[1] + $right_type_part->fallback_params[1], ), ]; } else { @@ -606,14 +606,14 @@ private static function analyzeOperands( $new_keyed_array = new TKeyedArray( $properties, null, - $fallback_params + $fallback_params, ); $result_type_member = new Union([$new_keyed_array]); } else { $result_type_member = TypeCombiner::combine( [$left_type_part, $right_type_part], $codebase, - true + true, ); } @@ -628,7 +628,7 @@ private static function analyzeOperands( $left, $right, $result_type, - $context + $context, ); } @@ -651,16 +651,16 @@ private static function analyzeOperands( ) { $result_type = Type::combineUnionTypes( new Union([new TNamedObject('GMP')]), - $result_type + $result_type, ); } else { if ($statements_source) { IssueBuffer::maybeAdd( new InvalidOperand( 'Cannot add GMP to non-numeric type', - new CodeLocation($statements_source, $parent) + new CodeLocation($statements_source, $parent), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -693,16 +693,16 @@ private static function analyzeOperands( ) { $result_type = Type::combineUnionTypes( new Union([new TNamedObject("Decimal\\Decimal")]), - $result_type + $result_type, ); } else { if ($statements_source) { IssueBuffer::maybeAdd( new InvalidOperand( "Cannot add Decimal\\Decimal to {$non_decimal_type->getId()}", - new CodeLocation($statements_source, $parent) + new CodeLocation($statements_source, $parent), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -737,9 +737,9 @@ private static function analyzeOperands( new InvalidOperand( 'Cannot process different numeric types together in strict binary operands mode, '. 'please cast explicitly', - new CodeLocation($statements_source, $parent) + new CodeLocation($statements_source, $parent), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -770,7 +770,7 @@ private static function analyzeOperands( $parent, $result_type, $left_type_part, - $right_type_part + $right_type_part, ); return null; } @@ -818,7 +818,7 @@ private static function analyzeOperands( $result_type = new Union([new TIntRange(0, $literal_value_max)]); } else { $result_type = new Union( - [new TIntRange(-$literal_value_max, $literal_value_max)] + [new TIntRange(-$literal_value_max, $literal_value_max)], ); } } else { @@ -831,7 +831,7 @@ private static function analyzeOperands( } else { $result_type = Type::combineUnionTypes( $always_positive ? new Union([new TIntRange(1, null)]) : Type::getInt(true), - $result_type + $result_type, ); } } @@ -864,9 +864,9 @@ private static function analyzeOperands( new InvalidOperand( 'Cannot process ints and floats in strict binary operands mode, '. 'please cast explicitly', - new CodeLocation($statements_source, $parent) + new CodeLocation($statements_source, $parent), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -890,9 +890,9 @@ private static function analyzeOperands( new InvalidOperand( 'Cannot process numeric types together in strict operands mode, '. 'please cast explicitly', - new CodeLocation($statements_source, $parent) + new CodeLocation($statements_source, $parent), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); } } @@ -989,7 +989,7 @@ private static function analyzeOperandsBetweenIntRange( //can't assume an int range will stay int after division $result_type = Type::combineUnionTypes( new Union([new TInt(), new TFloat()]), - $result_type + $result_type, ); return; } @@ -1006,7 +1006,7 @@ private static function analyzeOperandsBetweenIntRange( //really complex to calculate $result_type = Type::combineUnionTypes( Type::getInt(), - $result_type + $result_type, ); return; } @@ -1017,7 +1017,7 @@ private static function analyzeOperandsBetweenIntRange( //really complex to calculate $result_type = Type::combineUnionTypes( new Union([new TInt()]), - $result_type + $result_type, ); return; } @@ -1054,7 +1054,7 @@ private static function analyzeOperandsBetweenIntRange( $parent, $min_operand1, $min_operand2, - false + false, ); } @@ -1065,7 +1065,7 @@ private static function analyzeOperandsBetweenIntRange( $parent, $max_operand1, $max_operand2, - false + false, ); } @@ -1138,7 +1138,7 @@ private static function analyzeMulBetweenIntRange( $parent, $min_operand1, $min_operand2, - false + false, ); } @@ -1149,7 +1149,7 @@ private static function analyzeMulBetweenIntRange( $parent, $max_operand1, $max_operand2, - false + false, ); } @@ -1172,7 +1172,7 @@ private static function analyzeMulBetweenIntRange( $parent, $min_operand1, $min_operand2, - false + false, ); } @@ -1183,7 +1183,7 @@ private static function analyzeMulBetweenIntRange( $parent, $max_operand1, $max_operand2, - false + false, ); } @@ -1210,7 +1210,7 @@ private static function analyzeMulBetweenIntRange( $parent, $min_operand1, $min_operand2, - false + false, ); } @@ -1221,7 +1221,7 @@ private static function analyzeMulBetweenIntRange( $parent, $max_operand1, $max_operand2, - false + false, ); } @@ -1248,7 +1248,7 @@ private static function analyzeMulBetweenIntRange( $parent, $min_operand1, $min_operand2, - false + false, ); } @@ -1259,7 +1259,7 @@ private static function analyzeMulBetweenIntRange( $parent, $max_operand1, $max_operand2, - false + false, ); } @@ -1321,7 +1321,7 @@ private static function analyzePowBetweenIntRange( } else { $new_result_type = new Union( [new TFloat(), new TLiteralInt(0), new TLiteralInt(1)], - ['from_calculation' => true] + ['from_calculation' => true], ); } } else { @@ -1388,7 +1388,7 @@ private static function analyzeModBetweenIntRange( if ($right_type_part->max_bound !== null) { //we now that the result will be a range between 0 and $right->max - 1 $new_result_type = new Union( - [new TIntRange(0, $right_type_part->max_bound - 1)] + [new TIntRange(0, $right_type_part->max_bound - 1)], ); } else { $new_result_type = Type::getListKey(); @@ -1412,7 +1412,7 @@ private static function analyzeModBetweenIntRange( $result_type = Type::combineUnionTypes( $new_result_type, - $result_type + $result_type, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php index 8db1df84e6f..8a0eed58346 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php @@ -65,18 +65,18 @@ public static function analyze( $left_expr = new VirtualVariable( substr($left_var_id, 1), - $left_expr->getAttributes() + $left_expr->getAttributes(), ); } $ternary = new VirtualTernary( new VirtualIsset( [$left_expr], - $stmt->left->getAttributes() + $stmt->left->getAttributes(), ), $left_expr, $stmt->right, - $stmt->getAttributes() + $stmt->getAttributes(), ); $old_node_data = $statements_analyzer->node_data; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php index 6f19a633a50..44dc2859b7d 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php @@ -89,7 +89,7 @@ public static function analyze( foreach ($left_type->parent_nodes as $parent_node) { $origin_locations = [ ...$origin_locations, - ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node) + ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node), ]; } } @@ -104,9 +104,9 @@ public static function analyze( new MixedOperand( 'Left operand cannot be mixed', $arg_location, - $origin_location + $origin_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { $arg_location = new CodeLocation($statements_analyzer->getSource(), $right); @@ -116,7 +116,7 @@ public static function analyze( foreach ($right_type->parent_nodes as $parent_node) { $origin_locations = [ ...$origin_locations, - ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node) + ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node), ]; } } @@ -131,9 +131,9 @@ public static function analyze( new MixedOperand( 'Right operand cannot be mixed', $arg_location, - $origin_location + $origin_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -189,18 +189,18 @@ public static function analyze( $numeric_type = new Union([ new TNumericString, new TInt, - new TFloat + new TFloat, ]); $left_is_numeric = UnionTypeComparator::isContainedBy( $codebase, $left_type, - $numeric_type + $numeric_type, ); $right_is_numeric = UnionTypeComparator::isContainedBy( $codebase, $right_type, - $numeric_type + $numeric_type, ); $has_numeric_type = $left_is_numeric || $right_is_numeric; @@ -210,7 +210,7 @@ public static function analyze( $right_is_uint = UnionTypeComparator::isContainedBy( $codebase, $right_type, - $right_uint + $right_uint, ); if ($right_is_uint) { @@ -224,11 +224,11 @@ public static function analyze( $all_lowercase = UnionTypeComparator::isContainedBy( $codebase, $left_type, - $lowercase_type + $lowercase_type, ) && UnionTypeComparator::isContainedBy( $codebase, $right_type, - $lowercase_type + $lowercase_type, ); $non_empty_string = $numeric_type->getBuilder()->addType(new TNonEmptyString())->freeze(); @@ -236,13 +236,13 @@ public static function analyze( $left_non_empty = UnionTypeComparator::isContainedBy( $codebase, $left_type, - $non_empty_string + $non_empty_string, ); $right_non_empty = UnionTypeComparator::isContainedBy( $codebase, $right_type, - $non_empty_string + $non_empty_string, ); $has_non_empty = $left_non_empty || $right_non_empty; @@ -288,9 +288,9 @@ private static function analyzeOperand( IssueBuffer::maybeAdd( new NullOperand( 'Cannot concatenate with a ' . $operand_type, - new CodeLocation($statements_analyzer->getSource(), $operand) + new CodeLocation($statements_analyzer->getSource(), $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -300,9 +300,9 @@ private static function analyzeOperand( IssueBuffer::maybeAdd( new FalseOperand( 'Cannot concatenate with a ' . $operand_type, - new CodeLocation($statements_analyzer->getSource(), $operand) + new CodeLocation($statements_analyzer->getSource(), $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -312,9 +312,9 @@ private static function analyzeOperand( IssueBuffer::maybeAdd( new PossiblyNullOperand( 'Cannot concatenate with a possibly null ' . $operand_type, - new CodeLocation($statements_analyzer->getSource(), $operand) + new CodeLocation($statements_analyzer->getSource(), $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -322,9 +322,9 @@ private static function analyzeOperand( IssueBuffer::maybeAdd( new PossiblyFalseOperand( 'Cannot concatenate with a possibly false ' . $operand_type, - new CodeLocation($statements_analyzer->getSource(), $operand) + new CodeLocation($statements_analyzer->getSource(), $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -337,9 +337,9 @@ private static function analyzeOperand( IssueBuffer::maybeAdd( new MixedOperand( "$side operand cannot be a non-string template param", - new CodeLocation($statements_analyzer->getSource(), $operand) + new CodeLocation($statements_analyzer->getSource(), $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -355,7 +355,7 @@ private static function analyzeOperand( new TString, false, false, - $comparison_result + $comparison_result, ); $operand_type_match = $operand_type_match && $operand_type_part_match; @@ -366,9 +366,9 @@ private static function analyzeOperand( IssueBuffer::maybeAdd( new ImplicitToStringCast( "$side side of concat op expects string, '$operand_type' provided with a __toString method", - new CodeLocation($statements_analyzer->getSource(), $operand) + new CodeLocation($statements_analyzer->getSource(), $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -376,7 +376,7 @@ private static function analyzeOperand( if ($atomic_type instanceof TNamedObject) { $to_string_method_id = new MethodIdentifier( $atomic_type->value, - '__tostring' + '__tostring', ); if ($codebase->methods->methodExists( @@ -389,7 +389,7 @@ private static function analyzeOperand( && !$context->collect_mutations ? $statements_analyzer : null, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), )) { try { $storage = $codebase->methods->getStorage($to_string_method_id); @@ -402,9 +402,9 @@ private static function analyzeOperand( new ImpureMethodCall( 'Cannot call a possibly-mutating method ' . $atomic_type->value . '::__toString from a pure context', - new CodeLocation($statements_analyzer, $operand) + new CodeLocation($statements_analyzer, $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer @@ -425,17 +425,17 @@ private static function analyzeOperand( IssueBuffer::maybeAdd( new PossiblyInvalidOperand( 'Cannot concatenate with a ' . $operand_type, - new CodeLocation($statements_analyzer->getSource(), $operand) + new CodeLocation($statements_analyzer->getSource(), $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidOperand( 'Cannot concatenate with a ' . $operand_type, - new CodeLocation($statements_analyzer->getSource(), $operand) + new CodeLocation($statements_analyzer->getSource(), $operand), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php index c4381115206..7f3e7f5391f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php @@ -43,7 +43,7 @@ public static function analyze( $stmt, $stmt->left, $stmt->right, - 'nondivop' + 'nondivop', ); return; @@ -67,7 +67,7 @@ public static function analyze( $stmt->right, $stmt, $result_type, - $context + $context, ); if (!$result_type) { @@ -81,7 +81,7 @@ public static function analyze( $stmt, $stmt->left, $stmt->right, - 'nondivop' + 'nondivop', ); return; @@ -97,7 +97,7 @@ public static function analyze( $stmt, $stmt->left, $stmt->right, - 'xor' + 'xor', ); return; @@ -111,7 +111,7 @@ public static function analyze( $stmt->right, $stmt, $result_type, - $context + $context, ); if (!$result_type) { @@ -125,7 +125,7 @@ public static function analyze( $stmt, $stmt->left, $stmt->right, - 'div' + 'div', ); return; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php index 8177e730605..d315e36f900 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php @@ -50,11 +50,11 @@ public static function analyze( [ 'stmts' => [ new VirtualExpression( - $stmt->right - ) - ] + $stmt->right, + ), + ], ], - $stmt->getAttributes() + $stmt->getAttributes(), ); return IfElseAnalyzer::analyze($statements_analyzer, $fake_if_stmt, $context) !== false; @@ -79,7 +79,7 @@ public static function analyze( $context, $codebase, $if_scope, - $context->branch_point ?: (int) $stmt->getAttribute('startFilePos') + $context->branch_point ?: (int) $stmt->getAttribute('startFilePos'), ); $left_context = $if_conditional_scope->if_context; @@ -124,7 +124,7 @@ public static function analyze( $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $context->vars_in_scope[$var_id], $type, - $codebase + $codebase, ); } } @@ -146,7 +146,7 @@ public static function analyze( $stmt->left, $context->self, $statements_analyzer, - $codebase + $codebase, ); try { @@ -160,7 +160,7 @@ public static function analyze( $context->self, $statements_analyzer, $codebase, - false + false, ); } catch (ComplicatedExpressionException $e) { return false; @@ -174,7 +174,7 @@ public static function analyze( array_filter( $negated_left_clauses, static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses) - ) + ), ); if (count($negated_left_clauses) === 1 @@ -186,7 +186,7 @@ public static function analyze( } $clauses_for_right_analysis = Algebra::simplifyCNF( - [...$context->clauses, ...$negated_left_clauses] + [...$context->clauses, ...$negated_left_clauses], ); $active_negated_type_assertions = []; @@ -195,7 +195,7 @@ public static function analyze( $clauses_for_right_analysis, $left_cond_id, $left_referenced_var_ids, - $active_negated_type_assertions + $active_negated_type_assertions, ); $changed_var_ids = []; @@ -211,7 +211,7 @@ public static function analyze( $stmt->left, $post_leaving_if_context, $right_context, - $left_assigned_var_ids + $left_assigned_var_ids, ); } @@ -229,7 +229,7 @@ public static function analyze( [], $left_context->inside_loop, new CodeLocation($statements_analyzer->getSource(), $stmt->left), - !$context->inside_negation + !$context->inside_negation, ); } @@ -280,16 +280,16 @@ public static function analyze( $stmt->right, $context->self, $statements_analyzer, - $codebase + $codebase, ); $clauses_for_right_analysis = Context::removeReconciledClauses( $clauses_for_right_analysis, - $right_assigned_var_ids + $right_assigned_var_ids, )[0]; $combined_right_clauses = Algebra::simplifyCNF( - [...$clauses_for_right_analysis, ...$right_clauses] + [...$clauses_for_right_analysis, ...$right_clauses], ); $active_right_type_assertions = []; @@ -298,7 +298,7 @@ public static function analyze( $combined_right_clauses, $right_cond_id, $right_referenced_var_ids, - $active_right_type_assertions + $active_right_type_assertions, ); if ($right_type_assertions) { @@ -315,7 +315,7 @@ public static function analyze( [], $left_context->inside_loop, new CodeLocation($statements_analyzer->getSource(), $stmt->right), - $context->inside_negation + $context->inside_negation, ); } @@ -325,7 +325,7 @@ public static function analyze( $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $context->vars_in_scope[$var_id], $type, - $codebase + $codebase, ); } } @@ -341,7 +341,7 @@ public static function analyze( $context->inside_loop, [], new CodeLocation($statements_analyzer->getSource(), $stmt->left), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $context->vars_in_scope[$var_id] = $left_inferred_reconciled; @@ -354,12 +354,12 @@ public static function analyze( $context->cond_referenced_var_ids = array_merge( $right_context->cond_referenced_var_ids, - $context->cond_referenced_var_ids + $context->cond_referenced_var_ids, ); $context->assigned_var_ids = array_merge( $context->assigned_var_ids, - $right_context->assigned_var_ids + $right_context->assigned_var_ids, ); if ($context->if_body_context) { @@ -370,25 +370,25 @@ public static function analyze( $if_body_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, $if_body_context->vars_in_scope[$var_id], - $codebase + $codebase, ); } elseif (isset($left_context->vars_in_scope[$var_id])) { $if_body_context->vars_in_scope[$var_id] = Type::combineUnionTypes( $type, $left_context->vars_in_scope[$var_id], - $codebase + $codebase, ); } } $if_body_context->cond_referenced_var_ids = array_merge( $context->cond_referenced_var_ids, - $if_body_context->cond_referenced_var_ids + $if_body_context->cond_referenced_var_ids, ); $if_body_context->assigned_var_ids = array_merge( $context->assigned_var_ids, - $if_body_context->assigned_var_ids + $if_body_context->assigned_var_ids, ); $if_body_context->updateChecks($context); @@ -396,7 +396,7 @@ public static function analyze( $context->vars_possibly_in_scope = array_merge( $right_context->vars_possibly_in_scope, - $context->vars_possibly_in_scope + $context->vars_possibly_in_scope, ); return true; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php index 2380f1201d8..58e8ad5ab96 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php @@ -64,7 +64,7 @@ public static function analyze( $statements_analyzer, $stmt, $context, - $from_stmt + $from_stmt, ); $context->inside_general_use = $was_inside_general_use; @@ -84,7 +84,7 @@ public static function analyze( $statements_analyzer, $stmt, $context, - $from_stmt + $from_stmt, ); $context->inside_general_use = $was_inside_general_use; @@ -98,7 +98,7 @@ public static function analyze( $expr_result = CoalesceAnalyzer::analyze( $statements_analyzer, $stmt, - $context + $context, ); self::addDataFlow( @@ -106,7 +106,7 @@ public static function analyze( $stmt, $stmt->left, $stmt->right, - 'coalesce' + 'coalesce', ); return $expr_result; @@ -140,7 +140,7 @@ public static function analyze( $stmt->left, $stmt->right, $context, - $result_type + $result_type, ); if ($result_type) { @@ -160,7 +160,7 @@ public static function analyze( $statements_analyzer->data_flow_graph->addNode($new_parent_node); $stmt_type = $stmt_type->setParentNodes([ - $new_parent_node->id => $new_parent_node + $new_parent_node->id => $new_parent_node, ]); $codebase = $statements_analyzer->getCodebase(); @@ -176,7 +176,7 @@ public static function analyze( $new_parent_node, 'concat', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -188,7 +188,7 @@ public static function analyze( $new_parent_node, 'concat', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -206,9 +206,9 @@ public static function analyze( [ new TLiteralInt(-1), new TLiteralInt(0), - new TLiteralInt(1) - ] - ) + new TLiteralInt(1), + ], + ), ); self::addDataFlow( @@ -216,7 +216,7 @@ public static function analyze( $stmt, $stmt->left, $stmt->right, - '<=>' + '<=>', ); return true; @@ -249,9 +249,9 @@ public static function analyze( IssueBuffer::maybeAdd( new InvalidOperand( 'Cannot compare ' . $stmt_left_type->getId() . ' to ' . $stmt_right_type->getId(), - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -292,18 +292,18 @@ public static function analyze( new DocblockTypeContradiction( $atomic_right_type . ' string length is not ' . $string_length, new CodeLocation($statements_analyzer, $stmt), - "strlen($atomic_right_type) !== $string_length" + "strlen($atomic_right_type) !== $string_length", ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new TypeDoesNotContainType( $atomic_right_type . ' string length is not ' . $string_length, new CodeLocation($statements_analyzer, $stmt), - "strlen($atomic_right_type) !== $string_length" + "strlen($atomic_right_type) !== $string_length", ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { @@ -312,18 +312,18 @@ public static function analyze( new RedundantConditionGivenDocblockType( $atomic_right_type . ' string length is never ' . $string_length, new CodeLocation($statements_analyzer, $stmt), - "strlen($atomic_right_type) !== $string_length" + "strlen($atomic_right_type) !== $string_length", ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantCondition( $atomic_right_type . ' string length is never ' . $string_length, new CodeLocation($statements_analyzer, $stmt), - "strlen($atomic_right_type) !== $string_length" + "strlen($atomic_right_type) !== $string_length", ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -344,7 +344,7 @@ public static function analyze( $statements_analyzer, $stmt, $stmt_left_type, - $stmt_right_type + $stmt_right_type, ); } @@ -353,7 +353,7 @@ public static function analyze( $stmt, $stmt->left, $stmt->right, - 'comparison' + 'comparison', ); return true; @@ -362,7 +362,7 @@ public static function analyze( NonComparisonOpAnalyzer::analyze( $statements_analyzer, $stmt, - $context + $context, ); return true; @@ -403,7 +403,7 @@ public static function addDataFlow( $statements_analyzer->data_flow_graph->addNode($new_parent_node); $result_type = $result_type->setParentNodes([ - $new_parent_node->id => $new_parent_node + $new_parent_node->id => $new_parent_node, ]); $statements_analyzer->node_data->setType($stmt, $result_type); @@ -432,19 +432,19 @@ public static function addDataFlow( $statements_analyzer->data_flow_graph->addPath( $new_parent_node, new DataFlowNode('variable-use', 'variable use', null), - 'used-by-instance-property' + 'used-by-instance-property', ); } if ($left instanceof PhpParser\Node\Expr\StaticPropertyFetch) { $statements_analyzer->data_flow_graph->addPath( $new_parent_node, new DataFlowNode('variable-use', 'variable use', null), - 'use-in-static-property' + 'use-in-static-property', ); } elseif (!$left instanceof PhpParser\Node\Expr\Variable) { $statements_analyzer->data_flow_graph->addPath( $new_parent_node, new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } } @@ -466,8 +466,8 @@ private static function checkForImpureEqualityComparison( $storage = $codebase->methods->getStorage( new MethodIdentifier( $atomic_type->value, - '__tostring' - ) + '__tostring', + ), ); } catch (UnexpectedValueException $e) { continue; @@ -485,9 +485,9 @@ private static function checkForImpureEqualityComparison( new ImpureMethodCall( 'Cannot call a possibly-mutating method ' . $atomic_type->value . '::__toString from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -500,8 +500,8 @@ private static function checkForImpureEqualityComparison( $storage = $codebase->methods->getStorage( new MethodIdentifier( $atomic_type->value, - '__tostring' - ) + '__tostring', + ), ); } catch (UnexpectedValueException $e) { continue; @@ -518,9 +518,9 @@ private static function checkForImpureEqualityComparison( new ImpureMethodCall( 'Cannot call a possibly-mutating method ' . $atomic_type->value . '::__toString from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BitwiseNotAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BitwiseNotAnalyzer.php index 9fa093ca4d7..00542cbb5e8 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BitwiseNotAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BitwiseNotAnalyzer.php @@ -76,17 +76,17 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyInvalidOperand( $message, - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidOperand( $message, - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php index f97c320d8ea..fa053702791 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php @@ -44,7 +44,7 @@ public static function analyze( } $stmt_type = new Union([$stmt_type], [ - 'parent_nodes' => $expr_type->parent_nodes + 'parent_nodes' => $expr_type->parent_nodes, ]); } else { $stmt_type = Type::getBool(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index c2a8bf771a7..d47b07adb55 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -137,9 +137,9 @@ public static function checkArgumentMatches( 'Argument ' . ($argument_offset + 1) . ' of ' . $cased_method_id . ' cannot be mixed, expecting ' . $param_type, new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -180,9 +180,9 @@ public static function checkArgumentMatches( 'Argument ' . ($argument_offset + 1) . ' of ' . $cased_method_id . ' expects a non-literal value, but ' . $arg_value_type->getId() . ' provided', new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -206,7 +206,7 @@ public static function checkArgumentMatches( $class_generic_params, $template_result, $specialize_taint, - $in_call_map + $in_call_map, ) === false) { return false; } @@ -278,7 +278,7 @@ private static function checkFunctionLikeTypeMatches( true, false, $static_classlike_storage->final ?? false, - true + true, ); if ($class_generic_params) { @@ -305,7 +305,7 @@ private static function checkFunctionLikeTypeMatches( $arg_value_type, $argument_offset, $context->self, - $context->calling_function_id ?: $context->calling_method_id + $context->calling_function_id ?: $context->calling_method_id, ); $arg_value_type = TemplateStandinTypeReplacer::replace( @@ -316,7 +316,7 @@ private static function checkFunctionLikeTypeMatches( $arg_value_type, $argument_offset, $context->self, - $context->calling_function_id ?: $context->calling_method_id + $context->calling_function_id ?: $context->calling_method_id, ); } @@ -346,14 +346,14 @@ private static function checkFunctionLikeTypeMatches( $arg_atomic_type, $codebase, $key_type, - $arg_type_param + $arg_type_param, ); } } if (!$arg_type_param) { $arg_type_param = new Union([ - new TMixed() + new TMixed(), ], ['parent_nodes' => $arg_value_type->parent_nodes]); } } @@ -369,32 +369,32 @@ private static function checkFunctionLikeTypeMatches( && (!$method_id || $method_id->method_name !== '__construct') ? $context->self : null, - $context->calling_method_id ?: $context->calling_function_id + $context->calling_method_id ?: $context->calling_function_id, ); foreach ($bindable_template_params as $template_type) { if (!isset( $template_result->lower_bounds [$template_type->param_name] - [$template_type->defining_class] + [$template_type->defining_class], )) { if (isset( $template_result->upper_bounds [$template_type->param_name] - [$template_type->defining_class] + [$template_type->defining_class], )) { $template_result->lower_bounds[$template_type->param_name][$template_type->defining_class] = [ new TemplateBound( $template_result->upper_bounds [$template_type->param_name] - [$template_type->defining_class]->type - ) + [$template_type->defining_class]->type, + ), ]; } else { $template_result->lower_bounds[$template_type->param_name][$template_type->defining_class] = [ new TemplateBound( - $template_type->as - ) + $template_type->as, + ), ]; } } @@ -409,7 +409,7 @@ private static function checkFunctionLikeTypeMatches( true, false, $static_classlike_storage->final ?? false, - true + true, ); } @@ -419,7 +419,7 @@ private static function checkFunctionLikeTypeMatches( $function_param->signature_type, $classlike_storage->name ?? null, $static_classlike_storage->name ?? null, - $parent_class + $parent_class, ) : null; @@ -442,9 +442,9 @@ private static function checkFunctionLikeTypeMatches( 'Argument ' . ($argument_offset + 1) . ' of ' . $cased_method_id . ' cannot unpack ' . $arg_value_type->getId() . ', expecting iterable', new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); if ($cased_method_id) { @@ -461,7 +461,7 @@ private static function checkFunctionLikeTypeMatches( $arg_value_type, $arg->value, $context, - $specialize_taint + $specialize_taint, ); } @@ -497,7 +497,7 @@ private static function checkFunctionLikeTypeMatches( $arg_value_type_atomic = ConstantTypeResolver::resolve( $codebase->classlikes, $function_param->default_type, - $statements_analyzer + $statements_analyzer, ); $arg_value_type = new Union([$arg_value_type_atomic]); @@ -521,9 +521,9 @@ private static function checkFunctionLikeTypeMatches( . ' called with named unpacked array ' . $unpacked_atomic_array->getId() . ' (array with string keys)', new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { @@ -539,7 +539,7 @@ private static function checkFunctionLikeTypeMatches( if (!UnionTypeComparator::isContainedBy( $codebase, $key_type, - Type::getArrayKey() + Type::getArrayKey(), )) { $invalid_key = true; @@ -562,9 +562,9 @@ private static function checkFunctionLikeTypeMatches( new $issue_type( 'Tried to unpack non-iterable ' . $arg_value_type->getId(), new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } if ($invalid_key) { @@ -575,9 +575,9 @@ private static function checkFunctionLikeTypeMatches( . ' with invalid key (must be ' . ($codebase->analysis_php_version_id < 8_00_00 ? 'int' : 'int|string') . ')', new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } if ($invalid_string_key) { @@ -586,9 +586,9 @@ private static function checkFunctionLikeTypeMatches( new $issue_type( 'String keys not supported in unpacked arguments', new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -597,9 +597,9 @@ private static function checkFunctionLikeTypeMatches( . ' called with named unpacked iterable ' . $arg_value_type->getId() . ' (iterable with string keys)', new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -612,9 +612,9 @@ private static function checkFunctionLikeTypeMatches( new NamedArgumentNotAllowed( 'Method ' . $cased_method_id. ' called with named argument ' . $arg->name->name, new CodeLocation($statements_analyzer->getSource(), $arg->value), - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -644,7 +644,7 @@ private static function checkFunctionLikeTypeMatches( $unpacked_atomic_array, $specialize_taint, $in_call_map, - $function_call_location + $function_call_location, ) === false) { return false; } @@ -692,7 +692,7 @@ public static function verifyType( = Type::combineUnionTypes( $codebase->analyzer->possible_method_param_types[$id_lc][$argument_offset] ?? null, $input_type, - $codebase + $codebase, ); } } @@ -709,7 +709,7 @@ public static function verifyType( $input_type, $input_expr, $context, - $specialize_taint + $specialize_taint, ); } @@ -735,7 +735,7 @@ public static function verifyType( foreach ($input_type->parent_nodes as $parent_node) { $origin_locations = [ ...$origin_locations, - ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node) + ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node), ]; } } @@ -753,9 +753,9 @@ public static function verifyType( $param_type, $arg_location, $cased_method_id, - $origin_location + $origin_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); if ($input_type->isMixed()) { @@ -774,7 +774,7 @@ public static function verifyType( $signature_param_type, $context, $unpack, - $unpacked_atomic_array + $unpacked_atomic_array, ); } } @@ -791,7 +791,7 @@ public static function verifyType( $input_type, $input_expr, $context, - $specialize_taint + $specialize_taint, ); } @@ -804,9 +804,9 @@ public static function verifyType( IssueBuffer::maybeAdd( new NoValue( 'All possible types for this argument were invalidated - This may be dead code', - $arg_location + $arg_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return null; @@ -843,7 +843,7 @@ public static function verifyType( $atomic_type, null, $statements_analyzer, - true + true, ); if ($candidate_callable) { @@ -862,7 +862,7 @@ public static function verifyType( $param_type, true, true, - $union_comparison_results + $union_comparison_results, ); $replace_input_type = false; @@ -884,7 +884,7 @@ public static function verifyType( $input_type, $input_expr, $context, - $specialize_taint + $specialize_taint, ); if ($function_param->assert_untainted) { @@ -908,7 +908,7 @@ public static function verifyType( $input_type_part, $codebase, $context->calling_method_id, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), ); if ($potential_method_id && $potential_method_id !== 'not-callable') { @@ -920,7 +920,7 @@ public static function verifyType( $parts = explode('::', $input_type_part->value); $potential_method_ids[] = new MethodIdentifier( $parts[0], - strtolower($parts[1]) + strtolower($parts[1]), ); } } @@ -933,7 +933,7 @@ public static function verifyType( $statements_analyzer, $statements_analyzer->getFilePath(), true, - $context->insideUse() + $context->insideUse(), ); } } @@ -961,7 +961,7 @@ public static function verifyType( foreach ($input_type->parent_nodes as $parent_node) { $origin_locations = [ ...$origin_locations, - ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node) + ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node), ]; } } @@ -978,9 +978,9 @@ public static function verifyType( ', but parent type ' . $input_type->getId() . ' provided', $arg_location, $cased_method_id, - $origin_location + $origin_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($cased_method_id !== 'echo' && $cased_method_id !== 'print') { IssueBuffer::maybeAdd( @@ -988,9 +988,9 @@ public static function verifyType( 'Argument ' . ($argument_offset + 1) . $method_identifier . ' expects ' . $param_type->getId() . ', but parent type ' . $input_type->getId() . ' provided', $arg_location, - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1000,9 +1000,9 @@ public static function verifyType( new ImplicitToStringCast( 'Argument ' . ($argument_offset + 1) . $method_identifier . ' expects ' . $param_type->getId() . ', but ' . $input_type->getId() . ' provided with a __toString method', - $arg_location + $arg_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1012,7 +1012,7 @@ public static function verifyType( $input_type, $param_type, true, - true + true, ); $type = ($input_type->possibly_undefined ? 'possibly undefined ' : '') . $input_type->getId(); @@ -1023,9 +1023,9 @@ public static function verifyType( 'Argument ' . ($argument_offset + 1) . $method_identifier . ' expects ' . $param_type->getId() . ', but ' . $type . ' provided', $arg_location, - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } elseif ($types_can_be_identical) { @@ -1034,9 +1034,9 @@ public static function verifyType( 'Argument ' . ($argument_offset + 1) . $method_identifier . ' expects ' . $param_type->getId() . ', but possibly different type ' . $type . ' provided', $arg_location, - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -1050,9 +1050,9 @@ public static function verifyType( : '') . ' provided', $arg_location, - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1068,7 +1068,7 @@ public static function verifyType( $param_type, $arg_location, $input_expr, - $context + $context, ); return null; @@ -1081,9 +1081,9 @@ public static function verifyType( 'Argument ' . ($argument_offset + 1) . $method_identifier . ' cannot be null, ' . 'null value provided to parameter with type ' . $param_type->getId(), $arg_location, - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return null; @@ -1095,9 +1095,9 @@ public static function verifyType( 'Argument ' . ($argument_offset + 1) . $method_identifier . ' cannot be null, possibly ' . 'null value provided', $arg_location, - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1114,9 +1114,9 @@ public static function verifyType( 'Argument ' . ($argument_offset + 1) . $method_identifier . ' cannot be false, ' . $param_type->getId() . ' value expected', $arg_location, - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return null; @@ -1128,9 +1128,9 @@ public static function verifyType( 'Argument ' . ($argument_offset + 1) . $method_identifier . ' cannot be false, possibly ' . $param_type->getId() . ' value expected', $arg_location, - $cased_method_id + $cased_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1151,7 +1151,7 @@ public static function verifyType( $signature_param_type, $context, $unpack, - $unpacked_atomic_array + $unpacked_atomic_array, ); } @@ -1182,7 +1182,7 @@ private static function verifyExplicitParam( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(true) + new ClassLikeNameOptions(true), ) === false ) { return; @@ -1201,7 +1201,7 @@ private static function verifyExplicitParam( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(true) + new ClassLikeNameOptions(true), ) === false ) { return; @@ -1232,7 +1232,7 @@ private static function verifyExplicitParam( if (!$can_be_callable_like_array) { $function_ids = CallAnalyzer::getFunctionIdsFromCallableArg( $statements_analyzer, - $input_expr + $input_expr, ); foreach ($function_ids as $function_id) { @@ -1272,7 +1272,7 @@ private static function verifyExplicitParam( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(true) + new ClassLikeNameOptions(true), ) === false ) { return; @@ -1280,12 +1280,12 @@ private static function verifyExplicitParam( $function_id_part = new MethodIdentifier( $callable_fq_class_name, - strtolower($method_name) + strtolower($method_name), ); $call_method_id = new MethodIdentifier( $callable_fq_class_name, - '__call' + '__call', ); if (!$codebase->classOrInterfaceOrEnumExists($callable_fq_class_name)) { @@ -1304,7 +1304,7 @@ private static function verifyExplicitParam( $codebase, $non_existent_method_ids[0], $arg_location, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false ) { return; @@ -1317,7 +1317,7 @@ private static function verifyExplicitParam( $statements_analyzer, $function_id, $arg_location, - false + false, ) === false ) { return; @@ -1369,7 +1369,7 @@ private static function coerceValueAfterGatekeeperArgument( [...$input_atomic_type->type_params, ...$new_type_params], $input_atomic_type->remapped_params, false, - $input_atomic_type->extra_types + $input_atomic_type->extra_types, ); } } @@ -1388,7 +1388,7 @@ private static function coerceValueAfterGatekeeperArgument( $var_id = ExpressionIdentifier::getVarId( $input_expr, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($var_id) { @@ -1412,7 +1412,7 @@ private static function coerceValueAfterGatekeeperArgument( $input_type = $signature_param_type->setProperties([ 'ignore_nullable_issues' => $signature_param_type->isNullable(), 'parent_nodes' => $parent_nodes, - 'by_ref' => $by_ref + 'by_ref' => $by_ref, ]); } @@ -1428,7 +1428,7 @@ private static function coerceValueAfterGatekeeperArgument( if ($unpacked_atomic_array instanceof TArray) { $unpacked_atomic_array = $unpacked_atomic_array->setTypeParams([ $unpacked_atomic_array->type_params[0], - $input_type + $input_type, ]); $context->vars_in_scope[$var_id] = new Union([$unpacked_atomic_array]); @@ -1446,7 +1446,7 @@ private static function coerceValueAfterGatekeeperArgument( $context->vars_in_scope[$var_id] = new Union([ new TArray([ Type::getInt(), - $input_type + $input_type, ]), ]); } @@ -1505,7 +1505,7 @@ private static function processTaintedness( $context, $input_type, $expr, - false + false, ); } @@ -1517,7 +1517,7 @@ private static function processTaintedness( $statements_analyzer->data_flow_graph instanceof TaintFlowGraph ? $function_param->location : null, - $function_call_location + $function_call_location, ); } else { $method_node = DataFlowNode::getForMethodArgument( @@ -1526,7 +1526,7 @@ private static function processTaintedness( $argument_offset, $statements_analyzer->data_flow_graph instanceof TaintFlowGraph ? $function_param->location - : null + : null, ); if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph @@ -1541,14 +1541,14 @@ private static function processTaintedness( foreach ($class_storage->dependent_classlikes as $dependent_classlike_lc => $_) { $dependent_classlike_storage = $codebase->classlike_storage_provider->get( - $dependent_classlike_lc + $dependent_classlike_lc, ); $new_sink = DataFlowNode::getForMethodArgument( $dependent_classlike_lc . '::' . $method_name, $dependent_classlike_storage->name . '::' . $cased_method_name, $argument_offset, $arg_location, - null + null, ); $statements_analyzer->data_flow_graph->addNode($new_sink); @@ -1557,7 +1557,7 @@ private static function processTaintedness( $new_sink, 'arg', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -1572,7 +1572,7 @@ private static function processTaintedness( $codebase->methods->getCasedMethodId($declaring_method_id), $argument_offset, $arg_location, - null + null, ); $statements_analyzer->data_flow_graph->addNode($new_sink); @@ -1581,7 +1581,7 @@ private static function processTaintedness( $new_sink, 'arg', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -1590,7 +1590,7 @@ private static function processTaintedness( $argument_value_node = DataFlowNode::getForAssignment( 'call to ' . $cased_method_id, - $arg_location + $arg_location, ); $statements_analyzer->data_flow_graph->addNode($argument_value_node); @@ -1600,7 +1600,7 @@ private static function processTaintedness( $method_node, 'arg', $added_taints, - $removed_taints + $removed_taints, ); foreach ($input_type->parent_nodes as $parent_node) { @@ -1610,7 +1610,7 @@ private static function processTaintedness( $argument_value_node, 'arg', $added_taints, - $removed_taints + $removed_taints, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentMapPopulator.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentMapPopulator.php index ff8c2058ff5..fbbc5e24ea6 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentMapPopulator.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentMapPopulator.php @@ -47,7 +47,7 @@ public static function recordArgumentPositions( $method_name_and_first_paren_source_code = substr( $file_content, $stmt->getStartFilePos(), - $method_name_and_first_paren_source_code_length + $method_name_and_first_paren_source_code_length, ); $method_name_and_first_paren_tokens = token_get_all('getEndFilePos(), $function_reference, - $argument_number + $argument_number, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php index e0d2005802c..33fbdbcae12 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php @@ -97,7 +97,7 @@ public static function analyze( $statements_analyzer, $args, $context, - $method_id + $method_id, ) === false ) { return false; @@ -123,7 +123,7 @@ public static function analyze( if (self::evaluateArbitraryParam( $statements_analyzer, $arg, - $context + $context, ) === false) { return false; } @@ -178,7 +178,7 @@ public static function analyze( $method_id, $argument_offset, $arg, - $context + $context, ) === false) { return false; } @@ -208,7 +208,7 @@ public static function analyze( $statements_analyzer, $template_result ?? new TemplateResult([], []), $function_storage, - $param + $param, ); } elseif (($arg->value instanceof PhpParser\Node\Expr\Closure || $arg->value instanceof PhpParser\Node\Expr\ArrowFunction) @@ -223,7 +223,7 @@ public static function analyze( $template_result ?? new TemplateResult([], []), $argument_offset, $arg, - $param + $param, ); } @@ -238,7 +238,7 @@ public static function analyze( false, null, false, - $high_order_template_result + $high_order_template_result, ) === false) { $context->inside_call = $was_inside_call; @@ -256,7 +256,7 @@ public static function analyze( $argument_offset, $arg, $context, - $template_result + $template_result, ); } @@ -273,7 +273,7 @@ public static function analyze( $inferred_arg_type, $argument_offset, $context->self, - $context->calling_method_id ?: $context->calling_function_id + $context->calling_method_id ?: $context->calling_function_id, ); } @@ -309,7 +309,7 @@ private static function handleArrayMapFilterArrayArg( $replace_template_result = new TemplateResult( $template_types, - [] + [], ); $existing_type = $statements_analyzer->node_data->getType($arg->value); @@ -322,10 +322,10 @@ private static function handleArrayMapFilterArrayArg( new TTemplateParam( 'ArrayValue' . $argument_offset, Type::getMixed(), - $method_id - ) - ]) - ]) + $method_id, + ), + ]), + ]), ]), $replace_template_result, $codebase, @@ -333,7 +333,7 @@ private static function handleArrayMapFilterArrayArg( $existing_type, $argument_offset, $context->self, - $context->calling_method_id ?: $context->calling_function_id + $context->calling_method_id ?: $context->calling_function_id, ); if ($replace_template_result->lower_bounds) { @@ -389,7 +389,7 @@ private static function getHighOrderFuncStorage( $method_id = new MethodIdentifier( $lhs_type->value, - strtolower((string)$function_like_call->name) + strtolower((string)$function_like_call->name), ); return $codebase->methods->getStorage($method_id); @@ -400,7 +400,7 @@ private static function getHighOrderFuncStorage( ) { $method_id = new MethodIdentifier( (string)$function_like_call->class->getAttribute('resolvedName'), - strtolower($function_like_call->name->name) + strtolower($function_like_call->name->name), ); return $codebase->methods->getStorage($method_id); @@ -457,7 +457,7 @@ private static function handleHighOrderFuncCallArg( ) { $callable_from_invokable = CallableTypeComparator::getCallableFromAtomic( $codebase, - $input_hof_atomic + $input_hof_atomic, ); if ($callable_from_invokable) { @@ -492,7 +492,7 @@ private static function handleHighOrderFuncCallArg( $replaced_container_hof_atomic = TemplateInferredTypeReplacer::replace( $replaced_container_hof_atomic, $inferred_template_result, - $codebase + $codebase, ); /** @var TClosure|TCallable $container_hof_atomic */ @@ -515,7 +515,7 @@ private static function handleHighOrderFuncCallArg( $high_order_template_result, $codebase, null, - $container_hof_atomic->params[$offset]->type + $container_hof_atomic->params[$offset]->type, ); } } @@ -552,22 +552,22 @@ private static function handleClosureArg( new TTemplateParam( $template_name, Type::getMixed(), - $method_id - ) + $method_id, + ), ]); $function_like_params[] = new FunctionLikeParameter( 'function', false, $t, - $t + $t, ); } $replaced_type = new Union([ new TCallable( 'callable', - array_reverse($function_like_params) - ) + array_reverse($function_like_params), + ), ]); } else { $replaced_type = $param->type; @@ -578,13 +578,13 @@ private static function handleClosureArg( static fn(array $template_map): array => array_map( static fn(array $lower_bounds): Union => TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $lower_bounds, - $codebase + $codebase, ), - $template_map + $template_map, ), - $template_result->lower_bounds + $template_result->lower_bounds, ), - [] + [], ); $replaced_type = TemplateStandinTypeReplacer::replace( @@ -595,13 +595,13 @@ private static function handleClosureArg( null, null, null, - $context->calling_method_id ?: $context->calling_function_id + $context->calling_method_id ?: $context->calling_function_id, ); $replaced_type = TemplateInferredTypeReplacer::replace( $replaced_type, $replace_template_result, - $codebase + $codebase, ); $closure_id = strtolower($statements_analyzer->getFilePath()) @@ -612,7 +612,7 @@ private static function handleClosureArg( try { $closure_storage = $codebase->getClosureStorage( $statements_analyzer->getFilePath(), - $closure_id + $closure_id, ); } catch (UnexpectedValueException $e) { return; @@ -649,7 +649,7 @@ private static function handleClosureArg( false, false, true, - true + true, ); } @@ -657,7 +657,7 @@ private static function handleClosureArg( $type_match_found = UnionTypeComparator::isContainedBy( $codebase, $replaced_param_type, - $param_storage->type + $param_storage->type, ); if (!$type_match_found) { @@ -668,7 +668,7 @@ private static function handleClosureArg( $newly_inferred_type = Type::combineUnionTypes( $newly_inferred_type, $replaced_param_type, - $codebase + $codebase, ); } } @@ -687,7 +687,7 @@ private static function handleClosureArg( $args[1 - $argument_offset]->value, null, $param_storage->type, - $temp + $temp, ); } } @@ -732,7 +732,7 @@ public static function checkArgumentsMatch( $is_variadic = Functions::isVariadic( $codebase, strtolower($method_id), - $statements_analyzer->getRootFilePath() + $statements_analyzer->getRootFilePath(), ); } else { $is_variadic = $codebase->methods->isVariadic($method_id); @@ -806,7 +806,7 @@ public static function checkArgumentsMatch( $template_result, $args, $function_params, - $last_param + $last_param, ); } @@ -824,7 +824,7 @@ public static function checkArgumentsMatch( $default_type_atomic = ConstantTypeResolver::resolve( $codebase->classlikes, $function_params[$i]->default_type, - $statements_analyzer + $statements_analyzer, ); $default_type = new Union([$default_type_atomic]); @@ -843,14 +843,14 @@ public static function checkArgumentsMatch( $i, $function_storage->allow_named_arg_calls ?? true, new VirtualArg( - StubsGenerator::getExpressionFromType($default_type) + StubsGenerator::getExpressionFromType($default_type), ), $default_type, $context, $class_generic_params, $template_result, $function_storage->specialize_call ?? true, - $in_call_map + $in_call_map, ); } } @@ -871,9 +871,9 @@ public static function checkArgumentsMatch( new InvalidNamedArgument( 'Cannot use positional argument after named argument', new CodeLocation($statements_analyzer, $arg), - (string)$method_id + (string)$method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -912,9 +912,9 @@ public static function checkArgumentsMatch( 'Parameter $' . $key_type->value . ' has already been used in ' . ($cased_method_id ?: $method_id), new CodeLocation($statements_analyzer, $arg), - (string)$method_id + (string)$method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -932,9 +932,9 @@ public static function checkArgumentsMatch( 'Parameter $' . $key_type->value . ' does not exist on function ' . ($cased_method_id ?: $method_id), new CodeLocation($statements_analyzer, $arg), - (string)$method_id + (string)$method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -952,9 +952,9 @@ public static function checkArgumentsMatch( 'Parameter $' . $arg->name->name . ' has already been used in ' . ($cased_method_id ?: $method_id), new CodeLocation($statements_analyzer, $arg->name), - (string) $method_id + (string) $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -972,9 +972,9 @@ public static function checkArgumentsMatch( 'Parameter $' . $arg->name->name . ' does not exist on function ' . ($cased_method_id ?: $method_id), new CodeLocation($statements_analyzer, $arg->name), - (string) $method_id + (string) $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } elseif ($function_param_count > $argument_offset) { @@ -1004,7 +1004,7 @@ public static function checkArgumentsMatch( $argument_offset, $arg, $context, - $template_result + $template_result, ) === false) { return null; } @@ -1030,7 +1030,7 @@ public static function checkArgumentsMatch( $class_generic_params, $template_result, $function_storage->specialize_call ?? true, - $in_call_map + $in_call_map, ) === false) { return false; } @@ -1053,14 +1053,14 @@ public static function checkArgumentsMatch( $cased_method_id, $argument_offset, $function_param->location, - $code_location + $code_location, ); } else { $sink = TaintSink::getForMethodArgument( $cased_method_id, $cased_method_id, $argument_offset, - $function_param->location + $function_param->location, ); } @@ -1078,18 +1078,18 @@ public static function checkArgumentsMatch( new TooFewArguments( 'Too few arguments for ' . $method_id, $code_location, - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($method_id === 'array_filter' && count($args) < 1) { IssueBuffer::maybeAdd( new TooFewArguments( 'Too few arguments for ' . $method_id, $code_location, - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1098,7 +1098,7 @@ public static function checkArgumentsMatch( $context, $args, $method_id, - $context->check_functions + $context->check_functions, ); return null; @@ -1111,9 +1111,9 @@ public static function checkArgumentsMatch( new TooFewArguments( 'Cannot call get_class() without argument outside of class scope', $code_location, - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return null; @@ -1132,7 +1132,7 @@ public static function checkArgumentsMatch( $in_call_map, $method_id, $cased_method_id, - $code_location + $code_location, ); return null; @@ -1175,9 +1175,9 @@ private static function handlePossiblyMatchingByRefParam( IssueBuffer::maybeAdd( new InvalidPassByReference( 'Parameter ' . ($argument_offset + 1) . ' of ' . $cased_method_id . ' expects a variable', - new CodeLocation($statements_analyzer->getSource(), $arg->value) + new CodeLocation($statements_analyzer->getSource(), $arg->value), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return false; @@ -1190,7 +1190,7 @@ private static function handlePossiblyMatchingByRefParam( 'reset', 'end', 'next', 'prev', 'array_pop', 'array_shift', 'array_push', 'array_unshift', 'socket_select', 'array_splice', ], - true + true, )) { $by_ref_type = null; $by_ref_out_type = null; @@ -1226,14 +1226,14 @@ private static function handlePossiblyMatchingByRefParam( $statements_analyzer->node_data->getType($arg->value), $argument_offset, $context->self, - $context->calling_method_id ?: $context->calling_function_id + $context->calling_method_id ?: $context->calling_function_id, ); if ($template_result->lower_bounds) { $original_by_ref_type = TemplateInferredTypeReplacer::replace( $original_by_ref_type, $template_result, - $codebase + $codebase, ); $by_ref_type = $original_by_ref_type; @@ -1251,14 +1251,14 @@ private static function handlePossiblyMatchingByRefParam( $statements_analyzer->node_data->getType($arg->value), $argument_offset, $context->self, - $context->calling_method_id ?: $context->calling_function_id + $context->calling_method_id ?: $context->calling_function_id, ); if ($template_result->lower_bounds) { $original_by_ref_out_type = TemplateInferredTypeReplacer::replace( $original_by_ref_out_type, $template_result, - $codebase + $codebase, ); $by_ref_out_type = $original_by_ref_out_type; @@ -1284,7 +1284,7 @@ private static function handlePossiblyMatchingByRefParam( $by_ref_out_type ?: $by_ref_type, $context, $method_id && (strpos($method_id, '::') !== false || !InternalCallMapHandler::inCallMap($method_id)), - $check_null_ref + $check_null_ref, ); } @@ -1342,7 +1342,7 @@ private static function evaluateArbitraryParam( $var_id = ExpressionIdentifier::getVarId( $arg->value, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); } @@ -1361,9 +1361,9 @@ private static function evaluateArbitraryParam( new PossiblyUndefinedVariable( 'Variable ' . $var_id . ' must be defined prior to use within an unknown function or method', - new CodeLocation($statements_analyzer->getSource(), $arg->value) + new CodeLocation($statements_analyzer->getSource(), $arg->value), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1379,7 +1379,7 @@ private static function evaluateArbitraryParam( $context->removeVarFromConflictingClauses( $var_id, $context->vars_in_scope[$var_id], - $statements_analyzer + $statements_analyzer, ); $t = $context->vars_in_scope[$var_id]->getBuilder(); @@ -1388,8 +1388,8 @@ private static function evaluateArbitraryParam( $t->removeType('array'); $t->addType( new TArray( - [Type::getArrayKey(), Type::getMixed()] - ) + [Type::getArrayKey(), Type::getMixed()], + ), ); } } @@ -1413,7 +1413,7 @@ private static function handleByRefFunctionArg( $var_id = ExpressionIdentifier::getVarId( $arg->value, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $builtin_array_functions = [ @@ -1426,7 +1426,7 @@ private static function handleByRefFunctionArg( && in_array( $method_id, $builtin_array_functions, - true + true, )) ) { $was_inside_assignment = $context->inside_assignment; @@ -1437,7 +1437,7 @@ private static function handleByRefFunctionArg( if (ExpressionAnalyzer::analyze( $statements_analyzer, $arg->value, - $context + $context, ) === false) { $context->inside_assignment = $was_inside_assignment; @@ -1453,7 +1453,7 @@ private static function handleByRefFunctionArg( && in_array( $method_id, $builtin_array_functions, - true + true, ) ) { if (in_array($method_id, ['array_pop', 'array_shift'], true)) { @@ -1461,7 +1461,7 @@ private static function handleByRefFunctionArg( $statements_analyzer, $arg, $context, - $method_id === 'array_shift' + $method_id === 'array_shift', ); return null; @@ -1492,7 +1492,7 @@ private static function handleByRefFunctionArg( $by_ref_type, $by_ref_type, $context, - false + false, ); return null; @@ -1503,7 +1503,7 @@ private static function handleByRefFunctionArg( if (ExpressionAnalyzer::analyze( $statements_analyzer, $arg->value, - $context + $context, ) === false) { return false; } @@ -1553,7 +1553,7 @@ private static function getProvisionalTemplateResultForFunctionLike( $self_fq_class_name, $calling_class_storage, $function_storage->template_types ?: [], - $class_generic_params + $class_generic_params, ); if (!$template_types) { @@ -1604,7 +1604,7 @@ private static function getProvisionalTemplateResultForFunctionLike( null, true, false, - $calling_class_storage->final ?? false + $calling_class_storage->final ?? false, ); TemplateStandinTypeReplacer::fillTemplateResult( @@ -1616,7 +1616,7 @@ private static function getProvisionalTemplateResultForFunctionLike( $argument_offset, $context->self, $context->calling_method_id ?: $context->calling_function_id, - false + false, ); } @@ -1656,9 +1656,9 @@ private static function checkArgCount( 'Too many arguments for ' . ($cased_method_id ?: $method_id) . ' - expecting ' . count($function_params) . ' but saw ' . count($args), $code_location, - (string)$method_id + (string)$method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -1763,9 +1763,9 @@ private static function checkArgCount( 'Too few arguments for ' . $cased_method_id . ' - expecting ' . $param->name . ' to be passed', $code_location, - (string)$method_id + (string)$method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); continue; } @@ -1781,7 +1781,7 @@ private static function checkArgCount( $default_type_atomic = ConstantTypeResolver::resolve( $codebase->classlikes, $param->default_type, - $statements_analyzer + $statements_analyzer, ); $default_type = new Union([$default_type_atomic]); @@ -1796,7 +1796,7 @@ private static function checkArgCount( $i, $context->self, $context->calling_method_id ?: $context->calling_function_id, - true + true, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php index aa4dc680713..8b55808b73e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArrayFunctionArgumentsAnalyzer.php @@ -120,14 +120,14 @@ public static function checkArgumentsMatch( $min_closure_param_count, $max_closure_param_count, $array_arg_types, - $check_functions + $check_functions, ); $new []= $closure_type; } $statements_analyzer->node_data->setType( $closure_arg->value, - $closure_arg_type->getBuilder()->setTypes($new)->freeze() + $closure_arg_type->getBuilder()->setTypes($new)->freeze(), ); } } @@ -147,7 +147,7 @@ public static function handleAddition( $unpacked_args = array_filter( $args, - static fn(PhpParser\Node\Arg $arg): bool => $arg->unpack + static fn(PhpParser\Node\Arg $arg): bool => $arg->unpack, ); if ($method_id === 'array_push' && !$unpacked_args) { @@ -159,7 +159,7 @@ public static function handleAddition( if (ExpressionAnalyzer::analyze( $statements_analyzer, $args[$i]->value, - $context + $context, ) === false) { $context->inside_assignment = $was_inside_assignment; @@ -177,11 +177,11 @@ public static function handleAddition( new VirtualArrayDimFetch( $args[0]->value, null, - $args[$i]->value->getAttributes() + $args[$i]->value->getAttributes(), ), $context, $args[$i]->value, - $statements_analyzer->node_data->getType($args[$i]->value) ?? Type::getMixed() + $statements_analyzer->node_data->getType($args[$i]->value) ?? Type::getMixed(), ); $statements_analyzer->node_data = $old_node_data; @@ -195,7 +195,7 @@ public static function handleAddition( if (ExpressionAnalyzer::analyze( $statements_analyzer, $array_arg, - $context + $context, ) === false) { return false; } @@ -204,7 +204,7 @@ public static function handleAddition( if (ExpressionAnalyzer::analyze( $statements_analyzer, $args[$i]->value, - $context + $context, ) === false) { return false; } @@ -233,7 +233,7 @@ public static function handleAddition( if (ExpressionAnalyzer::analyze( $statements_analyzer, $arg->value, - $context + $context, ) === false) { return false; } @@ -249,7 +249,7 @@ public static function handleAddition( ) { $by_ref_type = Type::combineUnionTypes( $by_ref_type, - new Union([new TArray([$new_offset_type, Type::getMixed()])]) + new Union([new TArray([$new_offset_type, Type::getMixed()])]), ); } elseif ($arg->unpack) { $arg_value_type = $arg_value_type->getBuilder(); @@ -263,11 +263,11 @@ public static function handleAddition( if ($was_list) { if ($arg_value_atomic_type instanceof TNonEmptyArray) { $arg_value_atomic_type = Type::getNonEmptyListAtomic( - $arg_value_atomic_type->type_params[1] + $arg_value_atomic_type->type_params[1], ); } else { $arg_value_atomic_type = Type::getListAtomic( - $arg_value_atomic_type->type_params[1] + $arg_value_atomic_type->type_params[1], ); } } @@ -279,7 +279,7 @@ public static function handleAddition( $by_ref_type = Type::combineUnionTypes( $by_ref_type, - $arg_value_type + $arg_value_type, ); } else { if ($objectlike_list) { @@ -289,7 +289,7 @@ public static function handleAddition( $by_ref_type = new Union([$objectlike_list->setProperties($properties)]); } elseif ($array_type instanceof TArray && $array_type->isEmptyArray()) { $by_ref_type = new Union([new TKeyedArray([ - $arg_value_type + $arg_value_type, ], null, null, true)]); } else { $by_ref_type = Type::combineUnionTypes( @@ -299,13 +299,13 @@ public static function handleAddition( new TNonEmptyArray( [ $new_offset_type, - $arg_value_type - ] + $arg_value_type, + ], ), - ] + ], ), null, - true + true, ); } } @@ -317,7 +317,7 @@ public static function handleAddition( $by_ref_type, $by_ref_type, $context, - false + false, ); } @@ -341,7 +341,7 @@ public static function handleSplice( if (ExpressionAnalyzer::analyze( $statements_analyzer, $array_arg, - $context + $context, ) === false) { return false; } @@ -351,7 +351,7 @@ public static function handleSplice( if (ExpressionAnalyzer::analyze( $statements_analyzer, $offset_arg, - $context + $context, ) === false) { return false; } @@ -365,7 +365,7 @@ public static function handleSplice( if (ExpressionAnalyzer::analyze( $statements_analyzer, $length_arg, - $context + $context, ) === false) { return false; } @@ -379,7 +379,7 @@ public static function handleSplice( if (ExpressionAnalyzer::analyze( $statements_analyzer, $replacement_arg, - $context + $context, ) === false) { return false; } @@ -394,7 +394,7 @@ public static function handleSplice( && $replacement_arg_type->isSingle() ) { $replacement_arg_type = new Union([ - new TArray([Type::getInt(), $replacement_arg_type]) + new TArray([Type::getInt(), $replacement_arg_type]), ]); $statements_analyzer->node_data->setType($replacement_arg, $replacement_arg_type); @@ -456,7 +456,7 @@ public static function handleSplice( $by_ref_type, $by_ref_type, $context, - false + false, ); return null; @@ -470,7 +470,7 @@ public static function handleSplice( $array_type, $array_type, $context, - false + false, ); return null; @@ -485,7 +485,7 @@ public static function handleByRefArrayAdjustment( $var_id = ExpressionIdentifier::getVarId( $arg->value, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($var_id) { @@ -543,7 +543,7 @@ public static function handleByRefArrayAdjustment( [ Type::getNever(), Type::getNever(), - ] + ], ); } else { $array_atomic_type = $array_atomic_type->setCount($array_atomic_type->count-1); @@ -563,7 +563,7 @@ public static function handleByRefArrayAdjustment( [ Type::getNever(), Type::getNever(), - ] + ], ); } else { $properties = $array_atomic_type->properties; @@ -621,7 +621,7 @@ private static function checkClosureType( $function_ids = CallAnalyzer::getFunctionIdsFromCallableArg( $statements_analyzer, - $closure_arg->value + $closure_arg->value, ); $closure_types = []; @@ -662,7 +662,7 @@ private static function checkClosureType( $function_id_part = new MethodIdentifier( $callable_fq_class_name, - strtolower($method_name) + strtolower($method_name), ); try { @@ -675,7 +675,7 @@ private static function checkClosureType( $closure_types[] = new TClosure( 'Closure', $method_storage->params, - $method_storage->return_type ?: Type::getMixed() + $method_storage->return_type ?: Type::getMixed(), ); } } else { @@ -689,7 +689,7 @@ private static function checkClosureType( $function_storage = $codebase->functions->getStorage( $statements_analyzer, - $function_id + $function_id, ); if (InternalCallMapHandler::inCallMap($function_id)) { @@ -728,7 +728,7 @@ private static function checkClosureType( $closure_types[] = new TClosure( 'Closure', $function_storage->params, - $function_storage->return_type ?: Type::getMixed() + $function_storage->return_type ?: Type::getMixed(), ); } } @@ -750,7 +750,7 @@ private static function checkClosureType( $closure_arg, $min_closure_param_count, $max_closure_param_count, - $array_arg_types + $array_arg_types, ); } unset($closure_type); @@ -794,9 +794,9 @@ private static function checkClosureTypeArgs( 'The callable passed to ' . $method_id . ' will be called with ' . $argument_text . ', expecting ' . $required_param_count, new CodeLocation($statements_analyzer->getSource(), $closure_arg), - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -810,9 +810,9 @@ private static function checkClosureTypeArgs( 'The callable passed to ' . $method_id . ' will be called with ' . $argument_text . ', expecting ' . $required_param_count, new CodeLocation($statements_analyzer->getSource(), $closure_arg), - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -849,12 +849,12 @@ private static function checkClosureTypeArgs( ) { $template_result = new TemplateResult( [], - [] + [], ); foreach ($closure_param_type->getTemplateTypes() as $template_type) { $template_result->template_types[$template_type->param_name] = [ - ($template_type->defining_class) => $template_type->as + ($template_type->defining_class) => $template_type->as, ]; } @@ -866,12 +866,12 @@ private static function checkClosureTypeArgs( $input_type, $i, $context->self, - $context->calling_method_id ?: $context->calling_function_id + $context->calling_method_id ?: $context->calling_function_id, ); $closure_type = $closure_type->replaceTemplateTypesWithArgTypes( $template_result, - $codebase + $codebase, ); } @@ -880,7 +880,7 @@ private static function checkClosureTypeArgs( $closure_param_type, $context->self, null, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); $union_comparison_results = new TypeComparisonResult(); @@ -891,7 +891,7 @@ private static function checkClosureTypeArgs( $closure_param_type, $input_type->ignore_nullable_issues, $input_type->ignore_falsable_issues, - $union_comparison_results + $union_comparison_results, ); if ($union_comparison_results->type_coerced) { @@ -902,9 +902,9 @@ private static function checkClosureTypeArgs( $closure_param_type->getId() . ', but parent type ' . $input_type->getId() . ' provided', new CodeLocation($statements_analyzer->getSource(), $closure_arg), - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -913,9 +913,9 @@ private static function checkClosureTypeArgs( $closure_param_type->getId() . ', but parent type ' . $input_type->getId() . ' provided', new CodeLocation($statements_analyzer->getSource(), $closure_arg), - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -924,7 +924,7 @@ private static function checkClosureTypeArgs( $types_can_be_identical = UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $input_type, - $closure_param_type + $closure_param_type, ); if ($union_comparison_results->scalar_type_match_found) { @@ -933,9 +933,9 @@ private static function checkClosureTypeArgs( 'Parameter ' . ($i + 1) . ' of closure passed to function ' . $method_id . ' expects ' . $closure_param_type->getId() . ', but ' . $input_type->getId() . ' provided', new CodeLocation($statements_analyzer->getSource(), $closure_arg), - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($types_can_be_identical) { IssueBuffer::maybeAdd( @@ -944,9 +944,9 @@ private static function checkClosureTypeArgs( . $closure_param_type->getId() . ', but possibly different type ' . $input_type->getId() . ' provided', new CodeLocation($statements_analyzer->getSource(), $closure_arg), - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -954,9 +954,9 @@ private static function checkClosureTypeArgs( 'Parameter ' . ($i + 1) . ' of closure passed to function ' . $method_id . ' expects ' . $closure_param_type->getId() . ', but ' . $input_type->getId() . ' provided', new CodeLocation($statements_analyzer->getSource(), $closure_arg), - $method_id + $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php index 30022eb2a82..d9fe8c241a4 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php @@ -76,7 +76,7 @@ public static function collect( if (isset($template_types[$template_name])) { $template_types[$template_name] = array_merge( $template_types[$template_name], - $template_map + $template_map, ); } else { $template_types[$template_name] = $template_map; @@ -116,14 +116,14 @@ public static function collect( $static_class_storage, $static_class_storage, null, - $lhs_type_part + $lhs_type_part, ); if ($templates === null) { throw new AssertionError("Could not collect templates!"); } $template_result = new TemplateResult( $static_class_storage->template_types, - $templates + $templates, ); } foreach ($template_types as $type_name => $_) { @@ -141,7 +141,7 @@ public static function collect( $input_type_extends, $static_class_storage, $lhs_type_part, - $template_result + $template_result, ); $class_template_params[$type_name][$class_storage->name] @@ -167,8 +167,8 @@ public static function collect( $e[$candidate_class_storage->name][$type_name], $e, $static_class_storage->name, - $static_class_storage->template_types - ) + $static_class_storage->template_types, + ), ); } } @@ -198,13 +198,13 @@ private static function resolveTemplateParam( $static_class_storage ->template_types [$type_extends_atomic->param_name] - [$type_extends_atomic->defining_class] + [$type_extends_atomic->defining_class], ) ) { $mapped_offset = array_search( $type_extends_atomic->param_name, array_keys($static_class_storage->template_types), - true + true, ); if ($mapped_offset !== false @@ -212,14 +212,14 @@ private static function resolveTemplateParam( ) { $output_type_extends = Type::combineUnionTypes( $lhs_type_part->type_params[$mapped_offset], - $output_type_extends + $output_type_extends, ); } } elseif (isset( $static_class_storage ->template_extended_params [$type_extends_atomic->defining_class] - [$type_extends_atomic->param_name] + [$type_extends_atomic->param_name], )) { $nested_output_type = self::resolveTemplateParam( $codebase, @@ -229,12 +229,12 @@ private static function resolveTemplateParam( [$type_extends_atomic->param_name], $static_class_storage, $lhs_type_part, - $template_result + $template_result, ); if ($nested_output_type !== null) { $output_type_extends = Type::combineUnionTypes( $nested_output_type, - $output_type_extends + $output_type_extends, ); } } @@ -242,12 +242,12 @@ private static function resolveTemplateParam( if ($template_result !== null) { $type_extends_atomic = $type_extends_atomic->replaceTemplateTypesWithArgTypes( $template_result, - $codebase + $codebase, ); } $output_type_extends = Type::combineUnionTypes( new Union([$type_extends_atomic]), - $output_type_extends + $output_type_extends, ); } } @@ -278,7 +278,7 @@ private static function expandType( $e[$type_extends_atomic->defining_class][$type_extends_atomic->param_name], $e, $static_fq_class_name, - $static_template_types + $static_template_types, )]; } elseif ($type_extends_atomic instanceof TClassConstant) { $expanded = TypeExpander::expandAtomic( @@ -288,7 +288,7 @@ private static function expandType( $type_extends_atomic->fq_classlike_name, null, true, - true + true, ); foreach ($expanded as $type) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index f2b070e8708..2ece1a32fcd 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -112,7 +112,7 @@ public static function analyze( $stmt = new VirtualFuncCall( $function_name, $other_args, - $stmt->getAttributes() + $stmt->getAttributes(), ); } @@ -122,7 +122,7 @@ public static function analyze( $stmt = new VirtualFuncCall( $function_name, [new VirtualArg($stmt->getArgs()[1]->value, false, true)], - $stmt->getAttributes() + $stmt->getAttributes(), ); } } @@ -133,7 +133,7 @@ public static function analyze( $stmt, $real_stmt, $function_name, - $context + $context, ); if ($function_call_info->function_exists === false) { @@ -149,7 +149,7 @@ public static function analyze( $stmt, $function_name, $context, - $code_location + $code_location, ); if (!$function_call_info->function_exists) { @@ -183,7 +183,7 @@ public static function analyze( $function_call_info->function_id, $function_call_info->allow_named_args, $context, - $template_result + $template_result, ); } @@ -202,7 +202,7 @@ public static function analyze( $codebase, $function_call_info->function_id, $stmt->getArgs(), - $statements_analyzer->node_data + $statements_analyzer->node_data, ); $function_call_info->function_params = $function_callable->params; @@ -224,7 +224,7 @@ public static function analyze( null, $template_result, $code_location, - $context + $context, ); } @@ -232,7 +232,7 @@ public static function analyze( $statements_analyzer, $template_result, $code_location, - $function_call_info->function_id + $function_call_info->function_id, ); $template_result->lower_bounds += $already_inferred_lower_bounds; @@ -249,7 +249,7 @@ public static function analyze( $function_call_info->function_storage, $function_callable, $template_result, - $context + $context, ); $statements_analyzer->node_data->setType($real_stmt, $stmt_type); @@ -263,7 +263,7 @@ public static function analyze( $function_call_info->function_id, $context, $statements_analyzer->getSource(), - $codebase + $codebase, ); $config->eventDispatcher->dispatchAfterEveryFunctionCallAnalysis($event); @@ -283,7 +283,7 @@ public static function analyze( $codebase, $atomic_type, null, - $statements_analyzer + $statements_analyzer, ); if ($candidate_callable) { @@ -291,7 +291,7 @@ public static function analyze( 'Closure', $candidate_callable->params, $candidate_callable->return_type, - $candidate_callable->is_pure + $candidate_callable->is_pure, ); } } @@ -327,7 +327,7 @@ public static function analyze( $codebase, $stmt, $stmt->getArgs()[0], - $context + $context, ); } @@ -339,7 +339,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt, - $stmt_type->getId() + $stmt_type->getId(), ); } @@ -349,7 +349,7 @@ public static function analyze( $stmt, $function_name, $function_call_info, - $context + $context, ); if ($function_call_info->function_storage) { @@ -361,7 +361,7 @@ public static function analyze( $stmt->getArgs(), $template_result, $context, - $statements_analyzer + $statements_analyzer, ); } @@ -371,8 +371,8 @@ public static function analyze( array_map( static fn(Possibilities $assertion): Possibilities => $assertion->getUntemplatedCopy($template_result, null, $codebase), - $function_call_info->function_storage->if_true_assertions - ) + $function_call_info->function_storage->if_true_assertions, + ), ); } @@ -382,8 +382,8 @@ public static function analyze( array_map( static fn(Possibilities $assertion): Possibilities => $assertion->getUntemplatedCopy($template_result, null, $codebase), - $function_call_info->function_storage->if_false_assertions - ) + $function_call_info->function_storage->if_false_assertions, + ), ); } @@ -392,9 +392,9 @@ public static function analyze( new DeprecatedFunction( 'The function ' . $function_call_info->function_id . ' has been marked as deprecated', $code_location, - $function_call_info->function_id + $function_call_info->function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -414,7 +414,7 @@ public static function analyze( $real_stmt, $function_name, strtolower($function_call_info->function_id), - $context + $context, ); } @@ -442,7 +442,7 @@ private static function handleNamedFunction( if (!$function_name instanceof PhpParser\Node\Name\FullyQualified) { $function_call_info->function_id = $codebase_functions->getFullyQualifiedFunctionNameFromString( $original_function_id, - $statements_analyzer + $statements_analyzer, ); } else { $function_call_info->function_id = $original_function_id; @@ -450,7 +450,7 @@ private static function handleNamedFunction( $namespaced_function_exists = $codebase_functions->functionExists( $statements_analyzer, - strtolower($function_call_info->function_id) + strtolower($function_call_info->function_id), ); if (!$namespaced_function_exists @@ -479,7 +479,7 @@ private static function handleNamedFunction( $statements_analyzer, $stmt, $codebase, - $function_call_info->function_id + $function_call_info->function_id, ); } @@ -500,7 +500,7 @@ private static function handleNamedFunction( $statements_analyzer, $function_call_info->function_id, $code_location, - $is_maybe_root_function + $is_maybe_root_function, ) === false) { if ($args) { ArgumentsAnalyzer::analyze( @@ -509,7 +509,7 @@ private static function handleNamedFunction( null, null, true, - $context + $context, ); } @@ -534,7 +534,7 @@ private static function handleNamedFunction( $statements_analyzer, $function_call_info->function_id, $context, - $code_location + $code_location, ); } @@ -549,7 +549,7 @@ private static function handleNamedFunction( try { $function_call_info->function_storage = $function_storage = $codebase_functions->getStorage( $statements_analyzer, - strtolower($function_call_info->function_id) + strtolower($function_call_info->function_id), ); $function_call_info->function_params = $function_call_info->function_storage->params; @@ -564,7 +564,7 @@ private static function handleNamedFunction( } } catch (UnexpectedValueException $e) { $function_call_info->function_params = [ - new FunctionLikeParameter('args', false, null, null, null, null, false, false, true) + new FunctionLikeParameter('args', false, null, null, null, null, false, false, true), ]; } } else { @@ -572,7 +572,7 @@ private static function handleNamedFunction( $codebase, $function_call_info->function_id, $args, - $statements_analyzer->node_data + $statements_analyzer->node_data, ); $function_call_info->function_params = $function_callable->params; @@ -584,7 +584,7 @@ private static function handleNamedFunction( $function_call_info->function_id, $args, $context, - $code_location + $code_location, ); } @@ -595,7 +595,7 @@ private static function handleNamedFunction( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $function_name, - $function_call_info->function_id . '()' + $function_call_info->function_id . '()', ); } } @@ -632,9 +632,9 @@ private static function getAnalyzeNamedExpression( IssueBuffer::maybeAdd( new NullFunctionCall( 'Cannot call function on null value', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return $function_call_info; @@ -644,9 +644,9 @@ private static function getAnalyzeNamedExpression( IssueBuffer::maybeAdd( new PossiblyNullFunctionCall( 'Cannot call function on possibly null value', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -673,9 +673,9 @@ private static function getAnalyzeNamedExpression( IssueBuffer::maybeAdd( new ImpureFunctionCall( 'Cannot call an impure function from a mutation-free context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -696,13 +696,13 @@ private static function getAnalyzeNamedExpression( $real_stmt, Type::combineUnionTypes( $stmt_type, - $var_type_part->return_type - ) + $var_type_part->return_type, + ), ); } else { $statements_analyzer->node_data->setType( $real_stmt, - $var_type_part->return_type ?? Type::getMixed() + $var_type_part->return_type ?? Type::getMixed(), ); } @@ -718,9 +718,9 @@ private static function getAnalyzeNamedExpression( IssueBuffer::maybeAdd( new MixedFunctionCall( 'Cannot call function on ' . $var_type_part->getId(), - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($var_type_part instanceof TCallableObject || $var_type_part instanceof TCallableString @@ -741,7 +741,7 @@ private static function getAnalyzeNamedExpression( $var_type_part, $codebase, $context->calling_method_id, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), ); if ($potential_method_id === 'not-callable') { @@ -761,7 +761,7 @@ private static function getAnalyzeNamedExpression( } else { $function_call_info->new_function_name = new VirtualFullyQualified( $var_type_part->value, - $function_name->getAttributes() + $function_name->getAttributes(), ); } } @@ -772,7 +772,7 @@ private static function getAnalyzeNamedExpression( $context->calling_method_id, null, $statements_analyzer, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), ); } @@ -785,8 +785,8 @@ private static function getAnalyzeNamedExpression( || !$codebase->methods->methodExists( new MethodIdentifier( $var_type_part->value, - '__invoke' - ) + '__invoke', + ), ) ) { $invalid_function_call_types[] = (string)$var_type_part; @@ -797,7 +797,7 @@ private static function getAnalyzeNamedExpression( $real_stmt, $function_name, $context, - $var_type_part + $var_type_part, ); } } @@ -809,17 +809,17 @@ private static function getAnalyzeNamedExpression( IssueBuffer::maybeAdd( new PossiblyInvalidFunctionCall( 'Cannot treat type ' . $var_type_part . ' as callable', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidFunctionCall( 'Cannot treat type ' . $var_type_part . ' as callable', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -837,7 +837,7 @@ private static function getAnalyzeNamedExpression( 'variable-call', 0, $arg_location, - $arg_location + $arg_location, ); $custom_call_sink->taints = [TaintKind::INPUT_CALLABLE]; @@ -855,7 +855,7 @@ private static function getAnalyzeNamedExpression( $custom_call_sink, 'call', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -883,7 +883,7 @@ private static function analyzeInvokeCall( $fake_method_call = new VirtualMethodCall( $function_name, new VirtualIdentifier('__invoke', $function_name->getAttributes()), - $stmt->args + $stmt->args, ); $suppressed_issues = $statements_analyzer->getSuppressedIssues(); @@ -898,7 +898,7 @@ private static function analyzeInvokeCall( $statements_analyzer, $fake_method_call, $context, - false + false, ); if (!in_array('InternalMethod', $suppressed_issues, true)) { @@ -914,13 +914,13 @@ private static function analyzeInvokeCall( $real_stmt, Type::combineUnionTypes( $fake_method_call_type ?? Type::getMixed(), - $stmt_type - ) + $stmt_type, + ), ); } else { $statements_analyzer->node_data->setType( $real_stmt, - $fake_method_call_type ?? Type::getMixed() + $fake_method_call_type ?? Type::getMixed(), ); } } @@ -940,7 +940,7 @@ private static function processAssertFunctionEffects( $first_arg->value, $context->self, $statements_analyzer, - $codebase + $codebase, ); AlgebraAnalyzer::checkForParadox( @@ -948,7 +948,7 @@ private static function processAssertFunctionEffects( $assert_clauses, $statements_analyzer, $stmt, - [] + [], ); $simplified_clauses = Algebra::simplifyCNF([...$context->clauses, ...$assert_clauses]); @@ -968,12 +968,12 @@ private static function processAssertFunctionEffects( $changed_var_ids, array_map( static fn($_): bool => true, - $assert_type_assertions + $assert_type_assertions, ), $statements_analyzer, $statements_analyzer->getTemplateTypeMap() ?: [], $context->inside_loop, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ); foreach ($changed_var_ids as $var_id => $_) { @@ -996,7 +996,7 @@ private static function processAssertFunctionEffects( IssueBuffer::remove( $statements_analyzer->getFilePath(), 'MixedAssignment', - $first_appearance->raw_file_start + $first_appearance->raw_file_start, ); } @@ -1043,7 +1043,7 @@ private static function checkFunctionCallPurity( $statements_analyzer->node_data, $function_call_info->function_id, $stmt->isFirstClassCallable() ? [] : $stmt->getArgs(), - $must_use + $must_use, ) : null; @@ -1057,9 +1057,9 @@ private static function checkFunctionCallPurity( IssueBuffer::maybeAdd( new ImpureFunctionCall( 'Cannot call an impure function from a mutation-free context', - new CodeLocation($statements_analyzer, $function_name) + new CodeLocation($statements_analyzer, $function_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations @@ -1097,9 +1097,9 @@ private static function checkFunctionCallPurity( new UnusedFunctionCall( 'The call to ' . $function_call_info->function_id . ' is not used', new CodeLocation($statements_analyzer, $function_name), - $function_call_info->function_id + $function_call_info->function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { $stmt->setAttribute('pure', true); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php index 02e7f2fa526..bd54e0f90d5 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php @@ -83,7 +83,7 @@ public static function fetch( new TLiteralString($function_id), null, $statements_analyzer, - true + true, ); if ($candidate_callable) { @@ -91,7 +91,7 @@ public static function fetch( 'Closure', $candidate_callable->params, $candidate_callable->return_type, - $candidate_callable->is_pure + $candidate_callable->is_pure, )]); } else { $stmt_type = Type::getClosure(); @@ -102,7 +102,7 @@ public static function fetch( $function_id, $stmt, $context, - new CodeLocation($statements_analyzer->getSource(), $function_name) + new CodeLocation($statements_analyzer->getSource(), $function_name), ); } @@ -115,17 +115,17 @@ public static function fetch( $template_result->lower_bounds[$template_name] = [ 'fn-' . $function_id => [ new TemplateBound( - Type::getInt(false, count($stmt->getArgs())) - ) - ] + Type::getInt(false, count($stmt->getArgs())), + ), + ], ]; } elseif ($template_name === 'TPhpMajorVersion') { $template_result->lower_bounds[$template_name] = [ 'fn-' . $function_id => [ new TemplateBound( - Type::getInt(false, $codebase->getMajorAnalysisPhpVersion()) - ) - ] + Type::getInt(false, $codebase->getMajorAnalysisPhpVersion()), + ), + ], ]; } elseif ($template_name === 'TPhpVersionId') { $template_result->lower_bounds[$template_name] = [ @@ -133,18 +133,18 @@ public static function fetch( new TemplateBound( Type::getInt( false, - $codebase->analysis_php_version_id - ) - ) - ] + $codebase->analysis_php_version_id, + ), + ), + ], ]; } else { $template_result->lower_bounds[$template_name] = [ 'fn-' . $function_id => [ new TemplateBound( - Type::getNever() - ) - ] + Type::getNever(), + ), + ], ]; } } @@ -154,7 +154,7 @@ public static function fetch( if ($function_storage && !$context->isSuppressingExceptions($statements_analyzer)) { $context->mergeFunctionExceptions( $function_storage, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ); } @@ -168,13 +168,13 @@ public static function fetch( $return_type, null, null, - null + null, ); $return_type = TemplateInferredTypeReplacer::replace( $return_type, $template_result, - $codebase + $codebase, ); } @@ -187,7 +187,7 @@ public static function fetch( true, false, false, - true + true, ); $return_type_location = $function_storage->return_type_location; @@ -199,7 +199,7 @@ public static function fetch( $statements_analyzer->getSource(), $codebase, $return_type, - [] + [], ); $config->eventDispatcher->dispatchAfterFunctionCallAnalysis($event); @@ -208,7 +208,7 @@ public static function fetch( if ($file_manipulations) { FileManipulationBuffer::add( $statements_analyzer->getFilePath(), - $file_manipulations + $file_manipulations, ); } @@ -229,7 +229,7 @@ public static function fetch( true, false, false, - $context->calling_method_id + $context->calling_method_id, ); } } @@ -247,7 +247,7 @@ public static function fetch( $function_id, $stmt->getArgs(), $callmap_callable, - $context + $context, ); } } @@ -267,7 +267,7 @@ public static function fetch( $function_storage, $stmt_type, $template_result, - $context + $context, ); if ($function_storage->proxy_calls !== null) { @@ -326,7 +326,7 @@ private static function getReturnTypeFromCallMapWithArgs( case 'hrtime': $keyed_array = new TKeyedArray([ Type::getInt(), - Type::getInt() + Type::getInt(), ], null, null, true); return new Union([$keyed_array]); @@ -334,8 +334,8 @@ private static function getReturnTypeFromCallMapWithArgs( return new Union([ new TClassString( $context->self ?: 'object', - $context->self ? new TNamedObject($context->self, true) : null - ) + $context->self ? new TNamedObject($context->self, true) : null, + ), ]); case 'get_parent_class': @@ -345,8 +345,8 @@ private static function getReturnTypeFromCallMapWithArgs( if ($classlike_storage->parent_classes) { return new Union([ new TClassString( - array_values($classlike_storage->parent_classes)[0] - ) + array_values($classlike_storage->parent_classes)[0], + ), ]); } } @@ -372,7 +372,7 @@ private static function getReturnTypeFromCallMapWithArgs( return new Union([ $atomic_types['array']->count !== null ? new TLiteralInt($atomic_types['array']->count) - : new TIntRange(1, null) + : new TIntRange(1, null), ]); } @@ -393,7 +393,7 @@ private static function getReturnTypeFromCallMapWithArgs( } return new Union([ - new TIntRange(0, null) + new TIntRange(0, null), ]); } } @@ -409,7 +409,7 @@ private static function getReturnTypeFromCallMapWithArgs( $keyed_array = new TKeyedArray([ Type::getInt(), - Type::getInt() + Type::getInt(), ], null, null, true); if ((string) $first_arg_type === 'false') { @@ -418,7 +418,7 @@ private static function getReturnTypeFromCallMapWithArgs( return new Union([ $keyed_array, - new TInt() + new TInt(), ]); } @@ -464,17 +464,17 @@ private static function getReturnTypeFromCallMapWithArgs( case 'fgetcsv': $string_type = new Union([ new TString, - new TNull + new TNull, ], [ - 'ignore_nullable_issues' => true + 'ignore_nullable_issues' => true, ]); $call_map_return_type = new Union([ Type::getNonEmptyListAtomic( - $string_type + $string_type, ), new TFalse, - new TNull + new TNull, ], [ 'ignore_nullable_issues' => $codebase->config->ignore_internal_nullable_issues, 'ignore_falsable_issues' => $codebase->config->ignore_internal_falsable_issues, @@ -556,7 +556,7 @@ private static function taintReturnType( $statements_analyzer->data_flow_graph instanceof TaintFlowGraph ? ($function_storage->signature_return_type_location ?: $function_storage->location) : ($function_storage->return_type_location ?: $function_storage->location), - $function_storage->specialize_call ? $node_location : null + $function_storage->specialize_call ? $node_location : null, ); $statements_analyzer->data_flow_graph->addNode($function_call_node); @@ -569,7 +569,7 @@ private static function taintReturnType( $conditionally_removed_taint = TemplateInferredTypeReplacer::replace( $conditionally_removed_taint, $template_result, - $codebase + $codebase, ); $expanded_type = TypeExpander::expandUnion( @@ -579,7 +579,7 @@ private static function taintReturnType( null, null, true, - true + true, ); if (!$expanded_type->isNullable()) { @@ -593,7 +593,7 @@ private static function taintReturnType( $assignment_node = DataFlowNode::getForAssignment( $function_id . '-escaped', $function_storage->signature_return_type_location ?: $function_storage->location, - $function_call_node->specialization_key + $function_call_node->specialization_key, ); $statements_analyzer->data_flow_graph->addPath( @@ -601,7 +601,7 @@ private static function taintReturnType( $assignment_node, 'conditionally-escaped', $added_taints, - [...$removed_taints, ...$conditionally_removed_taints] + [...$removed_taints, ...$conditionally_removed_taints], ); $stmt_type = $stmt_type->addParentNodes([$assignment_node->id => $assignment_node]); @@ -647,7 +647,7 @@ private static function taintReturnType( $added_taints = $codebase->config->eventDispatcher->dispatchAddTaints($event); $removed_taints = array_merge( $removed_taints, - $codebase->config->eventDispatcher->dispatchRemoveTaints($event) + $codebase->config->eventDispatcher->dispatchRemoveTaints($event), ); self::taintUsingFlows( @@ -659,7 +659,7 @@ private static function taintReturnType( $node_location, $function_call_node, $removed_taints, - $added_taints + $added_taints, ); } @@ -667,7 +667,7 @@ private static function taintReturnType( $method_node = TaintSource::getForMethodReturn( $function_id, $function_id, - $node_location + $node_location, ); $method_node->taints = $function_storage->taint_source_types; @@ -712,7 +712,7 @@ public static function taintUsingFlows( foreach ($taintable_arg_index as $arg_index) { $arg_location = new CodeLocation( $statements_analyzer, - $args[$arg_index]->value + $args[$arg_index]->value, ); $function_param_sink = DataFlowNode::getForMethodArgument( @@ -720,7 +720,7 @@ public static function taintUsingFlows( $function_id, $arg_index, $arg_location, - $function_storage->specialize_call ? $node_location : null + $function_storage->specialize_call ? $node_location : null, ); $graph->addNode($function_param_sink); @@ -730,7 +730,7 @@ public static function taintUsingFlows( $function_call_node, $path_type, array_merge($added_taints, $function_storage->added_taints), - $removed_taints + $removed_taints, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php index aa6ac74b96d..74109d03ea0 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php @@ -85,7 +85,7 @@ public static function analyze( $extra_types = $lhs_type_part->extra_types; $lhs_type_part = array_values( - $lhs_type_part->as->getAtomicTypes() + $lhs_type_part->as->getAtomicTypes(), )[0]; if ($lhs_type_part instanceof TNamedObject) { @@ -114,7 +114,7 @@ public static function analyze( $lhs_var_id, $context, $is_intersection, - $result + $result, ); return; @@ -153,7 +153,7 @@ public static function analyze( null, null, true, - $context + $context, ); return; @@ -169,7 +169,7 @@ public static function analyze( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(true, false, true, true, $lhs_type_part->from_docblock) + new ClassLikeNameOptions(true, false, true, true, $lhs_type_part->from_docblock), ); } @@ -187,7 +187,7 @@ public static function analyze( if (!$context->ignore_variable_method) { $codebase->analyzer->addMixedMemberName( strtolower($fq_class_name) . '::', - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } @@ -197,7 +197,7 @@ public static function analyze( if ($method_name_type && $method_name_type->isSingleStringLiteral()) { $method_identifier = new MethodIdentifier( $fq_class_name, - strtolower($method_name_type->getSingleStringLiteral()->value) + strtolower($method_name_type->getSingleStringLiteral()->value), ); //the call to methodExists will register that the method was called from somewhere if ($codebase->methods->methodExists( @@ -207,7 +207,7 @@ public static function analyze( $statements_analyzer, $statements_analyzer->getFilePath(), true, - $context->insideUse() + $context->insideUse(), )) { $method_storage = $codebase->methods->getStorage($method_identifier); @@ -215,7 +215,7 @@ public static function analyze( 'Closure', $method_storage->params, $method_storage->return_type, - $method_storage->pure + $method_storage->pure, )]); } } @@ -232,7 +232,7 @@ public static function analyze( null, null, true, - $context + $context, ); $result->return_type = Type::getMixed(); @@ -260,7 +260,7 @@ public static function analyze( : null, $statements_analyzer->getFilePath(), false, - $context->insideUse() + $context->insideUse(), ); $fake_method_exists = false; @@ -272,7 +272,7 @@ public static function analyze( $fq_class_name, $method_id->method_name, $source, - null + null, ); if ($method_exists) { @@ -299,7 +299,7 @@ public static function analyze( $source, $stmt, $statements_analyzer, - $fq_class_name + $fq_class_name, ); } elseif ($class_storage->mixin_declaring_fqcln && $class_storage->namedMixins @@ -316,7 +316,7 @@ public static function analyze( $stmt, $statements_analyzer, $fq_class_name, - $lhs_var_id + $lhs_var_id, ); } } @@ -336,7 +336,7 @@ public static function analyze( $lhs_type_part, $lhs_var_id, $result, - $intersection_types + $intersection_types, ); } @@ -346,7 +346,7 @@ public static function analyze( || !MethodAnalyzer::isMethodVisible( $method_id, $context, - $statements_analyzer->getSource() + $statements_analyzer->getSource(), ) ) { $interface_has_method = false; @@ -360,7 +360,7 @@ public static function analyze( $fq_class_name = $interface_storage->name; $method_id = new MethodIdentifier( $fq_class_name, - $method_name_lc + $method_name_lc, ); break; } @@ -380,7 +380,7 @@ public static function analyze( : null, $statements_analyzer->getFilePath(), true, - $context->insideUse() + $context->insideUse(), ) ) { $new_call_context = MissingMethodCallHandler::handleMagicMethod( @@ -393,7 +393,7 @@ public static function analyze( $codebase->config, $all_intersection_return_type, $result, - $lhs_type_part + $lhs_type_part, ); if ($new_call_context) { @@ -418,7 +418,7 @@ public static function analyze( && $context->self && $fq_class_name !== $context->self && $codebase->methods->methodExists( - new MethodIdentifier($context->self, $method_name_lc) + new MethodIdentifier($context->self, $method_name_lc), ) ) { $method_id = new MethodIdentifier($context->self, $method_name_lc); @@ -437,7 +437,7 @@ public static function analyze( $context->calling_method_id, $codebase->collect_locations && $method_id !== $source_method_id ? new CodeLocation($source, $stmt->name) - : null + : null, )); if (!$corrected_method_exists @@ -457,7 +457,7 @@ public static function analyze( $intersection_method_id, $cased_method_id, $result, - $lhs_type_part + $lhs_type_part, ); return; @@ -477,7 +477,7 @@ public static function analyze( $lhs_var_id, $method_id, $result, - $inferred_template_result + $inferred_template_result, ); $statements_analyzer->node_data = $old_node_data; @@ -495,7 +495,7 @@ public static function analyze( $context, $statements_analyzer->getSource(), $name_code_location, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -504,7 +504,7 @@ public static function analyze( $result, $return_type_candidate, $all_intersection_return_type, - $codebase + $codebase, ); } @@ -543,7 +543,7 @@ private static function getIntersectionReturnType( $lhs_type_part, true, $lhs_var_id, - $intersection_result + $intersection_result, ); $result->returns_by_ref = $intersection_result->returns_by_ref; @@ -556,7 +556,7 @@ private static function getIntersectionReturnType( $all_intersection_existent_method_ids = array_merge( $all_intersection_existent_method_ids, - $intersection_result->existent_method_ids + $intersection_result->existent_method_ids, ); if ($intersection_result->return_type) { @@ -566,7 +566,7 @@ private static function getIntersectionReturnType( $all_intersection_return_type = Type::intersectUnionTypes( $all_intersection_return_type, $intersection_result->return_type, - $codebase + $codebase, ) ?? Type::getMixed(); } } @@ -585,7 +585,7 @@ private static function updateResultReturnType( $return_type_candidate = Type::intersectUnionTypes( $all_intersection_return_type, $return_type_candidate, - $codebase + $codebase, ) ?? Type::getMixed(); } @@ -637,7 +637,7 @@ private static function handleInvalidClass( if ($stmt->name instanceof PhpParser\Node\Identifier) { $codebase->analyzer->addMixedMemberName( strtolower($stmt->name->name), - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } @@ -659,7 +659,7 @@ private static function handleInvalidClass( foreach ($lhs_type->parent_nodes as $parent_node) { $origin_locations = [ ...$origin_locations, - ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node) + ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node), ]; } } @@ -676,9 +676,9 @@ private static function handleInvalidClass( new MixedMethodCall( $message, $name_code_location, - $origin_location + $origin_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -692,7 +692,7 @@ private static function handleInvalidClass( null, null, true, - $context + $context, ) === false) { return; } @@ -734,7 +734,7 @@ private static function handleTemplatedMixins( foreach ($class_storage->templatedMixins as $mixin) { $param_position = array_search( $mixin->param_name, - $template_type_keys + $template_type_keys, ); if ($param_position !== false @@ -743,17 +743,17 @@ private static function handleTemplatedMixins( $current_type_param = $lhs_type_part->type_params[$param_position]; if ($current_type_param->isSingle()) { $lhs_type_part_new = array_values( - $current_type_param->getAtomicTypes() + $current_type_param->getAtomicTypes(), )[0]; if ($lhs_type_part_new instanceof TNamedObject) { $new_method_id = new MethodIdentifier( $lhs_type_part_new->value, - $method_name_lc + $method_name_lc, ); $mixin_class_storage = $codebase->classlike_storage_provider->get( - $lhs_type_part_new->value + $lhs_type_part_new->value, ); if ($codebase->methods->methodExists( @@ -768,7 +768,7 @@ private static function handleTemplatedMixins( : null, $statements_analyzer->getFilePath(), true, - $context->insideUse() + $context->insideUse(), )) { $lhs_type_part = $lhs_type_part_new; $class_storage = $mixin_class_storage; @@ -791,7 +791,7 @@ private static function handleTemplatedMixins( $class_storage, $naive_method_exists, $method_id, - $fq_class_name + $fq_class_name, ]; } @@ -821,7 +821,7 @@ private static function handleRegularMixins( $new_method_id = new MethodIdentifier( $mixin->value, - $method_name_lc + $method_name_lc, ); if ($codebase->methods->methodExists( @@ -836,10 +836,10 @@ private static function handleRegularMixins( : null, $statements_analyzer->getFilePath(), true, - $context->insideUse() + $context->insideUse(), )) { $mixin_declaring_class_storage = $codebase->classlike_storage_provider->get( - $class_storage->mixin_declaring_fqcln + $class_storage->mixin_declaring_fqcln, ); $mixin_class_template_params = ClassTemplateParamCollector::collect( @@ -848,12 +848,12 @@ private static function handleRegularMixins( $codebase->classlike_storage_provider->get($fq_class_name), null, $lhs_type_part, - $lhs_var_id === '$this' + $lhs_var_id === '$this', ); $lhs_type_part = $mixin->replaceTemplateTypesWithArgTypes( new TemplateResult([], $mixin_class_template_params ?: []), - $codebase + $codebase, ); $lhs_type_expanded = TypeExpander::expandUnion( @@ -864,7 +864,7 @@ private static function handleRegularMixins( $class_storage->parent_class, true, false, - $class_storage->final + $class_storage->final, ); $new_lhs_type_part = $lhs_type_expanded->getSingleAtomic(); @@ -888,7 +888,7 @@ private static function handleRegularMixins( $class_storage, $naive_method_exists, $method_id, - $fq_class_name + $fq_class_name, ]; } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php index 0855adbd968..5d814f53e27 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php @@ -90,7 +90,7 @@ public static function analyze( $codebase->file_reference_provider->addMethodReferenceToClassMember( $calling_method_class . '::__construct', strtolower((string) $method_id), - false + false, ); } @@ -102,7 +102,7 @@ public static function analyze( $statements_analyzer, $stmt, $codebase, - (string) $method_id + (string) $method_id, ); } @@ -112,13 +112,13 @@ public static function analyze( $fake_function_call = new VirtualFuncCall( $stmt->var, $args, - $stmt->getAttributes() + $stmt->getAttributes(), ); FunctionCallAnalyzer::analyze( $statements_analyzer, $fake_function_call, - $context + $context, ); return $statements_analyzer->node_data->getType($fake_function_call) ?? Type::getMixed(); @@ -133,7 +133,7 @@ public static function analyze( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt_name, - $method_id . '()' + $method_id . '()', ); } @@ -142,7 +142,7 @@ public static function analyze( $codebase->file_reference_provider->addMethodReferenceToClassMember( $calling_method_class . '::__construct', strtolower((string) $method_id), - false + false, ); } @@ -166,7 +166,7 @@ public static function analyze( $class_storage, $method_name_lc, $lhs_type_part, - $lhs_var_id === '$this' + $lhs_var_id === '$this', ); if ($lhs_var_id === '$this' && $parent_source instanceof FunctionLikeAnalyzer) { @@ -188,7 +188,7 @@ public static function analyze( $class_storage, $method_name_lc, $lhs_type_part, - true + true, ); } } @@ -212,7 +212,7 @@ public static function analyze( $method_template_result, $codebase, null, - new Union([$lhs_type_part]) + new Union([$lhs_type_part]), ); $method_template_params = $method_template_result->lower_bounds; @@ -233,7 +233,7 @@ public static function analyze( $statements_analyzer, $stmt, $codebase, - (string) $method_id + (string) $method_id, ); } @@ -245,7 +245,7 @@ public static function analyze( $template_result, $context, new CodeLocation($source, $stmt_name), - $statements_analyzer + $statements_analyzer, ) === false) { return Type::getMixed(); } @@ -263,7 +263,7 @@ public static function analyze( $static_type, $args, $result, - $template_result + $template_result, ); if ($is_first_class_callable) { @@ -281,7 +281,7 @@ public static function analyze( $method_id, $statements_analyzer->getFullyQualifiedFunctionMethodOrNamespaceName(), $name_code_location, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $getter_return_type = self::getMagicGetterOrSetterProperty( @@ -289,7 +289,7 @@ public static function analyze( $stmt, $stmt_name, $context, - $fq_class_name + $fq_class_name, ); if ($getter_return_type) { @@ -303,7 +303,7 @@ public static function analyze( $if_this_is_type = TemplateInferredTypeReplacer::replace( $method_storage->if_this_is_type, $template_result, - $codebase + $codebase, ); if (!UnionTypeComparator::isContainedBy($codebase, $class_type, $if_this_is_type)) { @@ -311,9 +311,9 @@ public static function analyze( new IfThisIsMismatch( 'Class type must be ' . $method_storage->if_this_is_type->getId() . ' current type ' . $class_type->getId(), - new CodeLocation($source, $stmt->name) + new CodeLocation($source, $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -332,7 +332,7 @@ public static function analyze( false, $static_type instanceof TNamedObject && $codebase->classlike_storage_provider->get($static_type->value)->final, - true + true, ); } @@ -341,7 +341,7 @@ public static function analyze( $template_result, $method_id, count($args), - $codebase + $codebase, ); $self_out_candidate = TypeExpander::expandUnion( @@ -354,7 +354,7 @@ public static function analyze( false, $static_type instanceof TNamedObject && $codebase->classlike_storage_provider->get($static_type->value)->final, - true + true, ); $context->vars_in_scope[$lhs_var_id] = $self_out_candidate; @@ -372,7 +372,7 @@ public static function analyze( $class_storage, $context, $config, - $result + $result, ); } @@ -415,7 +415,7 @@ public static function analyze( $args, $template_result, $context, - $statements_analyzer + $statements_analyzer, ); } @@ -426,10 +426,10 @@ public static function analyze( static fn(Possibilities $assertion): Possibilities => $assertion->getUntemplatedCopy( $template_result, $lhs_var_id, - $codebase + $codebase, ), - $method_storage->if_true_assertions - ) + $method_storage->if_true_assertions, + ), ); } @@ -440,10 +440,10 @@ public static function analyze( static fn(Possibilities $assertion): Possibilities => $assertion->getUntemplatedCopy( $template_result, $lhs_var_id, - $codebase + $codebase, ), - $method_storage->if_false_assertions - ) + $method_storage->if_false_assertions, + ), ); } } @@ -457,13 +457,13 @@ public static function analyze( new FileManipulation( (int) $stmt_name->getAttribute('startFilePos'), (int) $stmt_name->getAttribute('endFilePos') + 1, - $new_method_name - ) + $new_method_name, + ), ]; FileManipulationBuffer::add( $statements_analyzer->getFilePath(), - $file_manipulations + $file_manipulations, ); } } @@ -485,7 +485,7 @@ public static function analyze( $statements_analyzer, $codebase, $file_manipulations, - $return_type_candidate + $return_type_candidate, ); $config->eventDispatcher->dispatchAfterMethodCallAnalysis($event); @@ -537,7 +537,7 @@ private static function getMagicGetterOrSetterProperty( $method_name === '__get', $statements_analyzer, $context, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ); switch ($method_name) { @@ -551,9 +551,9 @@ private static function getMagicGetterOrSetterProperty( new UndefinedThisPropertyAssignment( 'Instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -569,7 +569,7 @@ private static function getMagicGetterOrSetterProperty( $class_storage->pseudo_property_set_types['$' . $prop_name], $fq_class_name, new TNamedObject($fq_class_name), - $class_storage->parent_class + $class_storage->parent_class, ); $union_comparison_results = new TypeComparisonResult(); @@ -580,7 +580,7 @@ private static function getMagicGetterOrSetterProperty( $pseudo_set_type, $second_arg_type->ignore_nullable_issues, $second_arg_type->ignore_falsable_issues, - $union_comparison_results + $union_comparison_results, ); if ($union_comparison_results->type_coerced) { @@ -590,9 +590,9 @@ private static function getMagicGetterOrSetterProperty( $prop_name . ' expects \'' . $pseudo_set_type->getId() . '\', ' . ' parent type `' . $second_arg_type . '` provided', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -600,9 +600,9 @@ private static function getMagicGetterOrSetterProperty( $prop_name . ' expects \'' . $pseudo_set_type->getId() . '\', ' . ' parent type `' . $second_arg_type . '` provided', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -611,7 +611,7 @@ private static function getMagicGetterOrSetterProperty( if (UnionTypeComparator::canBeContainedBy( $codebase, $second_arg_type, - $pseudo_set_type + $pseudo_set_type, )) { IssueBuffer::maybeAdd( new PossiblyInvalidPropertyAssignmentValue( @@ -619,9 +619,9 @@ private static function getMagicGetterOrSetterProperty( . $pseudo_set_type . '\' cannot be assigned possibly different type \'' . $second_arg_type . '\'', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -630,9 +630,9 @@ private static function getMagicGetterOrSetterProperty( . $pseudo_set_type . '\' cannot be assigned type \'' . $second_arg_type . '\'', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -649,9 +649,9 @@ private static function getMagicGetterOrSetterProperty( new UndefinedThisPropertyFetch( 'Instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php index cd141e51ba1..d3d42a95ef3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallProhibitionAnalyzer.php @@ -44,9 +44,9 @@ public static function analyze( 'The method ' . $codebase_methods->getCasedMethodId($method_id) . ' has been marked as deprecated', $code_location, - (string) $method_id + (string) $method_id, ), - $suppressed_issues + $suppressed_issues, ); } @@ -60,9 +60,9 @@ public static function analyze( . ' is internal to ' . InternalClass::listToPhrase($storage->internal) . ' but called from ' . ($caller_identifier ?: 'root namespace'), $code_location, - (string) $method_id + (string) $method_id, ), - $suppressed_issues + $suppressed_issues, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php index 0fde9d86617..760adf93590 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php @@ -48,9 +48,9 @@ public static function analyze( new ImpureMethodCall( 'Cannot call a non-mutation-free method ' . $cased_method_id . ' from a pure context', - new CodeLocation($statements_analyzer, $stmt->name) + new CodeLocation($statements_analyzer, $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($context->mutation_free && !$method_storage->mutation_free @@ -60,9 +60,9 @@ public static function analyze( new ImpureMethodCall( 'Cannot call a possibly-mutating method ' . $cased_method_id . ' from a mutation-free context', - new CodeLocation($statements_analyzer, $stmt->name) + new CodeLocation($statements_analyzer, $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($context->external_mutation_free && !$method_storage->mutation_free @@ -73,9 +73,9 @@ public static function analyze( new ImpureMethodCall( 'Cannot call a possibly-mutating method ' . $cased_method_id . ' from a mutation-free context', - new CodeLocation($statements_analyzer, $stmt->name) + new CodeLocation($statements_analyzer, $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif (($method_storage->mutation_free || ($method_storage->external_mutation_free @@ -121,9 +121,9 @@ public static function analyze( new UnusedMethodCall( 'The call to ' . $cased_method_id . ' is not used', new CodeLocation($statements_analyzer, $stmt->name), - (string) $method_id + (string) $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif (!$method_storage->mutation_free_inferred) { $stmt->setAttribute('pure', true); @@ -164,7 +164,7 @@ public static function analyze( $codebase, $class_storage->name, $name, - $class_storage + $class_storage, ) ?? Type::getMixed(); $context->vars_in_scope[$mutation_var_id] = $new_type; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php index e94fffeff12..a277406d062 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php @@ -76,7 +76,7 @@ public static function fetch( 'Closure', $method_storage->params, $method_storage->return_type, - $method_storage->pure + $method_storage->pure, )]); } @@ -91,7 +91,7 @@ public static function fetch( $stmt, $context, new CodeLocation($statements_analyzer->getSource(), $stmt->name), - $lhs_type_part instanceof TGenericObject ? $lhs_type_part->type_params : null + $lhs_type_part instanceof TGenericObject ? $lhs_type_part->type_params : null, ); if ($return_type_candidate) { @@ -125,7 +125,7 @@ public static function fetch( new CodeLocation($statements_analyzer->getSource(), $stmt->name), $lhs_type_part instanceof TGenericObject ? $lhs_type_part->type_params : null, $fq_class_name, - $method_name + $method_name, ); if ($return_type_candidate) { @@ -146,7 +146,7 @@ public static function fetch( $template_result, $method_id, count($stmt->getArgs()), - $codebase + $codebase, ); } else { $callmap_callables = InternalCallMapHandler::getCallablesFromCallMap((string) $call_map_id); @@ -160,7 +160,7 @@ public static function fetch( if ($return_type_candidate->isFalsable()) { $return_type_candidate = $return_type_candidate->setProperties([ - 'ignore_falsable_issues' => true + 'ignore_falsable_issues' => true, ]); } @@ -173,7 +173,7 @@ public static function fetch( true, false, false, - true + true, ); } else { $self_fq_class_name = $fq_class_name; @@ -182,7 +182,7 @@ public static function fetch( $method_id, $self_fq_class_name, $statements_analyzer, - $args + $args, ); if ($return_type_candidate) { @@ -197,7 +197,7 @@ public static function fetch( false, $static_type instanceof TNamedObject && $codebase->classlike_storage_provider->get($static_type->value)->final, - true + true, ); } @@ -206,7 +206,7 @@ public static function fetch( $template_result, $method_id, count($stmt->getArgs()), - $codebase + $codebase, ); $return_type_candidate = TypeExpander::expandUnion( @@ -219,12 +219,12 @@ public static function fetch( false, $static_type instanceof TNamedObject && $codebase->classlike_storage_provider->get($static_type->value)->final, - true + true, ); $return_type_location = $codebase->methods->getMethodReturnTypeLocation( $method_id, - $secondary_return_type_location + $secondary_return_type_location, ); if ($secondary_return_type_location) { @@ -244,7 +244,7 @@ public static function fetch( true, false, false, - $context->calling_method_id + $context->calling_method_id, ); } } else { @@ -267,7 +267,7 @@ public static function fetch( $method_id, $declaring_method_id, $cased_method_id, - $context + $context, ); return $return_type_candidate; @@ -307,7 +307,7 @@ public static function taintMethodCallResult( $removed_taints = $codebase->config->eventDispatcher->dispatchRemoveTaints($event); $method_storage = $codebase->methods->getStorage( - $declaring_method_id + $declaring_method_id, ); $node_location = new CodeLocation($statements_analyzer, $name_expr); @@ -317,7 +317,7 @@ public static function taintMethodCallResult( $var_id = ExpressionIdentifier::getExtendedVarId( $var_expr, null, - $statements_analyzer + $statements_analyzer, ); if ($method_storage->specialize_call @@ -330,23 +330,23 @@ public static function taintMethodCallResult( $unspecialized_parent_nodes = array_filter( $parent_nodes, - static fn(DataFlowNode $parent_node): bool => !$parent_node->specialization_key + static fn(DataFlowNode $parent_node): bool => !$parent_node->specialization_key, ); $specialized_parent_nodes = array_filter( $parent_nodes, - static fn(DataFlowNode $parent_node): bool => (bool) $parent_node->specialization_key + static fn(DataFlowNode $parent_node): bool => (bool) $parent_node->specialization_key, ); $var_node = DataFlowNode::getForAssignment( $var_id, - new CodeLocation($statements_analyzer, $var_expr) + new CodeLocation($statements_analyzer, $var_expr), ); if ($method_storage->location) { $this_parent_node = DataFlowNode::getForAssignment( '$this in ' . $method_id, - $method_storage->location + $method_storage->location, ); foreach ($parent_nodes as $parent_node) { @@ -355,7 +355,7 @@ public static function taintMethodCallResult( $this_parent_node, '=', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -370,7 +370,7 @@ public static function taintMethodCallResult( $cased_method_id, $is_declaring ? ($method_storage->signature_return_type_location ?: $method_storage->location) : null, - $node_location + $node_location, ); $method_call_nodes[$method_call_node->id] = $method_call_node; @@ -382,7 +382,7 @@ public static function taintMethodCallResult( $cased_method_id, $is_declaring ? ($method_storage->signature_return_type_location ?: $method_storage->location) : null, - null + null, ); $method_call_node = new DataFlowNode( @@ -390,7 +390,7 @@ public static function taintMethodCallResult( $cased_method_id, $is_declaring ? ($method_storage->signature_return_type_location ?: $method_storage->location) : null, - $parent_node->specialization_key + $parent_node->specialization_key, ); $statements_analyzer->data_flow_graph->addPath( @@ -398,7 +398,7 @@ public static function taintMethodCallResult( $method_call_node, '=', $added_taints, - $removed_taints + $removed_taints, ); $method_call_nodes[$method_call_node->id] = $method_call_node; @@ -419,7 +419,7 @@ public static function taintMethodCallResult( $var_node, 'method-call-' . $method_id->method_name, $added_taints, - $removed_taints + $removed_taints, ); } @@ -430,7 +430,7 @@ public static function taintMethodCallResult( strtolower((string) $declaring_method_id), $cased_declaring_method_id, $method_storage->signature_return_type_location ?: $method_storage->location, - $method_call_node->specialization_key + $method_call_node->specialization_key, ); $statements_analyzer->data_flow_graph->addNode($declaring_method_call_node); @@ -439,7 +439,7 @@ public static function taintMethodCallResult( $method_call_node, 'parent', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -447,7 +447,7 @@ public static function taintMethodCallResult( $return_type_candidate = $return_type_candidate->setParentNodes($method_call_nodes); $stmt_var_type = $context->vars_in_scope[$var_id]->setParentNodes( - $var_nodes + $var_nodes, ); $context->vars_in_scope[$var_id] = $stmt_var_type; @@ -458,7 +458,7 @@ public static function taintMethodCallResult( $is_declaring ? ($method_storage->signature_return_type_location ?: $method_storage->location) : null, - $node_location + $node_location, ); if (!$is_declaring) { @@ -468,7 +468,7 @@ public static function taintMethodCallResult( (string) $declaring_method_id, $cased_declaring_method_id, $method_storage->signature_return_type_location ?: $method_storage->location, - $node_location + $node_location, ); $statements_analyzer->data_flow_graph->addNode($declaring_method_call_node); @@ -477,14 +477,14 @@ public static function taintMethodCallResult( $method_call_node, 'parent', $added_taints, - $removed_taints + $removed_taints, ); } $statements_analyzer->data_flow_graph->addNode($method_call_node); $return_type_candidate = $return_type_candidate->setParentNodes([ - $method_call_node->id => $method_call_node + $method_call_node->id => $method_call_node, ]); } } else { @@ -496,7 +496,7 @@ public static function taintMethodCallResult( ? ($method_storage->signature_return_type_location ?: $method_storage->location) : ($method_storage->return_type_location ?: $method_storage->location)) : null, - null + null, ); if (!$is_declaring) { @@ -506,7 +506,7 @@ public static function taintMethodCallResult( (string) $declaring_method_id, $cased_declaring_method_id, $method_storage->signature_return_type_location ?: $method_storage->location, - null + null, ); $statements_analyzer->data_flow_graph->addNode($declaring_method_call_node); @@ -515,14 +515,14 @@ public static function taintMethodCallResult( $method_call_node, 'parent', $added_taints, - $removed_taints + $removed_taints, ); } $statements_analyzer->data_flow_graph->addNode($method_call_node); $return_type_candidate = $return_type_candidate->setParentNodes([ - $method_call_node->id => $method_call_node + $method_call_node->id => $method_call_node, ]); } @@ -534,7 +534,7 @@ public static function taintMethodCallResult( $method_node = TaintSource::getForMethodReturn( (string) $method_id, $cased_method_id, - $method_storage->signature_return_type_location ?: $method_storage->location + $method_storage->signature_return_type_location ?: $method_storage->location, ); $method_node->taints = $method_storage->taint_source_types; @@ -550,7 +550,7 @@ public static function taintMethodCallResult( $args, $node_location, $method_call_node, - $method_storage->removed_taints + $method_storage->removed_taints, ); } @@ -569,24 +569,24 @@ public static function replaceTemplateTypes( && !isset( $template_result->lower_bounds [$template_type->param_name] - [$template_type->defining_class] + [$template_type->defining_class], ) ) { if ($template_type->param_name === 'TFunctionArgCount') { $template_result->lower_bounds[$template_type->param_name] = [ 'fn-' . strtolower((string) $method_id) => [ new TemplateBound( - Type::getInt(false, $arg_count) - ) - ] + Type::getInt(false, $arg_count), + ), + ], ]; } elseif ($template_type->param_name === 'TPhpMajorVersion') { $template_result->lower_bounds[$template_type->param_name] = [ 'fn-' . strtolower((string) $method_id) => [ new TemplateBound( - Type::getInt(false, $codebase->getMajorAnalysisPhpVersion()) - ) - ] + Type::getInt(false, $codebase->getMajorAnalysisPhpVersion()), + ), + ], ]; } elseif ($template_type->param_name === 'TPhpVersionId') { $template_result->lower_bounds[$template_type->param_name] = [ @@ -594,16 +594,16 @@ public static function replaceTemplateTypes( new TemplateBound( Type::getInt( false, - $codebase->analysis_php_version_id - ) - ) - ] + $codebase->analysis_php_version_id, + ), + ), + ], ]; } else { $template_result->lower_bounds[$template_type->param_name] = [ ($template_type->defining_class) => [ - new TemplateBound(Type::getNever()) - ] + new TemplateBound(Type::getNever()), + ], ]; } } @@ -616,13 +616,13 @@ public static function replaceTemplateTypes( $return_type_candidate, null, null, - null + null, ); $return_type_candidate = TemplateInferredTypeReplacer::replace( $return_type_candidate, $template_result, - $codebase + $codebase, ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php index f96f679fc98..2cc632a35e3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodVisibilityAnalyzer.php @@ -46,7 +46,7 @@ public static function analyze( $fq_classlike_name, $method_name, $context, - $code_location + $code_location, ); if ($method_visible === false) { @@ -54,9 +54,9 @@ public static function analyze( new InaccessibleMethod( 'Cannot access method ' . $codebase_methods->getCasedMethodId($method_id) . ' from context ' . $context->self, - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -145,9 +145,9 @@ public static function analyze( new InaccessibleMethod( 'Cannot access private method ' . $codebase_methods->getCasedMethodId($method_id) . ' from context ' . $context->self, - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -160,9 +160,9 @@ public static function analyze( if (IssueBuffer::accepts( new InaccessibleMethod( 'Cannot access protected method ' . $method_id, - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } @@ -184,9 +184,9 @@ public static function analyze( new InaccessibleMethod( 'Cannot access protected method ' . $codebase_methods->getCasedMethodId($method_id) . ' from context ' . $context->self, - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, )) { return false; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php index 11a00eeb38c..2f16c392ab4 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php @@ -54,7 +54,7 @@ public static function handleMagicMethod( $result->has_valid_method_call_type = true; $result->existent_method_ids[] = $method_id->__toString(); $result->return_type = self::createFirstClassCallableReturnType( - $class_storage->pseudo_methods[$method_name_lc] + $class_storage->pseudo_methods[$method_name_lc], ); } else { $result->non_existent_magic_method_ids[] = $method_id->__toString(); @@ -71,7 +71,7 @@ public static function handleMagicMethod( $method_id->method_name, $stmt, $context, - new CodeLocation($statements_analyzer->getSource(), $stmt->name) + new CodeLocation($statements_analyzer->getSource(), $stmt->name), ); if ($return_type_candidate) { @@ -79,14 +79,14 @@ public static function handleMagicMethod( $return_type_candidate = Type::intersectUnionTypes( $all_intersection_return_type, $return_type_candidate, - $codebase + $codebase, ) ?? Type::getMixed(); } $result->return_type = Type::combineUnionTypes( $return_type_candidate, $result->return_type, - $codebase + $codebase, ); CallAnalyzer::checkMethodArgs( @@ -95,7 +95,7 @@ public static function handleMagicMethod( new TemplateResult([], []), $context, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer + $statements_analyzer, ); return null; @@ -105,7 +105,7 @@ public static function handleMagicMethod( $found_method_and_class_storage = self::findPseudoMethodAndClassStorages( $codebase, $class_storage, - $method_name_lc + $method_name_lc, ); if ($found_method_and_class_storage) { @@ -120,7 +120,7 @@ public static function handleMagicMethod( $class_storage, $method_name_lc, $lhs_type_part, - !$statements_analyzer->isStatic() && $method_id->fq_class_name === $context->self + !$statements_analyzer->isStatic() && $method_id->fq_class_name === $context->self, ); ArgumentsAnalyzer::analyze( @@ -130,7 +130,7 @@ public static function handleMagicMethod( (string) $method_id, true, $context, - $found_generic_params ? new TemplateResult([], $found_generic_params) : null + $found_generic_params ? new TemplateResult([], $found_generic_params) : null, ); ArgumentsAnalyzer::checkArgumentsMatch( @@ -142,7 +142,7 @@ public static function handleMagicMethod( null, new TemplateResult([], $found_generic_params ?: []), new CodeLocation($statements_analyzer, $stmt), - $context + $context, ); if ($pseudo_method_storage->return_type) { @@ -152,7 +152,7 @@ public static function handleMagicMethod( $return_type_candidate = TemplateInferredTypeReplacer::replace( $return_type_candidate, new TemplateResult([], $found_generic_params), - $codebase + $codebase, ); } @@ -161,21 +161,21 @@ public static function handleMagicMethod( $return_type_candidate, $defining_class_storage->name, $lhs_type_part instanceof Atomic\TNamedObject ? $lhs_type_part : $fq_class_name, - $defining_class_storage->parent_class + $defining_class_storage->parent_class, ); if ($all_intersection_return_type) { $return_type_candidate = Type::intersectUnionTypes( $all_intersection_return_type, $return_type_candidate, - $codebase + $codebase, ) ?? Type::getMixed(); } $result->return_type = Type::combineUnionTypes( $return_type_candidate, $result->return_type, - $codebase + $codebase, ); return null; @@ -187,7 +187,7 @@ public static function handleMagicMethod( null, null, true, - $context + $context, ); if ($class_storage->sealed_methods || $config->seal_all_methods) { @@ -205,9 +205,9 @@ public static function handleMagicMethod( $arg->value, null, false, - $arg->getAttributes() + $arg->getAttributes(), ), - $stmt->getArgs() + $stmt->getArgs(), ); $statements_analyzer->node_data = clone $statements_analyzer->node_data; @@ -219,18 +219,18 @@ public static function handleMagicMethod( new VirtualString($method_name_lc), false, false, - $stmt->getAttributes() + $stmt->getAttributes(), ), new VirtualArg( new VirtualArray( $array_values, - $stmt->getAttributes() + $stmt->getAttributes(), ), false, false, - $stmt->getAttributes() + $stmt->getAttributes(), ), - ] + ], ); } @@ -260,7 +260,7 @@ public static function handleMissingOrMagicMethod( $found_method_and_class_storage = self::findPseudoMethodAndClassStorages( $codebase, $class_storage, - $method_name_lc + $method_name_lc, ); if (($is_interface || $config->use_phpdoc_method_without_magic_or_parent) @@ -282,7 +282,7 @@ public static function handleMissingOrMagicMethod( $class_storage, $method_name_lc, $lhs_type_part, - !$statements_analyzer->isStatic() && $method_id->fq_class_name === $context->self + !$statements_analyzer->isStatic() && $method_id->fq_class_name === $context->self, ); if (ArgumentsAnalyzer::analyze( @@ -292,7 +292,7 @@ public static function handleMissingOrMagicMethod( (string) $method_id, true, $context, - $found_generic_params ? new TemplateResult([], $found_generic_params) : null + $found_generic_params ? new TemplateResult([], $found_generic_params) : null, ) === false) { return; } @@ -306,7 +306,7 @@ public static function handleMissingOrMagicMethod( null, new TemplateResult([], $found_generic_params ?: []), new CodeLocation($statements_analyzer, $stmt->name), - $context + $context, ) === false) { return; } @@ -318,7 +318,7 @@ public static function handleMissingOrMagicMethod( $return_type_candidate = TemplateInferredTypeReplacer::replace( $return_type_candidate, new TemplateResult([], $found_generic_params), - $codebase + $codebase, ); } @@ -326,7 +326,7 @@ public static function handleMissingOrMagicMethod( $return_type_candidate = Type::intersectUnionTypes( $all_intersection_return_type, $return_type_candidate, - $codebase + $codebase, ) ?? Type::getMixed(); } @@ -338,7 +338,7 @@ public static function handleMissingOrMagicMethod( $defining_class_storage->parent_class, true, false, - $class_storage->final + $class_storage->final, ); $result->return_type = Type::combineUnionTypes($return_type_candidate, $result->return_type); @@ -363,7 +363,7 @@ public static function handleMissingOrMagicMethod( null, null, true, - $context + $context, ) === false) { return; } @@ -371,7 +371,7 @@ public static function handleMissingOrMagicMethod( if ($all_intersection_return_type && $all_intersection_existent_method_ids) { $result->existent_method_ids = array_merge( $result->existent_method_ids, - $all_intersection_existent_method_ids + $all_intersection_existent_method_ids, ); $result->return_type = Type::combineUnionTypes($all_intersection_return_type, $result->return_type); @@ -397,7 +397,7 @@ private static function createFirstClassCallableReturnType(?MethodStorage $metho 'Closure', $method_storage->params, $method_storage->return_type, - $method_storage->pure + $method_storage->pure, )]); } @@ -440,7 +440,7 @@ private static function findPseudoMethodAndClassStorages( if ($class_storage && isset($class_storage->pseudo_methods[$method_name_lc])) { return [ $class_storage->pseudo_methods[$method_name_lc], - $class_storage + $class_storage, ]; } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php index 9bc4a6ccda1..f7dd973fde7 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php @@ -83,9 +83,9 @@ public static function analyze( if (IssueBuffer::accepts( new InvalidScope( 'Use of $this in non-class context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -95,7 +95,7 @@ public static function analyze( $lhs_var_id = ExpressionIdentifier::getExtendedVarId( $stmt->var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $class_type = $lhs_var_id && $context->hasVariable($lhs_var_id) @@ -115,7 +115,7 @@ public static function analyze( null, null, true, - $context + $context, ) === false) { return false; } @@ -130,9 +130,9 @@ public static function analyze( return !IssueBuffer::accepts( new NullReference( 'Cannot call method ' . $stmt->name->name . ' on null value', - new CodeLocation($statements_analyzer->getSource(), $stmt->name) + new CodeLocation($statements_analyzer->getSource(), $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -146,9 +146,9 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyNullReference( 'Cannot call method ' . $stmt->name->name . ' on possibly null value', - new CodeLocation($statements_analyzer->getSource(), $stmt->name) + new CodeLocation($statements_analyzer->getSource(), $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -160,9 +160,9 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyFalseReference( 'Cannot call method ' . $stmt->name->name . ' on possibly false value', - new CodeLocation($statements_analyzer->getSource(), $stmt->name) + new CodeLocation($statements_analyzer->getSource(), $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -194,7 +194,7 @@ public static function analyze( false, $lhs_var_id, $result, - $template_result + $template_result, ); if (isset($context->vars_in_scope[$lhs_var_id]) && ($possible_new_class_type = $context->vars_in_scope[$lhs_var_id]) instanceof Union @@ -213,7 +213,7 @@ public static function analyze( $result->return_type = $context->vars_in_scope[$method_var_id]; } elseif ($result->return_type !== null) { $context->vars_in_scope[$method_var_id] = $result->return_type->setProperties([ - 'has_mutations' => false + 'has_mutations' => false, ]); } @@ -237,17 +237,17 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyInvalidMethodCall( 'Cannot call method on possible ' . $invalid_class_type . ' variable ' . $lhs_var_id, - new CodeLocation($source, $stmt->name) + new CodeLocation($source, $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidMethodCall( 'Cannot call method on ' . $invalid_class_type . ' variable ' . $lhs_var_id, - new CodeLocation($source, $stmt->name) + new CodeLocation($source, $stmt->name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -258,9 +258,9 @@ public static function analyze( new UndefinedMagicMethod( 'Magic method ' . $result->non_existent_magic_method_ids[0] . ' does not exist', new CodeLocation($source, $stmt->name), - $result->non_existent_magic_method_ids[0] + $result->non_existent_magic_method_ids[0], ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -272,18 +272,18 @@ public static function analyze( new PossiblyUndefinedMethod( 'Method ' . $result->non_existent_class_method_ids[0] . ' does not exist', new CodeLocation($source, $stmt->name), - $result->non_existent_class_method_ids[0] + $result->non_existent_class_method_ids[0], ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new UndefinedMethod( 'Method ' . $result->non_existent_class_method_ids[0] . ' does not exist', new CodeLocation($source, $stmt->name), - $result->non_existent_class_method_ids[0] + $result->non_existent_class_method_ids[0], ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -298,18 +298,18 @@ public static function analyze( new PossiblyUndefinedMethod( 'Method ' . $result->non_existent_interface_method_ids[0] . ' does not exist', new CodeLocation($source, $stmt->name), - $result->non_existent_interface_method_ids[0] + $result->non_existent_interface_method_ids[0], ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new UndefinedInterfaceMethod( 'Method ' . $result->non_existent_interface_method_ids[0] . ' does not exist', new CodeLocation($source, $stmt->name), - $result->non_existent_interface_method_ids[0] + $result->non_existent_interface_method_ids[0], ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -324,9 +324,9 @@ public static function analyze( new TooManyArguments( 'Too many arguments for method ' . $error_method_id . ' - saw ' . count($stmt->getArgs()), new CodeLocation($source, $stmt->name), - (string) $error_method_id + (string) $error_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -337,9 +337,9 @@ public static function analyze( new TooFewArguments( 'Too few arguments for method ' . $error_method_id . ' saw ' . count($stmt->getArgs()), new CodeLocation($source, $stmt->name), - (string) $error_method_id + (string) $error_method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -371,7 +371,7 @@ public static function analyze( $statements_analyzer->getFilePath(), $stmt->name, $stmt_type->getId(), - $stmt + $stmt, ); } @@ -382,7 +382,7 @@ public static function analyze( new TemplateResult([], []), $context, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer + $statements_analyzer, ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php index d4029dd5c63..9d84fdbbd4e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php @@ -80,7 +80,7 @@ public static function handle( $stmt, $real_stmt, $function_id, - $context + $context, ); return; @@ -223,7 +223,7 @@ public static function handle( } $mixed_type = new Union([new TMixed()], [ - 'parent_nodes' => $context->vars_in_scope[$var_id]->parent_nodes + 'parent_nodes' => $context->vars_in_scope[$var_id]->parent_nodes, ]); $context->vars_in_scope[$var_id] = $mixed_type; @@ -252,7 +252,7 @@ public static function handle( new VirtualVariable($var_name, $arg->value->getAttributes()), new VirtualString($var_name, $arg->value->getAttributes()), false, - $arg->getAttributes() + $arg->getAttributes(), ); } @@ -284,7 +284,7 @@ public static function handle( $statements_analyzer->data_flow_graph->addPath( $param_node, new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } } @@ -299,9 +299,9 @@ public static function handle( IssueBuffer::maybeAdd( new ForbiddenCode( 'Unsafe ' . implode('', $function_name->parts), - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -309,9 +309,9 @@ public static function handle( IssueBuffer::maybeAdd( new ForbiddenCode( 'You have forbidden the use of ' . $function_name, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -323,7 +323,7 @@ public static function handle( $first_arg->value, $statements_analyzer->node_data, $codebase, - $statements_analyzer->getAliases() + $statements_analyzer->getAliases(), ); if ($fq_const_name !== null && isset($stmt->getArgs()[1])) { @@ -337,7 +337,7 @@ public static function handle( $statements_analyzer, $fq_const_name, $statements_analyzer->node_data->getType($second_arg->value) ?? Type::getMixed(), - $context + $context, ); } } else { @@ -353,7 +353,7 @@ public static function handle( $first_arg->value, $statements_analyzer->node_data, $codebase, - $statements_analyzer->getAliases() + $statements_analyzer->getAliases(), ); if ($fq_const_name !== null) { @@ -361,7 +361,7 @@ public static function handle( $statements_analyzer, $fq_const_name, true, - $context + $context, ); if ($const_type) { @@ -386,7 +386,7 @@ public static function handle( $context->self, $statements_analyzer, $codebase, - $context->inside_negation + $context->inside_negation, ); $changed_vars = []; @@ -394,7 +394,7 @@ public static function handle( foreach ($anded_assertions as $assertions) { $referenced_var_ids = array_map( static fn(array $_): bool => true, - $assertions + $assertions, ); Reconciler::reconcileKeyedTypes( @@ -407,7 +407,7 @@ public static function handle( $statements_analyzer, [], $context->inside_loop, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ); } @@ -421,24 +421,24 @@ public static function handle( && UnionTypeComparator::isContainedBy( $codebase, $first_arg_type, - Type::getList() + Type::getList(), ) ) { if ($first_arg_type->from_docblock) { IssueBuffer::maybeAdd( new RedundantFunctionCallGivenDocblockType( "The call to $function_id is unnecessary given the list docblock type $first_arg_type", - new CodeLocation($statements_analyzer, $function_name) + new CodeLocation($statements_analyzer, $function_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantFunctionCall( "The call to $function_id is unnecessary, $first_arg_type is already a list", - new CodeLocation($statements_analyzer, $function_name) + new CodeLocation($statements_analyzer, $function_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -450,24 +450,24 @@ public static function handle( && UnionTypeComparator::isContainedBy( $codebase, $first_arg_type, - new Union([new TLowercaseString()]) + new Union([new TLowercaseString()]), ) ) { if ($first_arg_type->from_docblock) { IssueBuffer::maybeAdd( new RedundantFunctionCallGivenDocblockType( 'The call to strtolower is unnecessary given the docblock type', - new CodeLocation($statements_analyzer, $function_name) + new CodeLocation($statements_analyzer, $function_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new RedundantFunctionCall( 'The call to strtolower is unnecessary', - new CodeLocation($statements_analyzer, $function_name) + new CodeLocation($statements_analyzer, $function_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -485,15 +485,15 @@ public static function handle( IssueBuffer::maybeAdd( new RawObjectIteration( 'Possibly undesired iteration over object properties', - new CodeLocation($statements_analyzer, $function_name) - ) + new CodeLocation($statements_analyzer, $function_name), + ), ); } else { IssueBuffer::maybeAdd( new PossibleRawObjectIteration( 'Possibly undesired iteration over object properties', - new CodeLocation($statements_analyzer, $function_name) - ) + new CodeLocation($statements_analyzer, $function_name), + ), ); } } @@ -524,7 +524,7 @@ private static function handleDependentTypeFunction( $var_id, $context->vars_in_scope[$var_id]->hasMixed() ? Type::getObject() - : $context->vars_in_scope[$var_id] + : $context->vars_in_scope[$var_id], ); } elseif ($function_id === 'gettype') { $atomic_type = new TDependentGetType($var_id); @@ -559,14 +559,14 @@ private static function handleDependentTypeFunction( $class_type->param_name, 'object', null, - $class_type->defining_class + $class_type->defining_class, ); } elseif ($as_atomic_type instanceof TNamedObject) { $class_string_types[] = new TTemplateParamClass( $class_type->param_name, $as_atomic_type->value, $as_atomic_type, - $class_type->defining_class + $class_type->defining_class, ); } } elseif ($function_id === 'get_class') { @@ -602,9 +602,9 @@ private static function handleDependentTypeFunction( new Union([ new TClassString( $get_class_name, - new TNamedObject($get_class_name) - ) - ]) + new TNamedObject($get_class_name), + ), + ]), ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php index 60a436a1e5a..c02cb9304a0 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php @@ -94,13 +94,13 @@ public static function analyze( $codebase->file_reference_provider->addMethodReferenceToClassMember( $context->calling_method_id, 'use:' . $stmt->class->parts[0] . ':' . md5($statements_analyzer->getFilePath()), - false + false, ); } $fq_class_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $aliases + $aliases, ); $fq_class_name = $codebase->classlikes->getUnAliasedName($fq_class_name); @@ -143,7 +143,7 @@ public static function analyze( . ($stmt->class instanceof PhpParser\Node\Name\FullyQualified ? '\\' : $statements_analyzer->getNamespace() . '-') - . implode('\\', $stmt->class->parts) + . implode('\\', $stmt->class->parts), ); } } elseif ($stmt->class instanceof PhpParser\Node\Stmt\Class_) { @@ -158,7 +158,7 @@ public static function analyze( $stmt->class, $config, $fq_class_name, - $can_extend + $can_extend, ); } @@ -172,7 +172,7 @@ public static function analyze( $statements_analyzer, $stmt->class, $fq_class_name, - $context->calling_method_id + $context->calling_method_id, ); } @@ -184,7 +184,7 @@ public static function analyze( null, null, true, - $context + $context, ); return true; @@ -196,7 +196,7 @@ public static function analyze( new CodeLocation($statements_analyzer->getSource(), $stmt->class), $context->self, $context->calling_method_id, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false) { ArgumentsAnalyzer::analyze( $statements_analyzer, @@ -204,7 +204,7 @@ public static function analyze( null, null, true, - $context + $context, ); return true; @@ -214,9 +214,9 @@ public static function analyze( IssueBuffer::maybeAdd( new InterfaceInstantiation( 'Interface ' . $fq_class_name . ' cannot be instantiated', - new CodeLocation($statements_analyzer->getSource(), $stmt->class) + new CodeLocation($statements_analyzer->getSource(), $stmt->class), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return true; } @@ -233,7 +233,7 @@ public static function analyze( $statements_analyzer->node_data->setType( $stmt, - new Union([$result_atomic_type]) + new Union([$result_atomic_type]), ); if (strtolower($fq_class_name) !== 'stdclass' && @@ -246,7 +246,7 @@ public static function analyze( $context, $fq_class_name, $from_static, - $can_extend + $can_extend, ); } else { ArgumentsAnalyzer::analyze( @@ -255,14 +255,14 @@ public static function analyze( null, null, true, - $context + $context, ); if ($codebase->classlikes->enumExists($fq_class_name)) { IssueBuffer::maybeAdd(new UndefinedClass( 'Enums cannot be instantiated', new CodeLocation($statements_analyzer, $stmt), - $fq_class_name + $fq_class_name, )); } } @@ -292,9 +292,9 @@ private static function analyzeNamedConstructor( new UnsafeInstantiation( 'Cannot safely instantiate class ' . $fq_class_name . ' with "new static" as' . ' its constructor might change in child classes', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($storage->template_types && !$storage->enforce_template_inheritance @@ -312,9 +312,9 @@ private static function analyzeNamedConstructor( 'Cannot safely instantiate generic class ' . $fq_class_name . ' with "new static" as' . ' its generic parameters may be constrained in child classes.', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -326,9 +326,9 @@ private static function analyzeNamedConstructor( if (IssueBuffer::accepts( new AbstractInstantiation( 'Unable to instantiate a abstract class ' . $fq_class_name, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -339,9 +339,9 @@ private static function analyzeNamedConstructor( new DeprecatedClass( $fq_class_name . ' is marked deprecated', new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -356,9 +356,9 @@ private static function analyzeNamedConstructor( $fq_class_name . ' is internal to ' . InternalClass::listToPhrase($storage->internal) . ' but called from ' . $context->self, new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -369,7 +369,7 @@ private static function analyzeNamedConstructor( $context->calling_method_id, $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) : null, $statements_analyzer, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), )) { if ($codebase->store_node_types && !$context->collect_initializations @@ -379,7 +379,7 @@ private static function analyzeNamedConstructor( $statements_analyzer, $stmt, $codebase, - (string)$method_id + (string)$method_id, ); } @@ -391,7 +391,7 @@ private static function analyzeNamedConstructor( $template_result, $context, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer + $statements_analyzer, ) === false) { return; } @@ -401,7 +401,7 @@ private static function analyzeNamedConstructor( $context, $statements_analyzer->getSource(), new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false) { return; } @@ -419,9 +419,9 @@ private static function analyzeNamedConstructor( . ' is internal to ' . InternalClass::listToPhrase($method_storage->internal) . ' but called from ' . ($caller_identifier ?: 'root namespace'), new CodeLocation($statements_analyzer, $stmt), - (string) $method_id + (string) $method_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -430,9 +430,9 @@ private static function analyzeNamedConstructor( IssueBuffer::maybeAdd( new ImpureMethodCall( 'Cannot call an impure constructor from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer @@ -451,7 +451,7 @@ private static function analyzeNamedConstructor( $stmt->getArgs(), $template_result, $context, - $statements_analyzer + $statements_analyzer, ); } @@ -461,8 +461,8 @@ private static function analyzeNamedConstructor( array_map( static fn(Possibilities $assertion): Possibilities => $assertion->getUntemplatedCopy($template_result, null, $codebase), - $method_storage->if_true_assertions - ) + $method_storage->if_true_assertions, + ), ); } @@ -472,8 +472,8 @@ private static function analyzeNamedConstructor( array_map( static fn(Possibilities $assertion): Possibilities => $assertion->getUntemplatedCopy($template_result, null, $codebase), - $method_storage->if_false_assertions - ) + $method_storage->if_false_assertions, + ), ); } } @@ -485,7 +485,7 @@ private static function analyzeNamedConstructor( if (isset($template_result->lower_bounds[$template_name][$fq_class_name])) { $generic_param_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $template_result->lower_bounds[$template_name][$fq_class_name], - $codebase + $codebase, ); } elseif ($storage->template_extended_params && $template_result->lower_bounds) { $generic_param_type = self::getGenericParamForOffset( @@ -497,12 +497,12 @@ private static function analyzeNamedConstructor( static fn(array $bounds): Union => TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $bounds, - $codebase + $codebase, ), - $type_map + $type_map, ), - $template_result->lower_bounds - ) + $template_result->lower_bounds, + ), ); } else { if ($fq_class_name === 'SplObjectStorage') { @@ -513,7 +513,7 @@ private static function analyzeNamedConstructor( } $generic_param_types[] = $generic_param_type->setProperties([ - 'had_template' => true + 'had_template' => true, ]); } } @@ -523,12 +523,12 @@ private static function analyzeNamedConstructor( $fq_class_name, $generic_param_types, false, - $from_static + $from_static, ); $statements_analyzer->node_data->setType( $stmt, - new Union([$result_atomic_type]) + new Union([$result_atomic_type]), ); } } elseif ($stmt->getArgs()) { @@ -536,9 +536,9 @@ private static function analyzeNamedConstructor( new TooManyArguments( 'Class ' . $fq_class_name . ' has no __construct, but arguments were passed', new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name . '::__construct' + $fq_class_name . '::__construct', ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($storage->template_types) { $result_atomic_type = new TGenericObject( @@ -546,16 +546,16 @@ private static function analyzeNamedConstructor( array_values( array_map( static fn($map) => reset($map), - $storage->template_types - ) + $storage->template_types, + ), ), false, - $from_static + $from_static, ); $statements_analyzer->node_data->setType( $stmt, - new Union([$result_atomic_type]) + new Union([$result_atomic_type]), ); } @@ -565,7 +565,7 @@ private static function analyzeNamedConstructor( if ($stmt_type) { $stmt_type = $stmt_type->setProperties([ - 'reference_free' => true + 'reference_free' => true, ]); $statements_analyzer->node_data->setType($stmt, $stmt_type); } @@ -592,13 +592,13 @@ private static function analyzeNamedConstructor( (string)$method_id, $fq_class_name . '::__construct', $storage->location, - $code_location + $code_location, ); } else { $method_source = DataFlowNode::getForMethodReturn( (string)$method_id, $fq_class_name . '::__construct', - $storage->location + $storage->location, ); } @@ -633,7 +633,7 @@ private static function analyzeConstructorExpression( null, null, true, - $context + $context, ); return; @@ -655,7 +655,7 @@ private static function analyzeConstructorExpression( 'variable-call', 0, $arg_location, - $arg_location + $arg_location, ); $custom_call_sink->taints = [TaintKind::INPUT_CALLABLE]; @@ -673,7 +673,7 @@ private static function analyzeConstructorExpression( $custom_call_sink, 'call', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -684,7 +684,7 @@ private static function analyzeConstructorExpression( new TemplateResult([], []), $context, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer + $statements_analyzer, ) === false) { return; } @@ -709,16 +709,16 @@ private static function analyzeConstructorExpression( $lhs_type_part->as_type ? new Union([$lhs_type_part->as_type]) : Type::getObject(), - $lhs_type_part->defining_class + $lhs_type_part->defining_class, ); if (!$lhs_type_part->as_type) { IssueBuffer::maybeAdd( new MixedMethodCall( 'Cannot call constructor on an unknown class', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -728,7 +728,7 @@ private static function analyzeConstructorExpression( && $codebase->classlikes->classExists($lhs_type_part->as_type->value) ) { $as_storage = $codebase->classlike_storage_provider->get( - $lhs_type_part->as_type->value + $lhs_type_part->as_type->value, ); if (!$as_storage->preserve_constructor_signature) { @@ -737,9 +737,9 @@ private static function analyzeConstructorExpression( 'Cannot safely instantiate class ' . $lhs_type_part->as_type->value . ' with "new $class_name" as' . ' its constructor might change in child classes', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -749,13 +749,13 @@ private static function analyzeConstructorExpression( $codebase->methods->methodExists( new MethodIdentifier( $lhs_type_part->as_type->value, - '__construct' + '__construct', ), $context->calling_method_id, $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) : null, $statements_analyzer, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), ); } @@ -776,7 +776,7 @@ private static function analyzeConstructorExpression( && $codebase->classlikes->classExists($lhs_type_part->as_type->value) ) { $as_storage = $codebase->classlike_storage_provider->get( - $lhs_type_part->as_type->value + $lhs_type_part->as_type->value, ); if (!$as_storage->preserve_constructor_signature) { @@ -785,9 +785,9 @@ private static function analyzeConstructorExpression( 'Cannot safely instantiate class ' . $lhs_type_part->as_type->value . ' with "new $class_name" as' . ' its constructor might change in child classes', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -800,14 +800,14 @@ private static function analyzeConstructorExpression( foreach ($lhs_type_part->as_type->getAtomicTypes() as $typeof_type_atomic) { if ($typeof_type_atomic instanceof TNamedObject) { $generated_type = new TNamedObject( - $typeof_type_atomic->value + $typeof_type_atomic->value, ); } } } } else { $generated_type = new TNamedObject( - $lhs_type_part->value + $lhs_type_part->value, ); } @@ -819,9 +819,9 @@ private static function analyzeConstructorExpression( IssueBuffer::maybeAdd( new MixedMethodCall( 'Cannot call constructor on an unknown class', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -838,9 +838,9 @@ private static function analyzeConstructorExpression( IssueBuffer::maybeAdd( new InvalidStringClass( 'String cannot be used as a class', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } elseif ($lhs_type_part instanceof TMixed @@ -849,9 +849,9 @@ private static function analyzeConstructorExpression( IssueBuffer::maybeAdd( new MixedMethodCall( 'Cannot call constructor on an unknown class', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($lhs_type_part instanceof TFalse && $stmt_class_type->ignore_falsable_issues @@ -869,9 +869,9 @@ private static function analyzeConstructorExpression( new UndefinedClass( 'Type ' . $lhs_type_part . ' cannot be called as a class', new CodeLocation($statements_analyzer->getSource(), $stmt), - (string)$lhs_type_part + (string)$lhs_type_part, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -889,7 +889,7 @@ private static function analyzeConstructorExpression( null, null, true, - $context + $context, ); return; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php index e4020067acd..a79f2760e53 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php @@ -70,9 +70,9 @@ public static function analyze( return !IssueBuffer::accepts( new ParentNotFound( 'Cannot call method on parent as this class does not extend another', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -94,9 +94,9 @@ public static function analyze( return !IssueBuffer::accepts( new NonStaticSelfCall( 'Cannot use ' . $stmt->class->parts[0] . ' outside class context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -112,13 +112,13 @@ public static function analyze( $codebase->file_reference_provider->addMethodReferenceToClassMember( $context->calling_method_id, 'use:' . $stmt->class->parts[0] . ':' . md5($statements_analyzer->getFilePath()), - false + false, ); } $fq_class_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $aliases + $aliases, ); if ($context->isPhantomClass($fq_class_name)) { @@ -152,7 +152,7 @@ public static function analyze( ? $context->calling_method_id : null, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(false, false, false, true) + new ClassLikeNameOptions(false, false, false, true), ); } @@ -169,7 +169,7 @@ public static function analyze( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->class, - $fq_class_name + $fq_class_name, ); } @@ -191,7 +191,7 @@ public static function analyze( null, null, true, - $context + $context, ) === false) { return false; } @@ -213,7 +213,7 @@ public static function analyze( $moved_call, $has_mock, $has_existing_method, - $template_result + $template_result, ); } @@ -224,7 +224,7 @@ public static function analyze( new TemplateResult([], []), $context, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer + $statements_analyzer, ); } @@ -272,13 +272,13 @@ public static function taintReturnType( (string) $method_id, $cased_method_id, $method_location, - $node_location + $node_location, ); } else { $method_source = DataFlowNode::getForMethodReturn( (string) $method_id, $cased_method_id, - $method_location + $method_location, ); } @@ -293,7 +293,7 @@ public static function taintReturnType( $conditionally_removed_taint = TemplateInferredTypeReplacer::replace( $conditionally_removed_taint, $template_result, - $codebase + $codebase, ); $expanded_type = TypeExpander::expandUnion( @@ -303,7 +303,7 @@ public static function taintReturnType( null, null, true, - true + true, ); foreach ($expanded_type->getLiteralStrings() as $literal_string) { @@ -326,7 +326,7 @@ public static function taintReturnType( $assignment_node = DataFlowNode::getForAssignment( $method_id . '-escaped', $method_location, - $method_source->specialization_key + $method_source->specialization_key, ); $statements_analyzer->data_flow_graph->addPath( @@ -334,7 +334,7 @@ public static function taintReturnType( $assignment_node, 'conditionally-escaped', $added_taints, - [...$conditionally_removed_taints, ...$removed_taints] + [...$conditionally_removed_taints, ...$removed_taints], ); $return_type_candidate = $return_type_candidate->addParentNodes([$assignment_node->id => $assignment_node]); @@ -349,7 +349,7 @@ public static function taintReturnType( $method_node = TaintSource::getForMethodReturn( (string) $method_id, $cased_method_id, - $method_storage->signature_return_type_location ?: $method_storage->location + $method_storage->signature_return_type_location ?: $method_storage->location, ); $method_node->taints = $method_storage->taint_source_types; @@ -367,7 +367,7 @@ public static function taintReturnType( $node_location, $method_source, array_merge($method_storage->removed_taints, $removed_taints), - $added_taints + $added_taints, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php index 49c44759037..ac857f23be1 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php @@ -100,8 +100,8 @@ public static function analyze( new ClassLikeNameOptions( $stmt->class instanceof PhpParser\Node\Name && count($stmt->class->parts) === 1 - && in_array(strtolower($stmt->class->parts[0]), ['self', 'static'], true) - ) + && in_array(strtolower($stmt->class->parts[0]), ['self', 'static'], true), + ), )) { return; } @@ -118,7 +118,7 @@ public static function analyze( new CodeLocation($statements_analyzer, $stmt->class), $context->self, $context->calling_method_id, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -151,7 +151,7 @@ public static function analyze( new CodeLocation($statements_analyzer, $stmt->class), $context->self, $context->calling_method_id, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -175,9 +175,9 @@ public static function analyze( new UndefinedClass( 'Type ' . $lhs_type_part->as . ' cannot be called as a class', new CodeLocation($statements_analyzer->getSource(), $stmt), - (string) $lhs_type_part + (string) $lhs_type_part, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -188,7 +188,7 @@ public static function analyze( $stmt, $context, $lhs_type_part, - $ignore_nullable_issues + $ignore_nullable_issues, ); return; @@ -213,7 +213,7 @@ public static function analyze( $fq_class_name, $moved_call, $has_existing_method, - $inferred_template_result + $inferred_template_result, ); } else { if ($stmt->name instanceof PhpParser\Node\Expr) { @@ -228,7 +228,7 @@ public static function analyze( if (!$context->ignore_variable_method) { $codebase->analyzer->addMixedMemberName( strtolower($fq_class_name) . '::', - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } @@ -239,7 +239,7 @@ public static function analyze( if ($method_name_type && $method_name_type->isSingleStringLiteral()) { $method_identifier = new MethodIdentifier( $fq_class_name, - strtolower($method_name_type->getSingleStringLiteral()->value) + strtolower($method_name_type->getSingleStringLiteral()->value), ); //the call to methodExists will register that the method was called from somewhere if ($codebase->methods->methodExists( @@ -249,7 +249,7 @@ public static function analyze( $statements_analyzer, $statements_analyzer->getFilePath(), true, - $context->insideUse() + $context->insideUse(), )) { $method_storage = $codebase->methods->getStorage($method_identifier); @@ -257,7 +257,7 @@ public static function analyze( 'Closure', $method_storage->params, $method_storage->return_type, - $method_storage->pure + $method_storage->pure, )]); } } @@ -274,7 +274,7 @@ public static function analyze( null, null, true, - $context + $context, ) === false) { return; } @@ -293,7 +293,7 @@ public static function analyze( $fq_class_name, $context->calling_method_id, false, - $stmt->class->parts[0] === 'self' + $stmt->class->parts[0] === 'self', ); } } @@ -329,7 +329,7 @@ private static function handleNamedCall( $statements_analyzer, $stmt, $codebase, - (string) $method_id + (string) $method_id, ); } @@ -343,7 +343,7 @@ private static function handleNamedCall( $intersection_method_id = new MethodIdentifier( $intersection_type->value, - $method_name_lc + $method_name_lc, ); if ($codebase->methods->methodExists($intersection_method_id)) { @@ -369,7 +369,7 @@ private static function handleNamedCall( $statements_analyzer, $statements_analyzer->getFilePath(), false, - $context->insideUse() + $context->insideUse(), ); $fake_method_exists = false; @@ -381,7 +381,7 @@ private static function handleNamedCall( $fq_class_name, $method_id->method_name, $statements_analyzer, - null + null, ) ?? false; } @@ -394,7 +394,7 @@ private static function handleNamedCall( foreach ($class_storage->namedMixins as $mixin) { $new_method_id = new MethodIdentifier( $mixin->value, - $method_name_lc + $method_name_lc, ); if ($codebase->methods->methodExists( @@ -409,7 +409,7 @@ private static function handleNamedCall( : null, $statements_analyzer->getFilePath(), true, - $context->insideUse() + $context->insideUse(), )) { $mixin_candidates = []; foreach ($class_storage->templatedMixins as $mixin_candidate) { @@ -437,7 +437,7 @@ private static function handleNamedCall( } $mixin_declaring_class_storage = $codebase->classlike_storage_provider->get( - $class_storage->mixin_declaring_fqcln + $class_storage->mixin_declaring_fqcln, ); $new_mixin_candidate_type = AtomicPropertyFetchAnalyzer::localizePropertyType( @@ -445,7 +445,7 @@ private static function handleNamedCall( new Union([$lhs_type_part]), $tGenericMixin, $class_storage, - $mixin_declaring_class_storage + $mixin_declaring_class_storage, )->getBuilder(); foreach ($mixin_candidate_type->getAtomicTypes() as $type) { @@ -463,7 +463,7 @@ private static function handleNamedCall( $class_storage->parent_class, true, false, - $class_storage->final + $class_storage->final, ); $mixin_context = clone $context; @@ -475,7 +475,7 @@ private static function handleNamedCall( $stmt_name, $mixin_context, '__tmp_mixin_var__', - true + true, ); } } @@ -486,7 +486,7 @@ private static function handleNamedCall( $found_method_and_class_storage = self::findPseudoMethodAndClassStorages( $codebase, $class_storage, - $method_name_lc + $method_name_lc, ); if ($stmt->isFirstClassCallable()) { @@ -497,7 +497,7 @@ private static function handleNamedCall( 'Closure', $method_storage->params, $method_storage->return_type, - $method_storage->pure + $method_storage->pure, )]); } else { $method_exists = $naive_method_exists @@ -512,7 +512,7 @@ private static function handleNamedCall( 'Closure', array_values($codebase->getMethodParams($method_id)), $codebase->getMethodReturnType($method_id, $fq_class_name), - $codebase->methods->getStorage($declaring_method_id)->pure + $codebase->methods->getStorage($declaring_method_id)->pure, )]); } else { // FIXME: perhaps Psalm should complain about nonexisting method here, or throw a logic exception? @@ -528,7 +528,7 @@ private static function handleNamedCall( $context->parent, true, false, - true + true, ); $statements_analyzer->node_data->setType($stmt, $expanded_return_type); @@ -540,7 +540,7 @@ private static function handleNamedCall( || !MethodAnalyzer::isMethodVisible( $method_id, $context, - $statements_analyzer->getSource() + $statements_analyzer->getSource(), ) || $fake_method_exists || ($found_method_and_class_storage @@ -548,7 +548,7 @@ private static function handleNamedCall( ) { $callstatic_id = new MethodIdentifier( $fq_class_name, - '__callstatic' + '__callstatic', ); if ($codebase->methods->methodExists( @@ -563,7 +563,7 @@ private static function handleNamedCall( : null, $statements_analyzer->getFilePath(), true, - $context->insideUse() + $context->insideUse(), )) { $callstatic_appearing_id = $codebase->methods->getAppearingMethodId($callstatic_id); assert($callstatic_appearing_id !== null); @@ -584,7 +584,7 @@ private static function handleNamedCall( new CodeLocation($statements_analyzer->getSource(), $stmt_name), null, null, - strtolower($stmt_name->name) + strtolower($stmt_name->name), ); if ($return_type_candidate) { @@ -594,7 +594,7 @@ private static function handleNamedCall( new TemplateResult([], []), $context, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer + $statements_analyzer, ); $statements_analyzer->node_data->setType($stmt, $return_type_candidate); @@ -614,7 +614,7 @@ private static function handleNamedCall( $args, $defining_class_storage, $pseudo_method_storage, - $context + $context, ) === false ) { return false; @@ -625,17 +625,17 @@ private static function handleNamedCall( IssueBuffer::maybeAdd( new ImpureMethodCall( 'Cannot call an impure method from a pure context', - new CodeLocation($statements_analyzer, $stmt_name) + new CodeLocation($statements_analyzer, $stmt_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($context->mutation_free && !$callstatic_mutation_free) { IssueBuffer::maybeAdd( new ImpureMethodCall( 'Cannot call a possibly-mutating method from a mutation-free context', - new CodeLocation($statements_analyzer, $stmt_name) + new CodeLocation($statements_analyzer, $stmt_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer @@ -660,7 +660,7 @@ private static function handleNamedCall( null, null, true, - $context + $context, ) === false) { return false; } @@ -671,9 +671,9 @@ private static function handleNamedCall( $arg->value, null, false, - $arg->getAttributes() + $arg->getAttributes(), ), - $args + $args, ); $args = [ @@ -681,19 +681,19 @@ private static function handleNamedCall( new VirtualString((string) $method_id, $stmt_name->getAttributes()), false, false, - $stmt_name->getAttributes() + $stmt_name->getAttributes(), ), new VirtualArg( new VirtualArray($array_values, $stmt->getAttributes()), false, false, - $stmt->getAttributes() + $stmt->getAttributes(), ), ]; $method_id = new MethodIdentifier( $fq_class_name, - '__callstatic' + '__callstatic', ); } elseif ($found_method_and_class_storage && ($config->use_phpdoc_method_without_magic_or_parent || $class_storage->parent_class) @@ -708,7 +708,7 @@ private static function handleNamedCall( $args, $defining_class_storage, $pseudo_method_storage, - $context + $context, ) === false ) { return false; @@ -733,7 +733,7 @@ private static function handleNamedCall( $stmt, $stmt_name, $tmp_context, - '__tmp_parent_var__' + '__tmp_parent_var__', ) === false) { return false; } @@ -767,7 +767,7 @@ private static function handleNamedCall( null, null, true, - $context + $context, ) === false) { return false; } @@ -781,7 +781,7 @@ private static function handleNamedCall( $method_id, new CodeLocation($statements_analyzer, $stmt), $statements_analyzer->getSuppressedIssues(), - $context->calling_method_id + $context->calling_method_id, ); if (!$does_method_exist) { @@ -791,7 +791,7 @@ private static function handleNamedCall( null, null, true, - $context + $context, ) === false) { return false; } @@ -802,7 +802,7 @@ private static function handleNamedCall( $statements_analyzer, $stmt->class, $fq_class_name, - $context->calling_method_id + $context->calling_method_id, ); } @@ -816,9 +816,9 @@ private static function handleNamedCall( new DeprecatedClass( $fq_class_name . ' is marked deprecated', new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -828,9 +828,9 @@ private static function handleNamedCall( $fq_class_name . ' is internal to ' . InternalClass::listToPhrase($class_storage->internal) . ' but called from ' . $context->self, new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -839,7 +839,7 @@ private static function handleNamedCall( $context, $statements_analyzer->getSource(), new CodeLocation($statements_analyzer, $stmt), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false) { return false; } @@ -862,7 +862,7 @@ private static function handleNamedCall( $codebase, new CodeLocation($statements_analyzer, $stmt), $statements_analyzer->getSuppressedIssues(), - $is_dynamic_this_method + $is_dynamic_this_method, ); if ($is_dynamic_this_method) { @@ -870,7 +870,7 @@ private static function handleNamedCall( $statements_analyzer, $stmt, $stmt_name, - $context + $context, ); } } @@ -888,7 +888,7 @@ private static function handleNamedCall( $cased_method_id, $class_storage, $moved_call, - $inferred_template_result + $inferred_template_result, ); return true; @@ -914,7 +914,7 @@ private static function checkPseudoMethod( $pseudo_method_storage->params, (string) $method_id, true, - $context + $context, ) === false) { return false; } @@ -930,7 +930,7 @@ private static function checkPseudoMethod( null, new TemplateResult([], []), new CodeLocation($statements_analyzer, $stmt), - $context + $context, ) === false) { return false; } @@ -947,7 +947,7 @@ private static function checkPseudoMethod( $method_storage->params, (string) $method_id, true, - $context + $context, ); ArgumentsAnalyzer::checkArgumentsMatch( @@ -959,7 +959,7 @@ private static function checkPseudoMethod( null, new TemplateResult([], []), new CodeLocation($statements_analyzer, $stmt), - $context + $context, ); } catch (Exception $e) { // do nothing @@ -974,7 +974,7 @@ private static function checkPseudoMethod( $return_type_candidate, $class_storage->name, $static_fq_class_name, - $class_storage->parent_class + $class_storage->parent_class, ); if ($method_storage) { @@ -986,7 +986,7 @@ private static function checkPseudoMethod( $return_type_candidate, $method_storage, null, - $context + $context, ); } @@ -996,8 +996,8 @@ private static function checkPseudoMethod( $stmt, Type::combineUnionTypes( $return_type_candidate, - $stmt_type - ) + $stmt_type, + ), ); } @@ -1022,16 +1022,16 @@ public static function handleNonObjectCall( if ($stmt->name instanceof PhpParser\Node\Identifier) { $codebase->analyzer->addMixedMemberName( strtolower($stmt->name->name), - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } IssueBuffer::maybeAdd( new MixedMethodCall( 'Cannot call method on an unknown class', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -1047,9 +1047,9 @@ public static function handleNonObjectCall( IssueBuffer::maybeAdd( new InvalidStringClass( 'String cannot be used as a class', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -1065,9 +1065,9 @@ public static function handleNonObjectCall( new UndefinedClass( 'Type ' . $lhs_type_part . ' cannot be called as a class', new CodeLocation($statements_analyzer->getSource(), $stmt), - (string) $lhs_type_part + (string) $lhs_type_part, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1098,7 +1098,7 @@ private static function findPseudoMethodAndClassStorages( if ($class_storage && isset($class_storage->pseudo_static_methods[$method_name_lc])) { return [ $class_storage->pseudo_static_methods[$method_name_lc], - $class_storage + $class_storage, ]; } } @@ -1131,13 +1131,13 @@ private static function forwardCallToInstanceMethod( new VirtualVariable($virtual_var_name, $stmt->class->getAttributes()), $stmt_name, $stmt->getArgs(), - $stmt->getAttributes() + $stmt->getAttributes(), ); if (MethodCallAnalyzer::analyze( $statements_analyzer, $fake_method_call_expr, - $context + $context, ) === false) { return false; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php index 922b74f6759..ccad64bb588 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php @@ -78,7 +78,7 @@ public static function analyze( $method_id, $statements_analyzer->getFullyQualifiedFunctionMethodOrNamespaceName(), new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); if ($class_storage->user_defined @@ -150,7 +150,7 @@ public static function analyze( $class_storage, $method_name_lc, $lhs_type_part, - !$statements_analyzer->isStatic() && $method_id->fq_class_name === $context->self + !$statements_analyzer->isStatic() && $method_id->fq_class_name === $context->self, ); if ($found_generic_params @@ -195,7 +195,7 @@ public static function analyze( $template_result, $context, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer + $statements_analyzer, ) === false) { return; } @@ -215,7 +215,7 @@ public static function analyze( $stmt_name->name, $stmt, $context, - new CodeLocation($statements_analyzer->getSource(), $stmt_name) + new CodeLocation($statements_analyzer->getSource(), $stmt_name), ); } @@ -238,7 +238,7 @@ public static function analyze( new CodeLocation($statements_analyzer->getSource(), $stmt_name), null, $fq_class_name, - $stmt_name->name + $stmt_name->name, ); } } @@ -256,7 +256,7 @@ public static function analyze( $context, $fq_class_name, $class_storage, - $config + $config, ); } @@ -270,19 +270,19 @@ public static function analyze( $codebase, $context->vars_in_scope['$this'] ?? new Union([ - new TNamedObject($context->self) + new TNamedObject($context->self), ]), new Union([ - new TNamedObject($method_id->fq_class_name) - ]) + new TNamedObject($method_id->fq_class_name), + ]), )) ) { IssueBuffer::maybeAdd( new AbstractMethodCall( 'Cannot call an abstract static method ' . $method_id . ' directly', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -291,17 +291,17 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureMethodCall( 'Cannot call an impure method from a pure context', - new CodeLocation($statements_analyzer, $stmt_name) + new CodeLocation($statements_analyzer, $stmt_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($context->mutation_free && !$method_storage->mutation_free) { IssueBuffer::maybeAdd( new ImpureMethodCall( 'Cannot call a possibly-mutating method from a mutation-free context', - new CodeLocation($statements_analyzer, $stmt_name) + new CodeLocation($statements_analyzer, $stmt_name), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer @@ -324,7 +324,7 @@ public static function analyze( $stmt->getArgs(), $template_result, $context, - $statements_analyzer + $statements_analyzer, ); } @@ -334,8 +334,8 @@ public static function analyze( array_map( static fn(Possibilities $assertion): Possibilities => $assertion->getUntemplatedCopy($template_result, null, $codebase), - $method_storage->if_true_assertions - ) + $method_storage->if_true_assertions, + ), ); } @@ -345,8 +345,8 @@ public static function analyze( array_map( static fn(Possibilities $assertion): Possibilities => $assertion->getUntemplatedCopy($template_result, null, $codebase), - $method_storage->if_false_assertions - ) + $method_storage->if_false_assertions, + ), ); } } @@ -370,7 +370,7 @@ public static function analyze( $new_fq_class_name, $context->calling_method_id, strtolower($old_declaring_fq_class_name) !== strtolower($new_fq_class_name), - $stmt->class->parts[0] === 'self' + $stmt->class->parts[0] === 'self', )) { $moved_call = true; } @@ -380,12 +380,12 @@ public static function analyze( $file_manipulations[] = new FileManipulation( (int) $stmt_name->getAttribute('startFilePos'), (int) $stmt_name->getAttribute('endFilePos') + 1, - $new_method_name + $new_method_name, ); FileManipulationBuffer::add( $statements_analyzer->getFilePath(), - $file_manipulations + $file_manipulations, ); } } @@ -407,7 +407,7 @@ public static function analyze( $statements_analyzer, $codebase, $file_manipulations, - $return_type_candidate + $return_type_candidate, ); $config->eventDispatcher->dispatchAfterMethodCallAnalysis($event); $file_manipulations = $event->getFileReplacements(); @@ -429,13 +429,13 @@ public static function analyze( $return_type_candidate, $method_storage, $template_result, - $context + $context, ); $stmt_type = $statements_analyzer->node_data->getType($stmt); $statements_analyzer->node_data->setType( $stmt, - Type::combineUnionTypes($stmt_type, $return_type_candidate) + Type::combineUnionTypes($stmt_type, $return_type_candidate), ); if ($codebase->store_node_types @@ -445,7 +445,7 @@ public static function analyze( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->name, - $method_id . '()' + $method_id . '()', ); if ($stmt_type = $statements_analyzer->node_data->getType($stmt)) { @@ -453,7 +453,7 @@ public static function analyze( $statements_analyzer->getFilePath(), $stmt->name, $stmt_type->getId(), - $stmt + $stmt, ); } } @@ -480,7 +480,7 @@ private static function getMethodReturnType( $method_id, $self_fq_class_name, $statements_analyzer, - $args + $args, ); if ($return_type_candidate) { @@ -491,23 +491,23 @@ private static function getMethodReturnType( if (!isset( $template_result->lower_bounds [$template_type->param_name] - [$template_type->defining_class] + [$template_type->defining_class], )) { if ($template_type->param_name === 'TFunctionArgCount') { $template_result->lower_bounds[$template_type->param_name] = [ 'fn-' . strtolower((string)$method_id) => [ new TemplateBound( - Type::getInt(false, count($stmt->getArgs())) - ) - ] + Type::getInt(false, count($stmt->getArgs())), + ), + ], ]; } elseif ($template_type->param_name === 'TPhpMajorVersion') { $template_result->lower_bounds[$template_type->param_name] = [ 'fn-' . strtolower((string)$method_id) => [ new TemplateBound( - Type::getInt(false, $codebase->getMajorAnalysisPhpVersion()) - ) - ] + Type::getInt(false, $codebase->getMajorAnalysisPhpVersion()), + ), + ], ]; } elseif ($template_type->param_name === 'TPhpVersionId') { $template_result->lower_bounds[$template_type->param_name] = [ @@ -515,16 +515,16 @@ private static function getMethodReturnType( new TemplateBound( Type::getInt( false, - $codebase->analysis_php_version_id - ) - ) - ] + $codebase->analysis_php_version_id, + ), + ), + ], ]; } else { $template_result->lower_bounds[$template_type->param_name] = [ ($template_type->defining_class) => [ - new TemplateBound(Type::getNever()) - ] + new TemplateBound(Type::getNever()), + ], ]; } } @@ -541,7 +541,7 @@ private static function getMethodReturnType( $lhs_type_part->as_type ? new Union([$lhs_type_part->as_type]) : Type::getObject(), - $lhs_type_part->defining_class + $lhs_type_part->defining_class, ); } elseif ($stmt->class instanceof PhpParser\Node\Name && count($stmt->class->parts) === 1 @@ -569,13 +569,13 @@ private static function getMethodReturnType( $return_type_candidate, null, null, - null + null, ); $return_type_candidate = TemplateInferredTypeReplacer::replace( $return_type_candidate, $template_result, - $codebase + $codebase, ); } @@ -590,14 +590,14 @@ private static function getMethodReturnType( is_string($static_type) && ($static_type !== $context->self || $class_storage->final - || $context_final) + || $context_final), ); $secondary_return_type_location = null; $return_type_location = $codebase->methods->getMethodReturnTypeLocation( $method_id, - $secondary_return_type_location + $secondary_return_type_location, ); if ($secondary_return_type_location) { @@ -615,7 +615,7 @@ private static function getMethodReturnType( true, false, false, - $context->calling_method_id + $context->calling_method_id, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php index 659111f8259..5d072adb334 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php @@ -91,13 +91,13 @@ public static function collectSpecialInformation( $context->self === $fq_class_name || $codebase->classExtends( $context->self, - $fq_class_name + $fq_class_name, ) ) ) { $method_id = new MethodIdentifier( $fq_class_name, - $method_name_lc + $method_name_lc, ); if ((string) $method_id !== $source->getId()) { @@ -117,7 +117,7 @@ public static function collectSpecialInformation( $method_id, $context, $source->getRootFilePath(), - $source->getRootFileName() + $source->getRootFileName(), ); } } elseif ($context->collect_initializations && @@ -126,7 +126,7 @@ public static function collectSpecialInformation( $context->self === $fq_class_name || $codebase->classlikes->classExtends( $context->self, - $fq_class_name + $fq_class_name, ) ) && $source->getMethodName() !== $method_name @@ -145,7 +145,7 @@ public static function collectSpecialInformation( $method_id = new MethodIdentifier( $fq_class_name, - $method_name_lc + $method_name_lc, ); $alt_declaring_method_id = $codebase->methods->getDeclaringMethodId($method_id); @@ -165,7 +165,7 @@ public static function collectSpecialInformation( $fq_class_name = $intersection_type->value; $method_id = new MethodIdentifier( $fq_class_name, - $method_name_lc + $method_name_lc, ); $alt_declaring_method_id = $codebase->methods->getDeclaringMethodId($method_id); @@ -206,7 +206,7 @@ public static function collectSpecialInformation( if ($appearing_method_id) { $appearing_class_storage = $codebase->classlike_storage_provider->get( - $appearing_method_id->fq_class_name + $appearing_method_id->fq_class_name, ); if (isset($appearing_class_storage->trait_final_map[$method_name_lc])) { @@ -250,7 +250,7 @@ public static function collectSpecialInformation( $declaring_method_id, $context, $source->getRootFilePath(), - $source->getRootFileName() + $source->getRootFileName(), ); $context->self = $old_self; } @@ -289,7 +289,7 @@ public static function checkMethodArgs( null, true, $context, - $template_result + $template_result, ) !== false; } @@ -347,7 +347,7 @@ public static function checkMethodArgs( (string) $method_id, $method_storage->allow_named_arg_calls ?? true, $context, - $template_result + $template_result, ) === false) { return false; } @@ -361,7 +361,7 @@ public static function checkMethodArgs( $class_storage, $template_result, $code_location, - $context + $context, ) === false) { return false; } @@ -371,7 +371,7 @@ public static function checkMethodArgs( $statements_analyzer, $template_result, $code_location, - strtolower((string) $method_id) + strtolower((string) $method_id), ); } @@ -412,7 +412,7 @@ public static function getTemplateTypesForCall( $atomic_type->defining_class, $atomic_type->param_name, $calling_class_storage->template_extended_params, - $class_template_params + $template_types + $class_template_params + $template_types, ); } else { $output_type_candidate = new Union([$atomic_type]); @@ -420,7 +420,7 @@ public static function getTemplateTypesForCall( $output_type = Type::combineUnionTypes( $output_type_candidate, - $output_type + $output_type, ); } @@ -448,7 +448,7 @@ public static function getTemplateTypesForCall( null, true, false, - $calling_class_storage->final ?? false + $calling_class_storage->final ?? false, ); } } @@ -481,7 +481,7 @@ public static function getGenericParamForOffset( $extended_class_name, $extended_template_name, $template_extended_params, - $found_generic_params + $found_generic_params, ); } } @@ -558,7 +558,7 @@ public static function getFunctionIdsFromCallableArg( ) { $fq_class_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $class_arg->class, - $file_source->getAliases() + $file_source->getAliases(), ); return [$fq_class_name . '::' . $method_name_arg->value]; @@ -622,9 +622,9 @@ public static function checkFunctionExists( new UndefinedFunction( 'Function ' . $cased_function_id . ' does not exist', $code_location, - $function_id + $function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return false; @@ -687,8 +687,8 @@ public static function applyAssertionsToContext( IssueBuffer::maybeAdd( new InvalidDocblock( 'Assert notation is malformed', - new CodeLocation($statements_analyzer, $expr) - ) + new CodeLocation($statements_analyzer, $expr), + ), ); continue; } @@ -701,8 +701,8 @@ public static function applyAssertionsToContext( IssueBuffer::maybeAdd( new InvalidDocblock( 'Variable ' . $var_id . ' is not an argument so cannot be asserted', - new CodeLocation($statements_analyzer, $expr) - ) + new CodeLocation($statements_analyzer, $expr), + ), ); continue; } @@ -716,8 +716,8 @@ public static function applyAssertionsToContext( IssueBuffer::maybeAdd( new InvalidDocblock( 'Variable being asserted as argument ' . ($var_id+1) . ' cannot be found in local scope', - new CodeLocation($statements_analyzer, $expr) - ) + new CodeLocation($statements_analyzer, $expr), + ), ); continue; } @@ -727,12 +727,12 @@ public static function applyAssertionsToContext( $property, $statements_analyzer->getNodeTypeProvider(), $statements_analyzer->getCodebase()->classlike_storage_provider, - $arg_value + $arg_value, ); if (null !== $failedMessage) { IssueBuffer::maybeAdd( - new InvalidDocblock($failedMessage, new CodeLocation($statements_analyzer, $expr)) + new InvalidDocblock($failedMessage, new CodeLocation($statements_analyzer, $expr)), ); continue; } @@ -753,7 +753,7 @@ public static function applyAssertionsToContext( $assertion_type = TemplateInferredTypeReplacer::replace( new Union([$assertion_type_atomic]), $template_result, - $codebase + $codebase, ); if (count($assertion_type->getAtomicTypes()) === 1) { @@ -778,9 +778,9 @@ public static function applyAssertionsToContext( $asserted_type->getId() . ' is not contained by ' . $assertion_type->getId(), new CodeLocation($statements_analyzer->getSource(), $expr), - $asserted_type->getId() . ' ' . $assertion_type->getId() + $asserted_type->getId() . ' ' . $assertion_type->getId(), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $intersection = Type::getNever(); } elseif ($intersection->getId(true) === $asserted_type->getId(true)) { @@ -793,16 +793,16 @@ public static function applyAssertionsToContext( if (!UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $assertion_type, - $asserted_type + $asserted_type, )) { IssueBuffer::maybeAdd( new TypeDoesNotContainType( $asserted_type->getId() . ' is not contained by ' . $assertion_type->getId(), new CodeLocation($statements_analyzer->getSource(), $expr), - $asserted_type->getId() . ' ' . $assertion_type->getId() + $asserted_type->getId() . ' ' . $assertion_type->getId(), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { @@ -818,7 +818,7 @@ public static function applyAssertionsToContext( if (isset($type_assertions[$assertion_var_id])) { $type_assertions[$assertion_var_id] = array_merge( $type_assertions[$assertion_var_id], - [$orred_rules] + [$orred_rules], ); } else { $type_assertions[$assertion_var_id] = [$orred_rules]; @@ -838,7 +838,7 @@ public static function applyAssertionsToContext( $arg_value, $context->self, $statements_analyzer, - $statements_analyzer->getCodebase() + $statements_analyzer->getCodebase(), ); } elseif ($single_rule instanceof Falsy) { $assert_clauses = Algebra::negateFormula( @@ -848,15 +848,15 @@ public static function applyAssertionsToContext( $arg_value, $context->self, $statements_analyzer, - $codebase - ) + $codebase, + ), ); } elseif ($single_rule instanceof IsType && $single_rule->type instanceof TTrue ) { $conditional = new VirtualIdentical( $arg_value, - new VirtualConstFetch(new VirtualName('true')) + new VirtualConstFetch(new VirtualName('true')), ); $assert_clauses = FormulaGenerator::getFormula( @@ -865,16 +865,16 @@ public static function applyAssertionsToContext( $conditional, $context->self, $statements_analyzer, - $codebase + $codebase, ); } $simplified_clauses = Algebra::simplifyCNF( - [...$context->clauses, ...$assert_clauses] + [...$context->clauses, ...$assert_clauses], ); $assert_type_assertions = Algebra::getTruthsFromFormula( - $simplified_clauses + $simplified_clauses, ); $type_assertions = array_merge($type_assertions, $assert_type_assertions); @@ -904,7 +904,7 @@ public static function applyAssertionsToContext( $statements_analyzer, $template_type_map, $context->inside_loop, - new CodeLocation($statements_analyzer->getSource(), $expr) + new CodeLocation($statements_analyzer->getSource(), $expr), ); foreach ($changed_var_ids as $var_id => $_) { @@ -928,7 +928,7 @@ public static function applyAssertionsToContext( IssueBuffer::remove( $statements_analyzer->getFilePath(), 'MixedAssignment', - $first_appearance->raw_file_start + $first_appearance->raw_file_start, ); } @@ -979,7 +979,7 @@ public static function checkTemplateResult( if (isset($template_result->lower_bounds[$template_name][$defining_id])) { $lower_bound_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $template_result->lower_bounds[$template_name][$defining_id], - $statements_analyzer->getCodebase() + $statements_analyzer->getCodebase(), ); $upper_bound_type = $upper_bound->type; @@ -997,7 +997,7 @@ public static function checkTemplateResult( $upper_bound_type, false, false, - $union_comparison_result + $union_comparison_result, )) { if ($union_comparison_result->type_coerced) { if ($union_comparison_result->type_coerced_from_mixed) { @@ -1006,9 +1006,9 @@ public static function checkTemplateResult( 'Type ' . $lower_bound_type->getId() . ' should be a subtype of ' . $upper_bound_type->getId(), $code_location, - $function_id + $function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -1016,9 +1016,9 @@ public static function checkTemplateResult( 'Type ' . $lower_bound_type->getId() . ' should be a subtype of ' . $upper_bound_type->getId(), $code_location, - $function_id + $function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } elseif ($union_comparison_result->scalar_type_match_found) { @@ -1027,9 +1027,9 @@ public static function checkTemplateResult( 'Type ' . $lower_bound_type->getId() . ' should be a subtype of ' . $upper_bound_type->getId(), $code_location, - $function_id + $function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -1037,17 +1037,17 @@ public static function checkTemplateResult( 'Type ' . $lower_bound_type->getId() . ' should be a subtype of ' . $upper_bound_type->getId(), $code_location, - $function_id + $function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } } else { $template_result->lower_bounds[$template_name][$defining_id] = [ new TemplateBound( - $upper_bound->type - ) + $upper_bound->type, + ), ]; } } @@ -1060,7 +1060,7 @@ public static function checkTemplateResult( if (count($lower_bounds) > 1) { $bounds_with_equality = array_filter( $lower_bounds, - static fn($lower_bound): bool => (bool)$lower_bound->equality_bound_classlike + static fn($lower_bound): bool => (bool)$lower_bound->equality_bound_classlike, ); if (!$bounds_with_equality) { @@ -1070,8 +1070,8 @@ public static function checkTemplateResult( $equality_types = array_unique( array_map( static fn($bound_with_equality) => $bound_with_equality->type->getId(), - $bounds_with_equality - ) + $bounds_with_equality, + ), ); if (count($equality_types) > 1) { @@ -1080,9 +1080,9 @@ public static function checkTemplateResult( 'Incompatible types found for ' . $template_name . ' (must have only one of ' . implode(', ', $equality_types) . ')', $code_location, - $function_id + $function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { foreach ($lower_bounds as $lower_bound) { @@ -1091,7 +1091,7 @@ public static function checkTemplateResult( if (UnionTypeComparator::isContainedBy( $statements_analyzer->getCodebase(), $lower_bound->type, - $bound_with_equality->type + $bound_with_equality->type, )) { continue 2; } @@ -1103,9 +1103,9 @@ public static function checkTemplateResult( $lower_bound->type->getId() . ' is not in ' . implode(', ', $equality_types) . ')', $code_location, - $function_id + $function_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php index e6892fe58c0..21d67fdbe95 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php @@ -91,7 +91,7 @@ public static function analyze( $statements_analyzer, $maybe_type, $stmt->expr, - true + true, ); } else { $type = Type::getInt(); @@ -118,7 +118,7 @@ public static function analyze( $statements_analyzer, $maybe_type, $stmt->expr, - true + true, ); } else { $type = Type::getFloat(); @@ -145,7 +145,7 @@ public static function analyze( if ($statements_analyzer->data_flow_graph instanceof VariableUseGraph ) { $type = new Union([new TBool()], [ - 'parent_nodes' => $maybe_type->parent_nodes ?? [] + 'parent_nodes' => $maybe_type->parent_nodes ?? [], ]); } else { $type = Type::getBool(); @@ -173,7 +173,7 @@ public static function analyze( $context, $stmt_expr_type, $stmt->expr, - true + true, ); } else { $stmt_type = Type::getString(); @@ -265,7 +265,7 @@ public static function analyze( : new TKeyedArray( $type->properties, null, - [Type::getArrayKey(), Type::getMixed()] + [Type::getArrayKey(), Type::getMixed()], ); $permissible_atomic_types[] = $array_type; } else { @@ -305,9 +305,9 @@ public static function analyze( IssueBuffer::maybeAdd( new UnrecognizedExpression( 'Psalm does not understand the cast ' . get_class($stmt), - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return false; @@ -420,7 +420,7 @@ public static function castIntAttempt( if (strtolower($intersection_type->value) === strtolower($pseudo_castable_class) || $codebase->classExtends( $intersection_type->value, - $pseudo_castable_class + $pseudo_castable_class, ) ) { $castable_types[] = new TInt(); @@ -469,17 +469,17 @@ public static function castIntAttempt( IssueBuffer::maybeAdd( new InvalidCast( $invalid_casts[0] . ' cannot be cast to int', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($risky_cast) { IssueBuffer::maybeAdd( new RiskyCast( 'Casting ' . $risky_cast[0] . ' to int has possibly unintended value of 0/1', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($explicit_cast && !$castable_types) { // todo: emit error here @@ -492,7 +492,7 @@ public static function castIntAttempt( } else { $int_type = TypeCombiner::combine( $valid_types, - $codebase + $codebase, ); } @@ -609,7 +609,7 @@ public static function castFloatAttempt( if (strtolower($intersection_type->value) === strtolower($pseudo_castable_class) || $codebase->classExtends( $intersection_type->value, - $pseudo_castable_class + $pseudo_castable_class, ) ) { $castable_types[] = new TFloat(); @@ -658,17 +658,17 @@ public static function castFloatAttempt( IssueBuffer::maybeAdd( new InvalidCast( $invalid_casts[0] . ' cannot be cast to float', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($risky_cast) { IssueBuffer::maybeAdd( new RiskyCast( 'Casting ' . $risky_cast[0] . ' to float has possibly unintended value of 0.0/1.0', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($explicit_cast && !$castable_types) { // todo: emit error here @@ -681,7 +681,7 @@ public static function castFloatAttempt( } else { $float_type = TypeCombiner::combine( $valid_types, - $codebase + $codebase, ); } @@ -786,17 +786,17 @@ public static function castStringAttempt( if ($intersection_type instanceof TNamedObject) { $intersection_method_id = new MethodIdentifier( $intersection_type->value, - '__tostring' + '__tostring', ); if ($codebase->methods->methodExists( $intersection_method_id, $context->calling_method_id, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), )) { $return_type = $codebase->methods->getMethodReturnType( $intersection_method_id, - $self_class + $self_class, ) ?? Type::getString(); $declaring_method_id = $codebase->methods->getDeclaringMethodId($intersection_method_id); @@ -810,7 +810,7 @@ public static function castStringAttempt( $intersection_method_id, $declaring_method_id, $intersection_type->value . '::__toString', - $context + $context, ); if ($statements_analyzer->data_flow_graph) { @@ -819,7 +819,7 @@ public static function castStringAttempt( $castable_types = array_merge( $castable_types, - array_values($return_type->getAtomicTypes()) + array_values($return_type->getAtomicTypes()), ); continue 2; @@ -850,17 +850,17 @@ public static function castStringAttempt( IssueBuffer::maybeAdd( new PossiblyInvalidCast( $invalid_casts[0] . ' cannot be cast to string', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidCast( $invalid_casts[0] . ' cannot be cast to string', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } elseif ($explicit_cast && !$castable_types) { @@ -874,7 +874,7 @@ public static function castStringAttempt( } else { $str_type = TypeCombiner::combine( $valid_types, - $codebase + $codebase, ); } @@ -909,7 +909,7 @@ private static function handleRedundantCast( if ($maybe_type->from_docblock) { $issue = new RedundantCastGivenDocblockType( 'Redundant cast to ' . $maybe_type->getKey() . ' given docblock-provided type', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ); if ($codebase->alter_code @@ -918,13 +918,13 @@ private static function handleRedundantCast( $file_manipulation = new FileManipulation( (int) $stmt->getAttribute('startFilePos'), (int) $stmt->expr->getAttribute('startFilePos'), - '' + '', ); } } else { $issue = new RedundantCast( 'Redundant cast to ' . $maybe_type->getKey(), - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ); if ($codebase->alter_code @@ -933,7 +933,7 @@ private static function handleRedundantCast( $file_manipulation = new FileManipulation( (int) $stmt->getAttribute('startFilePos'), (int) $stmt->expr->getAttribute('startFilePos'), - '' + '', ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ClassConstAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ClassConstAnalyzer.php index e1150a1a772..e00739c18fe 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ClassConstAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ClassConstAnalyzer.php @@ -77,9 +77,9 @@ public static function analyzeFetch( return !IssueBuffer::accepts( new NonStaticSelfCall( 'Cannot use ' . $first_part_lc . ' outside class context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -91,15 +91,15 @@ public static function analyzeFetch( return !IssueBuffer::accepts( new ParentNotFound( 'Cannot check property fetch on parent as this class does not extend another', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { $fq_class_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $statements_analyzer->getAliases() + $statements_analyzer->getAliases(), ); if ($stmt->name instanceof PhpParser\Node\Identifier) { @@ -113,7 +113,7 @@ public static function analyzeFetch( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(false, true) + new ClassLikeNameOptions(false, true), ) === false) { return true; } @@ -135,7 +135,7 @@ public static function analyzeFetch( $fq_class_name, $context->calling_method_id, false, - $stmt->class->parts[0] === 'self' + $stmt->class->parts[0] === 'self', ); } @@ -153,9 +153,9 @@ public static function analyzeFetch( new DeprecatedClass( 'Class ' . $fq_class_name . ' is deprecated', new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -166,8 +166,8 @@ public static function analyzeFetch( $statements_analyzer->node_data->setType( $stmt, new Union([ - new TClassString($fq_class_name, $static_named_object) - ]) + new TClassString($fq_class_name, $static_named_object), + ]), ); } else { $statements_analyzer->node_data->setType($stmt, Type::getLiteralClassString($fq_class_name, true)); @@ -180,7 +180,7 @@ public static function analyzeFetch( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->class, - $fq_class_name + $fq_class_name, ); } @@ -199,7 +199,7 @@ public static function analyzeFetch( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->class, - $fq_class_name + $fq_class_name, ); } @@ -216,7 +216,7 @@ public static function analyzeFetch( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->name, - $const_id + $const_id, ); } @@ -227,9 +227,9 @@ public static function analyzeFetch( IssueBuffer::maybeAdd( new DeprecatedConstant( "Enum Case $const_id is marked as deprecated", - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -257,7 +257,7 @@ public static function analyzeFetch( $class_visibility, $statements_analyzer, [], - $stmt->class->parts[0] === "static" + $stmt->class->parts[0] === "static", ); } catch (InvalidArgumentException $_) { return true; @@ -265,9 +265,9 @@ public static function analyzeFetch( IssueBuffer::maybeAdd( new CircularReference( 'Constant ' . $const_id . ' contains a circular reference', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return true; @@ -279,7 +279,7 @@ public static function analyzeFetch( $fq_class_name, $stmt->name->name, ReflectionProperty::IS_PRIVATE, - $statements_analyzer + $statements_analyzer, ); } @@ -287,17 +287,17 @@ public static function analyzeFetch( IssueBuffer::maybeAdd( new InaccessibleClassConstant( 'Constant ' . $const_id . ' is not visible in this context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($context->check_consts) { IssueBuffer::maybeAdd( new UndefinedConstant( 'Constant ' . $const_id . ' is not defined', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -308,7 +308,7 @@ public static function analyzeFetch( $codebase->file_reference_provider->addMethodReferenceToClassMember( $context->calling_method_id, $fq_class_name_lc . '::' . $stmt->name->name, - false + false, ); } @@ -329,15 +329,15 @@ public static function analyzeFetch( $new_fq_class_name, $statements_analyzer->getNamespace(), $statements_analyzer->getAliasedClassesFlipped(), - null - ) + null, + ), ); } $file_manipulations[] = new FileManipulation( (int) $stmt->name->getAttribute('startFilePos'), (int) $stmt->name->getAttribute('endFilePos') + 1, - $new_const_name + $new_const_name, ); FileManipulationBuffer::add($statements_analyzer->getFilePath(), $file_manipulations); @@ -356,9 +356,9 @@ public static function analyzeFetch( . InternalClass::listToPhrase($const_class_storage->internal) . ' but called from ' . $context->self, new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -367,9 +367,9 @@ public static function analyzeFetch( new DeprecatedClass( 'Class ' . $fq_class_name . ' is deprecated', new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif (isset($const_class_storage->constants[$stmt->name->name]) && $const_class_storage->constants[$stmt->name->name]->deprecated @@ -377,9 +377,9 @@ public static function analyzeFetch( IssueBuffer::maybeAdd( new DeprecatedConstant( 'Constant ' . $const_id . ' is deprecated', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -419,7 +419,7 @@ public static function analyzeFetch( if ($lhs_atomic_type instanceof TNamedObject) { $class_string_types[] = new TClassString( $lhs_atomic_type->value, - $lhs_atomic_type + $lhs_atomic_type, ); } elseif ($lhs_atomic_type instanceof TTemplateParam && $lhs_atomic_type->as->isSingle()) { @@ -430,14 +430,14 @@ public static function analyzeFetch( $lhs_atomic_type->param_name, 'object', null, - $lhs_atomic_type->defining_class + $lhs_atomic_type->defining_class, ); } elseif ($as_atomic_type instanceof TNamedObject) { $class_string_types[] = new TTemplateParamClass( $lhs_atomic_type->param_name, $as_atomic_type->value, $as_atomic_type, - $lhs_atomic_type->defining_class + $lhs_atomic_type->defining_class, ); } } elseif ($lhs_atomic_type instanceof TObject @@ -486,7 +486,7 @@ public static function analyzeFetch( $statements_analyzer, $stmt->class, $fq_class_name, - $context->calling_method_id + $context->calling_method_id, ); } @@ -502,7 +502,7 @@ public static function analyzeFetch( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->class, - $fq_class_name + $fq_class_name, ); } @@ -519,7 +519,7 @@ public static function analyzeFetch( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->name, - $const_id + $const_id, ); } @@ -546,7 +546,7 @@ public static function analyzeFetch( $fq_class_name, $stmt->name->name, $class_visibility, - $statements_analyzer + $statements_analyzer, ); } catch (InvalidArgumentException $_) { return true; @@ -554,9 +554,9 @@ public static function analyzeFetch( IssueBuffer::maybeAdd( new CircularReference( 'Constant ' . $const_id . ' contains a circular reference', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return true; @@ -568,7 +568,7 @@ public static function analyzeFetch( $fq_class_name, $stmt->name->name, ReflectionProperty::IS_PRIVATE, - $statements_analyzer + $statements_analyzer, ); } @@ -576,17 +576,17 @@ public static function analyzeFetch( IssueBuffer::maybeAdd( new InaccessibleClassConstant( 'Constant ' . $const_id . ' is not visible in this context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($context->check_consts) { IssueBuffer::maybeAdd( new UndefinedConstant( 'Constant ' . $const_id . ' is not defined', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -597,7 +597,7 @@ public static function analyzeFetch( $codebase->file_reference_provider->addMethodReferenceToClassMember( $context->calling_method_id, strtolower($fq_class_name) . '::' . $stmt->name->name, - false + false, ); } @@ -613,7 +613,7 @@ public static function analyzeFetch( $file_manipulations[] = new FileManipulation( (int) $stmt->name->getAttribute('startFilePos'), (int) $stmt->name->getAttribute('endFilePos') + 1, - $new_const_name + $new_const_name, ); FileManipulationBuffer::add($statements_analyzer->getFilePath(), $file_manipulations); @@ -632,9 +632,9 @@ public static function analyzeFetch( . InternalClass::listToPhrase($const_class_storage->internal) . ' but called from ' . $context->self, new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -643,9 +643,9 @@ public static function analyzeFetch( new DeprecatedClass( 'Class ' . $fq_class_name . ' is deprecated', new CodeLocation($statements_analyzer->getSource(), $stmt), - $fq_class_name + $fq_class_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif (isset($const_class_storage->constants[$stmt->name->name]) && $const_class_storage->constants[$stmt->name->name]->deprecated @@ -653,9 +653,9 @@ public static function analyzeFetch( IssueBuffer::maybeAdd( new DeprecatedConstant( 'Constant ' . $const_id . ' is deprecated', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -692,7 +692,7 @@ public static function analyzeAssignment( && !UnionTypeComparator::isContainedBy( $statements_analyzer->getCodebase(), $assigned_type, - $const_storage->type + $const_storage->type, ) ) { IssueBuffer::maybeAdd( @@ -700,7 +700,7 @@ public static function analyzeAssignment( "{$class_storage->name}::{$const->name->name} with declared type " . "{$const_storage->type->getId()} cannot be assigned type {$assigned_type->getId()}", $const_storage->stmt_location, - "{$class_storage->name}::{$const->name->name}" + "{$class_storage->name}::{$const->name->name}", ), $const_storage->suppressed_issues, ); @@ -718,7 +718,7 @@ public static function analyze( $class_storage, $const_storage, $const_name, - $codebase + $codebase, ); $type_location = $const_storage->location ?? $const_storage->stmt_location; @@ -735,7 +735,7 @@ public static function analyze( && !UnionTypeComparator::isContainedBy( $codebase, $const_storage->type, - $parent_const_storage->type + $parent_const_storage->type, ) ) { if (UnionTypeComparator::isContainedBy( @@ -751,9 +751,9 @@ public static function analyze( . "\"{$parent_const_storage->type->getId()}\" inherited from " . "{$parent_classlike_storage->name}::{$const_name}", $type_location, - "{$class_storage->name}::{$const_name}" + "{$class_storage->name}::{$const_name}", ), - $const_storage->suppressed_issues + $const_storage->suppressed_issues, ); } else { // Completely different @@ -764,9 +764,9 @@ public static function analyze( . "\"{$parent_const_storage->type->getId()}\" inherited from " . "{$parent_classlike_storage->name}::{$const_name}", $type_location, - "{$class_storage->name}::{$const_name}" + "{$class_storage->name}::{$const_name}", ), - $const_storage->suppressed_issues + $const_storage->suppressed_issues, ); } } @@ -778,9 +778,9 @@ public static function analyze( "{$const_name} cannot be overridden because it is marked as final in " . $parent_classlike_storage->name, $type_location, - "{$class_storage->name}::{$const_name}" + "{$class_storage->name}::{$const_name}", ), - $const_storage->suppressed_issues + $const_storage->suppressed_issues, ); } } @@ -793,7 +793,7 @@ public static function analyze( "Class constants cannot be marked final before PHP 8.1", $const_storage->stmt_location, ), - $const_storage->suppressed_issues + $const_storage->suppressed_issues, ); } } @@ -824,7 +824,7 @@ private static function getOverriddenConstant( $interface_overrides[strtolower($interface)] = new OverriddenInterfaceConstant( "{$class_storage->name}::{$const_name} cannot override constant from $interface", $const_storage->location, - "{$class_storage->name}::{$const_name}" + "{$class_storage->name}::{$const_name}", ); } if ($interface_const_storage !== null && $const_storage->location !== null) { @@ -837,9 +837,9 @@ private static function getOverriddenConstant( "Ambiguous inheritance of {$class_storage->name}::{$const_name} from $interface and " . $parent_classlike_storage->name, $const_storage->location, - "{$class_storage->name}::{$const_name}" + "{$class_storage->name}::{$const_name}", ), - $const_storage->suppressed_issues + $const_storage->suppressed_issues, ); } } @@ -860,9 +860,9 @@ private static function getOverriddenConstant( "Ambiguous inheritance of {$class_storage->name}::{$const_name} from " . "$parent_classlike_storage->name and $parent_class", $const_storage->location, - "{$class_storage->name}::{$const_name}" + "{$class_storage->name}::{$const_name}", ), - $const_storage->suppressed_issues + $const_storage->suppressed_issues, ); } } @@ -888,7 +888,7 @@ private static function getOverriddenConstant( foreach ($interface_overrides as $_ => $issue) { IssueBuffer::maybeAdd( $issue, - $const_storage->suppressed_issues + $const_storage->suppressed_issues, ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php index 4cd3d5ac280..7f1927951d2 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php @@ -67,18 +67,18 @@ public static function analyze( } else { $clone_method_id = new MethodIdentifier( $clone_type_part->value, - '__clone' + '__clone', ); $does_method_exist = $codebase_methods->methodExists( $clone_method_id, $context->calling_method_id, - $location + $location, ); $is_method_visible = MethodAnalyzer::isMethodVisible( $clone_method_id, $context, - $statements_analyzer->getSource() + $statements_analyzer->getSource(), ); if ($does_method_exist && !$is_method_visible) { $invalid_clones[] = $clone_type_part->getId(); @@ -89,7 +89,7 @@ public static function analyze( $clone_method_id, $statements_analyzer->getNamespace(), $location, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $possibly_valid = true; $immutable_cloned = true; @@ -118,9 +118,9 @@ public static function analyze( IssueBuffer::maybeAdd( new MixedClone( 'Cannot clone mixed', - $location + $location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -129,17 +129,17 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyInvalidClone( 'Cannot clone ' . $invalid_clones[0], - $location + $location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidClone( 'Cannot clone ' . $invalid_clones[0], - $location + $location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php index 429ad9bd1e3..9728d331397 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php @@ -29,9 +29,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ForbiddenCode( 'You have forbidden the use of empty', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -44,9 +44,9 @@ public static function analyze( new InvalidArgument( 'Calling empty on a boolean value is almost certainly unintended', new CodeLocation($statements_analyzer->getSource(), $stmt->expr), - 'empty' + 'empty', ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php index e95ae414798..0bf09dcd2ec 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php @@ -52,7 +52,7 @@ public static function analyze( $statements_analyzer, $context, $part_type, - $part + $part, ); if (!$casted_part_type->allLiterals()) { @@ -104,7 +104,7 @@ public static function analyze( $new_parent_node, 'concat', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -124,28 +124,28 @@ public static function analyze( if ($literal_string !== null) { $stmt_type = new Union( [new TLiteralString($literal_string)], - ['parent_nodes' => $parent_nodes] + ['parent_nodes' => $parent_nodes], ); } elseif ($all_literals) { $stmt_type = new Union( [new TNonEmptyNonspecificLiteralString()], - ['parent_nodes' => $parent_nodes] + ['parent_nodes' => $parent_nodes], ); } else { $stmt_type = new Union( [new TNonEmptyString()], - ['parent_nodes' => $parent_nodes] + ['parent_nodes' => $parent_nodes], ); } } elseif ($all_literals) { $stmt_type = new Union( [new TNonspecificLiteralString()], - ['parent_nodes' => $parent_nodes] + ['parent_nodes' => $parent_nodes], ); } else { $stmt_type = new Union( [new TString()], - ['parent_nodes' => $parent_nodes] + ['parent_nodes' => $parent_nodes], ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php index c8df04d5820..e02ad2c6ba7 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php @@ -44,7 +44,7 @@ public static function analyze( 'eval', 0, $arg_location, - $arg_location + $arg_location, ); $eval_param_sink->taints = [TaintKind::INPUT_EVAL]; @@ -63,7 +63,7 @@ public static function analyze( $eval_param_sink, 'arg', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -73,9 +73,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ForbiddenCode( 'You have forbidden the use of eval', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php index 6892e2b669b..36d6be84b95 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php @@ -51,9 +51,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ForbiddenCode( 'You have forbidden the use of ' . $forbidden, - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -72,14 +72,14 @@ public static function analyze( 'exit', 0, null, - $call_location + $call_location, ); $echo_param_sink->taints = [ TaintKind::INPUT_HTML, TaintKind::INPUT_HAS_QUOTES, TaintKind::USER_SECRET, - TaintKind::SYSTEM_SECRET + TaintKind::SYSTEM_SECRET, ]; $statements_analyzer->data_flow_graph->addSink($echo_param_sink); @@ -88,7 +88,7 @@ public static function analyze( if ($expr_type = $statements_analyzer->node_data->getType($stmt->expr)) { $exit_param = new FunctionLikeParameter( 'var', - false + false, ); if (ArgumentAnalyzer::verifyType( @@ -107,7 +107,7 @@ public static function analyze( null, true, true, - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ) === false) { return false; } @@ -127,9 +127,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureFunctionCall( 'Cannot call ' . $function_name . ' with a non-integer argument from a mutation-free context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ExpressionIdentifier.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ExpressionIdentifier.php index 512d8473ceb..04b808c32ad 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ExpressionIdentifier.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ExpressionIdentifier.php @@ -45,7 +45,7 @@ public static function getVarId( $fq_class_name = $source ? ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $source->getAliases() + $source->getAliases(), ) : implode('\\', $stmt->class->parts); } @@ -211,7 +211,7 @@ public static function getExtendedVarId( $lhs_var_name = self::getExtendedVarId( $stmt->var, $this_class_name, - $source + $source, ); if (!$lhs_var_name) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php index 44729ac3afc..835fb722ac2 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php @@ -110,7 +110,7 @@ public static function analyze( $extended_var_id = ExpressionIdentifier::getExtendedVarId( $stmt->var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($stmt->dim) { @@ -135,7 +135,7 @@ public static function analyze( $keyed_array_var_id = ExpressionIdentifier::getExtendedVarId( $stmt, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $dim_var_id = null; @@ -147,7 +147,7 @@ public static function analyze( $dim_var_id = ExpressionIdentifier::getExtendedVarId( $stmt->dim, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); } else { $used_key_type = Type::getInt(); @@ -156,7 +156,7 @@ public static function analyze( if (ExpressionAnalyzer::analyze( $statements_analyzer, $stmt->var, - $context + $context, ) === false) { return false; } @@ -179,7 +179,7 @@ public static function analyze( $keyed_array_var_id, $stmt_type, $used_key_type, - $context + $context, ); if ($stmt->dim && $statements_analyzer->node_data->getType($stmt->dim)) { @@ -188,7 +188,7 @@ public static function analyze( $statements_analyzer->node_data->setType( $stmt, - $stmt_type + $stmt_type, ); return true; @@ -202,16 +202,16 @@ public static function analyze( IssueBuffer::maybeAdd( new NullArrayAccess( 'Cannot access array value on null variable ' . $extended_var_id, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } $stmt_type = $statements_analyzer->node_data->getType($stmt); $statements_analyzer->node_data->setType( $stmt, - Type::combineUnionTypes($stmt_type, Type::getNull()) + Type::combineUnionTypes($stmt_type, Type::getNull()), ); return true; @@ -225,7 +225,7 @@ public static function analyze( false, $extended_var_id, $context, - null + null, ); if ($stmt->dim && $stmt_var_type->hasArray()) { @@ -279,7 +279,7 @@ public static function analyze( && !UnionTypeComparator::isContainedBy( $codebase, new Union([$offset_atomic_type]), - $const_array_key_type + $const_array_key_type, ) ) { $new_offset_type->removeType($offset_key); @@ -287,7 +287,7 @@ public static function analyze( } elseif (!UnionTypeComparator::isContainedBy( $codebase, $const_array_key_type, - new Union([$offset_atomic_type]) + new Union([$offset_atomic_type]), )) { $new_offset_type->removeType($offset_key); } @@ -317,9 +317,9 @@ public static function analyze( new PossiblyUndefinedArrayOffset( 'Possibly undefined array key ' . $keyed_array_var_id . ' on ' . $stmt_var_type->getId(), - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -336,7 +336,7 @@ public static function analyze( $keyed_array_var_id, $stmt_type, $used_key_type, - $context + $context, ); $statements_analyzer->node_data->setType($stmt, $stmt_type); @@ -393,7 +393,7 @@ public static function taintArrayFetch( $new_parent_node = DataFlowNode::getForAssignment( $keyed_array_var_id ?: 'arrayvalue-fetch', - $var_location + $var_location, ); $array_key_node = null; @@ -409,7 +409,7 @@ public static function taintArrayFetch( if ($keyed_array_var_id === null && $dim_value === null) { $array_key_node = DataFlowNode::getForAssignment( 'arraykey-fetch', - $var_location + $var_location, ); $statements_analyzer->data_flow_graph->addNode($array_key_node); @@ -421,7 +421,7 @@ public static function taintArrayFetch( $new_parent_node, 'arrayvalue-fetch' . ($dim_value !== null ? '-\'' . $dim_value . '\'' : ''), $added_taints, - $removed_taints + $removed_taints, ); if ($stmt_type->by_ref) { @@ -430,7 +430,7 @@ public static function taintArrayFetch( $parent_node, 'arrayvalue-assignment' . ($dim_value !== null ? '-\'' . $dim_value . '\'' : ''), $added_taints, - $removed_taints + $removed_taints, ); } @@ -440,7 +440,7 @@ public static function taintArrayFetch( $array_key_node, 'arraykey-fetch', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -507,9 +507,9 @@ public static function getArrayAccessTypeGivenOffset( IssueBuffer::maybeAdd( new NullArrayOffset( 'Cannot access value on variable ' . $extended_var_id . ' using null offset', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); if ($in_assignment) { @@ -524,9 +524,9 @@ public static function getArrayAccessTypeGivenOffset( new PossiblyNullArrayOffset( 'Cannot access value on variable ' . $extended_var_id . ' using possibly null offset ' . $offset_type, - new CodeLocation($statements_analyzer->getSource(), $stmt->var) + new CodeLocation($statements_analyzer->getSource(), $stmt->var), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -543,7 +543,7 @@ public static function getArrayAccessTypeGivenOffset( $has_valid_absolute_offset = self::checkArrayOffsetType( $offset_type, $offset_type->getAtomicTypes(), - $codebase + $codebase, ); if ($has_valid_absolute_offset === false) { @@ -578,7 +578,7 @@ public static function getArrayAccessTypeGivenOffset( $extended_var_id, $stmt, $array_access_type, - $type + $type, ); $has_valid_expected_offset = true; @@ -603,9 +603,9 @@ public static function getArrayAccessTypeGivenOffset( new PossiblyNullArrayAssignment( 'Cannot access array value on possibly null variable ' . $extended_var_id . ' of type ' . $array_type, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $array_access_type = new Union([new TNever]); @@ -616,9 +616,9 @@ public static function getArrayAccessTypeGivenOffset( new PossiblyNullArrayAccess( 'Cannot access array value on possibly null variable ' . $extended_var_id . ' of type ' . $array_type, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -648,7 +648,7 @@ public static function getArrayAccessTypeGivenOffset( $expected_offset_types, $array_access_type, $has_array_access, - $has_valid_expected_offset + $has_valid_expected_offset, ); if ($type !== $original_type) { @@ -672,7 +672,7 @@ public static function getArrayAccessTypeGivenOffset( $offset_type, $expected_offset_types, $array_access_type, - $has_valid_expected_offset + $has_valid_expected_offset, ); continue; @@ -701,7 +701,7 @@ public static function getArrayAccessTypeGivenOffset( $in_assignment, $assign_value, $array_access_type, - $has_array_access + $has_array_access, ); } elseif (!$array_type->hasMixed()) { $non_array_types[] = (string)$type; @@ -718,18 +718,18 @@ public static function getArrayAccessTypeGivenOffset( new PossiblyInvalidArrayAssignment( 'Cannot access array value on non-array variable ' . $extended_var_id . ' of type ' . $non_array_types[0], - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif (!$context->inside_isset) { IssueBuffer::maybeAdd( new PossiblyInvalidArrayAccess( 'Cannot access array value on non-array variable ' . $extended_var_id . ' of type ' . $non_array_types[0], - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { @@ -738,18 +738,18 @@ public static function getArrayAccessTypeGivenOffset( new InvalidArrayAssignment( 'Cannot access array value on non-array variable ' . $extended_var_id . ' of type ' . $non_array_types[0], - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidArrayAccess( 'Cannot access array value on non-array variable ' . $extended_var_id . ' of type ' . $non_array_types[0], - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -771,9 +771,9 @@ public static function getArrayAccessTypeGivenOffset( IssueBuffer::maybeAdd( new MixedArrayOffset( 'Cannot access value on variable ' . $extended_var_id . ' using mixed offset', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { if (!$context->collect_initializations @@ -805,9 +805,9 @@ public static function getArrayAccessTypeGivenOffset( new PossiblyInvalidArrayOffset( 'Cannot access value on variable ' . $extended_var_id . ' ' . $used_offset . ', expecting ' . $invalid_offset_type, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { @@ -846,7 +846,7 @@ public static function getArrayAccessTypeGivenOffset( if ($bad_types && $good_types) { $offset_type->substitute( TypeCombiner::combine($bad_types, $codebase), - TypeCombiner::combine($good_types, $codebase) + TypeCombiner::combine($good_types, $codebase), ); } @@ -854,9 +854,9 @@ public static function getArrayAccessTypeGivenOffset( new InvalidArrayOffset( 'Cannot access value on variable ' . $extended_var_id . ' ' . $used_offset . ', expecting ' . $invalid_offset_type, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -897,7 +897,7 @@ private static function checkLiteralIntArrayOffset( && isset( $context->vars_in_scope[ $extended_var_id . '[' . $offset_type_part->value . ']' - ] + ], ) && !$context->vars_in_scope[ $extended_var_id . '[' . $offset_type_part->value . ']' @@ -916,9 +916,9 @@ private static function checkLiteralIntArrayOffset( . 'is risky given expected type \'' . $expected_offset_type->getId() . '\'.' . ' Consider using isset beforehand.', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -945,7 +945,7 @@ private static function checkLiteralStringArrayOffset( && isset( $context->vars_in_scope[ $extended_var_id . '[\'' . $offset_type_part->value . '\']' - ] + ], ) && !$context->vars_in_scope[ $extended_var_id . '[\'' . $offset_type_part->value . '\']' @@ -964,9 +964,9 @@ private static function checkLiteralStringArrayOffset( . 'is risky given expected type \'' . $expected_offset_type->getId() . '\'.' . ' Consider using isset beforehand.', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1031,17 +1031,17 @@ public static function handleMixedArrayAccess( IssueBuffer::maybeAdd( new MixedArrayAssignment( 'Cannot access array value on mixed variable ' . $extended_var_id, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new MixedArrayAccess( 'Cannot access array value on mixed variable ' . $extended_var_id, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1063,19 +1063,19 @@ public static function handleMixedArrayAccess( $data_flow_graph->addPath( $parent_node, new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } $statements_analyzer->node_data->setType($stmt->var, $stmt_var_type->setParentNodes([ - $new_parent_node->id => $new_parent_node + $new_parent_node->id => $new_parent_node, ])); } } return Type::combineUnionTypes( $array_access_type, - Type::getMixed($type instanceof TNever) + Type::getMixed($type instanceof TNever), ); } @@ -1120,7 +1120,7 @@ private static function handleArrayAccessOnArray( $single_atomic->value => $from_mixed_array ? Type::getMixed() : Type::getNever(), ], $single_atomic instanceof TLiteralClassString ? [ - $single_atomic->value => true + $single_atomic->value => true, ] : null, $from_empty_array ? null : $type->type_params, ); @@ -1129,7 +1129,7 @@ private static function handleArrayAccessOnArray( [$replacement_type], null, null, - true + true, ); return; } @@ -1166,7 +1166,7 @@ private static function handleArrayAccessOnArray( $expected_offset_types, $array_access_type, $original_type, - $has_valid_offset + $has_valid_offset, ); } elseif ($type instanceof TArray) { self::handleArrayAccessOnTArray( @@ -1182,7 +1182,7 @@ private static function handleArrayAccessOnArray( $expected_offset_types, $array_access_type, $original_type, - $has_valid_offset + $has_valid_offset, ); } elseif ($type instanceof TClassStringMap) { self::handleArrayAccessOnClassStringMap( @@ -1190,7 +1190,7 @@ private static function handleArrayAccessOnArray( $type, $offset_type, $replacement_type, - $array_access_type + $array_access_type, ); } else { self::handleArrayAccessOnKeyedArray( @@ -1207,7 +1207,7 @@ private static function handleArrayAccessOnArray( $type, $hasMixed, $expected_offset_types, - $has_valid_offset + $has_valid_offset, ); } @@ -1242,7 +1242,7 @@ private static function handleArrayAccessOnTArray( $offset_type->isMixed() ? Type::getArrayKey() : $offset_type->freeze(), - $type->type_params[1] + $type->type_params[1], ]); } } elseif (!$type->isEmptyArray()) { @@ -1272,9 +1272,9 @@ private static function handleArrayAccessOnTArray( new TTemplateIndexedAccess( $offset_as->param_name, $templated_offset_type->param_name, - $offset_as->defining_class - ) - ]) + $offset_as->defining_class, + ), + ]), ]); $has_valid_offset = true; @@ -1287,7 +1287,7 @@ private static function handleArrayAccessOnTArray( $expected_offset_type, true, $offset_type->ignore_falsable_issues, - $union_comparison_results + $union_comparison_results, ); if ($codebase->config->ensure_array_string_offsets_exist @@ -1302,7 +1302,7 @@ private static function handleArrayAccessOnTArray( $extended_var_id, $stmt, $context, - $statements_analyzer + $statements_analyzer, ); } } @@ -1316,7 +1316,7 @@ private static function handleArrayAccessOnTArray( $extended_var_id, $stmt, $context, - $statements_analyzer + $statements_analyzer, ); } @@ -1331,9 +1331,9 @@ private static function handleArrayAccessOnTArray( new MixedArrayTypeCoercion( 'Coercion from array offset type \'' . $offset_type->getId() . '\' ' . 'to the expected type \'' . $expected_offset_type->getId() . '\'', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { $expected_offset_types[] = $expected_offset_type->getId(); @@ -1342,7 +1342,7 @@ private static function handleArrayAccessOnTArray( if (UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $offset_type->freeze(), - $expected_offset_type + $expected_offset_type, )) { $has_valid_offset = true; } @@ -1363,14 +1363,14 @@ private static function handleArrayAccessOnTArray( null, null, 'non-empty-array', - $type->from_docblock + $type->from_docblock, ); } } $array_access_type = Type::combineUnionTypes( $array_access_type, - $type->type_params[1] + $type->type_params[1], ); if ($array_access_type->isNever() @@ -1381,9 +1381,9 @@ private static function handleArrayAccessOnTArray( IssueBuffer::maybeAdd( new EmptyArrayAccess( 'Cannot access value on empty array variable ' . $extended_var_id, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); if (!IssueBuffer::isRecording()) { @@ -1414,11 +1414,11 @@ private static function handleArrayAccessOnClassStringMap( $offset_type_part->as_type ? new Union([$offset_type_part->as_type]) : Type::getObject(), - $offset_type_part->defining_class - ) - ]) - ] - ] + $offset_type_part->defining_class, + ), + ]), + ], + ], ); $template_result_set = new TemplateResult( @@ -1431,11 +1431,11 @@ private static function handleArrayAccessOnClassStringMap( $type->as_type ? new Union([$type->as_type]) : Type::getObject(), - 'class-string-map' - ) - ]) - ] - ] + 'class-string-map', + ), + ]), + ], + ], ); } else { $template_result_get = new TemplateResult( @@ -1444,28 +1444,28 @@ private static function handleArrayAccessOnClassStringMap( $type->param_name => [ 'class-string-map' => new Union([ $offset_type_part->as_type - ?: new TObject() - ]) - ] - ] + ?: new TObject(), + ]), + ], + ], ); $template_result_set = new TemplateResult( [], - [] + [], ); } $expected_value_param_get = TemplateInferredTypeReplacer::replace( $type->value_param, $template_result_get, - $codebase + $codebase, ); if ($replacement_type) { $replacement_type = TemplateInferredTypeReplacer::replace( $replacement_type, $template_result_set, - $codebase + $codebase, ); $type = new TClassStringMap( @@ -1474,15 +1474,15 @@ private static function handleArrayAccessOnClassStringMap( Type::combineUnionTypes( $replacement_type, $type->value_param, - $codebase - ) + $codebase, + ), ); } $array_access_type = Type::combineUnionTypes( $array_access_type, $expected_value_param_get, - $codebase + $codebase, ); } } @@ -1531,20 +1531,20 @@ private static function handleArrayAccessOnKeyedArray( if ($replacement_type) { $properties[$key_value->value] = Type::combineUnionTypes( $properties[$key_value->value] ?? null, - $replacement_type + $replacement_type, ); } $array_access_type = Type::combineUnionTypes( $array_access_type, - $properties[$key_value->value] + $properties[$key_value->value], ); } elseif ($in_assignment) { $properties[$key_value->value] = new Union([new TNever]); $array_access_type = Type::combineUnionTypes( $array_access_type, - $properties[$key_value->value] + $properties[$key_value->value], ); } elseif ($type->fallback_params !== null) { if ($codebase->config->ensure_array_string_offsets_exist) { @@ -1554,7 +1554,7 @@ private static function handleArrayAccessOnKeyedArray( $extended_var_id, $stmt, $context, - $statements_analyzer + $statements_analyzer, ); } @@ -1565,7 +1565,7 @@ private static function handleArrayAccessOnKeyedArray( $extended_var_id, $stmt, $context, - $statements_analyzer + $statements_analyzer, ); } @@ -1589,8 +1589,8 @@ private static function handleArrayAccessOnKeyedArray( array_map( /** @param int|string $key */ static fn($key): string => is_int($key) ? "$key" : '\'' . $key . '\'', - $object_like_keys - ) + $object_like_keys, + ), ); $key_string = $formatted_keys . ' or '; @@ -1618,7 +1618,7 @@ private static function handleArrayAccessOnKeyedArray( $key_type, true, $offset_type->ignore_falsable_issues, - $union_comparison_results + $union_comparison_results, ); if ($context->inside_isset && !$is_contained) { @@ -1627,7 +1627,7 @@ private static function handleArrayAccessOnKeyedArray( $key_type, $offset_type->freeze(), true, - $offset_type->ignore_falsable_issues + $offset_type->ignore_falsable_issues, ); } @@ -1640,12 +1640,12 @@ private static function handleArrayAccessOnKeyedArray( if ($replacement_type) { $generic_params = Type::combineUnionTypes( $type->getGenericValueType(), - $replacement_type + $replacement_type, ); $new_key_type = Type::combineUnionTypes( $generic_key_type, - $offset_type->isMixed() ? Type::getArrayKey() : $offset_type->freeze() + $offset_type->isMixed() ? Type::getArrayKey() : $offset_type->freeze(), ); if (!$stmt->dim) { @@ -1654,7 +1654,7 @@ private static function handleArrayAccessOnKeyedArray( $type->properties, null, [$new_key_type, $generic_params], - true + true, ); } else { $type = new TNonEmptyArray([ @@ -1679,12 +1679,12 @@ private static function handleArrayAccessOnKeyedArray( $array_access_type = Type::combineUnionTypes( $array_access_type, - $generic_params + $generic_params, ); } else { $array_access_type = Type::combineUnionTypes( $array_access_type, - $type->getGenericValueType() + $type->getGenericValueType(), ); } @@ -1722,8 +1722,8 @@ private static function handleArrayAccessOnNamedObject( $stmt->var, new VirtualIdentifier('item', $stmt->var->getAttributes()), [ - new VirtualArg($stmt->dim) - ] + new VirtualArg($stmt->dim), + ], ); $suppressed_issues = $statements_analyzer->getSuppressedIssues(); @@ -1739,7 +1739,7 @@ private static function handleArrayAccessOnNamedObject( MethodCallAnalyzer::analyze( $statements_analyzer, $fake_method_call, - $context + $context, ); if (!in_array('PossiblyInvalidMethodCall', $suppressed_issues, true)) { @@ -1777,22 +1777,22 @@ private static function handleArrayAccessOnNamedObject( $stmt->dim ?? new VirtualConstFetch( new VirtualName('null'), - $stmt->var->getAttributes() - ) + $stmt->var->getAttributes(), + ), ), new VirtualArg( $assign_value ?? new VirtualConstFetch( new VirtualName('null'), - $stmt->var->getAttributes() - ) + $stmt->var->getAttributes(), + ), ), - ] + ], ); MethodCallAnalyzer::analyze( $statements_analyzer, $fake_set_method_call, - $context + $context, ); $statements_analyzer->node_data = $old_node_data; @@ -1808,15 +1808,15 @@ private static function handleArrayAccessOnNamedObject( new VirtualIdentifier('offsetGet', $stmt->var->getAttributes()), [ new VirtualArg( - $stmt->dim - ) - ] + $stmt->dim, + ), + ], ); MethodCallAnalyzer::analyze( $statements_analyzer, $fake_get_method_call, - $context + $context, ); $call_array_access_type = @@ -1840,7 +1840,7 @@ private static function handleArrayAccessOnNamedObject( $array_access_type = Type::combineUnionTypes( $array_access_type, - $call_array_access_type + $call_array_access_type, ); } @@ -1875,9 +1875,9 @@ private static function handleArrayAccessOnString( IssueBuffer::maybeAdd( new MixedStringOffsetAssignment( 'Right-hand-side of string offset assignment cannot be mixed', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { if (!$context->collect_initializations @@ -1920,7 +1920,7 @@ private static function handleArrayAccessOnString( $codebase, $offset_type->freeze(), $valid_offset_type, - true + true, )) { $expected_offset_types[] = $valid_offset_type->getId(); @@ -1930,7 +1930,7 @@ private static function handleArrayAccessOnString( $array_access_type = Type::combineUnionTypes( $array_access_type, - Type::getSingleLetter() + Type::getSingleLetter(), ); } } @@ -1953,13 +1953,13 @@ private static function checkArrayOffsetType( $atomic_offset_type->fq_classlike_name, null, true, - true + true, ); $has_valid_absolute_offset = self::checkArrayOffsetType( $offset_type, $expanded, - $codebase + $codebase, ); if ($has_valid_absolute_offset) { @@ -1986,7 +1986,7 @@ private static function checkArrayOffsetType( $has_valid_absolute_offset = self::checkArrayOffsetType( $offset_type, $atomic_offset_type->as->getAtomicTypes(), - $codebase + $codebase, ); if ($has_valid_absolute_offset) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php index c0bcba608a7..6509ddde1f4 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php @@ -123,8 +123,8 @@ public static function analyze( $stmt, Type::combineUnionTypes( $lhs_type_part->properties[$prop_name], - $stmt_type - ) + $stmt_type, + ), ); return; @@ -172,7 +172,7 @@ public static function analyze( $class_exists, $interface_exists, $fq_class_name, - $override_property_visibility + $override_property_visibility, ); if (!$class_exists && !$interface_exists) { @@ -194,8 +194,8 @@ public static function analyze( $stmt, new Union([ new TString(), - new TInt() - ]) + new TInt(), + ]), ); } elseif ($prop_name === 'value' && $class_storage->enum_type !== null && $class_storage->enum_cases) { self::handleEnumValue($statements_analyzer, $stmt, $class_storage); @@ -216,7 +216,7 @@ public static function analyze( $in_assignment, $stmt_var_id, $has_magic_getter, - $var_id + $var_id, ); } @@ -228,7 +228,7 @@ public static function analyze( !$in_assignment, $statements_analyzer, $context, - $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) : null + $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) : null, ); // add method before changing fq_class_name @@ -254,7 +254,7 @@ public static function analyze( $context, $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) - : null + : null, ) || isset($new_class_storage->pseudo_property_get_types['$' . $prop_name])) ) { @@ -274,7 +274,7 @@ public static function analyze( $declaring_property_class = $codebase->properties->getDeclaringClassForProperty( $property_id, true, - $statements_analyzer + $statements_analyzer, ); if (self::propertyFetchCanBeAnalyzed( @@ -294,7 +294,7 @@ public static function analyze( $declaring_property_class, $class_storage, $get_method_id, - $in_assignment + $in_assignment, ) === false) { return; } @@ -306,7 +306,7 @@ public static function analyze( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->name, - $property_id + $property_id, ); } @@ -321,7 +321,7 @@ public static function analyze( $context, $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) - : null + : null, ) ) { $property_id = $context->self . '::$' . $prop_name; @@ -346,7 +346,7 @@ public static function analyze( $in_assignment, $stmt_var_id, $has_magic_getter, - $var_id + $var_id, ); return; @@ -358,7 +358,7 @@ public static function analyze( $context, $statements_analyzer, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false) { return; } @@ -370,7 +370,7 @@ public static function analyze( $declaring_property_class = $codebase->properties->getDeclaringClassForProperty( $property_id, true, - $statements_analyzer + $statements_analyzer, ); if ($declaring_property_class === null) { @@ -386,20 +386,20 @@ public static function analyze( new FileManipulation( (int) $stmt->name->getAttribute('startFilePos'), (int) $stmt->name->getAttribute('endFilePos') + 1, - $new_property_name - ) + $new_property_name, + ), ]; FileManipulationBuffer::add( $statements_analyzer->getFilePath(), - $file_manipulations + $file_manipulations, ); } } } $declaring_class_storage = $codebase->classlike_storage_provider->get( - $declaring_property_class + $declaring_property_class, ); if (isset($declaring_class_storage->properties[$prop_name])) { @@ -413,9 +413,9 @@ public static function analyze( $property_id . ' is internal to ' . InternalClass::listToPhrase($property_storage->internal) . ' but called from ' . $context->self, new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -426,7 +426,7 @@ public static function analyze( $property_id, $property_storage, $declaring_class_storage, - $context + $context, ); } } @@ -442,7 +442,7 @@ public static function analyze( $property_id, $fq_class_name, $prop_name, - $lhs_type_part + $lhs_type_part, ); if (!$context->collect_mutations @@ -454,9 +454,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpurePropertyFetch( 'Cannot access a property on a mutable object from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations @@ -472,19 +472,19 @@ public static function analyze( $property_id, $class_storage, $in_assignment, - $context + $context, ); if ($class_storage->mutation_free) { $class_property_type = $class_property_type->setProperties([ - 'has_mutations' => false + 'has_mutations' => false, ]); } $stmt_type = $statements_analyzer->node_data->getType($stmt); $statements_analyzer->node_data->setType( $stmt, - Type::combineUnionTypes($class_property_type, $stmt_type) + Type::combineUnionTypes($class_property_type, $stmt_type), ); } @@ -500,7 +500,7 @@ public static function checkPropertyDeprecation( $property_id = $declaring_property_class . '::$' . $prop_name; $codebase = $statements_analyzer->getCodebase(); $declaring_class_storage = $codebase->classlike_storage_provider->get( - $declaring_property_class + $declaring_property_class, ); if (isset($declaring_class_storage->properties[$prop_name])) { @@ -511,9 +511,9 @@ public static function checkPropertyDeprecation( new DeprecatedProperty( $property_id . ' is marked deprecated', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -547,7 +547,7 @@ private static function propertyFetchCanBeAnalyzed( $statements_analyzer, new CodeLocation($statements_analyzer->getSource(), $stmt), $statements_analyzer->getSuppressedIssues(), - false + false, ) !== true) ) && $codebase->methods->methodExists( @@ -560,7 +560,7 @@ private static function propertyFetchCanBeAnalyzed( && !$context->collect_mutations ? $statements_analyzer : null, - $statements_analyzer->getFilePath() + $statements_analyzer->getFilePath(), ) ) { $has_magic_getter = true; @@ -571,7 +571,7 @@ private static function propertyFetchCanBeAnalyzed( $class_storage->pseudo_property_get_types['$' . $prop_name], $class_storage->name, $class_storage->name, - $class_storage->parent_class + $class_storage->parent_class, ); if (count($template_types = $class_storage->getClassTemplateTypes()) !== 0) { @@ -586,8 +586,8 @@ private static function propertyFetchCanBeAnalyzed( $class_storage, $declaring_property_class ? $codebase->classlike_storage_provider->get( - $declaring_property_class - ) : $class_storage + $declaring_property_class, + ) : $class_storage, ); } @@ -598,7 +598,7 @@ private static function propertyFetchCanBeAnalyzed( $property_id, $class_storage, $in_assignment, - $context + $context, ); $statements_analyzer->node_data->setType($stmt, $stmt_type); @@ -619,10 +619,10 @@ private static function propertyFetchCanBeAnalyzed( new VirtualArg( new VirtualString( $prop_name, - $stmt->name->getAttributes() - ) - ) - ] + $stmt->name->getAttributes(), + ), + ), + ], ); $suppressed_issues = $statements_analyzer->getSuppressedIssues(); @@ -635,7 +635,7 @@ private static function propertyFetchCanBeAnalyzed( $statements_analyzer, $fake_method_call, $context, - false + false, ); if (!in_array('InternalMethod', $suppressed_issues, true)) { @@ -650,7 +650,7 @@ private static function propertyFetchCanBeAnalyzed( $stmt_type = $statements_analyzer->node_data->getType($stmt); $statements_analyzer->node_data->setType( $stmt, - Type::combineUnionTypes($fake_method_call_type, $stmt_type) + Type::combineUnionTypes($fake_method_call_type, $stmt_type), ); } else { $statements_analyzer->node_data->setType($stmt, Type::getMixed()); @@ -673,9 +673,9 @@ private static function propertyFetchCanBeAnalyzed( new UndefinedMagicPropertyFetch( 'Magic instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return false; @@ -697,7 +697,7 @@ public static function localizePropertyType( $property_declaring_class_storage, $property_declaring_class_storage->name, $property_class_storage, - $property_class_storage->template_types ?: [] + $property_class_storage->template_types ?: [], ); $extended_types = $property_class_storage->template_extended_params; @@ -734,7 +734,7 @@ public static function localizePropertyType( if (isset($property_class_storage->template_types[$param_name])) { $position = array_search( $param_name, - array_keys($property_class_storage->template_types) + array_keys($property_class_storage->template_types), ); } @@ -749,7 +749,7 @@ public static function localizePropertyType( $class_property_type = TemplateInferredTypeReplacer::replace( $class_property_type, new TemplateResult([], $template_types), - $codebase + $codebase, ); } @@ -786,13 +786,13 @@ public static function processTaints( $var_id = ExpressionIdentifier::getExtendedVarId( $stmt->var, null, - $statements_analyzer + $statements_analyzer, ); $var_property_id = ExpressionIdentifier::getExtendedVarId( $stmt, null, - $statements_analyzer + $statements_analyzer, ); if ($var_id) { @@ -811,14 +811,14 @@ public static function processTaints( $var_node = DataFlowNode::getForAssignment( $var_id, - $var_location + $var_location, ); $data_flow_graph->addNode($var_node); $property_node = DataFlowNode::getForAssignment( $var_property_id ?: $var_id . '->$property', - $property_location + $property_location, ); $data_flow_graph->addNode($property_node); @@ -829,7 +829,7 @@ public static function processTaints( 'property-fetch' . ($stmt->name instanceof PhpParser\Node\Identifier ? '-' . $stmt->name : ''), $added_taints, - $removed_taints + $removed_taints, ); if ($var_type && $var_type->parent_nodes) { @@ -839,7 +839,7 @@ public static function processTaints( $var_node, '=', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -854,7 +854,7 @@ public static function processTaints( $property_id, $in_assignment, $added_taints, - $removed_taints + $removed_taints, ); } } @@ -881,14 +881,14 @@ public static function processUnspecialTaints( $var_property_id = ExpressionIdentifier::getExtendedVarId( $stmt, null, - $statements_analyzer + $statements_analyzer, ); $property_location = new CodeLocation($statements_analyzer->getSource(), $stmt); $localized_property_node = DataFlowNode::getForAssignment( $var_property_id ?: $property_id, - $property_location + $property_location, ); $data_flow_graph->addNode($localized_property_node); @@ -897,7 +897,7 @@ public static function processUnspecialTaints( $property_id, $property_id, null, - null + null, ); $data_flow_graph->addNode($property_node); @@ -908,7 +908,7 @@ public static function processUnspecialTaints( $property_node, 'property-assignment', $added_taints, - $removed_taints + $removed_taints, ); } else { $data_flow_graph->addPath( @@ -916,7 +916,7 @@ public static function processUnspecialTaints( $localized_property_node, 'property-fetch', $added_taints, - $removed_taints + $removed_taints, ); } @@ -931,7 +931,7 @@ private static function handleEnumName( if ($lhs_type_part instanceof TEnumCase) { $statements_analyzer->node_data->setType( $stmt, - new Union([new TLiteralString($lhs_type_part->case_name)]) + new Union([new TLiteralString($lhs_type_part->case_name)]), ); } else { $statements_analyzer->node_data->setType($stmt, Type::getNonEmptyString()); @@ -960,7 +960,7 @@ private static function handleEnumValue( /** @psalm-suppress ArgumentTypeCoercion */ $statements_analyzer->node_data->setType( $stmt, - new Union($case_values) + new Union($case_values), ); } @@ -978,9 +978,9 @@ private static function handleUndefinedProperty( IssueBuffer::maybeAdd( new ImpurePropertyFetch( 'Cannot access a property on a mutable object from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($context->inside_isset && $statements_analyzer->getSource() @@ -998,9 +998,9 @@ private static function handleUndefinedProperty( new UndefinedThisPropertyFetch( 'Instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { if ($has_magic_getter) { @@ -1008,18 +1008,18 @@ private static function handleUndefinedProperty( new UndefinedMagicPropertyFetch( 'Magic instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new UndefinedPropertyFetch( 'Instance property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1072,9 +1072,9 @@ private static function handleNonExistentClass( new NoInterfaceProperties( 'Interfaces cannot have properties', new CodeLocation($statements_analyzer->getSource(), $stmt), - $lhs_type_part->value + $lhs_type_part->value, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -1091,18 +1091,18 @@ private static function handleNonExistentClass( new UndefinedDocblockClass( 'Cannot get properties of undefined docblock class ' . $lhs_type_part->value, new CodeLocation($statements_analyzer->getSource(), $stmt), - $lhs_type_part->value + $lhs_type_part->value, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new UndefinedClass( 'Cannot get properties of undefined class ' . $lhs_type_part->value, new CodeLocation($statements_analyzer->getSource(), $stmt), - $lhs_type_part->value + $lhs_type_part->value, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -1141,8 +1141,8 @@ private static function handleNonExistentProperty( $class_storage, $declaring_property_class ? $codebase->classlike_storage_provider->get( - $declaring_property_class - ) : $class_storage + $declaring_property_class, + ) : $class_storage, ); } @@ -1153,7 +1153,7 @@ private static function handleNonExistentProperty( $property_id, $class_storage, $in_assignment, - $context + $context, ); $statements_analyzer->node_data->setType($stmt, $stmt_type); @@ -1172,7 +1172,7 @@ private static function handleNonExistentProperty( $stmt_var_id, $property_id, $has_magic_getter, - $var_id + $var_id, ); } @@ -1193,13 +1193,13 @@ private static function getClassPropertyType( $property_id, false, $statements_analyzer, - $context + $context, ); if (!$class_property_type) { if ($declaring_class_storage->location && $config->isInProjectDirs( - $declaring_class_storage->location->file_path + $declaring_class_storage->location->file_path, ) ) { IssueBuffer::maybeAdd( @@ -1207,9 +1207,9 @@ private static function getClassPropertyType( 'Property ' . $fq_class_name . '::$' . $prop_name . ' does not have a declared type', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -1220,7 +1220,7 @@ private static function getClassPropertyType( $class_property_type, $declaring_class_storage->name, $declaring_class_storage->name, - $declaring_class_storage->parent_class + $declaring_class_storage->parent_class, ); if (count($template_types = $declaring_class_storage->getClassTemplateTypes()) !== 0) { @@ -1233,7 +1233,7 @@ private static function getClassPropertyType( $class_property_type, $lhs_type_part, $class_storage, - $declaring_class_storage + $declaring_class_storage, ); } elseif ($lhs_type_part instanceof TGenericObject) { $class_property_type = self::localizePropertyType( @@ -1241,7 +1241,7 @@ private static function getClassPropertyType( $class_property_type, $lhs_type_part, $class_storage, - $declaring_class_storage + $declaring_class_storage, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php index f1775239ba6..3ae0ead285a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php @@ -61,7 +61,7 @@ public static function analyze( $statements_analyzer, $const_name, $stmt->name instanceof PhpParser\Node\Name\FullyQualified, - $context + $context, ); $codebase = $statements_analyzer->getCodebase(); @@ -84,7 +84,7 @@ public static function analyze( . ($stmt->name instanceof PhpParser\Node\Name\FullyQualified ? '\\' : $statements_analyzer->getNamespace() . '-') - . $const_name + . $const_name, ); if ($const_type) { @@ -93,9 +93,9 @@ public static function analyze( IssueBuffer::maybeAdd( new UndefinedConstant( 'Const ' . $const_name . ' is not defined', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -115,7 +115,7 @@ public static function getGlobalConstType( if ($fq_const_name) { $stubbed_const_type = $codebase->getStubbedConstantType( - $fq_const_name + $fq_const_name, ); if ($stubbed_const_type) { @@ -124,7 +124,7 @@ public static function getGlobalConstType( } $stubbed_const_type = $codebase->getStubbedConstantType( - $const_name + $const_name, ); if ($stubbed_const_type) { @@ -215,7 +215,7 @@ public static function getConstType( $namespace_name = implode('\\', $const_name_parts); $namespace_constants = NamespaceAnalyzer::getConstantsForNamespace( $namespace_name, - ReflectionProperty::IS_PUBLIC + ReflectionProperty::IS_PUBLIC, ); if (isset($namespace_constants[$const_name])) { @@ -303,7 +303,7 @@ public static function analyzeConstAssignment( $statements_analyzer, $const->name->name, $statements_analyzer->node_data->getType($const->value) ?? Type::getMixed(), - $context + $context, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php index fce9809ae9d..528acd0609d 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php @@ -74,13 +74,13 @@ public static function analyze( $stmt_var_id = ExpressionIdentifier::getExtendedVarId( $stmt->var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $var_id = ExpressionIdentifier::getExtendedVarId( $stmt, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($var_id && $context->hasVariable($var_id)) { @@ -91,7 +91,7 @@ public static function analyze( $stmt, $codebase, $stmt_var_id, - $in_assignment + $in_assignment, ); return true; @@ -111,9 +111,9 @@ public static function analyze( return !IssueBuffer::accepts( new NullPropertyFetch( 'Cannot get property on null variable ' . $stmt_var_id, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -121,9 +121,9 @@ public static function analyze( return !IssueBuffer::accepts( new MixedPropertyFetch( 'Cannot fetch property on empty var ' . $stmt_var_id, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -141,16 +141,16 @@ public static function analyze( if ($stmt->name instanceof PhpParser\Node\Identifier) { $codebase->analyzer->addMixedMemberName( '$' . $stmt->name->name, - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } IssueBuffer::maybeAdd( new MixedPropertyFetch( 'Cannot fetch property on mixed var ' . $stmt_var_id, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $statements_analyzer->node_data->setType($stmt, Type::getMixed()); @@ -162,7 +162,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt->name, - $stmt_var_type->getId() + $stmt_var_type->getId(), ); } } @@ -187,9 +187,9 @@ public static function analyze( new PossiblyNullPropertyFetch( rtrim('Cannot get property on possibly null variable ' . $stmt_var_id) . ' of type ' . $stmt_var_type, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { $statements_analyzer->node_data->setType($stmt, Type::getNull()); @@ -202,7 +202,7 @@ public static function analyze( if ($type instanceof TNamedObject) { $codebase->analyzer->addMixedMemberName( strtolower($type->value) . '::$', - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } } @@ -217,7 +217,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt->name, - $stmt_var_type->getId() + $stmt_var_type->getId(), ); } @@ -247,7 +247,7 @@ public static function analyze( $prop_name, $has_valid_fetch_type, $invalid_fetch_types, - $is_static_access + $is_static_access, ); } @@ -271,7 +271,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt->name, - $stmt_type->getId() + $stmt_type->getId(), ); } @@ -282,17 +282,17 @@ public static function analyze( IssueBuffer::maybeAdd( new PossiblyInvalidPropertyFetch( 'Cannot fetch property on possible non-object ' . $stmt_var_id . ' of type ' . $lhs_type_part, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new InvalidPropertyFetch( 'Cannot fetch property on non-object ' . $stmt_var_id . ' of type ' . $lhs_type_part, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -335,7 +335,7 @@ private static function handleScopedProperty( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt->name, - $stmt_type->getId() + $stmt_type->getId(), ); } @@ -379,9 +379,9 @@ private static function handleScopedProperty( new UninitializedProperty( 'Cannot use uninitialized property ' . $var_id, new CodeLocation($statements_analyzer->getSource(), $stmt), - $var_id + $var_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $stmt_type = $stmt_type->getBuilder()->addType(new TNull)->freeze(); @@ -415,7 +415,7 @@ private static function handleScopedProperty( $stmt_type, $property_id, $class_storage, - $in_assignment + $in_assignment, ); $context->vars_in_scope[$var_id] = $stmt_type; @@ -424,7 +424,7 @@ private static function handleScopedProperty( $declaring_property_class = $codebase->properties->getDeclaringClassForProperty( $property_id, true, - $statements_analyzer + $statements_analyzer, ); if ($declaring_property_class) { @@ -432,7 +432,7 @@ private static function handleScopedProperty( $stmt->name->name, $declaring_property_class, $stmt, - $statements_analyzer + $statements_analyzer, ); } @@ -443,7 +443,7 @@ private static function handleScopedProperty( $context, $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) - : null + : null, ); if ($codebase->store_node_types @@ -453,7 +453,7 @@ private static function handleScopedProperty( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->name, - $property_id + $property_id, ); } @@ -466,9 +466,9 @@ private static function handleScopedProperty( IssueBuffer::maybeAdd( new ImpurePropertyFetch( 'Cannot access a property on a mutable object from a pure context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php index d54b199ca56..84ab1558c6e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php @@ -61,9 +61,9 @@ public static function analyze( return !IssueBuffer::accepts( new ParentNotFound( 'Cannot check property fetch on parent as this class does not extend another', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } else { @@ -82,13 +82,13 @@ public static function analyze( $codebase->file_reference_provider->addMethodReferenceToClassMember( $context->calling_method_id, 'use:' . $stmt->class->parts[0] . ':' . md5($statements_analyzer->getFilePath()), - false + false, ); } $fq_class_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $aliases + $aliases, ); if ($context->isPhantomClass($fq_class_name)) { @@ -102,7 +102,7 @@ public static function analyze( new CodeLocation($statements_analyzer->getSource(), $stmt->class), $context->self, $context->calling_method_id, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) !== true) { return false; } @@ -121,14 +121,14 @@ public static function analyze( explode('::', $destination_method_id)[0], $statements_analyzer->getFilePath(), (int) $stmt->class->getAttribute('startFilePos'), - (int) $stmt->class->getAttribute('endFilePos') + 1 + (int) $stmt->class->getAttribute('endFilePos') + 1, ); } if ($fq_class_name) { $statements_analyzer->node_data->setType( $stmt->class, - new Union([new TNamedObject($fq_class_name)]) + new Union([new TNamedObject($fq_class_name)]), ); } @@ -146,7 +146,7 @@ public static function analyze( if ($fq_class_name) { $codebase->analyzer->addMixedMemberName( strtolower($fq_class_name) . '::$', - $context->calling_method_id ?: $statements_analyzer->getFileName() + $context->calling_method_id ?: $statements_analyzer->getFileName(), ); } @@ -164,7 +164,7 @@ public static function analyze( $var_id = ExpressionIdentifier::getVarId( $stmt, $context->self ?: $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $property_id = $fq_class_name . '::$' . $prop_name; @@ -176,7 +176,7 @@ public static function analyze( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt->name, - $property_id + $property_id, ); } @@ -184,9 +184,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureStaticProperty( 'Cannot use a static property in a mutation-free context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer @@ -206,7 +206,7 @@ public static function analyze( $property_id, false, [], - [] + [], ); $context->vars_in_scope[$var_id] = $stmt_type; @@ -221,7 +221,7 @@ public static function analyze( $context, $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) - : null + : null, ); } @@ -232,7 +232,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt->name, - $stmt_type->getId() + $stmt_type->getId(), ); } @@ -246,7 +246,7 @@ public static function analyze( $context, $codebase->collect_locations ? new CodeLocation($statements_analyzer->getSource(), $stmt) - : null + : null, ) ) { if ($context->inside_isset) { @@ -257,9 +257,9 @@ public static function analyze( new UndefinedPropertyFetch( 'Static property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return true; @@ -268,7 +268,7 @@ public static function analyze( $declaring_property_class = $codebase->properties->getDeclaringClassForProperty( $fq_class_name . '::$' . $prop_name, true, - $statements_analyzer + $statements_analyzer, ); if ($declaring_property_class === null) { @@ -279,7 +279,7 @@ public static function analyze( $prop_name, $declaring_property_class, $stmt, - $statements_analyzer + $statements_analyzer, ); $class_storage = $codebase->classlike_storage_provider->get($declaring_property_class); @@ -295,18 +295,18 @@ public static function analyze( new UndefinedPropertyAssignment( 'Static property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new UndefinedPropertyFetch( 'Static property ' . $property_id . ' is not defined', new CodeLocation($statements_analyzer->getSource(), $stmt), - $property_id + $property_id, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -318,7 +318,7 @@ public static function analyze( $context, $statements_analyzer, new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false) { return false; } @@ -331,7 +331,7 @@ public static function analyze( $statements_analyzer, $stmt->class, $fq_class_name, - $context->calling_method_id + $context->calling_method_id, ); if (!$moved_class) { @@ -350,15 +350,15 @@ public static function analyze( $new_fq_class_name, $statements_analyzer->getNamespace(), $statements_analyzer->getAliasedClassesFlipped(), - null - ) + null, + ), ); } $file_manipulations[] = new FileManipulation( (int) $stmt->name->getAttribute('startFilePos'), (int) $stmt->name->getAttribute('endFilePos') + 1, - '$' . $new_property_name + '$' . $new_property_name, ); FileManipulationBuffer::add($statements_analyzer->getFilePath(), $file_manipulations); @@ -376,7 +376,7 @@ public static function analyze( $property->type, $class_storage->name, $class_storage->name, - $class_storage->parent_class + $class_storage->parent_class, ); } else { $context->vars_in_scope[$var_id] = Type::getMixed(); @@ -391,7 +391,7 @@ public static function analyze( $property_id, false, [], - [] + [], ); $context->vars_in_scope[$var_id] = $stmt_type; @@ -404,7 +404,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt->name, - $stmt_type->getId() + $stmt_type->getId(), ); } } else { @@ -427,7 +427,7 @@ private static function analyzeVariableStaticPropertyFetch( ExpressionAnalyzer::analyze( $statements_analyzer, $stmt_class, - $context + $context, ); $context->inside_general_use = $was_inside_general_use; @@ -453,13 +453,13 @@ private static function analyzeVariableStaticPropertyFetch( if ($string_type) { $new_stmt_name = new VirtualFullyQualified( $string_type, - $stmt_class->getAttributes() + $stmt_class->getAttributes(), ); $fake_static_property = new VirtualStaticPropertyFetch( $new_stmt_name, $stmt->name, - $stmt->getAttributes() + $stmt->getAttributes(), ); self::analyze($statements_analyzer, $fake_static_property, $context); @@ -470,7 +470,7 @@ private static function analyzeVariableStaticPropertyFetch( $fake_var = new VirtualVariable( $fake_var_name, - $stmt_class->getAttributes() + $stmt_class->getAttributes(), ); $context->vars_in_scope['$' . $fake_var_name] = new Union([$class_atomic_type]); @@ -478,7 +478,7 @@ private static function analyzeVariableStaticPropertyFetch( $fake_instance_property = new VirtualPropertyFetch( $fake_var, $stmt->name, - $stmt->getAttributes() + $stmt->getAttributes(), ); InstancePropertyFetchAnalyzer::analyze( @@ -486,7 +486,7 @@ private static function analyzeVariableStaticPropertyFetch( $fake_instance_property, $context, false, - true + true, ); $fake_stmt_type = $statements_analyzer->node_data->getType($fake_instance_property) ?? Type::getMixed(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php index 09a58a063a7..e72b5c5e456 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php @@ -79,9 +79,9 @@ public static function analyze( return !IssueBuffer::accepts( new InvalidScope( 'Invalid reference to $this in a static context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -89,9 +89,9 @@ public static function analyze( if (IssueBuffer::accepts( new InvalidScope( 'Invalid reference to $this in a non-class context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -112,7 +112,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt, - $stmt_type->getId() + $stmt_type->getId(), ); } @@ -121,9 +121,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureVariable( 'Cannot reference $this in a pure context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations @@ -183,7 +183,7 @@ public static function analyze( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt, - $var_name + $var_name, ); return true; @@ -194,9 +194,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureVariable( 'Cannot reference an unknown variable in a pure context', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations @@ -218,7 +218,7 @@ public static function analyze( $stmt, $by_ref_type, $by_ref_type, - $context + $context, ); return true; @@ -247,7 +247,7 @@ public static function analyze( $statements_analyzer->registerVariable( $var_name, new CodeLocation($statements_analyzer, $stmt), - $context->branch_point + $context->branch_point, ); } $statements_analyzer->node_data->setType($stmt, $stmt_type); @@ -268,9 +268,9 @@ public static function analyze( new UndefinedGlobalVariable( 'Cannot find referenced variable ' . $var_name . ' in global scope', new CodeLocation($statements_analyzer->getSource(), $stmt), - $var_name + $var_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $statements_analyzer->node_data->setType($stmt, Type::getMixed()); @@ -281,9 +281,9 @@ public static function analyze( IssueBuffer::maybeAdd( new UndefinedVariable( 'Cannot find referenced variable ' . $var_name, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $statements_analyzer->node_data->setType($stmt, Type::getMixed()); @@ -315,10 +315,10 @@ public static function analyze( 'Possibly undefined global variable ' . $var_name . ', first seen on line ' . $first_appearance->getLineNumber(), new CodeLocation($statements_analyzer->getSource(), $stmt), - $var_name + $var_name, ), $statements_analyzer->getSuppressedIssues(), - (bool) $statements_analyzer->getBranchPoint($var_name) + (bool) $statements_analyzer->getBranchPoint($var_name), ); } else { if ($codebase->alter_code) { @@ -339,10 +339,10 @@ public static function analyze( new PossiblyUndefinedVariable( 'Possibly undefined variable ' . $var_name . ', first seen on line ' . $first_appearance->getLineNumber(), - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), $statements_analyzer->getSuppressedIssues(), - (bool) $statements_analyzer->getBranchPoint($var_name) + (bool) $statements_analyzer->getBranchPoint($var_name), ); } @@ -353,7 +353,7 @@ public static function analyze( $codebase->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $stmt, - $first_appearance->raw_file_start . '-' . $first_appearance->raw_file_end . ':mixed' + $first_appearance->raw_file_start . '-' . $first_appearance->raw_file_end . ':mixed', ); } @@ -381,17 +381,17 @@ public static function analyze( new PossiblyUndefinedGlobalVariable( 'Possibly undefined global variable ' . $var_name . ' defined in try block', new CodeLocation($statements_analyzer->getSource(), $stmt), - $var_name + $var_name, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new PossiblyUndefinedVariable( 'Possibly undefined variable ' . $var_name . ' defined in try block', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -403,7 +403,7 @@ public static function analyze( $codebase->analyzer->addNodeType( $statements_analyzer->getFilePath(), $stmt, - $stmt_type->getId() + $stmt_type->getId(), ); } @@ -419,7 +419,7 @@ public static function analyze( $stmt, $first_appearance->raw_file_start . '-' . $first_appearance->raw_file_end - . ':' . $stmt_type->getId() + . ':' . $stmt_type->getId(), ); } } @@ -449,11 +449,11 @@ private static function addDataFlowToVariable( if (!$stmt_type->parent_nodes) { $assignment_node = DataFlowNode::getForAssignment( $var_name, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ); $stmt_type = $stmt_type->setParentNodes([ - $assignment_node->id => $assignment_node + $assignment_node->id => $assignment_node, ]); } @@ -464,9 +464,9 @@ private static function addDataFlowToVariable( new DataFlowNode( 'variable-use', 'variable use', - null + null, ), - 'use-inside-call' + 'use-inside-call', ); } elseif ($context->inside_conditional) { $statements_analyzer->data_flow_graph->addPath( @@ -474,9 +474,9 @@ private static function addDataFlowToVariable( new DataFlowNode( 'variable-use', 'variable use', - null + null, ), - 'use-inside-conditional' + 'use-inside-conditional', ); } elseif ($context->inside_isset) { $statements_analyzer->data_flow_graph->addPath( @@ -484,9 +484,9 @@ private static function addDataFlowToVariable( new DataFlowNode( 'variable-use', 'variable use', - null + null, ), - 'use-inside-isset' + 'use-inside-isset', ); } else { $statements_analyzer->data_flow_graph->addPath( @@ -494,9 +494,9 @@ private static function addDataFlowToVariable( new DataFlowNode( 'variable-use', 'variable use', - null + null, ), - 'variable-use' + 'variable-use', ); } } @@ -524,13 +524,13 @@ private static function taintVariable( $var_name, null, null, - TaintKindGroup::ALL_INPUT + TaintKindGroup::ALL_INPUT, ); $statements_analyzer->data_flow_graph->addSource($server_taint_source); $type = $type->setParentNodes([ - $server_taint_source->id => $server_taint_source + $server_taint_source->id => $server_taint_source, ]); } } @@ -544,7 +544,7 @@ public static function isSuperGlobal(string $var_id): bool return in_array( $var_id, self::SUPER_GLOBALS, - true + true, ); } @@ -565,7 +565,7 @@ public static function getGlobalType(string $var_id, int $codebase_analysis_php_ } self::$globalCache['$_FILES full path'] = self::getGlobalTypeInner( '$_FILES', - true + true, ); self::$globalCache['$argv'] = self::getGlobalTypeInner('$argv'); self::$globalCache['$argc'] = self::getGlobalTypeInner('$argc'); @@ -591,9 +591,9 @@ private static function getGlobalTypeInner(string $var_id, bool $files_full_path // only in CLI, null otherwise return new Union([ Type::getNonEmptyListAtomic(Type::getString()), - new TNull() + new TNull(), ], [ - 'ignore_nullable_issues' => true + 'ignore_nullable_issues' => true, ]); // use TNull explicitly instead of this // as it will cause weird errors due to ignore_nullable_issues true @@ -605,9 +605,9 @@ private static function getGlobalTypeInner(string $var_id, bool $files_full_path // only in CLI, null otherwise return new Union([ new TIntRange(1, null), - new TNull() + new TNull(), ], [ - 'ignore_nullable_issues' => true + 'ignore_nullable_issues' => true, ]); } @@ -619,8 +619,8 @@ private static function getGlobalTypeInner(string $var_id, bool $files_full_path return new Union([ new TNonEmptyArray([ Type::getNonEmptyString(), - Type::getMixed() - ]) + Type::getMixed(), + ]), ]); } @@ -629,7 +629,7 @@ private static function getGlobalTypeInner(string $var_id, bool $files_full_path [ Type::getNonEmptyString(), Type::getString(), - ] + ], ); return new Union([$type]); @@ -644,17 +644,17 @@ private static function getGlobalTypeInner(string $var_id, bool $files_full_path new TString(), new TArray([ $array_key, - Type::getMixed() - ]) - ]) - ] + Type::getMixed(), + ]), + ]), + ], ); $type = new TArray( [ $array_key, new Union([new TString(), $array]), - ] + ], ); return new Union([$type]); @@ -665,19 +665,19 @@ private static function getGlobalTypeInner(string $var_id, bool $files_full_path $non_empty_string_helper = new Union([new TNonEmptyString()], ['possibly_undefined' => true]); $argv_helper = new Union([ - Type::getNonEmptyListAtomic(Type::getString()) + Type::getNonEmptyListAtomic(Type::getString()), ], ['possibly_undefined' => true]); $argc_helper = new Union([ - new TIntRange(1, null) + new TIntRange(1, null), ], ['possibly_undefined' => true]); $request_time_helper = new Union([ - new TIntRange(time(), null) + new TIntRange(time(), null), ], ['possibly_undefined' => true]); $request_time_float_helper = new Union([ - new TFloat() + new TFloat(), ], ['possibly_undefined' => true]); $bool_string_helper = new Union([new TBool(), new TString()], ['possibly_undefined' => true]); @@ -767,7 +767,7 @@ private static function getGlobalTypeInner(string $var_id, bool $files_full_path $detailed_type = new TKeyedArray( $arr, null, - [Type::getNonEmptyString(), Type::getString()] + [Type::getNonEmptyString(), Type::getString()], ); return new Union([$detailed_type]); @@ -800,7 +800,7 @@ private static function getGlobalTypeInner(string $var_id, bool $files_full_path new TArray([ Type::getNonEmptyString(), Type::getMixed(), - ]) + ]), ], ['possibly_undefined' => true]); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php index d9ff596d0c1..1526bb6a59f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php @@ -63,7 +63,7 @@ public static function analyze( $fake_right_expr, $stmt, $return_type, - $context + $context, ); $result_type = $return_type ?? Type::getMixed(); @@ -74,7 +74,7 @@ public static function analyze( $stmt, $stmt->var, $fake_right_expr, - 'inc' + 'inc', ); $var_id = ExpressionIdentifier::getExtendedVarId($stmt->var, null); @@ -94,7 +94,7 @@ public static function analyze( $var_id, $context->vars_in_scope[$var_id], $return_type, - $statements_analyzer + $statements_analyzer, ); } } else { @@ -104,18 +104,18 @@ public static function analyze( ? new VirtualPlus( $stmt->var, $fake_right_expr, - $stmt->var->getAttributes() + $stmt->var->getAttributes(), ) : new VirtualMinus( $stmt->var, $fake_right_expr, - $stmt->var->getAttributes() + $stmt->var->getAttributes(), ); $fake_assignment = new VirtualAssign( $stmt->var, $operation, - $stmt->getAttributes() + $stmt->getAttributes(), ); $old_node_data = $statements_analyzer->node_data; @@ -129,7 +129,7 @@ public static function analyze( if ($stmt instanceof PreInc || $stmt instanceof PreDec) { $old_node_data->setType( $stmt, - $statements_analyzer->node_data->getType($fake_assignment) ?? Type::getMixed() + $statements_analyzer->node_data->getType($fake_assignment) ?? Type::getMixed(), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php index 4b6c3dae06f..2cae6ff6af9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php @@ -60,7 +60,7 @@ public static function analyze( if (!$config->allow_includes) { throw new FileIncludeException( - 'File includes are not allowed per your Psalm config - check the allowFileIncludes flag.' + 'File includes are not allowed per your Psalm config - check the allowFileIncludes flag.', ); } @@ -108,7 +108,7 @@ public static function analyze( $statements_analyzer->node_data, $statements_analyzer, $statements_analyzer->getFileName(), - $config + $config, ); } @@ -124,7 +124,7 @@ public static function analyze( 'include', 0, $arg_location, - $arg_location + $arg_location, ); $include_param_sink->taints = [TaintKind::INPUT_INCLUDE]; @@ -143,7 +143,7 @@ public static function analyze( $include_param_sink, 'arg', $added_taints, - $removed_taints + $removed_taints, ); } } @@ -176,18 +176,18 @@ public static function analyze( $nesting = $statements_analyzer->getRequireNesting() + 1; $current_file_analyzer->project_analyzer->progress->debug( - str_repeat(' ', $nesting) . 'checking ' . $file_name . PHP_EOL + str_repeat(' ', $nesting) . 'checking ' . $file_name . PHP_EOL, ); $include_file_analyzer = new FileAnalyzer( $current_file_analyzer->project_analyzer, $path_to_file, - $file_name + $file_name, ); $include_file_analyzer->setRootFilePath( $current_file_analyzer->getRootFilePath(), - $current_file_analyzer->getRootFileName() + $current_file_analyzer->getRootFileName(), ); $include_file_analyzer->addParentFilePath($current_file_analyzer->getFilePath()); @@ -204,7 +204,7 @@ public static function analyze( try { $include_file_analyzer->analyze( $context, - $global_context + $global_context, ); } catch (UnpreparedAnalysisException $e) { if ($config->skip_checks_on_unresolvable_includes) { @@ -236,9 +236,9 @@ public static function analyze( IssueBuffer::maybeAdd( new MissingFile( 'Cannot find file ' . $path_to_file . ' to include', - new CodeLocation($source, $stmt) + new CodeLocation($source, $stmt), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } else { $var_id = ExpressionIdentifier::getExtendedVarId($stmt->expr, null); @@ -249,9 +249,9 @@ public static function analyze( IssueBuffer::maybeAdd( new UnresolvableInclude( 'Cannot resolve the given expression to a file path', - new CodeLocation($source, $stmt) + new CodeLocation($source, $stmt), ), - $source->getSuppressedIssues() + $source->getSuppressedIssues(), ); } } @@ -299,7 +299,7 @@ public static function getPathTo( return str_replace( '/', DIRECTORY_SEPARATOR, - $stmt_type->getSingleStringLiteral()->value + $stmt_type->getSingleStringLiteral()->value, ); } @@ -343,7 +343,7 @@ public static function getPathTo( $type_provider, $statements_analyzer, $file_name, - $config + $config, ); if (!$evaled_path) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php index 2c2ba1292c5..380279b7b1f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php @@ -45,7 +45,7 @@ public static function analyze( $fq_class_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $statements_analyzer->getAliases() + $statements_analyzer->getAliases(), ); if ($codebase->store_node_types @@ -62,7 +62,7 @@ public static function analyze( . ($stmt->class instanceof PhpParser\Node\Name\FullyQualified ? '\\' : $statements_analyzer->getNamespace() . '-') - . implode('\\', $stmt->class->parts) + . implode('\\', $stmt->class->parts), ); } @@ -73,7 +73,7 @@ public static function analyze( new CodeLocation($statements_analyzer->getSource(), $stmt->class), $context->self, $context->calling_method_id, - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ) === false) { return false; } @@ -85,7 +85,7 @@ public static function analyze( $statements_analyzer, $stmt->class, $fq_class_name, - $context->calling_method_id + $context->calling_method_id, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php index b38db459356..f439a59b710 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php @@ -37,9 +37,9 @@ public static function analyze( IssueBuffer::maybeAdd( new UndefinedConstant( 'Cannot get __class__ outside a class', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $statements_analyzer->node_data->setType($stmt, Type::getClassString()); @@ -50,7 +50,7 @@ public static function analyze( $statements_analyzer, $stmt, $context->self, - $context->calling_method_id + $context->calling_method_id, ); } @@ -62,9 +62,9 @@ public static function analyze( IssueBuffer::maybeAdd( new UndefinedConstant( 'Cannot get __namespace__ outside a namespace', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -79,7 +79,7 @@ public static function analyze( } else { $statements_analyzer->node_data->setType( $stmt, - Type::getString($source->getCorrectlyCasedMethodId()) + Type::getString($source->getCorrectlyCasedMethodId()), ); } } elseif ($source instanceof FunctionAnalyzer) { @@ -90,12 +90,12 @@ public static function analyze( } elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\Dir) { $statements_analyzer->node_data->setType( $stmt, - Type::getString(dirname($statements_analyzer->getSource()->getFilePath())) + Type::getString(dirname($statements_analyzer->getSource()->getFilePath())), ); } elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\File) { $statements_analyzer->node_data->setType( $stmt, - Type::getString($statements_analyzer->getSource()->getFilePath()) + Type::getString($statements_analyzer->getSource()->getFilePath()), ); } elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\Trait_) { if ($statements_analyzer->getSource() instanceof TraitAnalyzer) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php index 08f1749e6c5..677d36a5786 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php @@ -70,7 +70,7 @@ public static function analyze( $switch_var_id = ExpressionIdentifier::getExtendedVarId( $stmt->cond, null, - $statements_analyzer + $statements_analyzer, ); $match_condition = $stmt->cond; @@ -99,14 +99,14 @@ public static function analyze( new VirtualArg( new VirtualVariable( substr($switch_var_id, 1), - $first_arg->value->getAttributes() + $first_arg->value->getAttributes(), ), false, false, - $first_arg->getAttributes() - ) + $first_arg->getAttributes(), + ), ], - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ); } } elseif ($stmt->cond instanceof PhpParser\Node\Expr\FuncCall @@ -121,7 +121,7 @@ public static function analyze( $match_condition = new VirtualVariable( substr($switch_var_id, 1), - $stmt->cond->getAttributes() + $stmt->cond->getAttributes(), ); } } @@ -144,9 +144,9 @@ public static function analyze( IssueBuffer::maybeAdd( new UnhandledMatchCondition( 'This match expression does not match anything', - new CodeLocation($statements_analyzer->getSource(), $match_condition) + new CodeLocation($statements_analyzer->getSource(), $match_condition), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return false; @@ -166,13 +166,13 @@ public static function analyze( new VirtualNew( new VirtualFullyQualified( 'UnhandledMatchError', - $stmt->getAttributes() + $stmt->getAttributes(), ), [], - $stmt->getAttributes() - ) + $stmt->getAttributes(), + ), ), - $stmt->getAttributes() + $stmt->getAttributes(), ); } @@ -185,7 +185,7 @@ public static function analyze( self::convertCondsToConditional($arm->conds, $match_condition, $arm->getAttributes()), $arm->body, $ternary, - $arm->getAttributes() + $arm->getAttributes(), ); } @@ -227,7 +227,7 @@ public static function analyze( $all_match_condition = self::convertCondsToConditional( $all_conds, $match_condition, - $match_condition->getAttributes() + $match_condition->getAttributes(), ); ExpressionAnalyzer::analyze($statements_analyzer, $all_match_condition, $context); @@ -240,11 +240,11 @@ public static function analyze( $statements_analyzer, $codebase, false, - false + false, ); $reconcilable_types = Algebra::getTruthsFromFormula( - Algebra::negateFormula($clauses) + Algebra::negateFormula($clauses), ); // if the if has an || in the conditional, we cannot easily reason about it @@ -261,7 +261,7 @@ public static function analyze( $statements_analyzer, [], $context->inside_loop, - null + null, ); if (isset($vars_in_scope_reconciled[$switch_var_id])) { @@ -270,7 +270,7 @@ public static function analyze( static fn(Atomic $type): bool => $type instanceof TLiteralInt || $type instanceof TLiteralString || $type instanceof TLiteralFloat - || $type instanceof TEnumCase + || $type instanceof TEnumCase, ); if ($array_literal_types) { @@ -278,9 +278,9 @@ public static function analyze( new UnhandledMatchCondition( 'This match expression is not exhaustive - consider values ' . $vars_in_scope_reconciled[$switch_var_id]->getId(), - new CodeLocation($statements_analyzer->getSource(), $match_condition) + new CodeLocation($statements_analyzer->getSource(), $match_condition), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -310,14 +310,14 @@ private static function convertCondsToConditional( return new VirtualIdentical( $match_condition, $conds[0], - $attributes + $attributes, ); } $array_items = array_map( static fn(PhpParser\Node\Expr $cond): PhpParser\Node\Expr\ArrayItem => new VirtualArrayItem($cond, null, false, $cond->getAttributes()), - $conds + $conds, ); return new VirtualFuncCall( @@ -327,28 +327,28 @@ private static function convertCondsToConditional( $match_condition, false, false, - $attributes + $attributes, ), new VirtualArg( new VirtualArray( $array_items, - $attributes + $attributes, ), false, false, - $attributes + $attributes, ), new VirtualArg( new VirtualConstFetch( new VirtualFullyQualified(['true']), - $attributes + $attributes, ), false, false, - $attributes + $attributes, ), ], - $attributes + $attributes, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php index c1d49922d3f..739bb5b7ba2 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php @@ -55,18 +55,18 @@ public static function analyze( $null_value1 = new VirtualConstFetch( new VirtualName('null'), - $stmt->var->getAttributes() + $stmt->var->getAttributes(), ); $null_comparison = new VirtualIdentical( $tmp_var, $null_value1, - $stmt->var->getAttributes() + $stmt->var->getAttributes(), ); $null_value2 = new VirtualConstFetch( new VirtualName('null'), - $stmt->var->getAttributes() + $stmt->var->getAttributes(), ); if ($stmt instanceof PhpParser\Node\Expr\NullsafePropertyFetch) { @@ -74,14 +74,14 @@ public static function analyze( $null_comparison, $null_value2, new VirtualPropertyFetch($tmp_var, $stmt->name, $stmt->getAttributes()), - $stmt->getAttributes() + $stmt->getAttributes(), ); } else { $ternary = new VirtualTernary( $null_comparison, $null_value2, new VirtualMethodCall($tmp_var, $stmt->name, $stmt->args, $stmt->getAttributes()), - $stmt->getAttributes() + $stmt->getAttributes(), ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php index 558544a6094..64cebbc80d4 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php @@ -42,14 +42,14 @@ public static function analyze( 'print', 0, null, - $call_location + $call_location, ); $print_param_sink->taints = [ TaintKind::INPUT_HTML, TaintKind::INPUT_HAS_QUOTES, TaintKind::USER_SECRET, - TaintKind::SYSTEM_SECRET + TaintKind::SYSTEM_SECRET, ]; $statements_analyzer->data_flow_graph->addSink($print_param_sink); @@ -72,7 +72,7 @@ public static function analyze( null, true, true, - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ) === false) { return false; } @@ -82,9 +82,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ForbiddenCode( 'You have forbidden the use of print', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -93,9 +93,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureFunctionCall( 'Cannot call print from a mutation-free context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } elseif ($statements_analyzer->getSource() instanceof FunctionLikeAnalyzer && $statements_analyzer->getSource()->track_mutations diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/SimpleTypeInferer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/SimpleTypeInferer.php index 72db8101d96..dbb69546161 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/SimpleTypeInferer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/SimpleTypeInferer.php @@ -68,7 +68,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); $right = self::infer( $codebase, @@ -77,7 +77,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if ($left @@ -128,8 +128,8 @@ public static function infer( [ new TLiteralInt(-1), new TLiteralInt(0), - new TLiteralInt(1) - ] + new TLiteralInt(1), + ], ); } @@ -140,7 +140,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); $stmt_right_type = self::infer( @@ -150,7 +150,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if (!$stmt_left_type || !$stmt_right_type) { @@ -159,12 +159,12 @@ public static function infer( $nodes->setType( $stmt->left, - $stmt_left_type + $stmt_left_type, ); $nodes->setType( $stmt->right, - $stmt_right_type + $stmt_right_type, ); if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\Plus @@ -184,7 +184,7 @@ public static function infer( $stmt->left, $stmt->right, $stmt, - $result_type + $result_type, ); if ($result_type) { @@ -210,7 +210,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if ($stmt_expr_type === null) { @@ -245,7 +245,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if ($stmt_expr_type === null) { @@ -322,7 +322,7 @@ public static function infer( } else { $const_fq_class_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $aliases + $aliases, ); } @@ -345,7 +345,7 @@ public static function infer( $const_fq_class_name, $stmt->name->name, ReflectionProperty::IS_PRIVATE, - $file_source + $file_source, ); if ($foreign_class_constant) { @@ -386,7 +386,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); } @@ -422,7 +422,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if (!$type_to_invert) { @@ -457,7 +457,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); $dim_type = self::infer( @@ -467,7 +467,7 @@ public static function infer( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if ($array_type !== null && $dim_type !== null) { @@ -500,7 +500,7 @@ public static function infer( } return new Union([ - new Type\Atomic\TNamedObject($resolved_class_name) + new Type\Atomic\TNamedObject($resolved_class_name), ]); } @@ -538,7 +538,7 @@ private static function inferArrayType( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, )) { return null; } @@ -551,7 +551,7 @@ private static function inferArrayType( null, false, true, - 30 + 30, ); } @@ -562,7 +562,7 @@ private static function inferArrayType( null, false, true, - 30 + 30, ); } @@ -577,7 +577,7 @@ private static function inferArrayType( $array_creation_info->property_types, $array_creation_info->class_strings, null, - $array_creation_info->all_list + $array_creation_info->all_list, ); return new Union([$objectlike]); } @@ -619,7 +619,7 @@ private static function handleArrayItem( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if (!$unpacked_array_type) { @@ -641,7 +641,7 @@ private static function handleArrayItem( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if ($single_item_key_type) { @@ -661,7 +661,7 @@ private static function handleArrayItem( $array_creation_info->item_key_atomic_types = array_merge( $array_creation_info->item_key_atomic_types, - array_values($key_type->getAtomicTypes()) + array_values($key_type->getAtomicTypes()), ); if ($key_type->isSingleStringLiteral()) { @@ -695,7 +695,7 @@ private static function handleArrayItem( $aliases, $file_source, $existing_class_constants, - $fq_classlike_name + $fq_classlike_name, ); if (!$single_item_value_type) { @@ -748,7 +748,7 @@ private static function handleArrayItem( $array_creation_info->item_value_atomic_types = array_merge( $array_creation_info->item_value_atomic_types, - array_values($single_item_value_type->getAtomicTypes()) + array_values($single_item_value_type->getAtomicTypes()), ); return true; @@ -774,7 +774,7 @@ private static function handleUnpackedArray( $array_creation_info->item_value_atomic_types = array_merge( $array_creation_info->item_value_atomic_types, - array_values($property_value->getAtomicTypes()) + array_values($property_value->getAtomicTypes()), ); $array_creation_info->array_keys[$new_offset] = true; @@ -795,8 +795,8 @@ private static function handleUnpackedArray( $array_creation_info->item_value_atomic_types = array_merge( $array_creation_info->item_value_atomic_types, array_values( - $unpacked_atomic_type->fallback_params[1]->getAtomicTypes() - ) + $unpacked_atomic_type->fallback_params[1]->getAtomicTypes(), + ), ); } } elseif ($unpacked_atomic_type instanceof TArray) { @@ -818,8 +818,8 @@ private static function handleUnpackedArray( array_values( isset($unpacked_atomic_type->type_params[1]) ? $unpacked_atomic_type->type_params[1]->getAtomicTypes() - : [new TMixed()] - ) + : [new TMixed()], + ), ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php index 9014263e058..7d990eaf1dd 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php @@ -56,7 +56,7 @@ public static function analyze( $context, $codebase, $if_scope, - $context->branch_point ?: (int) $stmt->getAttribute('startFilePos') + $context->branch_point ?: (int) $stmt->getAttribute('startFilePos'), ); // this is the context for stuff that happens within the first operand of the ternary @@ -76,7 +76,7 @@ public static function analyze( $stmt->cond, $context->self, $statements_analyzer, - $codebase + $codebase, ); if (count($if_clauses) > 200) { @@ -113,7 +113,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { return $c; }, - $if_clauses + $if_clauses, ); $entry_clauses = $context->clauses; @@ -124,7 +124,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $if_clauses, $statements_analyzer, $stmt->cond, - $assigned_in_conditional_var_ids + $assigned_in_conditional_var_ids, ); $if_clauses = Algebra::simplifyCNF($if_clauses); @@ -140,7 +140,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { array_filter( $ternary_context_clauses, static fn(Clause $c): bool => !in_array($c->hash, $reconciled_expression_clauses) - ) + ), ); if (count($if_context->clauses) === 1 @@ -163,7 +163,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $context->self, $statements_analyzer, $codebase, - false + false, ); } catch (ComplicatedExpressionException $e) { $if_scope->negated_clauses = []; @@ -172,8 +172,8 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $if_scope->negated_types = Algebra::getTruthsFromFormula( Algebra::simplifyCNF( - [...$context->clauses, ...$if_scope->negated_clauses] - ) + [...$context->clauses, ...$if_scope->negated_clauses], + ), ); $active_if_types = []; @@ -182,7 +182,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $ternary_context_clauses, $cond_object_id, $cond_referenced_var_ids, - $active_if_types + $active_if_types, ); $changed_var_ids = []; @@ -198,7 +198,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $statements_analyzer, $statements_analyzer->getTemplateTypeMap() ?: [], $if_context->inside_loop, - new CodeLocation($statements_analyzer->getSource(), $stmt->cond) + new CodeLocation($statements_analyzer->getSource(), $stmt->cond), ); } @@ -211,12 +211,12 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $context->cond_referenced_var_ids = array_merge( $context->cond_referenced_var_ids, - $if_context->cond_referenced_var_ids + $if_context->cond_referenced_var_ids, ); } $t_else_context->clauses = Algebra::simplifyCNF( - [...$t_else_context->clauses, ...$if_scope->negated_clauses] + [...$t_else_context->clauses, ...$if_scope->negated_clauses], ); $changed_var_ids = []; @@ -232,7 +232,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $statements_analyzer, $statements_analyzer->getTemplateTypeMap() ?: [], $t_else_context->inside_loop, - new CodeLocation($statements_analyzer->getSource(), $stmt->else) + new CodeLocation($statements_analyzer->getSource(), $stmt->else), ); $t_else_context->clauses = Context::removeReconciledClauses($t_else_context->clauses, $changed_var_ids)[0]; @@ -251,7 +251,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { if (isset($if_context->vars_in_scope[$var_id]) && isset($t_else_context->vars_in_scope[$var_id])) { $context->vars_in_scope[$var_id] = Type::combineUnionTypes( $if_context->vars_in_scope[$var_id], - $t_else_context->vars_in_scope[$var_id] + $t_else_context->vars_in_scope[$var_id], ); } } @@ -264,7 +264,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { foreach ($redef_all as $redef_var_id) { $context->vars_in_scope[$redef_var_id] = Type::combineUnionTypes( $if_context->vars_in_scope[$redef_var_id], - $t_else_context->vars_in_scope[$redef_var_id] + $t_else_context->vars_in_scope[$redef_var_id], ); } @@ -273,7 +273,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { if (isset($context->vars_in_scope[$redef_var_ifs_id])) { $context->vars_in_scope[$redef_var_ifs_id] = Type::combineUnionTypes( $context->vars_in_scope[$redef_var_ifs_id], - $if_context->vars_in_scope[$redef_var_ifs_id] + $if_context->vars_in_scope[$redef_var_ifs_id], ); } } @@ -283,7 +283,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { if (isset($context->vars_in_scope[$redef_var_else_id])) { $context->vars_in_scope[$redef_var_else_id] = Type::combineUnionTypes( $context->vars_in_scope[$redef_var_else_id], - $t_else_context->vars_in_scope[$redef_var_else_id] + $t_else_context->vars_in_scope[$redef_var_else_id], ); } } @@ -291,12 +291,12 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $context->vars_possibly_in_scope = array_merge( $context->vars_possibly_in_scope, $if_context->vars_possibly_in_scope, - $t_else_context->vars_possibly_in_scope + $t_else_context->vars_possibly_in_scope, ); $context->cond_referenced_var_ids = array_merge( $context->cond_referenced_var_ids, - $t_else_context->cond_referenced_var_ids + $t_else_context->cond_referenced_var_ids, ); $lhs_type = null; @@ -314,7 +314,7 @@ static function (Clause $c) use ($mixed_var_ids, $cond_object_id): Clause { $context->inside_loop, [], new CodeLocation($statements_analyzer->getSource(), $stmt), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $lhs_type = $if_return_type_reconciled; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php index f18de5dac7e..07f12204342 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php @@ -99,7 +99,7 @@ public static function analyze( $statements_analyzer, $stmt, $stmt->expr, - $stmt instanceof UnaryMinus ? 'unary-minus' : 'unary-plus' + $stmt instanceof UnaryMinus ? 'unary-minus' : 'unary-plus', ); return true; @@ -123,7 +123,7 @@ private static function addDataFlow( $stmt, $result_type->setParentNodes([ $new_parent_node->id => $new_parent_node, - ]) + ]), ); if ($stmt_value_type && $stmt_value_type->parent_nodes) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php index 406350f1411..d5e6174b230 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php @@ -47,14 +47,14 @@ public static function analyze( $var_comments = CommentAnalyzer::getTypeFromComment( $doc_comment, $statements_analyzer, - $statements_analyzer->getAliases() + $statements_analyzer->getAliases(), ); } catch (DocblockParseException $e) { IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $stmt) - ) + new CodeLocation($statements_analyzer->getSource(), $stmt), + ), ); } @@ -68,7 +68,7 @@ public static function analyze( $var_comment->type, $context->self, $context->self ? new TNamedObject($context->self) : null, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); $type_location = null; @@ -81,7 +81,7 @@ public static function analyze( $statements_analyzer, $var_comment->type_start, $var_comment->type_end, - $var_comment->line_number + $var_comment->line_number, ); } @@ -105,17 +105,17 @@ public static function analyze( IssueBuffer::maybeAdd( new UnnecessaryVarAnnotation( 'The @var annotation for ' . $var_comment->var_id . ' is unnecessary', - $type_location + $type_location, ), $statements_analyzer->getSuppressedIssues(), - true + true, ); } } if (isset($context->vars_in_scope[$var_comment->var_id])) { $comment_type = $comment_type->setParentNodes( - $context->vars_in_scope[$var_comment->var_id]->parent_nodes + $context->vars_in_scope[$var_comment->var_id]->parent_nodes, ); } @@ -187,7 +187,7 @@ public static function analyze( $classlike_storage, null, $expression_atomic_type, - true + true, ); if ($class_template_params) { @@ -206,14 +206,14 @@ public static function analyze( $yield_candidate_type, $expression_atomic_type, $classlike_storage, - $declaring_classlike_storage + $declaring_classlike_storage, ); } $yield_type = Type::combineUnionTypes( $yield_type, $yield_candidate_type, - $codebase + $codebase, ); } @@ -241,7 +241,7 @@ public static function analyze( if (!$atomic_return_type->type_params[2]->isVoid()) { $statements_analyzer->node_data->setType( $stmt, - $atomic_return_type->type_params[2] + $atomic_return_type->type_params[2], ); } } else { @@ -249,8 +249,8 @@ public static function analyze( $stmt, Type::combineUnionTypes( Type::getMixed(), - $expression_type - ) + $expression_type, + ), ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php index a00dab6ef2d..03f63c637f3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php @@ -47,7 +47,7 @@ public static function analyze( $context, $key_type, $value_type, - $always_non_empty_array + $always_non_empty_array, ) === false ) { $context->inside_call = $was_inside_call; diff --git a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php index 479e7866306..0a946a36604 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php @@ -121,7 +121,7 @@ public static function analyze( $codebase, $negate, true, - false + false, ); } } @@ -131,7 +131,7 @@ public static function analyze( $context, $statements_analyzer, $codebase, - [] + [], ); if ($codebase->config->eventDispatcher->dispatchAfterExpressionAnalysis($event) === false) { @@ -170,7 +170,7 @@ private static function handleExpression( null, $array_assignment, false, - $assigned_to_reference + $assigned_to_reference, ); } @@ -245,7 +245,7 @@ private static function handleExpression( $statements_analyzer, $stmt, $context, - $array_assignment + $array_assignment, ); } @@ -253,7 +253,7 @@ private static function handleExpression( return StaticPropertyFetchAnalyzer::analyze( $statements_analyzer, $stmt, - $context + $context, ); } @@ -267,7 +267,7 @@ private static function handleExpression( $stmt, $context, 0, - $from_stmt + $from_stmt, ); } @@ -296,7 +296,7 @@ private static function handleExpression( $statements_analyzer, $stmt, $context, - $template_result + $template_result, ); } @@ -324,7 +324,7 @@ private static function handleExpression( return ArrayFetchAnalyzer::analyze( $statements_analyzer, $stmt, - $context + $context, ); } @@ -358,7 +358,7 @@ private static function handleExpression( IssueBuffer::maybeAdd( new UnsupportedReferenceUsage( "This reference cannot be analyzed by Psalm", - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), $statements_analyzer->getSuppressedIssues(), ); @@ -396,7 +396,7 @@ private static function handleExpression( 'shell_exec', 0, null, - $call_location + $call_location, ); $sink->taints = [TaintKind::INPUT_SHELL]; @@ -417,7 +417,7 @@ private static function handleExpression( $shell_exec_param = new FunctionLikeParameter( 'var', - false + false, ); if (ArgumentAnalyzer::verifyType( @@ -436,7 +436,7 @@ private static function handleExpression( null, true, true, - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ) === false) { return false; } @@ -445,7 +445,7 @@ private static function handleExpression( $statements_analyzer->data_flow_graph->addPath( $parent_node, new DataFlowNode('variable-use', 'variable use', null), - 'variable-use' + 'variable-use', ); } } @@ -455,9 +455,9 @@ private static function handleExpression( IssueBuffer::maybeAdd( new ForbiddenCode( 'Use of shell_exec', - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return true; @@ -511,9 +511,9 @@ private static function handleExpression( new UnrecognizedExpression( 'Psalm does not understand ' . get_class($stmt) . ' for PHP ' . $codebase->getMajorAnalysisPhpVersion() . '.' . $codebase->getMinorAnalysisPhpVersion(), - new CodeLocation($statements_analyzer->getSource(), $stmt) + new CodeLocation($statements_analyzer->getSource(), $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return false; @@ -541,7 +541,7 @@ private static function analyzeAssignment( $context, $stmt->getDocComment(), [], - !$from_stmt ? $stmt : null + !$from_stmt ? $stmt : null, ); if ($assignment_type === false) { diff --git a/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php index 7173a232e32..a96755c3c6c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php @@ -30,9 +30,9 @@ public static function analyze( IssueBuffer::maybeAdd( new InvalidGlobal( 'Cannot use global scope here (unless this file is included from a non-global scope)', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSource()->getSuppressedIssues() + $statements_analyzer->getSource()->getSuppressedIssues(), ); } @@ -66,7 +66,7 @@ public static function analyze( $assignment_node = DataFlowNode::getForAssignment( $var_id, - new CodeLocation($statements_analyzer, $var) + new CodeLocation($statements_analyzer, $var), ); $context->vars_in_scope[$var_id] = $context->vars_in_scope[$var_id]->setParentNodes([ $assignment_node->id => $assignment_node, @@ -81,12 +81,12 @@ public static function analyze( $statements_analyzer->registerVariable( $var_id, new CodeLocation($statements_analyzer, $var), - $context->branch_point + $context->branch_point, ); $statements_analyzer->getCodebase()->analyzer->addNodeReference( $statements_analyzer->getFilePath(), $var, - $var_id + $var_id, ); if ($global_context !== null && $global_context->hasVariable($var_id)) { diff --git a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php index 0d6f6f06c1f..2ea1e981544 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php @@ -82,14 +82,14 @@ public static function analyze( $statements_analyzer->getSource(), $statements_analyzer->getAliases(), $statements_analyzer->getTemplateTypeMap(), - $file_storage->type_aliases + $file_storage->type_aliases, ); } catch (DocblockParseException $e) { IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($source, $stmt) - ) + new CodeLocation($source, $stmt), + ), ); } @@ -103,7 +103,7 @@ public static function analyze( $var_comment->type, $context->self, $context->self, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); if ($codebase->alter_code @@ -115,7 +115,7 @@ public static function analyze( $statements_analyzer, $var_comment->type_start, $var_comment->type_end, - $var_comment->line_number + $var_comment->line_number, ); $codebase->classlikes->handleDocblockTypeInMigration( @@ -123,7 +123,7 @@ public static function analyze( $statements_analyzer, $comment_type, $type_location, - $context->calling_method_id + $context->calling_method_id, ); } @@ -134,7 +134,7 @@ public static function analyze( if (isset($context->vars_in_scope[$var_comment->var_id])) { $comment_type = $comment_type->setParentNodes( - $context->vars_in_scope[$var_comment->var_id]->parent_nodes + $context->vars_in_scope[$var_comment->var_id]->parent_nodes, ); } @@ -151,7 +151,7 @@ public static function analyze( self::potentiallyInferTypesOnClosureFromParentReturnType( $statements_analyzer, $stmt->expr, - $context + $context, ); } @@ -179,9 +179,9 @@ public static function analyze( IssueBuffer::maybeAdd( new NoValue( 'All possible types for this return were invalidated - This may be dead code', - new CodeLocation($source, $stmt) + new CodeLocation($source, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); $stmt_type = Type::getNever(); @@ -207,7 +207,7 @@ public static function analyze( $context->finally_scope->vars_in_scope[$var_id] = Type::combineUnionTypes( $context->finally_scope->vars_in_scope[$var_id], $type, - $statements_analyzer->getCodebase() + $statements_analyzer->getCodebase(), ); } else { $type = $type->setPossiblyUndefined(true, true); @@ -235,7 +235,7 @@ public static function analyze( $stmt_type, $source->getFQCLN(), $source->getFQCLN(), - $source->getParentFQCLN() + $source->getParentFQCLN(), ); if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph) { @@ -244,7 +244,7 @@ public static function analyze( $stmt, $cased_method_id, $inferred_type, - $storage + $storage, ); } @@ -255,7 +255,7 @@ public static function analyze( MethodIdentifier::wrap($cased_method_id), $self_class, $statements_analyzer, - null + null, ); } else { $declared_return_type = $storage->return_type; @@ -264,7 +264,7 @@ public static function analyze( if ($declared_return_type && !$declared_return_type->hasMixed()) { $local_return_type = $source->getLocalReturnType( $declared_return_type, - $storage instanceof MethodStorage && $storage->final + $storage instanceof MethodStorage && $storage->final, ); if ($storage instanceof MethodStorage) { @@ -278,7 +278,7 @@ public static function analyze( $class_storage, strtolower($method_name), null, - true + true, ); if ($found_generic_params) { @@ -289,7 +289,7 @@ public static function analyze( $local_return_type = TemplateInferredTypeReplacer::replace( $local_return_type, new TemplateResult([], $found_generic_params), - $codebase + $codebase, ); } } @@ -303,9 +303,9 @@ public static function analyze( if (IssueBuffer::accepts( new InvalidReturnStatement( 'No return values are expected for ' . $cased_method_id, - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return; } @@ -326,7 +326,7 @@ public static function analyze( foreach ($stmt_type->parent_nodes as $parent_node) { $origin_locations = [ ...$origin_locations, - ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node) + ...$statements_analyzer->data_flow_graph->getOriginLocations($parent_node), ]; } } @@ -343,9 +343,9 @@ public static function analyze( new MixedReturnStatement( 'Could not infer a return type', $return_location, - $origin_location + $origin_location, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; @@ -354,9 +354,9 @@ public static function analyze( IssueBuffer::maybeAdd( new MixedReturnStatement( 'Possibly-mixed return value', - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -376,9 +376,9 @@ public static function analyze( IssueBuffer::maybeAdd( new InvalidReturnStatement( 'No return values are expected for ' . $cased_method_id, - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); return; } @@ -391,7 +391,7 @@ public static function analyze( $local_return_type, true, true, - $union_comparison_results + $union_comparison_results, ) ) { // is the declared return type more specific than the inferred one? @@ -402,9 +402,9 @@ public static function analyze( IssueBuffer::maybeAdd( new MixedReturnStatement( 'Could not infer a return type', - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( @@ -412,9 +412,9 @@ public static function analyze( 'The type \'' . $stmt_type->getId() . '\' is more general than the' . ' declared return type \'' . $local_return_type->getId() . '\'' . ' for ' . $cased_method_id, - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -424,9 +424,9 @@ public static function analyze( 'The type \'' . $stmt_type->getId() . '\' is more general than the' . ' declared return type \'' . $local_return_type->getId() . '\'' . ' for ' . $cased_method_id, - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -441,7 +441,7 @@ public static function analyze( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(true) + new ClassLikeNameOptions(true), ) === false ) { return; @@ -462,7 +462,7 @@ public static function analyze( $context->self, $context->calling_method_id, $statements_analyzer->getSuppressedIssues(), - new ClassLikeNameOptions(true) + new ClassLikeNameOptions(true), ) === false ) { return; @@ -484,9 +484,9 @@ public static function analyze( . implode(', ', $union_comparison_results->missing_shape_fields) . ')' : ''), - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -501,9 +501,9 @@ public static function analyze( 'The declared return type \'' . $local_return_type->getId() . '\' for ' . $cased_method_id . ' is not nullable, but the function returns \'' . $inferred_type->getId() . '\'', - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -518,9 +518,9 @@ public static function analyze( 'The declared return type \'' . $local_return_type . '\' for ' . $cased_method_id . ' does not allow false, but the function returns \'' . $inferred_type . '\'', - new CodeLocation($source, $stmt->expr) + new CodeLocation($source, $stmt->expr), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -532,9 +532,9 @@ public static function analyze( IssueBuffer::maybeAdd( new InvalidReturnStatement( 'Empty return statement is not expected in ' . $cased_method_id, - new CodeLocation($source, $stmt) + new CodeLocation($source, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -558,7 +558,7 @@ private static function handleTaints( $method_node = DataFlowNode::getForMethodReturn( strtolower($cased_method_id), $cased_method_id, - $storage->signature_return_type_location ?: $storage->location + $storage->signature_return_type_location ?: $storage->location, ); $statements_analyzer->data_flow_graph->addNode($method_node); @@ -570,7 +570,7 @@ private static function handleTaints( $method_node, 'return', $storage->added_taints, - $storage->removed_taints + $storage->removed_taints, ); } } @@ -602,7 +602,7 @@ private static function potentiallyInferTypesOnClosureFromParentReturnType( ->getCodebase() ->getFunctionLikeStorage( $statements_analyzer, - $context->calling_function_id ?: $context->calling_method_id + $context->calling_function_id ?: $context->calling_method_id, ); if ($parent_fn_storage->return_type === null) { @@ -631,14 +631,14 @@ private static function potentiallyInferTypesOnClosureFromParentReturnType( $param->type = self::inferInnerClosureTypeFromParent( $statements_analyzer->getCodebase(), $param->type, - $parent_param->type ?? null + $parent_param->type ?? null, ); } $closure_storage->return_type = self::inferInnerClosureTypeFromParent( $statements_analyzer->getCodebase(), $closure_storage->return_type, - $parent_callable_return_type->return_type + $parent_callable_return_type->return_type, ); } diff --git a/src/Psalm/Internal/Analyzer/Statements/StaticAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/StaticAnalyzer.php index 800a55a9833..efd9d9e7ac8 100644 --- a/src/Psalm/Internal/Analyzer/Statements/StaticAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/StaticAnalyzer.php @@ -39,9 +39,9 @@ public static function analyze( IssueBuffer::maybeAdd( new ImpureStaticVariable( 'Cannot use a static variable in a mutation-free context', - new CodeLocation($statements_analyzer, $stmt) + new CodeLocation($statements_analyzer, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } @@ -67,21 +67,21 @@ public static function analyze( $parsed_docblock, $statements_analyzer->getSource(), $statements_analyzer->getSource()->getAliases(), - $statements_analyzer->getSource()->getTemplateTypeMap() + $statements_analyzer->getSource()->getTemplateTypeMap(), ); } catch (IncorrectDocblockException $e) { IssueBuffer::maybeAdd( new MissingDocblockType( $e->getMessage(), - new CodeLocation($statements_analyzer, $var) - ) + new CodeLocation($statements_analyzer, $var), + ), ); } catch (DocblockParseException $e) { IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $var) - ) + new CodeLocation($statements_analyzer->getSource(), $var), + ), ); } @@ -96,7 +96,7 @@ public static function analyze( $var_comment->type, $context->self, $context->self, - $statements_analyzer->getParentFQCLN() + $statements_analyzer->getParentFQCLN(), ); $var_comment_type = $var_comment_type->setFromDocblock(); @@ -105,7 +105,7 @@ public static function analyze( $var_comment_type->check( $statements_analyzer, new CodeLocation($statements_analyzer->getSource(), $var), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); if ($codebase->alter_code @@ -117,7 +117,7 @@ public static function analyze( $statements_analyzer, $var_comment->type_start, $var_comment->type_end, - $var_comment->line_number + $var_comment->line_number, ); $codebase->classlikes->handleDocblockTypeInMigration( @@ -125,7 +125,7 @@ public static function analyze( $statements_analyzer, $var_comment_type, $type_location, - $context->calling_method_id + $context->calling_method_id, ); } @@ -139,8 +139,8 @@ public static function analyze( IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer, $var) - ) + new CodeLocation($statements_analyzer, $var), + ), ); } } @@ -160,15 +160,15 @@ public static function analyze( && !UnionTypeComparator::isContainedBy( $codebase, $var_default_type, - $comment_type + $comment_type, ) ) { IssueBuffer::maybeAdd( new ReferenceConstraintViolation( $var_id . ' of type ' . $comment_type->getId() . ' cannot be assigned type ' . $var_default_type->getId(), - new CodeLocation($statements_analyzer, $var) - ) + new CodeLocation($statements_analyzer, $var), + ), ); } } @@ -184,7 +184,7 @@ public static function analyze( $statements_analyzer->registerVariable( $var_id, $location, - $context->branch_point + $context->branch_point, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php index 43a72aa3d19..c0d1b0b2a45 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php @@ -40,7 +40,7 @@ public static function analyze( $context->finally_scope->vars_in_scope[$var_id] = Type::combineUnionTypes( $context->finally_scope->vars_in_scope[$var_id], $type, - $statements_analyzer->getCodebase() + $statements_analyzer->getCodebase(), ); } else { $type = $type->setPossiblyUndefined(true, true); @@ -67,9 +67,9 @@ public static function analyze( 'Cannot throw ' . $throw_type_part . ' as it does not extend Exception or implement Throwable', new CodeLocation($file_analyzer, $stmt), - (string) $throw_type_part + (string) $throw_type_part, ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } diff --git a/src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php index 9eb5a0a62e6..5299d8d63e3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/UnsetAnalyzer.php @@ -43,7 +43,7 @@ public static function analyze( $var_id = ExpressionIdentifier::getExtendedVarId( $var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); if ($var_id) { @@ -55,7 +55,7 @@ public static function analyze( $root_var_id = ExpressionIdentifier::getExtendedVarId( $var->var, $statements_analyzer->getFQCLN(), - $statements_analyzer + $statements_analyzer, ); $key_type = $statements_analyzer->node_data->getType($var->dim); @@ -94,12 +94,12 @@ public static function analyze( } elseif ($key_value === 1) { $list_key = new Union([ new TLiteralInt(0), - new TIntRange(2, null) + new TIntRange(2, null), ]); } else { $list_key = new Union([ new TIntRange(0, $key_value-1), - new TIntRange($key_value+1, null) + new TIntRange($key_value+1, null), ]); } } @@ -128,7 +128,7 @@ public static function analyze( $list_key ?? $atomic_root_type->fallback_params[0], $atomic_root_type->fallback_params[1], ] : null, - $is_list + $is_list, ); } } else { @@ -157,7 +157,7 @@ public static function analyze( $context->removeVarFromConflictingClauses( $root_var_id, $context->vars_in_scope[$root_var_id], - $statements_analyzer + $statements_analyzer, ); } } diff --git a/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php b/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php index 8a83cd265a6..188ad00bb3c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php +++ b/src/Psalm/Internal/Analyzer/Statements/UnusedAssignmentRemover.php @@ -82,7 +82,7 @@ public function findUnusedAssignment( $codebase, $original_location, $assign_stmt->getEndFilePos(), - $is_assign_ref + $is_assign_ref, ); $this->removed_unref_vars[$var_id] = $original_location; } else { @@ -92,7 +92,7 @@ public function findUnusedAssignment( $assign_stmt->getEndFilePos() + 1, "", false, - true + true, ); // If statement we are removing is a chain of assignments, mark other variables as removed @@ -110,7 +110,7 @@ public function findUnusedAssignment( $codebase, $original_location, $assign_exp->getEndFilePos(), - $is_assign_ref + $is_assign_ref, ); FileManipulationBuffer::add($original_location->file_path, [$new_file_manipulation]); @@ -126,7 +126,7 @@ private static function getPartialRemovalBounds( ): FileManipulation { $var_start_loc= $var_loc->raw_file_start; $stmt_content = $codebase->file_provider->getContents( - $var_loc->file_path + $var_loc->file_path, ); $str_for_token = "node_data, $const->value, $statements_analyzer->getAliases(), - $statements_analyzer + $statements_analyzer, ) ?? Type::getMixed(), - $context + $context, ); } } elseif ($stmt instanceof PhpParser\Node\Stmt\Expression @@ -311,7 +311,7 @@ private static function hoistConstants( $stmt->expr->getArgs()[0]->value, $statements_analyzer->node_data, $codebase, - $statements_analyzer->getAliases() + $statements_analyzer->getAliases(), ); if ($const_name !== null) { @@ -323,9 +323,9 @@ private static function hoistConstants( $statements_analyzer->node_data, $stmt->expr->getArgs()[1]->value, $statements_analyzer->getAliases(), - $statements_analyzer + $statements_analyzer, ) ?? Type::getMixed(), - $context + $context, ); } } @@ -367,7 +367,7 @@ private static function analyzeStatement( '/(?:\s*,\s*|\s+)/', $traced_variable_line, -1, - PREG_SPLIT_NO_EMPTY + PREG_SPLIT_NO_EMPTY, ); if ($possible_traced_variable_names) { $traced_variables = [...$traced_variables, ...$possible_traced_variable_names]; @@ -415,7 +415,7 @@ private static function analyzeStatement( IssueBuffer::addUnusedSuppression( $statements_analyzer->getFilePath(), $offset, - $issue_type + $issue_type, ); } } @@ -449,21 +449,21 @@ private static function analyzeStatement( $statements_analyzer->getSource(), $statements_analyzer->getAliases(), $template_type_map, - $file_storage->type_aliases + $file_storage->type_aliases, ); } catch (IncorrectDocblockException $e) { IssueBuffer::maybeAdd( new MissingDocblockType( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $stmt) - ) + new CodeLocation($statements_analyzer->getSource(), $stmt), + ), ); } catch (DocblockParseException $e) { IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($statements_analyzer->getSource(), $stmt) - ) + new CodeLocation($statements_analyzer->getSource(), $stmt), + ), ); } @@ -472,7 +472,7 @@ private static function analyzeStatement( $statements_analyzer, $stmt, $var_comment, - $context + $context, ); if ($var_comment->var_id === '$this' @@ -501,9 +501,9 @@ private static function analyzeStatement( IssueBuffer::maybeAdd( new UnevaluatedCode( 'Expressions after return/throw/continue', - new CodeLocation($statements_analyzer->source, $stmt) + new CodeLocation($statements_analyzer->source, $stmt), ), - $statements_analyzer->source->getSuppressedIssues() + $statements_analyzer->source->getSuppressedIssues(), ); } return null; @@ -562,7 +562,7 @@ private static function analyzeStatement( $context, false, $global_context, - true + true, ) === false) { return false; } @@ -579,7 +579,7 @@ private static function analyzeStatement( $class_analyzer = new ClassAnalyzer( $stmt, $statements_analyzer->source, - $stmt->name->name ?? null + $stmt->name->name ?? null, ); $class_analyzer->analyze(null, $global_context); @@ -610,9 +610,9 @@ private static function analyzeStatement( if (IssueBuffer::accepts( new UnrecognizedStatement( 'Psalm does not understand ' . get_class($stmt), - new CodeLocation($statements_analyzer->source, $stmt) + new CodeLocation($statements_analyzer->source, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), )) { return false; } @@ -639,17 +639,17 @@ private static function analyzeStatement( IssueBuffer::maybeAdd( new Trace( $traced_variable . ': ' . $context->vars_in_scope[$traced_variable]->getId(), - new CodeLocation($statements_analyzer->source, $stmt) + new CodeLocation($statements_analyzer->source, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } else { IssueBuffer::maybeAdd( new UndefinedTrace( 'Attempt to trace undefined variable ' . $traced_variable, - new CodeLocation($statements_analyzer->source, $stmt) + new CodeLocation($statements_analyzer->source, $stmt), ), - $statements_analyzer->getSuppressedIssues() + $statements_analyzer->getSuppressedIssues(), ); } } @@ -729,7 +729,7 @@ private static function dispatchAfterStatementAnalysis( $context, $statements_analyzer, $codebase, - [] + [], ); if ($codebase->config->eventDispatcher->dispatchAfterStatementAnalysis($event) === false) { @@ -755,7 +755,7 @@ private static function dispatchBeforeStatementAnalysis( $context, $statements_analyzer, $codebase, - [] + [], ); if ($codebase->config->eventDispatcher->dispatchBeforeStatementAnalysis($event) === false) { @@ -782,8 +782,8 @@ private function parseStatementDocblock( IssueBuffer::maybeAdd( new InvalidDocblock( $e->getMessage(), - new CodeLocation($this->getSource(), $stmt, null, true) - ) + new CodeLocation($this->getSource(), $stmt, null, true), + ), ); $this->parsed_docblock = null; @@ -799,8 +799,8 @@ private function parseStatementDocblock( new UndefinedDocblockClass( 'Scope class ' . $trimmed . ' does not exist', new CodeLocation($this->getSource(), $stmt, null, true), - $trimmed - ) + $trimmed, + ), ); } else { $this_type = Type::parseString($trimmed); @@ -846,18 +846,18 @@ public function checkUnreferencedVars(array $stmts, Context $context): void new ComplexFunction( 'This function’s complexity is greater than the project limit' . ' (method graph size = ' . $count .', average path length = ' . round($mean). ')', - $function_storage->location + $function_storage->location, ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } elseif ($source instanceof MethodAnalyzer) { IssueBuffer::maybeAdd( new ComplexMethod( 'This method’s complexity is greater than the project limit' . ' (method graph size = ' . $count .', average path length = ' . round($mean) . ')', - $function_storage->location + $function_storage->location, ), - $this->getSuppressedIssues() + $this->getSuppressedIssues(), ); } } @@ -904,12 +904,12 @@ public function checkUnreferencedVars(array $stmts, Context $context): void if ($is_foreach_var) { $issue = new UnusedForeachValue( $var_id . ' is never referenced or the value is not used', - $original_location + $original_location, ); } else { $issue = new UnusedVariable( $var_id . ' is never referenced or the value is not used', - $original_location + $original_location, ); } @@ -924,14 +924,14 @@ public function checkUnreferencedVars(array $stmts, Context $context): void $stmts, array_combine($var_list, $loc_list), $var_id, - $original_location + $original_location, ); } IssueBuffer::maybeAdd( $issue, $this->getSuppressedIssues(), - $issue instanceof UnusedVariable + $issue instanceof UnusedVariable, ); } } @@ -1071,12 +1071,12 @@ public function getUncaughtThrows(Context $context): array $ignored_exceptions = array_change_key_case( $context->is_global ? $config->ignored_exceptions_in_global_scope : - $config->ignored_exceptions + $config->ignored_exceptions, ); $ignored_exceptions_and_descendants = array_change_key_case( $context->is_global ? $config->ignored_exceptions_and_descendants_in_global_scope : - $config->ignored_exceptions_and_descendants + $config->ignored_exceptions_and_descendants, ); foreach ($context->possibly_thrown_exceptions as $possibly_thrown_exception => $codelocations) { diff --git a/src/Psalm/Internal/Analyzer/TraitAnalyzer.php b/src/Psalm/Internal/Analyzer/TraitAnalyzer.php index f5a71a5ce42..8bea62d068c 100644 --- a/src/Psalm/Internal/Analyzer/TraitAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/TraitAnalyzer.php @@ -78,7 +78,7 @@ public static function analyze(StatementsAnalyzer $statements_analyzer, Trait_ $ $storage, $stmt->attrGroups, AttributesAnalyzer::TARGET_CLASS, - $storage->suppressed_issues + $statements_analyzer->getSuppressedIssues() + $storage->suppressed_issues + $statements_analyzer->getSuppressedIssues(), ); } } diff --git a/src/Psalm/Internal/Clause.php b/src/Psalm/Internal/Clause.php index 7e1c952bed2..31f32bea065 100644 --- a/src/Psalm/Internal/Clause.php +++ b/src/Psalm/Internal/Clause.php @@ -214,7 +214,7 @@ public function removePossibilities(string $var_id): ?self $this->wedge, $this->reconcilable, $this->generated, - $this->redefined_vars + $this->redefined_vars, ); } @@ -233,7 +233,7 @@ public function addPossibilities(string $var_id, array $clause_var_possibilities $this->wedge, $this->reconcilable, $this->generated, - $this->redefined_vars + $this->redefined_vars, ); } diff --git a/src/Psalm/Internal/Cli/LanguageServer.php b/src/Psalm/Internal/Cli/LanguageServer.php index 68c9a669fe4..1be270948ea 100644 --- a/src/Psalm/Internal/Cli/LanguageServer.php +++ b/src/Psalm/Internal/Cli/LanguageServer.php @@ -84,7 +84,7 @@ public static function run(array $argv): void 'disable-on-change::', 'enable-autocomplete::', 'use-extended-diagnostic-codes', - 'verbose' + 'verbose', ]; $args = array_slice($argv, 1); @@ -107,14 +107,14 @@ static function (string $arg) use ($valid_long_options): void { fwrite( STDERR, 'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL - . 'Type --help to see a list of supported arguments' . PHP_EOL + . 'Type --help to see a list of supported arguments' . PHP_EOL, ); error_log('Bad argument'); exit(1); } } }, - $args + $args, ); // get options from command line @@ -211,7 +211,7 @@ static function (string $arg) use ($valid_long_options): void { if (!$root_path) { fwrite( STDERR, - 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL + 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL, ); exit(1); } @@ -259,7 +259,7 @@ static function (string $arg) use ($valid_long_options): void { $path_to_config, $current_dir, Report::TYPE_CONSOLE, - $first_autoloader + $first_autoloader, ); $config->setIncludeCollector($include_collector); @@ -286,12 +286,12 @@ static function (string $arg) use ($valid_long_options): void { new FileStorageCacheProvider($config), new ClassLikeStorageCacheProvider($config), new FileReferenceCacheProvider($config), - new ProjectCacheProvider(Composer::getLockFilePath($current_dir)) + new ProjectCacheProvider(Composer::getLockFilePath($current_dir)), ); $project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); if ($config->find_unused_variables) { diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index 383ea361914..4d3bdcf55e1 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -238,7 +238,7 @@ public static function run(array $argv): void $path_to_config, $output_format, $run_taint_analysis, - $options + $options, ); if (isset($options['no-cache'])) { @@ -347,10 +347,10 @@ public static function run(array $argv): void $report_file_paths, isset($options['report-show-info']) ? $options['report-show-info'] !== 'false' && $options['report-show-info'] !== '0' - : true + : true, ), $threads, - $progress + $progress, ); CliUtils::initPhpVersion($options, $config, $project_analyzer); @@ -364,7 +364,7 @@ public static function run(array $argv): void $find_references_to, $find_unused_code, $find_unused_variables, - $run_taint_analysis + $run_taint_analysis, ); if ($config->run_taint_analysis || $run_taint_analysis) { @@ -402,7 +402,7 @@ public static function run(array $argv): void !$paths_to_check, $start_time, isset($options['stats']), - self::initBaseline($options, $config, $current_dir, $path_to_config) + self::initBaseline($options, $config, $current_dir, $path_to_config), ); } else { self::autoGenerateConfig($project_analyzer, $current_dir, $init_source_dir, $vendor_dir); @@ -447,7 +447,7 @@ static function (string $arg): void { fwrite( STDERR, 'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL - . 'Type --help to see a list of supported arguments'. PHP_EOL + . 'Type --help to see a list of supported arguments'. PHP_EOL, ); exit(1); } @@ -460,13 +460,13 @@ static function (string $arg): void { fwrite( STDERR, 'Unrecognised argument "-' . $arg_name . '"' . PHP_EOL - . 'Type --help to see a list of supported arguments'. PHP_EOL + . 'Type --help to see a list of supported arguments'. PHP_EOL, ); exit(1); } } }, - $args + $args, ); } @@ -542,7 +542,7 @@ private static function generateConfig(string $current_dir, array &$args): void $current_dir, $init_source_dir, $init_level, - $vendor_dir + $vendor_dir, ); } catch (ConfigCreationException $e) { die($e->getMessage() . PHP_EOL); @@ -569,7 +569,7 @@ private static function loadConfig( $current_dir, $output_format, $first_autoloader, - $run_taint_analysis + $run_taint_analysis, ); if (isset($options['error-level']) @@ -579,7 +579,7 @@ private static function loadConfig( if (!in_array($config_level, [1, 2, 3, 4, 5, 6, 7, 8], true)) { throw new ConfigException( - 'Invalid error level ' . $config_level + 'Invalid error level ' . $config_level, ); } @@ -615,7 +615,7 @@ private static function initProviders(array $options, Config $config, string $cu { if (isset($options['no-cache']) || isset($options['i'])) { $providers = new Providers( - new FileProvider + new FileProvider, ); } else { $no_reflection_cache = isset($options['no-reflection-cache']); @@ -635,7 +635,7 @@ private static function initProviders(array $options, Config $config, string $cu $file_storage_cache_provider, $classlike_storage_cache_provider, new FileReferenceCacheProvider($config), - new ProjectCacheProvider(Composer::getLockFilePath($current_dir)) + new ProjectCacheProvider(Composer::getLockFilePath($current_dir)), ); } return $providers; @@ -656,7 +656,7 @@ private static function generateBaseline( try { $issue_baseline = ErrorBaseline::read( new FileProvider, - $options['set-baseline'] + $options['set-baseline'], ); } catch (ConfigException $e) { $issue_baseline = []; @@ -666,7 +666,7 @@ private static function generateBaseline( new FileProvider, $options['set-baseline'], IssueBuffer::getIssuesData(), - $config->include_php_versions_in_error_baseline || isset($options['include-php-versions']) + $config->include_php_versions_in_error_baseline || isset($options['include-php-versions']), ); fwrite(STDERR, "Baseline saved to {$options['set-baseline']}."); @@ -674,7 +674,7 @@ private static function generateBaseline( CliUtils::updateConfigFile( $config, $path_to_config ?? $current_dir, - $options['set-baseline'] + $options['set-baseline'], ); fwrite(STDERR, PHP_EOL); @@ -696,7 +696,7 @@ private static function updateBaseline(array $options, Config $config): array try { $issue_current_baseline = ErrorBaseline::read( new FileProvider, - $baselineFile + $baselineFile, ); $total_issues_current_baseline = ErrorBaseline::countTotalIssues($issue_current_baseline); @@ -704,7 +704,7 @@ private static function updateBaseline(array $options, Config $config): array new FileProvider, $baselineFile, IssueBuffer::getIssuesData(), - $config->include_php_versions_in_error_baseline || isset($options['include-php-versions']) + $config->include_php_versions_in_error_baseline || isset($options['include-php-versions']), ); $total_issues_updated_baseline = ErrorBaseline::countTotalIssues($issue_baseline); @@ -741,17 +741,17 @@ private static function storeTypeMap(Providers $providers, Config $config, strin $reference_dictionary = ReferenceMapGenerator::getReferenceMap( $providers->classlike_storage_provider, - $expected_references + $expected_references, ); $type_map_string = json_encode( ['files' => $name_file_map, 'references' => $reference_dictionary], - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); $providers->file_provider->setContents( $type_map_location, - $type_map_string + $type_map_string, ); } @@ -771,7 +771,7 @@ private static function autoGenerateConfig( $init_level = Creator::getLevel( array_merge(...array_values($issues_by_file)), - array_sum($mixed_counts) + array_sum($mixed_counts), ); } @@ -782,7 +782,7 @@ private static function autoGenerateConfig( $current_dir, $init_source_dir, $init_level, - $vendor_dir + $vendor_dir, ); } catch (ConfigCreationException $e) { die($e->getMessage() . PHP_EOL); @@ -857,7 +857,7 @@ private static function getCurrentDir(array $options): string if (!$root_path) { fwrite( STDERR, - 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL + 'Could not locate root directory ' . $current_dir . DIRECTORY_SEPARATOR . $options['r'] . PHP_EOL, ); exit(1); } @@ -1012,7 +1012,7 @@ private static function initConfig( $output_format, $first_autoloader, $run_taint_analysis, - $options + $options, ); } return [$config, $init_source_dir]; @@ -1053,7 +1053,7 @@ private static function initBaseline( try { $issue_baseline = ErrorBaseline::read( new FileProvider, - $baseline_file_path + $baseline_file_path, ); } catch (ConfigException $exception) { fwrite(STDERR, 'Error while reading baseline: ' . $exception->getMessage() . PHP_EOL); @@ -1074,7 +1074,7 @@ private static function storeFlowGraph(array $options, ProjectAnalyzer $project_ file_put_contents($dump_taint_graph, "digraph Taints {\n\t". implode("\n\t", array_map( static fn(array $edges) => '"'.implode('" -> "', $edges).'"', - $flow_graph->summarizeEdges() + $flow_graph->summarizeEdges(), )) . "\n}\n"); } @@ -1170,8 +1170,8 @@ private static function generateStubs( StubsGenerator::getAll( $project_analyzer->getCodebase(), $providers->classlike_storage_provider, - $providers->file_storage_provider - ) + $providers->file_storage_provider, + ), ); } } diff --git a/src/Psalm/Internal/Cli/Psalter.php b/src/Psalm/Internal/Cli/Psalter.php index 7cb9ac925b2..d19ad988833 100644 --- a/src/Psalm/Internal/Cli/Psalter.php +++ b/src/Psalm/Internal/Cli/Psalter.php @@ -88,7 +88,7 @@ final class Psalter 'allow-backwards-incompatible-changes:', 'add-newline-between-docblock-annotations:', 'no-cache', - 'no-progress' + 'no-progress', ]; /** @param array $argv */ @@ -189,7 +189,7 @@ public static function run(array $argv): void STDERR, 'Please specify the issues you want to fix with --issues=IssueOne,IssueTwo or --issues=all, ' . 'or provide a plugin that has its own manipulations with --plugin=path/to/plugin.php' - . PHP_EOL + . PHP_EOL, ); exit(1); } @@ -231,7 +231,7 @@ public static function run(array $argv): void $path_to_config, $current_dir, Report::TYPE_CONSOLE, - $first_autoloader + $first_autoloader, ); if (isset($options['no-cache'])) { @@ -249,7 +249,7 @@ public static function run(array $argv): void if (isset($options['no-cache'])) { $providers = new Providers( - new FileProvider() + new FileProvider(), ); } else { $providers = new Providers( @@ -258,7 +258,7 @@ public static function run(array $argv): void new FileStorageCacheProvider($config), new ClassLikeStorageCacheProvider($config), null, - new ProjectCacheProvider(Composer::getLockFilePath($current_dir)) + new ProjectCacheProvider(Composer::getLockFilePath($current_dir)), ); } @@ -285,7 +285,7 @@ public static function run(array $argv): void $stdout_report_options, [], $threads, - $progress + $progress, ); if (array_key_exists('debug-by-line', $options)) { @@ -329,7 +329,7 @@ public static function run(array $argv): void $allow_backwards_incompatible_changes = filter_var( $options['allow-backwards-incompatible-changes'], FILTER_VALIDATE_BOOLEAN, - ['flags' => FILTER_NULL_ON_FAILURE] + ['flags' => FILTER_NULL_ON_FAILURE], ); if ($allow_backwards_incompatible_changes === null) { @@ -344,7 +344,7 @@ public static function run(array $argv): void $doc_block_add_new_line_before_return = filter_var( $options['add-newline-between-docblock-annotations'], FILTER_VALIDATE_BOOLEAN, - ['flags' => FILTER_NULL_ON_FAILURE] + ['flags' => FILTER_NULL_ON_FAILURE], ); if ($doc_block_add_new_line_before_return === null) { @@ -389,7 +389,7 @@ public static function run(array $argv): void $project_analyzer->alterCodeAfterCompletion( array_key_exists('dry-run', $options), - array_key_exists('safe-types', $options) + array_key_exists('safe-types', $options), ); if ($keyed_issues === ['all' => true]) { @@ -465,13 +465,13 @@ static function (string $arg): void { fwrite( STDERR, 'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL - . 'Type --help to see a list of supported arguments'. PHP_EOL + . 'Type --help to see a list of supported arguments'. PHP_EOL, ); exit(1); } } }, - $args + $args, ); } @@ -531,8 +531,8 @@ static function (string $line): bool { // currently we don’t match wildcard files or files that could appear anywhere // in the repo return $line && $line[0] === '/' && strpos($line, '*') === false; - } - ) + }, + ), ); $codeowner_files = []; diff --git a/src/Psalm/Internal/Cli/Refactor.php b/src/Psalm/Internal/Cli/Refactor.php index 16a056a8152..0fca3ab46f2 100644 --- a/src/Psalm/Internal/Cli/Refactor.php +++ b/src/Psalm/Internal/Cli/Refactor.php @@ -103,13 +103,13 @@ static function (string $arg) use ($valid_long_options): void { fwrite( STDERR, 'Unrecognised argument "--' . $arg_name . '"' . PHP_EOL - . 'Type --help to see a list of supported arguments'. PHP_EOL + . 'Type --help to see a list of supported arguments'. PHP_EOL, ); exit(1); } } }, - $args + $args, ); if (array_key_exists('help', $options)) { @@ -284,7 +284,7 @@ static function (string $arg) use ($valid_long_options): void { $path_to_config, $current_dir, Report::TYPE_CONSOLE, - $first_autoloader + $first_autoloader, ); $config->setIncludeCollector($include_collector); @@ -303,7 +303,7 @@ static function (string $arg) use ($valid_long_options): void { new FileStorageCacheProvider($config), new ClassLikeStorageCacheProvider($config), null, - new ProjectCacheProvider(Composer::getLockFilePath($current_dir)) + new ProjectCacheProvider(Composer::getLockFilePath($current_dir)), ); $debug = array_key_exists('debug', $options) || array_key_exists('debug-by-line', $options); @@ -321,7 +321,7 @@ static function (string $arg) use ($valid_long_options): void { new ReportOptions(), [], $threads, - $progress + $progress, ); if (array_key_exists('debug-by-line', $options)) { diff --git a/src/Psalm/Internal/CliUtils.php b/src/Psalm/Internal/CliUtils.php index b1b5ad0542d..08cdc4c2b5f 100644 --- a/src/Psalm/Internal/CliUtils.php +++ b/src/Psalm/Internal/CliUtils.php @@ -149,13 +149,13 @@ public static function requireAutoloaders( } else { fwrite( STDERR, - 'Failed to find a valid Composer autoloader in ' . implode(', ', $autoload_files) . "\n" + 'Failed to find a valid Composer autoloader in ' . implode(', ', $autoload_files) . "\n", ); } fwrite( STDERR, - 'Please make sure you’ve run `composer install` in the current directory before using Psalm.' . "\n" + 'Please make sure you’ve run `composer install` in the current directory before using Psalm.' . "\n", ); exit(1); } @@ -181,7 +181,7 @@ public static function getVendorDir(string $current_dir): string } catch (JsonException $e) { fwrite( STDERR, - 'Invalid composer.json at ' . $composer_json_path . "\n" . $e->getMessage() . "\n" + 'Invalid composer.json at ' . $composer_json_path . "\n" . $e->getMessage() . "\n", ); exit(1); } @@ -189,7 +189,7 @@ public static function getVendorDir(string $current_dir): string if (!$composer_json) { fwrite( STDERR, - 'Invalid composer.json at ' . $composer_json_path . "\n" + 'Invalid composer.json at ' . $composer_json_path . "\n", ); exit(1); } @@ -357,7 +357,7 @@ public static function initializeConfig( fwrite( STDERR, 'Could not locate a config XML file in path ' . $current_dir - . '. Have you run \'psalm --init\' ?' . PHP_EOL + . '. Have you run \'psalm --init\' ?' . PHP_EOL, ); exit(1); } @@ -368,14 +368,14 @@ public static function initializeConfig( $config = Creator::createBareConfig( $current_dir, null, - self::getVendorDir($current_dir) + self::getVendorDir($current_dir), ); } } } catch (ConfigException $e) { fwrite( STDERR, - $e->getMessage() . PHP_EOL + $e->getMessage() . PHP_EOL, ); exit(1); } @@ -409,7 +409,7 @@ public static function updateConfigFile(Config $config, string $config_file_path $amended_config_file_contents = preg_replace( '/errorBaseline=".*?"/', "errorBaseline=\"{$baseline_path}\"", - $config_file_contents + $config_file_contents, ); } else { $end_psalm_open_tag = strpos($config_file_contents, '>', (int)strpos($config_file_contents, '", $end_psalm_open_tag, - 1 + 1, ); } else { $amended_config_file_contents = substr_replace( $config_file_contents, " errorBaseline=\"{$baseline_path}\">", $end_psalm_open_tag, - 1 + 1, ); } } @@ -562,7 +562,7 @@ public static function checkRuntimeRequirements(): void STDERR, 'Psalm has detected issues in your platform:' . PHP_EOL . PHP_EOL . implode(PHP_EOL, $issues) - . PHP_EOL . PHP_EOL + . PHP_EOL . PHP_EOL, ); exit(1); } diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php index beeaa80aa3c..7b2a8b97326 100644 --- a/src/Psalm/Internal/Codebase/Analyzer.php +++ b/src/Psalm/Internal/Codebase/Analyzer.php @@ -266,7 +266,7 @@ public function analyzeFiles( $this->files_to_analyze = array_filter( $this->files_to_analyze, - [$this->file_provider, 'fileExists'] + [$this->file_provider, 'fileExists'], ); $this->doAnalysis($project_analyzer, $pool_size); @@ -394,7 +394,7 @@ static function (): void { }, $analysis_worker, Closure::fromCallable([$this, 'getWorkerData']), - $task_done_closure + $task_done_closure, ); $this->progress->debug('Forking analysis' . "\n"); @@ -421,53 +421,53 @@ static function (): void { } $codebase->file_reference_provider->addNonMethodReferencesToClasses( - $pool_data['nonmethod_references_to_classes'] + $pool_data['nonmethod_references_to_classes'], ); $codebase->file_reference_provider->addMethodReferencesToClasses( - $pool_data['method_references_to_classes'] + $pool_data['method_references_to_classes'], ); $codebase->file_reference_provider->addFileReferencesToClassMembers( - $pool_data['file_references_to_class_members'] + $pool_data['file_references_to_class_members'], ); $codebase->file_reference_provider->addFileReferencesToClassProperties( - $pool_data['file_references_to_class_properties'] + $pool_data['file_references_to_class_properties'], ); $codebase->file_reference_provider->addFileReferencesToMethodReturns( - $pool_data['file_references_to_method_returns'] + $pool_data['file_references_to_method_returns'], ); $codebase->file_reference_provider->addMethodReferencesToClassMembers( - $pool_data['method_references_to_class_members'] + $pool_data['method_references_to_class_members'], ); $codebase->file_reference_provider->addMethodDependencies( - $pool_data['method_dependencies'] + $pool_data['method_dependencies'], ); $codebase->file_reference_provider->addMethodReferencesToClassProperties( - $pool_data['method_references_to_class_properties'] + $pool_data['method_references_to_class_properties'], ); $codebase->file_reference_provider->addMethodReferencesToMethodReturns( - $pool_data['method_references_to_method_returns'] + $pool_data['method_references_to_method_returns'], ); $codebase->file_reference_provider->addFileReferencesToMissingClassMembers( - $pool_data['file_references_to_missing_class_members'] + $pool_data['file_references_to_missing_class_members'], ); $codebase->file_reference_provider->addMethodReferencesToMissingClassMembers( - $pool_data['method_references_to_missing_class_members'] + $pool_data['method_references_to_missing_class_members'], ); $codebase->file_reference_provider->addMethodParamUses( - $pool_data['method_param_uses'] + $pool_data['method_param_uses'], ); $this->addMixedMemberNames( - $pool_data['mixed_member_names'] + $pool_data['mixed_member_names'], ); $this->function_timings += $pool_data['function_timings']; $codebase->file_reference_provider->addClassLocations( - $pool_data['class_locations'] + $pool_data['class_locations'], ); $codebase->file_reference_provider->addClassMethodLocations( - $pool_data['class_method_locations'] + $pool_data['class_method_locations'], ); $codebase->file_reference_provider->addClassPropertyLocations( - $pool_data['class_property_locations'] + $pool_data['class_property_locations'], ); $this->mutable_classes = array_merge($this->mutable_classes, $pool_data['mutable_classes']); @@ -494,7 +494,7 @@ static function (): void { = Type::combineUnionTypes( $this->possible_method_param_types[$declaring_method_id][$offset] ?? null, $possible_param_type, - $codebase + $codebase, ); } } @@ -631,7 +631,7 @@ public function loadCachedResults(ProjectAnalyzer $project_analyzer): void } else { try { $referencing_storage = $codebase->classlike_storage_provider->get( - $referencing_base_classlike + $referencing_base_classlike, ); } catch (InvalidArgumentException $_) { // Workaround for #3671 @@ -658,7 +658,7 @@ public function loadCachedResults(ProjectAnalyzer $project_analyzer): void if (isset($all_referencing_methods[$member_id])) { $newly_invalidated_methods = array_merge( $all_referencing_methods[$member_id], - $newly_invalidated_methods + $newly_invalidated_methods, ); } @@ -673,7 +673,7 @@ public function loadCachedResults(ProjectAnalyzer $project_analyzer): void $method_references_to_missing_class_members[$member_id], $file_references_to_missing_class_members[$member_id], $references_to_mixed_member_names[$member_id], - $method_param_uses[$member_id] + $method_param_uses[$member_id], ); $member_stub = preg_replace('/::.*$/', '::*', $member_id, 1); @@ -681,7 +681,7 @@ public function loadCachedResults(ProjectAnalyzer $project_analyzer): void if (isset($all_referencing_methods[$member_stub])) { $newly_invalidated_methods = array_merge( $all_referencing_methods[$member_stub], - $newly_invalidated_methods + $newly_invalidated_methods, ); } } @@ -789,107 +789,107 @@ public function loadCachedResults(ProjectAnalyzer $project_analyzer): void } $method_references_to_class_members = array_filter( - $method_references_to_class_members + $method_references_to_class_members, ); $method_dependencies = array_filter( - $method_dependencies + $method_dependencies, ); $method_references_to_class_properties = array_filter( - $method_references_to_class_properties + $method_references_to_class_properties, ); $method_references_to_method_returns = array_filter( - $method_references_to_method_returns + $method_references_to_method_returns, ); $method_references_to_missing_class_members = array_filter( - $method_references_to_missing_class_members + $method_references_to_missing_class_members, ); $file_references_to_class_members = array_filter( - $file_references_to_class_members + $file_references_to_class_members, ); $file_references_to_class_properties = array_filter( - $file_references_to_class_properties + $file_references_to_class_properties, ); $file_references_to_method_returns = array_filter( - $file_references_to_method_returns + $file_references_to_method_returns, ); $file_references_to_missing_class_members = array_filter( - $file_references_to_missing_class_members + $file_references_to_missing_class_members, ); $references_to_mixed_member_names = array_filter( - $references_to_mixed_member_names + $references_to_mixed_member_names, ); $nonmethod_references_to_classes = array_filter( - $nonmethod_references_to_classes + $nonmethod_references_to_classes, ); $method_references_to_classes = array_filter( - $method_references_to_classes + $method_references_to_classes, ); $method_param_uses = array_filter( - $method_param_uses + $method_param_uses, ); $file_reference_provider->setCallingMethodReferencesToClassMembers( - $method_references_to_class_members + $method_references_to_class_members, ); $file_reference_provider->setMethodDependencies( - $method_dependencies + $method_dependencies, ); $file_reference_provider->setCallingMethodReferencesToClassProperties( - $method_references_to_class_properties + $method_references_to_class_properties, ); $file_reference_provider->setCallingMethodReferencesToMethodReturns( - $method_references_to_method_returns + $method_references_to_method_returns, ); $file_reference_provider->setFileReferencesToClassMembers( - $file_references_to_class_members + $file_references_to_class_members, ); $file_reference_provider->setFileReferencesToClassProperties( - $file_references_to_class_properties + $file_references_to_class_properties, ); $file_reference_provider->setFileReferencesToMethodReturns( - $file_references_to_method_returns + $file_references_to_method_returns, ); $file_reference_provider->setCallingMethodReferencesToMissingClassMembers( - $method_references_to_missing_class_members + $method_references_to_missing_class_members, ); $file_reference_provider->setFileReferencesToMissingClassMembers( - $file_references_to_missing_class_members + $file_references_to_missing_class_members, ); $file_reference_provider->setReferencesToMixedMemberNames( - $references_to_mixed_member_names + $references_to_mixed_member_names, ); $file_reference_provider->setCallingMethodReferencesToClasses( - $method_references_to_classes + $method_references_to_classes, ); $file_reference_provider->setNonMethodReferencesToClasses( - $nonmethod_references_to_classes + $nonmethod_references_to_classes, ); $file_reference_provider->setMethodParamUses( - $method_param_uses + $method_param_uses, ); } @@ -1076,7 +1076,7 @@ public function addMixedMemberNames(array $names): void if (isset($this->mixed_member_names[$key])) { $this->mixed_member_names[$key] = array_merge( $this->mixed_member_names[$key], - $name + $name, ); } else { $this->mixed_member_names[$key] = $name; @@ -1342,17 +1342,17 @@ public function updateFile(string $file_path, bool $dry_run): void { FileManipulationBuffer::add( $file_path, - FunctionDocblockManipulator::getManipulationsForFile($file_path) + FunctionDocblockManipulator::getManipulationsForFile($file_path), ); FileManipulationBuffer::add( $file_path, - PropertyDocblockManipulator::getManipulationsForFile($file_path) + PropertyDocblockManipulator::getManipulationsForFile($file_path), ); FileManipulationBuffer::add( $file_path, - ClassDocblockManipulator::getManipulationsForFile($file_path) + ClassDocblockManipulator::getManipulationsForFile($file_path), ); $file_manipulations = FileManipulationBuffer::getManipulationsForFile($file_path); @@ -1373,7 +1373,7 @@ static function (FileManipulation $a, FileManipulation $b): int { } return $b->end > $a->end ? 1 : -1; - } + }, ); $last_start = PHP_INT_MAX; @@ -1393,7 +1393,7 @@ static function (FileManipulation $a, FileManipulation $b): int { new StrictUnifiedDiffOutputBuilder([ 'fromFile' => $file_path, 'toFile' => $file_path, - ]) + ]), ); echo $differ->diff($this->file_provider->getContents($file_path), $existing_contents); @@ -1573,7 +1573,7 @@ private function analysisWorker(int $_, string $file_path): array $file_analyzer = $this->getFileAnalyzer( ProjectAnalyzer::getInstance(), $file_path, - $this->config->getFiletypeAnalyzers() + $this->config->getFiletypeAnalyzers(), ); $this->progress->debug('Analyzing ' . $file_analyzer->getFilePath() . "\n"); diff --git a/src/Psalm/Internal/Codebase/ClassLikes.php b/src/Psalm/Internal/Codebase/ClassLikes.php index 3bd1441471b..6e6508d1ffc 100644 --- a/src/Psalm/Internal/Codebase/ClassLikes.php +++ b/src/Psalm/Internal/Codebase/ClassLikes.php @@ -332,12 +332,12 @@ public function hasFullyQualifiedClassName( if ($calling_method_id) { $this->file_reference_provider->addMethodReferenceToClass( $calling_method_id, - $fq_class_name_lc + $fq_class_name_lc, ); } elseif (!$calling_fq_class_name || strtolower($calling_fq_class_name) !== $fq_class_name_lc) { $this->file_reference_provider->addNonMethodReferenceToClass( $code_location->file_path, - $fq_class_name_lc + $fq_class_name_lc, ); if ($calling_fq_class_name) { @@ -348,7 +348,7 @@ public function hasFullyQualifiedClassName( ) { $this->file_reference_provider->addNonMethodReferenceToClass( $class_storage->location->file_path, - $fq_class_name_lc + $fq_class_name_lc, ); } } @@ -380,7 +380,7 @@ public function hasFullyQualifiedClassName( if ($this->collect_locations && $code_location) { $this->file_reference_provider->addCallingLocationForClass( $code_location, - strtolower($fq_class_name) + strtolower($fq_class_name), ); } @@ -421,12 +421,12 @@ public function hasFullyQualifiedInterfaceName( if ($calling_method_id) { $this->file_reference_provider->addMethodReferenceToClass( $calling_method_id, - $fq_class_name_lc + $fq_class_name_lc, ); } else { $this->file_reference_provider->addNonMethodReferenceToClass( $code_location->file_path, - $fq_class_name_lc + $fq_class_name_lc, ); if ($calling_fq_class_name) { @@ -437,7 +437,7 @@ public function hasFullyQualifiedInterfaceName( ) { $this->file_reference_provider->addNonMethodReferenceToClass( $class_storage->location->file_path, - $fq_class_name_lc + $fq_class_name_lc, ); } } @@ -447,7 +447,7 @@ public function hasFullyQualifiedInterfaceName( if ($this->collect_locations && $code_location) { $this->file_reference_provider->addCallingLocationForClass( $code_location, - strtolower($fq_class_name) + strtolower($fq_class_name), ); } @@ -488,12 +488,12 @@ public function hasFullyQualifiedEnumName( if ($calling_method_id) { $this->file_reference_provider->addMethodReferenceToClass( $calling_method_id, - $fq_class_name_lc + $fq_class_name_lc, ); } else { $this->file_reference_provider->addNonMethodReferenceToClass( $code_location->file_path, - $fq_class_name_lc + $fq_class_name_lc, ); if ($calling_fq_class_name) { @@ -504,7 +504,7 @@ public function hasFullyQualifiedEnumName( ) { $this->file_reference_provider->addNonMethodReferenceToClass( $class_storage->location->file_path, - $fq_class_name_lc + $fq_class_name_lc, ); } } @@ -514,7 +514,7 @@ public function hasFullyQualifiedEnumName( if ($this->collect_locations && $code_location) { $this->file_reference_provider->addCallingLocationForClass( $code_location, - strtolower($fq_class_name) + strtolower($fq_class_name), ); } @@ -534,7 +534,7 @@ public function hasFullyQualifiedTraitName(string $fq_class_name, ?CodeLocation if ($this->collect_references && $code_location) { $this->file_reference_provider->addNonMethodReferenceToClass( $code_location->file_path, - $fq_class_name_lc + $fq_class_name_lc, ); } @@ -589,7 +589,7 @@ public function classExists( $fq_class_name, $code_location, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); } @@ -657,7 +657,7 @@ public function classImplements(string $fq_class_name, string $interface): bool foreach ($class_storage->class_implements as $implementing_interface_lc => $_) { $aliased_interface_lc = strtolower( - $this->getUnAliasedName($implementing_interface_lc) + $this->getUnAliasedName($implementing_interface_lc), ); if ($aliased_interface_lc === $interface_id) { @@ -682,7 +682,7 @@ public function interfaceExists( $fq_interface_name, $code_location, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); } @@ -700,7 +700,7 @@ public function enumExists( $fq_enum_name, $code_location, $calling_fq_class_name, - $calling_method_id + $calling_method_id, ); } @@ -783,14 +783,14 @@ public function getTraitNode(string $fq_trait_name): PhpParser\Node\Stmt\Trait_ $file_statements = $this->statements_provider->getStatementsForFile( $storage->location->file_path, - ProjectAnalyzer::getInstance()->getCodebase()->analysis_php_version_id + ProjectAnalyzer::getInstance()->getCodebase()->analysis_php_version_id, ); $trait_finder = new TraitFinder($fq_trait_name); $traverser = new NodeTraverser(); $traverser->addVisitor( - $trait_finder + $trait_finder, ); $traverser->traverse($file_statements); @@ -856,9 +856,9 @@ public function consolidateAnalyzedData(Methods $methods, ?Progress $progress, b new UnusedClass( 'Class ' . $classlike_storage->name . ' is never used', $classlike_storage->location, - $classlike_storage->name + $classlike_storage->name, ), - $classlike_storage->suppressed_issues + $classlike_storage->suppressed_issues, ); } else { $this->checkMethodReferences($classlike_storage, $methods); @@ -876,7 +876,7 @@ public function consolidateAnalyzedData(Methods $methods, ?Progress $progress, b && isset($classlike_storage->methods['__construct']) ) { $stmts = $codebase->getStatementsForFile( - $classlike_storage->location->file_path + $classlike_storage->location->file_path, ); foreach ($stmts as $stmt) { @@ -889,7 +889,7 @@ public function consolidateAnalyzedData(Methods $methods, ?Progress $progress, b self::makeImmutable( $namespace_stmt, $project_analyzer, - $classlike_storage->location->file_path + $classlike_storage->location->file_path, ); } } @@ -899,7 +899,7 @@ public function consolidateAnalyzedData(Methods $methods, ?Progress $progress, b self::makeImmutable( $stmt, $project_analyzer, - $classlike_storage->location->file_path + $classlike_storage->location->file_path, ); } } @@ -916,7 +916,7 @@ public static function makeImmutable( $manipulator = ClassDocblockManipulator::getForClass( $project_analyzer, $file_path, - $class_stmt + $class_stmt, ); $manipulator->makeImmutable(); @@ -944,7 +944,7 @@ public function moveMethods(Methods $methods, ?Progress $progress = null): void try { $source_method_storage = $methods->getStorage( - new MethodIdentifier(...$source_parts) + new MethodIdentifier(...$source_parts), ); } catch (InvalidArgumentException $e) { continue; @@ -975,9 +975,9 @@ public function moveMethods(Methods $methods, ?Progress $progress = null): void new FileManipulation( $old_method_name_bounds[0], $old_method_name_bounds[1], - $destination_name + $destination_name, ), - ] + ], ); $selection = $classlike_storage->stmt_location->getSnippet(); @@ -995,7 +995,7 @@ public function moveMethods(Methods $methods, ?Progress $progress = null): void $old_method_bounds[0], $old_method_bounds[1], $classlike_storage->stmt_location->file_path, - $new_class_bounds[0] + $insert_pos + $new_class_bounds[0] + $insert_pos, ); } } @@ -1050,7 +1050,7 @@ public function moveProperties(Properties $properties, ?Progress $progress = nul $source_property_storage->type, $source_classlike_storage->name, $source_classlike_storage->name, - $source_classlike_storage->parent_class + $source_classlike_storage->parent_class, ); $this->airliftClassDefinedDocblockType( @@ -1058,7 +1058,7 @@ public function moveProperties(Properties $properties, ?Progress $progress = nul $destination_fq_class_name, $source_property_storage->stmt_location->file_path, $bounds[0], - $bounds[1] + $bounds[1], ); } @@ -1073,9 +1073,9 @@ public function moveProperties(Properties $properties, ?Progress $progress = nul new FileManipulation( $old_property_name_bounds[0], $old_property_name_bounds[1], - '$' . $destination_name + '$' . $destination_name, ), - ] + ], ); $selection = $destination_classlike_storage->stmt_location->getSnippet(); @@ -1093,7 +1093,7 @@ public function moveProperties(Properties $properties, ?Progress $progress = nul $old_property_bounds[0], $old_property_bounds[1], $destination_classlike_storage->stmt_location->file_path, - $new_class_bounds[0] + $insert_pos + $new_class_bounds[0] + $insert_pos, ); } } @@ -1149,9 +1149,9 @@ public function moveClassConstants(?Progress $progress = null): void new FileManipulation( $old_const_name_bounds[0], $old_const_name_bounds[1], - $destination_name + $destination_name, ), - ] + ], ); $selection = $destination_classlike_storage->stmt_location->getSnippet(); @@ -1169,7 +1169,7 @@ public function moveClassConstants(?Progress $progress = null): void $old_const_bounds[0], $old_const_bounds[1], $destination_classlike_storage->stmt_location->file_path, - $new_class_bounds[0] + $insert_pos + $new_class_bounds[0] + $insert_pos, ); } } @@ -1214,7 +1214,7 @@ public function handleClassLikeReferenceInMigration( (int) $class_name_node->getAttribute('startFilePos'), (int) $class_name_node->getAttribute('endFilePos') + 1, $class_name_node instanceof PhpParser\Node\Scalar\MagicConst\Class_, - $was_self + $was_self, ); return true; @@ -1233,7 +1233,7 @@ public function handleClassLikeReferenceInMigration( $file_manipulations[] = new FileManipulation( (int) $class_name_node->getAttribute('startFilePos'), (int) $class_name_node->getAttribute('endFilePos') + 1, - $destination_class_name + $destination_class_name, ); FileManipulationBuffer::add($source->getFilePath(), $file_manipulations); @@ -1283,9 +1283,9 @@ public function handleClassLikeReferenceInMigration( $source_namespace, $uses_flipped, $migrated_source_fqcln, - $was_self + $was_self, ) - . ($class_name_node instanceof PhpParser\Node\Scalar\MagicConst\Class_ ? '::class' : '') + . ($class_name_node instanceof PhpParser\Node\Scalar\MagicConst\Class_ ? '::class' : ''), ); FileManipulationBuffer::add($source->getFilePath(), $file_manipulations); @@ -1309,7 +1309,7 @@ public function handleClassLikeReferenceInMigration( $file_manipulations[] = new FileManipulation( (int) $class_name_node->getAttribute('startFilePos'), (int) $class_name_node->getAttribute('endFilePos') + 1, - $destination_class_name + $destination_class_name, ); FileManipulationBuffer::add($source->getFilePath(), $file_manipulations); @@ -1322,7 +1322,7 @@ public function handleClassLikeReferenceInMigration( $source->getFilePath(), (int) $class_name_node->getAttribute('startFilePos'), (int) $class_name_node->getAttribute('endFilePos') + 1, - $class_name_node instanceof PhpParser\Node\Scalar\MagicConst\Class_ + $class_name_node instanceof PhpParser\Node\Scalar\MagicConst\Class_, ); } @@ -1336,7 +1336,7 @@ public function handleClassLikeReferenceInMigration( $calling_fq_class_name, $source->getFilePath(), (int) $class_name_node->getAttribute('startFilePos'), - (int) $class_name_node->getAttribute('endFilePos') + 1 + (int) $class_name_node->getAttribute('endFilePos') + 1, ); } else { $file_manipulations = []; @@ -1348,8 +1348,8 @@ public function handleClassLikeReferenceInMigration( $fq_class_name, $source->getNamespace(), $source->getAliasedClassesFlipped(), - null - ) + null, + ), ); FileManipulationBuffer::add($source->getFilePath(), $file_manipulations); @@ -1391,7 +1391,7 @@ public function handleDocblockTypeInMigration( $destination_class, $source->getFilePath(), $bounds[0], - $bounds[1] + $bounds[1], ); $moved_type = true; @@ -1437,7 +1437,7 @@ public function handleDocblockTypeInMigration( if ($type->containsClassLike($old_fq_class_name)) { $type = $type->replaceClassLike( $old_fq_class_name, - $new_fq_class_name + $new_fq_class_name, ); $bounds = $type_location->getSelectionBounds(); @@ -1451,13 +1451,13 @@ public function handleDocblockTypeInMigration( $source_namespace, $uses_flipped, $migrated_source_fqcln, - false - ) + false, + ), ); FileManipulationBuffer::add( $source->getFilePath(), - $file_manipulations + $file_manipulations, ); $moved_type = true; @@ -1478,7 +1478,7 @@ public function handleDocblockTypeInMigration( if ($type->containsClassLike($fq_class_name_lc)) { $type = $type->replaceClassLike( $fq_class_name_lc, - $destination_class + $destination_class, ); } @@ -1487,7 +1487,7 @@ public function handleDocblockTypeInMigration( $destination_class, $source->getFilePath(), $bounds[0], - $bounds[1] + $bounds[1], ); } } @@ -1520,13 +1520,13 @@ public function airliftClassLikeReference( $destination_class_storage->aliases->namespace, $destination_class_storage->aliases->uses_flipped, $destination_class_storage->name, - $allow_self - ) . ($add_class_constant ? '::class' : '') + $allow_self, + ) . ($add_class_constant ? '::class' : ''), ); FileManipulationBuffer::add( $source_file_path, - $file_manipulations + $file_manipulations, ); } @@ -1555,13 +1555,13 @@ public function airliftClassDefinedDocblockType( $destination_class_storage->aliases->namespace, $destination_class_storage->aliases->uses_flipped, $destination_class_storage->name, - false - ) + false, + ), ); FileManipulationBuffer::add( $source_file_path, - $file_manipulations + $file_manipulations, ); } @@ -1580,7 +1580,7 @@ public function getConstantsForClass(string $class_name, int $visibility): array return array_filter( $storage->constants, static fn(ClassConstantStorage $constant): bool => $constant->type - && $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC + && $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC, ); } @@ -1595,7 +1595,7 @@ public function getConstantsForClass(string $class_name, int $visibility): array return array_filter( $storage->constants, - static fn(ClassConstantStorage $constant): bool => $constant->type !== null + static fn(ClassConstantStorage $constant): bool => $constant->type !== null, ); } @@ -1641,7 +1641,7 @@ public function getClassConstantType( $this, $constant_storage->unresolved_node, $statements_analyzer, - $visited_constant_ids + $visited_constant_ids, )]); if ($constant_storage->type === null || !$constant_storage->type->from_docblock) { /** @psalm-suppress InaccessibleProperty Lazy resolution */ @@ -1698,7 +1698,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth } $method_referenced = $this->file_reference_provider->isClassMethodReferenced( - strtolower((string) $method_id) + strtolower((string) $method_id), ); if (!$method_referenced @@ -1746,7 +1746,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth } $parent_method_referenced = $this->file_reference_provider->isClassMethodReferenced( - strtolower((string) $parent_method_id) + strtolower((string) $parent_method_id), ); if (!$parent_method_storage->abstract || $parent_method_referenced) { @@ -1758,7 +1758,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth foreach ($classlike_storage->parent_classes as $parent_method_fqcln) { if ($codebase->analyzer->hasMixedMemberName( - strtolower($parent_method_fqcln) . '::' + strtolower($parent_method_fqcln) . '::', )) { $has_variable_calls = true; break; @@ -1773,14 +1773,14 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth } if ($codebase->analyzer->hasMixedMemberName( - $fq_interface_name_lc . '::' + $fq_interface_name_lc . '::', )) { $has_variable_calls = true; } if (isset($interface_storage->methods[$method_name])) { $interface_method_referenced = $this->file_reference_provider->isClassMethodReferenced( - $fq_interface_name_lc . '::' . $method_name + $fq_interface_name_lc . '::' . $method_name, ); if ($interface_method_referenced) { @@ -1795,7 +1795,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth . ' calls to method ' . $method_id . ($has_variable_calls ? ' (but did find some potential callers)' : ''), $method_storage->location, - $method_id + $method_id, ); if ($codebase->alter_code) { @@ -1808,7 +1808,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth FileManipulationBuffer::addForCodeLocation( $method_storage->stmt_location, '', - true + true, ); } } else { @@ -1817,13 +1817,13 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth $method_storage->suppressed_issues, $method_storage->stmt_location && !$declaring_classlike_storage->is_trait - && !$has_variable_calls + && !$has_variable_calls, ); } } } elseif (!isset($classlike_storage->declaring_method_ids['__call'])) { $has_variable_calls = $codebase->analyzer->hasMixedMemberName( - strtolower($classlike_storage->name . '::') + strtolower($classlike_storage->name . '::'), ) || $codebase->analyzer->hasMixedMemberName($method_name); if ($method_name === '__construct') { @@ -1832,7 +1832,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth . ' calls to private constructor ' . $method_id . ($has_variable_calls ? ' (but did find some potential callers)' : ''), $method_location, - $method_id + $method_id, ); } else { $issue = new UnusedMethod( @@ -1840,7 +1840,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth . ' calls to private method ' . $method_id . ($has_variable_calls ? ' (but did find some potential callers)' : ''), $method_location, - $method_id + $method_id, ); } @@ -1854,7 +1854,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth FileManipulationBuffer::addForCodeLocation( $method_storage->stmt_location, '', - true + true, ); } } else { @@ -1863,7 +1863,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth $method_storage->suppressed_issues, $method_storage->stmt_location && !$declaring_classlike_storage->is_trait - && !$has_variable_calls + && !$has_variable_calls, ); } } @@ -1877,7 +1877,7 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth && ($method_storage->is_static || !$method_storage->probably_fluent) ) { $method_return_referenced = $this->file_reference_provider->isMethodReturnReferenced( - strtolower((string) $method_id) + strtolower((string) $method_id), ); if (!$method_return_referenced) { @@ -1885,17 +1885,17 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth IssueBuffer::maybeAdd( new UnusedReturnValue( 'The return value for this private method is never used', - $method_storage->return_type_location + $method_storage->return_type_location, ), - $method_storage->suppressed_issues + $method_storage->suppressed_issues, ); } else { IssueBuffer::maybeAdd( new PossiblyUnusedReturnValue( 'The return value for this method is never used', - $method_storage->return_type_location + $method_storage->return_type_location, ), - $method_storage->suppressed_issues + $method_storage->suppressed_issues, ); } } @@ -1910,24 +1910,24 @@ private function checkMethodReferences(ClassLikeStorage $classlike_storage, Meth && !$param_storage->promoted_property && !$this->file_reference_provider->isMethodParamUsed( strtolower((string) $method_id), - $offset + $offset, ) ) { if ($method_storage->final) { IssueBuffer::maybeAdd( new UnusedParam( 'Param #' . ($offset + 1) . ' is never referenced in this method', - $param_storage->location + $param_storage->location, ), - $method_storage->suppressed_issues + $method_storage->suppressed_issues, ); } else { IssueBuffer::maybeAdd( new PossiblyUnusedParam( 'Param #' . ($offset + 1) . ' is never referenced in this method', - $param_storage->location + $param_storage->location, ), - $method_storage->suppressed_issues + $method_storage->suppressed_issues, ); } } @@ -2008,7 +2008,7 @@ private function findPossibleMethodParamTypes(ClassLikeStorage $classlike_storag $default_type_atomic = ConstantTypeResolver::resolve( $codebase->classlikes, $method_storage->params[$offset]->default_type, - null + null, ); $default_type = new Union([$default_type_atomic]); @@ -2016,7 +2016,7 @@ private function findPossibleMethodParamTypes(ClassLikeStorage $classlike_storag $possible_type = Type::combineUnionTypes( $possible_type, - $default_type + $default_type, ); } @@ -2025,14 +2025,14 @@ private function findPossibleMethodParamTypes(ClassLikeStorage $classlike_storag ) { $function_analyzer = $project_analyzer->getFunctionLikeAnalyzer( $method_id, - $method_storage->location->file_path + $method_storage->location->file_path, ); $has_variable_calls = $codebase->analyzer->hasMixedMemberName( - $method_name + $method_name, ) || $codebase->analyzer->hasMixedMemberName( - strtolower($classlike_storage->name . '::') + strtolower($classlike_storage->name . '::'), ); if ($has_variable_calls) { @@ -2045,7 +2045,7 @@ private function findPossibleMethodParamTypes(ClassLikeStorage $classlike_storag $param_name, $possible_type, $possible_type->from_docblock - && $project_analyzer->only_replace_php_types_with_non_docblock_types + && $project_analyzer->only_replace_php_types_with_non_docblock_types, ); } } else { @@ -2066,7 +2066,7 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v foreach ($classlike_storage->properties as $property_name => $property_storage) { $referenced_property_name = strtolower($classlike_storage->name) . '::$' . $property_name; $property_referenced = $this->file_reference_provider->isClassPropertyReferenced( - $referenced_property_name + $referenced_property_name, ); $property_constructor_referenced = false; @@ -2098,7 +2098,7 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v foreach ($classlike_storage->parent_classes as $parent_method_fqcln) { if ($codebase->analyzer->hasMixedMemberName( - strtolower($parent_method_fqcln) . '::$' + strtolower($parent_method_fqcln) . '::$', )) { $has_variable_calls = true; break; @@ -2107,7 +2107,7 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v foreach ($classlike_storage->class_implements as $fq_interface_name) { if ($codebase->analyzer->hasMixedMemberName( - strtolower($fq_interface_name) . '::$' + strtolower($fq_interface_name) . '::$', )) { $has_variable_calls = true; break; @@ -2123,7 +2123,7 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v . ' references to property ' . $property_id . ($has_variable_calls ? ' (but did find some potential references)' : ''), $property_storage->location, - $property_id + $property_id, ); if ($codebase->alter_code) { @@ -2135,13 +2135,13 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v FileManipulationBuffer::addForCodeLocation( $property_storage->stmt_location, '', - true + true, ); } } else { IssueBuffer::maybeAdd( $issue, - $classlike_storage->suppressed_issues + $property_storage->suppressed_issues + $classlike_storage->suppressed_issues + $property_storage->suppressed_issues, ); } } @@ -2153,7 +2153,7 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v . ' references to private property ' . $property_id . ($has_variable_calls ? ' (but did find some potential references)' : ''), $property_storage->location, - $property_id + $property_id, ); if ($codebase->alter_code) { @@ -2166,13 +2166,13 @@ private function checkPropertyReferences(ClassLikeStorage $classlike_storage): v FileManipulationBuffer::addForCodeLocation( $property_storage->stmt_location, '', - true + true, ); } } else { IssueBuffer::maybeAdd( $issue, - $classlike_storage->suppressed_issues + $property_storage->suppressed_issues + $classlike_storage->suppressed_issues + $property_storage->suppressed_issues, ); } } @@ -2225,7 +2225,7 @@ public function removeClassLike(string $fq_class_name): void $this->existing_interfaces[$fq_class_name], $this->existing_classes_lc[$fq_class_name_lc], $this->existing_classes[$fq_class_name], - $this->trait_nodes[$fq_class_name_lc] + $this->trait_nodes[$fq_class_name_lc], ); $this->scanner->removeClassLike($fq_class_name_lc); @@ -2283,7 +2283,7 @@ public function addThreadData(array $thread_data): void $existing_enums, $existing_interfaces_lc, $existing_interfaces, - $existing_classes + $existing_classes, ] = $thread_data; $this->existing_classlikes_lc = array_merge($existing_classlikes_lc, $this->existing_classlikes_lc); diff --git a/src/Psalm/Internal/Codebase/ConstantTypeResolver.php b/src/Psalm/Internal/Codebase/ConstantTypeResolver.php index 521817c3c06..a67ed0ff5d0 100644 --- a/src/Psalm/Internal/Codebase/ConstantTypeResolver.php +++ b/src/Psalm/Internal/Codebase/ConstantTypeResolver.php @@ -73,13 +73,13 @@ public static function resolve( $classlikes, $c->left, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); $right = self::resolve( $classlikes, $c->right, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); if ($left instanceof TMixed || $right instanceof TMixed) { @@ -141,7 +141,7 @@ public static function resolve( if ($left instanceof TKeyedArray && $right instanceof TKeyedArray) { $type = new TKeyedArray( $left->properties + $right->properties, - null + null, ); return $type; } @@ -157,19 +157,19 @@ public static function resolve( $classlikes, $c->cond, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); $if = $c->if ? self::resolve( $classlikes, $c->if, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ) : null; $else = self::resolve( $classlikes, $c->else, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); if ($cond instanceof TLiteralFloat @@ -202,7 +202,7 @@ public static function resolve( $classlikes, $entry->array, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); if ($spread_array instanceof TArray && $spread_array->isEmptyArray()) { @@ -224,7 +224,7 @@ public static function resolve( $classlikes, $entry->key, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); if (!$key_type instanceof TLiteralInt @@ -253,7 +253,7 @@ public static function resolve( $classlikes, $entry->value, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], )]); $properties[$key_value] = $value_type; @@ -281,7 +281,7 @@ public static function resolve( $c->name, ReflectionProperty::IS_PRIVATE, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); if ($found_type) { @@ -294,14 +294,14 @@ public static function resolve( $classlikes, $c->array, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); $offset_type = self::resolve( $classlikes, $c->offset, $statements_analyzer, - $visited_constant_ids + [$c_id => true] + $visited_constant_ids + [$c_id => true], ); if ($var_type instanceof TKeyedArray @@ -322,7 +322,7 @@ public static function resolve( $statements_analyzer, $c->name, $c->is_fully_qualified, - null + null, ); if ($found_type) { diff --git a/src/Psalm/Internal/Codebase/Functions.php b/src/Psalm/Internal/Codebase/Functions.php index 320540013d9..7435756a93c 100644 --- a/src/Psalm/Internal/Codebase/Functions.php +++ b/src/Psalm/Internal/Codebase/Functions.php @@ -118,7 +118,7 @@ public function getStorage( } throw new UnexpectedValueException( - 'Expecting non-empty $root_file_path and $checked_file_path' + 'Expecting non-empty $root_file_path and $checked_file_path', ); } @@ -140,7 +140,7 @@ public function getStorage( } throw new UnexpectedValueException( - 'Expecting ' . $function_id . ' to have storage in ' . $checked_file_path + 'Expecting ' . $function_id . ' to have storage in ' . $checked_file_path, ); } @@ -154,7 +154,7 @@ public function getStorage( } throw new UnexpectedValueException( - 'Not expecting ' . $function_id . ' to not have storage in ' . $declaring_file_path + 'Not expecting ' . $function_id . ' to not have storage in ' . $declaring_file_path, ); } @@ -519,7 +519,7 @@ public function isCallMapFunctionPure( 'hash_update', 'hash_update_file', 'hash_update_stream', // unserialize - 'unserialize' + 'unserialize', ]; if (in_array(strtolower($function_id), $impure_functions, true)) { @@ -563,7 +563,7 @@ public function isCallMapFunctionPure( if ($atomic_count_type instanceof TNamedObject) { $count_method_id = new MethodIdentifier( $atomic_count_type->value, - 'count' + 'count', ); try { @@ -580,7 +580,7 @@ public function isCallMapFunctionPure( $codebase, $function_id, $args ?: [], - null + null, ); if (!$function_callable->params @@ -601,7 +601,7 @@ public function isCallMapFunctionPure( foreach ($arg_type->getAtomicTypes() as $possible_callable) { $possible_callable = CallableTypeComparator::getCallableFromAtomic( $codebase, - $possible_callable + $possible_callable, ); if ($possible_callable && !$possible_callable->is_pure) { diff --git a/src/Psalm/Internal/Codebase/InternalCallMapHandler.php b/src/Psalm/Internal/Codebase/InternalCallMapHandler.php index 64ad62709e4..f25840dc199 100644 --- a/src/Psalm/Internal/Codebase/InternalCallMapHandler.php +++ b/src/Psalm/Internal/Codebase/InternalCallMapHandler.php @@ -70,7 +70,7 @@ public static function getCallableFromCallMapById( if ($possible_callables === null) { throw new UnexpectedValueException( - 'Not expecting $function_param_options to be null for ' . $method_id + 'Not expecting $function_param_options to be null for ' . $method_id, ); } @@ -79,7 +79,7 @@ public static function getCallableFromCallMapById( $possible_callables, $args, $nodes, - $method_id + $method_id, ); } @@ -177,7 +177,7 @@ public static function getMatchingCallableFromCallMapOptions( $param_type, true, true, - $arg_result + $arg_result, ) || $arg_result->type_coerced) { if ($arg_result->type_coerced) { $type_coerced = true; @@ -299,7 +299,7 @@ public static function getCallablesFromCallMap(string $function_id): ?array null, $optional, false, - $variadic + $variadic, ); if ($out_type) { diff --git a/src/Psalm/Internal/Codebase/Methods.php b/src/Psalm/Internal/Codebase/Methods.php index 940edc9c472..773cb94ff0a 100644 --- a/src/Psalm/Internal/Codebase/Methods.php +++ b/src/Psalm/Internal/Codebase/Methods.php @@ -106,7 +106,7 @@ public function methodExists( $fq_class_name, $method_name, $source, - $code_location + $code_location, ); if ($method_exists !== null) { @@ -157,12 +157,12 @@ public function methodExists( if ($calling_method_id) { $this->file_reference_provider->addMethodReferenceToClass( $calling_method_id, - $declaring_fq_class_name + $declaring_fq_class_name, ); } elseif ($source_file_path) { $this->file_reference_provider->addNonMethodReferenceToClass( $source_file_path, - $declaring_fq_class_name + $declaring_fq_class_name, ); } } @@ -176,13 +176,13 @@ public function methodExists( $this->file_reference_provider->addMethodReferenceToClassMember( $calling_method_id, $potential_id, - $is_used + $is_used, ); } elseif ($source_file_path) { $this->file_reference_provider->addFileReferenceToClassMember( $source_file_path, $potential_id, - $is_used + $is_used, ); } } @@ -191,13 +191,13 @@ public function methodExists( $this->file_reference_provider->addMethodReferenceToClassMember( $calling_method_id, strtolower((string) $declaring_method_id), - $is_used + $is_used, ); } elseif ($source_file_path) { $this->file_reference_provider->addFileReferenceToClassMember( $source_file_path, strtolower((string) $declaring_method_id), - $is_used + $is_used, ); } } @@ -205,7 +205,7 @@ public function methodExists( if ($this->collect_locations && $code_location) { $this->file_reference_provider->addCallingLocationForClassMethod( $code_location, - strtolower((string) $declaring_method_id) + strtolower((string) $declaring_method_id), ); } @@ -215,7 +215,7 @@ public function methodExists( if ($this->collect_locations && $code_location) { $this->file_reference_provider->addCallingLocationForClassMethod( $code_location, - $interface_method_id_lc + $interface_method_id_lc, ); } @@ -223,13 +223,13 @@ public function methodExists( $this->file_reference_provider->addMethodReferenceToClassMember( $calling_method_id, $interface_method_id_lc, - $is_used + $is_used, ); } elseif ($source_file_path) { $this->file_reference_provider->addFileReferenceToClassMember( $source_file_path, $interface_method_id_lc, - $is_used + $is_used, ); } } @@ -246,7 +246,7 @@ public function methodExists( if ($this->collect_locations && $code_location) { $this->file_reference_provider->addCallingLocationForClassMethod( $code_location, - strtolower((string) $overridden_method_id) + strtolower((string) $overridden_method_id), ); } @@ -255,13 +255,13 @@ public function methodExists( $this->file_reference_provider->addMethodReferenceToClassMember( $calling_method_id, strtolower((string) $overridden_method_id), - $is_used + $is_used, ); } elseif ($source_file_path) { $this->file_reference_provider->addFileReferenceToClassMember( $source_file_path, strtolower((string) $overridden_method_id), - $is_used + $is_used, ); } } @@ -274,12 +274,12 @@ public function methodExists( if ($calling_method_id) { $this->file_reference_provider->addMethodReferenceToClass( $calling_method_id, - $fq_class_name + $fq_class_name, ); } else { $this->file_reference_provider->addNonMethodReferenceToClass( $source_file_path, - $fq_class_name + $fq_class_name, ); } } @@ -309,12 +309,12 @@ public function methodExists( // also store failures in case the method is added later $this->file_reference_provider->addMethodReferenceToMissingClassMember( $calling_method_id, - $potential_id + $potential_id, ); } elseif ($source_file_path) { $this->file_reference_provider->addFileReferenceToMissingClassMember( $source_file_path, - $potential_id + $potential_id, ); } } @@ -323,12 +323,12 @@ public function methodExists( // also store failures in case the method is added later $this->file_reference_provider->addMethodReferenceToMissingClassMember( $calling_method_id, - strtolower((string) $method_id) + strtolower((string) $method_id), ); } elseif ($source_file_path) { $this->file_reference_provider->addFileReferenceToMissingClassMember( $source_file_path, - strtolower((string) $method_id) + strtolower((string) $method_id), ); } @@ -354,7 +354,7 @@ public function getMethodParams( $method_name, $args, $source, - $context + $context, ); if ($method_params !== null) { @@ -377,7 +377,7 @@ public function getMethodParams( if ($function_callables === null) { throw new UnexpectedValueException( - 'Not expecting $function_callables to be null for ' . $callmap_id + 'Not expecting $function_callables to be null for ' . $callmap_id, ); } @@ -396,7 +396,7 @@ public function getMethodParams( ExpressionAnalyzer::analyze( $source, $arg->value, - $context + $context, ); } @@ -408,7 +408,7 @@ public function getMethodParams( $function_callables, $args, $source->getNodeTypeProvider(), - (string) $callmap_id + (string) $callmap_id, ); assert($matching_callable->params !== null); @@ -465,7 +465,7 @@ public function getMethodParams( $source->getCodebase(), $params[$i]->type, $appearing_fq_class_name, - $overridden_class_storage->name + $overridden_class_storage->name, ); } @@ -500,7 +500,7 @@ public static function localizeType( (new TypeLocalizer( $extends, - $base_fq_class_name + $base_fq_class_name, ))->traverse($type); return $type; @@ -523,7 +523,7 @@ public static function getExtendedTemplatedTypes( if ($extended_atomic_type instanceof TTemplateParam) { $extra_added_types = [...$extra_added_types, ...self::getExtendedTemplatedTypes( $extended_atomic_type, - $extends + $extends, )]; } else { $extra_added_types[] = $extended_atomic_type; @@ -629,7 +629,7 @@ public function getMethodReturnType( is_int($case_storage->value) ? Type::getInt(false, $case_storage->value) : Type::getString($case_storage->value), - $first_arg_type + $first_arg_type, )) { $types[] = new TEnumCase($original_fq_class_name, $case_name); } @@ -663,23 +663,23 @@ public function getMethodReturnType( return new Union([new TClosure( 'Closure', $callable_type->params, - $callable_type->return_type + $callable_type->return_type, )]); } if ($atomic_type instanceof TNamedObject && $this->methodExists( - new MethodIdentifier($atomic_type->value, '__invoke') + new MethodIdentifier($atomic_type->value, '__invoke'), ) ) { $invokable_storage = $this->getStorage( - new MethodIdentifier($atomic_type->value, '__invoke') + new MethodIdentifier($atomic_type->value, '__invoke'), ); return new Union([new TClosure( 'Closure', $invokable_storage->params, - $invokable_storage->return_type + $invokable_storage->return_type, )]); } } @@ -695,7 +695,7 @@ public function getMethodReturnType( if ($return_type_candidate->isFalsable()) { return $return_type_candidate->setProperties([ - 'ignore_falsable_issues' => true + 'ignore_falsable_issues' => true, ]); } @@ -753,19 +753,19 @@ public function getMethodReturnType( $overridden_class_storage->parent_class, true, false, - $storage->final + $storage->final, ); $old_contained_by_new = UnionTypeComparator::isContainedBy( $source_analyzer->getCodebase(), $candidate_type, - $overridden_storage_return_type + $overridden_storage_return_type, ); $new_contained_by_old = UnionTypeComparator::isContainedBy( $source_analyzer->getCodebase(), $overridden_storage_return_type, - $candidate_type + $candidate_type, ); if ((!$old_contained_by_new && !$new_contained_by_old) @@ -777,7 +777,7 @@ public function getMethodReturnType( $attempted_intersection = Type::intersectUnionTypes( $candidate_type, $overridden_storage->return_type, - $source_analyzer->getCodebase() + $source_analyzer->getCodebase(), ); } catch (InvalidArgumentException $e) { // TODO: fix @@ -786,7 +786,7 @@ public function getMethodReturnType( $attempted_intersection = Type::intersectUnionTypes( $overridden_storage->return_type, $candidate_type, - $source_analyzer->getCodebase() + $source_analyzer->getCodebase(), ); } @@ -851,13 +851,13 @@ public function getMethodReturnType( $old_contained_by_new = UnionTypeComparator::isContainedBy( $source_analyzer->getCodebase(), $candidate_type, - $overridden_return_type + $overridden_return_type, ); $new_contained_by_old = UnionTypeComparator::isContainedBy( $source_analyzer->getCodebase(), $overridden_return_type, - $candidate_type + $candidate_type, ); if ((!$old_contained_by_new && !$new_contained_by_old) @@ -866,7 +866,7 @@ public function getMethodReturnType( $attempted_intersection = Type::intersectUnionTypes( $candidate_type, $overridden_return_type, - $source_analyzer->getCodebase() + $source_analyzer->getCodebase(), ); if ($attempted_intersection) { @@ -948,7 +948,7 @@ public function setDeclaringMethodId( $class_storage->declaring_method_ids[$method_name_lc] = new MethodIdentifier( $declaring_fq_class_name, - $declaring_method_name_lc + $declaring_method_name_lc, ); } @@ -966,7 +966,7 @@ public function setAppearingMethodId( $class_storage->appearing_method_ids[$method_name_lc] = new MethodIdentifier( $appearing_fq_class_name, - $appearing_method_name_lc + $appearing_method_name_lc, ); } @@ -1073,7 +1073,7 @@ public function getClassLikeStorageForMethod(MethodIdentifier $method_id): Class $fq_class_name, $method_name, null, - null + null, )) { return $this->classlike_storage_provider->get($fq_class_name); } @@ -1107,7 +1107,7 @@ public function getStorage(MethodIdentifier $method_id): MethodStorage if (!isset($class_storage->methods[$method_name])) { throw new UnexpectedValueException( - '$storage should not be null for ' . $method_id + '$storage should not be null for ' . $method_id, ); } diff --git a/src/Psalm/Internal/Codebase/Populator.php b/src/Psalm/Internal/Codebase/Populator.php index 3517da2cbcc..9327d4e8452 100644 --- a/src/Psalm/Internal/Codebase/Populator.php +++ b/src/Psalm/Internal/Codebase/Populator.php @@ -114,8 +114,8 @@ private function populateClassLikeStorage(ClassLikeStorage $storage, array $depe IssueBuffer::maybeAdd( new CircularReference( 'Circular reference discovered when loading ' . $storage->name, - $storage->location - ) + $storage->location, + ), ); } @@ -135,7 +135,7 @@ private function populateClassLikeStorage(ClassLikeStorage $storage, array $depe $storage, $storage_provider, $dependent_classlikes, - reset($storage->parent_classes) + reset($storage->parent_classes), ); } @@ -153,7 +153,7 @@ private function populateClassLikeStorage(ClassLikeStorage $storage, array $depe $storage, $storage_provider, $dependent_classlikes, - $parent_interface_lc + $parent_interface_lc, ); } @@ -162,7 +162,7 @@ private function populateClassLikeStorage(ClassLikeStorage $storage, array $depe $storage, $storage_provider, $dependent_classlikes, - $implemented_interface_lc + $implemented_interface_lc, ); } @@ -180,7 +180,7 @@ private function populateClassLikeStorage(ClassLikeStorage $storage, array $depe foreach ($storage->class_implements as $implemented_interface) { $this->file_reference_provider->addFileInheritanceToClass( $file_path, - strtolower($implemented_interface) + strtolower($implemented_interface), ); } @@ -245,8 +245,8 @@ private function populateClassLikeStorage(ClassLikeStorage $storage, array $depe IssueBuffer::maybeAdd( new CircularReference( 'Circular reference discovered when loading ' . $dependency->name, - $dependency->location - ) + $dependency->location, + ), ); } @@ -272,8 +272,8 @@ private function populateOverriddenMethods( try { $implemented_interface = strtolower( $this->classlikes->getUnAliasedName( - $interface - ) + $interface, + ), ); $implemented_interface_storage = $storage_provider->get($implemented_interface); } catch (InvalidArgumentException $e) { @@ -286,7 +286,7 @@ private function populateOverriddenMethods( if ($method->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC) { $interface_method_implementers[$method_name][] = new MethodIdentifier( $implemented_interface_storage->name, - $method_name + $method_name, ); } } @@ -347,7 +347,7 @@ private function populateOverriddenMethods( $candidate_overridden_ids = array_intersect_key( $candidate_overridden_ids, ($declaring_class_storage->overridden_method_ids[$method_name] ?? []) - + [$declaring_method_id->fq_class_name => $declaring_method_id] + + [$declaring_method_id->fq_class_name => $declaring_method_id], ); } } @@ -374,7 +374,7 @@ private function populateOverriddenMethods( } else { if (in_array( $storage->documenting_method_ids[$method_name]->fq_class_name, - $declaring_class_storage->parent_interfaces + $declaring_class_storage->parent_interfaces, )) { $storage->documenting_method_ids[$method_name] = $declaring_method_id; $method_storage->inherited_return_type = true; @@ -384,7 +384,7 @@ private function populateOverriddenMethods( if (!in_array( $declaring_class, - $documenting_class_storage->parent_interfaces + $documenting_class_storage->parent_interfaces, ) && $documenting_class_storage->is_interface ) { unset($storage->documenting_method_ids[$method_name]); @@ -423,8 +423,8 @@ private function populateDataFromTrait( try { $used_trait_lc = strtolower( $this->classlikes->getUnAliasedName( - $used_trait_lc - ) + $used_trait_lc, + ), ); $trait_storage = $storage_provider->get($used_trait_lc); } catch (InvalidArgumentException $e) { @@ -484,8 +484,8 @@ private function populateDataFromParentClass( ): void { $parent_storage_class = strtolower( $this->classlikes->getUnAliasedName( - $parent_storage_class - ) + $parent_storage_class, + ), ); try { @@ -512,7 +512,7 @@ private function populateDataFromParentClass( $storage->class_implements = array_merge($storage->class_implements, $parent_storage->class_implements); $storage->invalid_dependencies = array_merge( $storage->invalid_dependencies, - $parent_storage->invalid_dependencies + $parent_storage->invalid_dependencies, ); if ($parent_storage->has_visitor_issues) { @@ -524,9 +524,9 @@ private function populateDataFromParentClass( $parent_storage->constants, static fn(ClassConstantStorage $constant): bool => $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC - || $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PROTECTED + || $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PROTECTED, ), - $storage->constants + $storage->constants, ); if ($parent_storage->preserve_constructor_signature) { @@ -568,14 +568,14 @@ private function populateInterfaceData( array_filter( $interface_storage->constants, static fn(ClassConstantStorage $constant): bool - => $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC + => $constant->visibility === ClassLikeAnalyzer::VISIBILITY_PUBLIC, ), - $storage->constants + $storage->constants, ); $storage->invalid_dependencies = array_merge( $storage->invalid_dependencies, - $interface_storage->invalid_dependencies + $interface_storage->invalid_dependencies, ); self::extendTemplateParams($storage, $interface_storage, false); @@ -586,8 +586,8 @@ private function populateInterfaceData( try { $new_parent = strtolower( $this->classlikes->getUnAliasedName( - $new_parent - ) + $new_parent, + ), ); $new_parent_interface_storage = $storage_provider->get($new_parent); } catch (InvalidArgumentException $e) { @@ -627,7 +627,7 @@ private static function extendTemplateParams( foreach ($type_map as $i => $type) { $storage->template_extended_params[$t_storage_class][$i] = self::extendType( $type, - $storage + $storage, ); } } @@ -644,7 +644,7 @@ private static function extendTemplateParams( if ($parent_storage->template_extended_params) { $storage->template_extended_params = array_merge( $storage->template_extended_params, - $parent_storage->template_extended_params + $parent_storage->template_extended_params, ); } } @@ -652,7 +652,7 @@ private static function extendTemplateParams( } elseif ($parent_storage->template_extended_params) { $storage->template_extended_params = array_merge( $storage->template_extended_params ?: [], - $parent_storage->template_extended_params + $parent_storage->template_extended_params, ); } } @@ -666,8 +666,8 @@ private function populateInterfaceDataFromParentInterface( try { $parent_interface_lc = strtolower( $this->classlikes->getUnAliasedName( - $parent_interface_lc - ) + $parent_interface_lc, + ), ); $parent_interface_storage = $storage_provider->get($parent_interface_lc); } catch (InvalidArgumentException $e) { @@ -686,7 +686,7 @@ private function populateInterfaceDataFromParentInterface( $storage->parent_interfaces = array_merge( $parent_interface_storage->parent_interfaces, - $storage->parent_interfaces + $storage->parent_interfaces, ); } @@ -699,8 +699,8 @@ private function populateDataFromImplementedInterface( try { $implemented_interface_lc = strtolower( $this->classlikes->getUnAliasedName( - $implemented_interface_lc - ) + $implemented_interface_lc, + ), ); $implemented_interface_storage = $storage_provider->get($implemented_interface_lc); } catch (InvalidArgumentException $e) { @@ -714,12 +714,12 @@ private function populateDataFromImplementedInterface( $storage, $implemented_interface_storage, $storage_provider, - $dependent_classlikes + $dependent_classlikes, ); $storage->class_implements = array_merge( $storage->class_implements, - $implemented_interface_storage->parent_interfaces + $implemented_interface_storage->parent_interfaces, ); } @@ -763,12 +763,12 @@ private function populateFileStorage(FileStorage $storage, array $dependent_file $storage->declaring_function_ids = array_merge( $included_file_storage->declaring_function_ids, - $storage->declaring_function_ids + $storage->declaring_function_ids, ); $storage->declaring_constants = array_merge( $included_file_storage->declaring_constants, - $storage->declaring_constants + $storage->declaring_constants, ); } @@ -802,7 +802,7 @@ private function populateFileStorage(FileStorage $storage, array $dependent_file try { $included_trait_file_storage = $this->file_storage_provider->get( - $trait_storage->location->file_path + $trait_storage->location->file_path, ); } catch (InvalidArgumentException $e) { continue; @@ -810,13 +810,13 @@ private function populateFileStorage(FileStorage $storage, array $dependent_file $storage->declaring_function_ids = array_merge( $included_trait_file_storage->declaring_function_ids, - $storage->declaring_function_ids + $storage->declaring_function_ids, ); } $storage->declaring_function_ids = array_merge( $included_file_storage->declaring_function_ids, - $storage->declaring_function_ids + $storage->declaring_function_ids, ); } @@ -875,7 +875,7 @@ protected function inheritMethodsFromParent( ) { $aliased_method_names = array_merge( $aliased_method_names, - array_keys($storage->trait_alias_map, $method_name_lc, true) + array_keys($storage->trait_alias_map, $method_name_lc, true), ); } @@ -886,7 +886,7 @@ protected function inheritMethodsFromParent( $implemented_method_id = new MethodIdentifier( $fq_class_name, - $aliased_method_name + $aliased_method_name, ); $storage->appearing_method_ids[$aliased_method_name] = @@ -945,7 +945,7 @@ protected function inheritMethodsFromParent( ) { $aliased_method_names = array_merge( $aliased_method_names, - array_keys($storage->trait_alias_map, $method_name_lc, true) + array_keys($storage->trait_alias_map, $method_name_lc, true), ); } @@ -954,7 +954,7 @@ protected function inheritMethodsFromParent( $implementing_method_id = $storage->declaring_method_ids[$aliased_method_name]; $implementing_class_storage = $this->classlike_storage_provider->get( - $implementing_method_id->fq_class_name + $implementing_method_id->fq_class_name, ); if (!$implementing_class_storage->methods[$implementing_method_id->method_name]->abstract diff --git a/src/Psalm/Internal/Codebase/Properties.php b/src/Psalm/Internal/Codebase/Properties.php index ad44695ce87..ac7c8add999 100644 --- a/src/Psalm/Internal/Codebase/Properties.php +++ b/src/Psalm/Internal/Codebase/Properties.php @@ -76,7 +76,7 @@ public function propertyExists( $read_mode, $source, $context, - $code_location + $code_location, ); if ($property_exists !== null) { @@ -99,12 +99,12 @@ public function propertyExists( if ($context->calling_method_id) { $this->file_reference_provider->addMethodReferenceToClass( $context->calling_method_id, - $fq_class_name_lc + $fq_class_name_lc, ); } else { $this->file_reference_provider->addNonMethodReferenceToClass( $source->getFilePath(), - $fq_class_name_lc + $fq_class_name_lc, ); } } @@ -116,26 +116,26 @@ public function propertyExists( $this->file_reference_provider->addMethodReferenceToClassMember( $context->calling_method_id, $declaring_property_class . '::$' . $property_name, - false + false, ); if ($read_mode) { $this->file_reference_provider->addMethodReferenceToClassProperty( $context->calling_method_id, - $declaring_property_class . '::$' . $property_name + $declaring_property_class . '::$' . $property_name, ); } } elseif ($source) { $this->file_reference_provider->addFileReferenceToClassMember( $source->getFilePath(), $declaring_property_class . '::$' . $property_name, - false + false, ); if ($read_mode) { $this->file_reference_provider->addFileReferenceToClassProperty( $source->getFilePath(), - $declaring_property_class . '::$' . $property_name + $declaring_property_class . '::$' . $property_name, ); } } @@ -143,7 +143,7 @@ public function propertyExists( if ($this->collect_locations && $code_location) { $this->file_reference_provider->addCallingLocationForClassProperty( $code_location, - $declaring_property_class . '::$' . $property_name + $declaring_property_class . '::$' . $property_name, ); } @@ -153,12 +153,12 @@ public function propertyExists( if ($context && $context->calling_method_id) { $this->file_reference_provider->addMethodReferenceToMissingClassMember( $context->calling_method_id, - $fq_class_name_lc . '::$' . $property_name + $fq_class_name_lc . '::$' . $property_name, ); } elseif ($source) { $this->file_reference_provider->addFileReferenceToMissingClassMember( $source->getFilePath(), - $fq_class_name_lc . '::$' . $property_name + $fq_class_name_lc . '::$' . $property_name, ); } @@ -178,7 +178,7 @@ public function getDeclaringClassForProperty( $property_name, $read_mode, $source, - null + null, )) { return $fq_class_name; } @@ -209,7 +209,7 @@ public function getAppearingClassForProperty( $property_name, $read_mode, $source, - null + null, )) { return $fq_class_name; } @@ -282,7 +282,7 @@ public function getPropertyType( $property_name, !$property_set, $source, - $context + $context, ); if ($property_type !== null) { diff --git a/src/Psalm/Internal/Codebase/Reflection.php b/src/Psalm/Internal/Codebase/Reflection.php index a750d4ad673..f62cfdc7e28 100644 --- a/src/Psalm/Internal/Codebase/Reflection.php +++ b/src/Psalm/Internal/Codebase/Reflection.php @@ -97,7 +97,7 @@ public function registerClass(ReflectionClass $reflected_class): void $storage->parent_classes = array_merge( [$parent_class_name_lc => $parent_class_name], - $parent_storage->parent_classes + $parent_storage->parent_classes, ); $storage->used_traits = $parent_storage->used_traits; @@ -168,7 +168,7 @@ public function registerClass(ReflectionClass $reflected_class): void ClassLikeAnalyzer::getTypeFromValue($value), new Union([ConstantTypeResolver::getLiteralTypeFromScalarValue($value)]), ClassLikeAnalyzer::VISIBILITY_PUBLIC, - null + null, ); } @@ -181,7 +181,7 @@ public function registerClass(ReflectionClass $reflected_class): void } $reflection_methods = $reflected_class->getMethods( - (ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED) + (ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED), ); if ($class_name_lower === 'generator') { @@ -221,14 +221,14 @@ public function registerClass(ReflectionClass $reflected_class): void $class_name, $reflection_method_name, $reflection_method_class, - $reflection_method_name + $reflection_method_name, ); $this->codebase->methods->setAppearingMethodId( $class_name, $reflection_method_name, $reflection_method_class, - $reflection_method_name + $reflection_method_name, ); } } @@ -260,13 +260,13 @@ public function extractReflectionMethodInfo(ReflectionMethod $method): void $fq_class_name, '__construct', $fq_class_name, - $method_name_lc + $method_name_lc, ); $this->codebase->methods->setAppearingMethodId( $fq_class_name, '__construct', $fq_class_name, - $method_name_lc + $method_name_lc, ); } @@ -279,7 +279,7 @@ public function extractReflectionMethodInfo(ReflectionMethod $method): void $class_storage->declaring_method_ids[$method_name_lc] = new MethodIdentifier( $declaring_class->name, - $method_name_lc + $method_name_lc, ); $class_storage->inheritable_method_ids[$method_name_lc] @@ -345,7 +345,7 @@ private function getReflectionParamData(ReflectionParameter $param): FunctionLik null, $is_optional, $param_type->isNullable(), - $param->isVariadic() + $param->isVariadic(), ); $parameter->signature_type = Type::getMixed(); @@ -375,7 +375,7 @@ public function registerFunction(string $function_id): ?bool $this->codebase, $function_id, [], - null + null, ); } @@ -431,8 +431,8 @@ public static function getPsalmTypeFromReflectionType(?ReflectionType $reflectio '|', array_map( static fn(ReflectionNamedType $reflection): string => $reflection->getName(), - $reflection_type->getTypes() - ) + $reflection_type->getTypes(), + ), ); } else { throw new LogicException('Unexpected reflection class ' . get_class($reflection_type) . ' found.'); diff --git a/src/Psalm/Internal/Codebase/Scanner.php b/src/Psalm/Internal/Codebase/Scanner.php index 6d4d86d4fcc..0e215c32dfa 100644 --- a/src/Psalm/Internal/Codebase/Scanner.php +++ b/src/Psalm/Internal/Codebase/Scanner.php @@ -201,7 +201,7 @@ public function removeClassLike(string $fq_classlike_name_lc): void { unset( $this->classlike_files[$fq_classlike_name_lc], - $this->deep_scanned_classlike_files[$fq_classlike_name_lc] + $this->deep_scanned_classlike_files[$fq_classlike_name_lc], ); } @@ -265,7 +265,7 @@ public function queueClassLikeForScanning( $property_type->queueClassLikesForScanning( $this->codebase, null, - $phantom_classes + [$fq_classlike_name_lc => true] + $phantom_classes + [$fq_classlike_name_lc => true], ); } } @@ -299,7 +299,7 @@ private function scanFilePaths(int $pool_size): bool { $files_to_scan = array_filter( $this->files_to_scan, - [$this, 'shouldScan'] + [$this, 'shouldScan'], ); $this->files_to_scan = []; @@ -373,7 +373,7 @@ function () { : [], 'taint_data' => $codebase->taint_flow_graph, ]; - } + }, ); // Wait for all tasks to complete and collect the results. @@ -386,16 +386,16 @@ function () { IssueBuffer::addIssues($pool_data['issues']); $this->codebase->statements_provider->addChangedMembers( - $pool_data['changed_members'] + $pool_data['changed_members'], ); $this->codebase->statements_provider->addUnchangedSignatureMembers( - $pool_data['unchanged_signature_members'] + $pool_data['unchanged_signature_members'], ); $this->codebase->statements_provider->addDiffMap( - $pool_data['diff_map'] + $pool_data['diff_map'], ); $this->codebase->statements_provider->addDeletionRanges( - $pool_data['deletion_ranges'] + $pool_data['deletion_ranges'], ); $this->codebase->statements_provider->addErrors($pool_data['errors']); @@ -412,7 +412,7 @@ function () { if ($this->codebase->statements_provider->parser_cache_provider) { $this->codebase->statements_provider->parser_cache_provider->addNewFileContentHashes( - $pool_data['new_file_content_hashes'] + $pool_data['new_file_content_hashes'], ); } } @@ -443,7 +443,7 @@ function () { ) { $this->codebase->functions->addGlobalFunction( $function_storage->cased_name, - $function_storage + $function_storage, ); } } @@ -490,7 +490,7 @@ private function convertClassesToFilePaths(ClassLikes $classlikes): void $this->reflected_classlikes_lc[$fq_classlike_name_lc] = true; } elseif ($this->fileExistsForClassLike($classlikes, $fq_classlike_name)) { $fq_classlike_name_lc = strtolower($classlikes->getUnAliasedName( - $fq_classlike_name_lc + $fq_classlike_name_lc, )); // even though we've checked this above, calling the method invalidates it @@ -554,7 +554,7 @@ private function scanFile( $this->codebase, $file_storage, $from_cache, - $this->progress + $this->progress, ); if (!$from_cache) { @@ -595,7 +595,7 @@ private function scanFile( ) { $this->codebase->functions->addGlobalFunction( $function_storage->cased_name, - $function_storage + $function_storage, ); } } @@ -663,7 +663,7 @@ private function fileExistsForClassLike(ClassLikes $classlikes, string $fq_class $classlikes->addFullyQualifiedClassLikeName( $fq_class_name_lc, - realpath($composer_file_path) + realpath($composer_file_path), ); return true; @@ -686,7 +686,7 @@ function () use ($fq_class_name): ?ReflectionClass { } finally { error_reporting($old_level); } - } + }, ); if (null === $reflected_class) { @@ -754,7 +754,7 @@ public function addThreadData(array $thread_data): void $classlike_files, $deep_scanned_classlike_files, $scanned_files, - $reflected_classlikes_lc + $reflected_classlikes_lc, ] = $thread_data; $this->files_to_scan = array_merge($files_to_scan, $this->files_to_scan); @@ -765,7 +765,7 @@ public function addThreadData(array $thread_data): void $this->classlike_files = array_merge($classlike_files, $this->classlike_files); $this->deep_scanned_classlike_files = array_merge( $deep_scanned_classlike_files, - $this->deep_scanned_classlike_files + $this->deep_scanned_classlike_files, ); $this->scanned_files = array_merge($scanned_files, $this->scanned_files); $this->reflected_classlikes_lc = array_merge($reflected_classlikes_lc, $this->reflected_classlikes_lc); @@ -781,7 +781,7 @@ private function scanAPath(int $_, string $file_path): void $this->scanFile( $file_path, $this->config->getFiletypeScanners(), - isset($this->files_to_deep_scan[$file_path]) + isset($this->files_to_deep_scan[$file_path]), ); } } diff --git a/src/Psalm/Internal/Codebase/TaintFlowGraph.php b/src/Psalm/Internal/Codebase/TaintFlowGraph.php index 5bbf5ff6130..b18b82eb161 100644 --- a/src/Psalm/Internal/Codebase/TaintFlowGraph.php +++ b/src/Psalm/Internal/Codebase/TaintFlowGraph.php @@ -181,7 +181,7 @@ public function getIssueTrace(DataFlowNode $source): array $node = [ 'location' => $source->code_location, 'label' => $source->label, - 'entry_path_type' => end($source->path_types) ?: '' + 'entry_path_type' => end($source->path_types) ?: '', ]; if ($previous_source) { @@ -226,8 +226,8 @@ public function connectSinksAndSources(): void $generated_source, $source_taints, $sinks, - $visited_source_ids - ) + $visited_source_ids, + ), ); } } @@ -267,8 +267,8 @@ private function getChildNodes( $new_taints = array_unique( array_diff( array_merge($source_taints, $added_taints), - $removed_taints - ) + $removed_taints, + ), ); sort($new_taints); @@ -319,7 +319,7 @@ private function getChildNodes( 'Detected tainted text', $issue_location, $issue_trace, - $path + $path, ); break; @@ -328,7 +328,7 @@ private function getChildNodes( 'Detected tainted code passed to unserialize or similar', $issue_location, $issue_trace, - $path + $path, ); break; @@ -337,7 +337,7 @@ private function getChildNodes( 'Detected tainted code passed to include or similar', $issue_location, $issue_trace, - $path + $path, ); break; @@ -346,7 +346,7 @@ private function getChildNodes( 'Detected tainted code passed to eval or similar', $issue_location, $issue_trace, - $path + $path, ); break; @@ -355,7 +355,7 @@ private function getChildNodes( 'Detected tainted SQL', $issue_location, $issue_trace, - $path + $path, ); break; @@ -364,7 +364,7 @@ private function getChildNodes( 'Detected tainted HTML', $issue_location, $issue_trace, - $path + $path, ); break; @@ -373,7 +373,7 @@ private function getChildNodes( 'Detected tainted text with possible quotes', $issue_location, $issue_trace, - $path + $path, ); break; @@ -382,7 +382,7 @@ private function getChildNodes( 'Detected tainted shell code', $issue_location, $issue_trace, - $path + $path, ); break; @@ -391,7 +391,7 @@ private function getChildNodes( 'Detected tainted user secret leaking', $issue_location, $issue_trace, - $path + $path, ); break; @@ -400,7 +400,7 @@ private function getChildNodes( 'Detected tainted system secret leaking', $issue_location, $issue_trace, - $path + $path, ); break; @@ -409,7 +409,7 @@ private function getChildNodes( 'Detected tainted network request', $issue_location, $issue_trace, - $path + $path, ); break; @@ -418,7 +418,7 @@ private function getChildNodes( 'Detected tainted LDAP request', $issue_location, $issue_trace, - $path + $path, ); break; @@ -427,7 +427,7 @@ private function getChildNodes( 'Detected tainted cookie', $issue_location, $issue_trace, - $path + $path, ); break; @@ -436,7 +436,7 @@ private function getChildNodes( 'Detected tainted file handling', $issue_location, $issue_trace, - $path + $path, ); break; @@ -445,7 +445,7 @@ private function getChildNodes( 'Detected tainted header', $issue_location, $issue_trace, - $path + $path, ); break; @@ -454,7 +454,7 @@ private function getChildNodes( 'Detected tainted ' . $matching_taint, $issue_location, $issue_trace, - $path + $path, ); } @@ -521,7 +521,7 @@ private function getSpecializedSources(DataFlowNode $source): array return array_filter( $generated_sources, - [$this, 'doesForwardEdgeExist'] + [$this, 'doesForwardEdgeExist'], ); } diff --git a/src/Psalm/Internal/Codebase/VariableUseGraph.php b/src/Psalm/Internal/Codebase/VariableUseGraph.php index 608bfd64519..22069bca81f 100644 --- a/src/Psalm/Internal/Codebase/VariableUseGraph.php +++ b/src/Psalm/Internal/Codebase/VariableUseGraph.php @@ -76,7 +76,7 @@ public function isVariableUsed(DataFlowNode $assignment_node): bool $child_nodes = $this->getChildNodes( $source, - $visited_source_ids + $visited_source_ids, ); if ($child_nodes === null) { @@ -85,7 +85,7 @@ public function isVariableUsed(DataFlowNode $assignment_node): bool $new_child_nodes = array_merge( $new_child_nodes, - $child_nodes + $child_nodes, ); } @@ -118,7 +118,7 @@ public function getOriginLocations(DataFlowNode $assignment_node): array $parent_nodes = $this->getParentNodes( $child_node, - $visited_child_ids + $visited_child_ids, ); if (!$parent_nodes) { diff --git a/src/Psalm/Internal/DataFlow/DataFlowNode.php b/src/Psalm/Internal/DataFlow/DataFlowNode.php index e0c38e03934..90a4cbde518 100644 --- a/src/Psalm/Internal/DataFlow/DataFlowNode.php +++ b/src/Psalm/Internal/DataFlow/DataFlowNode.php @@ -83,7 +83,7 @@ final public static function getForMethodArgument( $arg_id, $label, $arg_location, - $specialization_key + $specialization_key, ); } @@ -122,7 +122,7 @@ final public static function getForMethodReturn( strtolower($method_id), $cased_method_id, $code_location, - $specialization_key + $specialization_key, ); } diff --git a/src/Psalm/Internal/Diff/AstDiffer.php b/src/Psalm/Internal/Diff/AstDiffer.php index 5165d47ceb1..ea93e85eebc 100644 --- a/src/Psalm/Internal/Diff/AstDiffer.php +++ b/src/Psalm/Internal/Diff/AstDiffer.php @@ -101,7 +101,7 @@ protected static function extractDiff(array $trace, int $x, int $y, array $a, ar $result[] = new DiffElem( $bc[$x - 1] ? DiffElem::TYPE_KEEP_SIGNATURE : DiffElem::TYPE_KEEP, $a[$x - 1], - $b[$y - 1] + $b[$y - 1], ); --$x; --$y; diff --git a/src/Psalm/Internal/Diff/ClassStatementsDiffer.php b/src/Psalm/Internal/Diff/ClassStatementsDiffer.php index fed20010c29..686aeb92917 100644 --- a/src/Psalm/Internal/Diff/ClassStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/ClassStatementsDiffer.php @@ -174,7 +174,7 @@ static function ( $a, $b, $a_code, - $b_code + $b_code, ); $diff = self::extractDiff($trace, $x, $y, $a, $b, $bc); @@ -238,7 +238,7 @@ static function ( $deletion_ranges[] = [ $start, - (int)$affected_elem->getAttribute('endFilePos') + (int)$affected_elem->getAttribute('endFilePos'), ]; } } diff --git a/src/Psalm/Internal/Diff/FileDiffer.php b/src/Psalm/Internal/Diff/FileDiffer.php index 6d72bc038ce..e9c06c02ae4 100644 --- a/src/Psalm/Internal/Diff/FileDiffer.php +++ b/src/Psalm/Internal/Diff/FileDiffer.php @@ -95,7 +95,7 @@ private static function extractDiff(array $trace, int $x, int $y, array $a, arra $result[] = new DiffElem( DiffElem::TYPE_KEEP, $a[$x - 1], - $b[$y - 1] + $b[$y - 1], ); --$x; --$y; @@ -298,7 +298,7 @@ private static function coalesceReplacements(array $diff): array $newDiff[] = new DiffElem( DiffElem::TYPE_REPLACE, $diff[$i + $n]->old, - $diff[$j + $n]->new + $diff[$j + $n]->new, ); } } else { diff --git a/src/Psalm/Internal/Diff/FileStatementsDiffer.php b/src/Psalm/Internal/Diff/FileStatementsDiffer.php index 02316c62589..d1864043446 100644 --- a/src/Psalm/Internal/Diff/FileStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/FileStatementsDiffer.php @@ -71,7 +71,7 @@ static function ( $a, $b, $a_code, - $b_code + $b_code, ); $diff = self::extractDiff($trace, $x, $y, $a, $b, $bc); @@ -92,7 +92,7 @@ static function ( $diff_elem->old->stmts, $diff_elem->new->stmts, $a_code, - $b_code + $b_code, ); $keep = [...$keep, ...$namespace_keep[0]]; @@ -112,7 +112,7 @@ static function ( $diff_elem->old->stmts, $diff_elem->new->stmts, $a_code, - $b_code + $b_code, ); $keep = [...$keep, ...$class_keep[0]]; @@ -145,7 +145,7 @@ static function ( $deletion_ranges[] = [ $start, - (int)$diff_elem->old->getAttribute('endFilePos') + (int)$diff_elem->old->getAttribute('endFilePos'), ]; } } elseif ($diff_elem->type === DiffElem::TYPE_ADD) { diff --git a/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php b/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php index 03b5469fba7..4232a405713 100644 --- a/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php +++ b/src/Psalm/Internal/Diff/NamespaceStatementsDiffer.php @@ -72,7 +72,7 @@ static function ( $a, $b, $a_code, - $b_code + $b_code, ); $diff = self::extractDiff($trace, $x, $y, $a, $b, $bc); @@ -97,7 +97,7 @@ static function ( $diff_elem->old->stmts, $diff_elem->new->stmts, $a_code, - $b_code + $b_code, ); $keep = [...$keep, ...$class_keep[0]]; diff --git a/src/Psalm/Internal/ErrorHandler.php b/src/Psalm/Internal/ErrorHandler.php index 74efb039f7d..e4b1b44966f 100644 --- a/src/Psalm/Internal/ErrorHandler.php +++ b/src/Psalm/Internal/ErrorHandler.php @@ -76,7 +76,7 @@ private static function installErrorHandler(): void 'PHP Error: ' . $error_message . ' in ' . $error_filename . ':' . $error_line . ' for command with CLI args "' . ErrorHandler::$args . '"', - $error_code + $error_code, ); } // let PHP handle suppressed errors how it sees fit diff --git a/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php b/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php index 2d87476fc77..30a96bae428 100644 --- a/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php +++ b/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php @@ -301,7 +301,7 @@ protected function fillGithubActions(): BuildInfoCollector ->setCommitterEmail($head_commit_data['committer']['email']) ->setMessage($head_commit_data['message']) ->setDate(strtotime($head_commit_data['timestamp'])), - [] + [], ); $this->readEnv['git'] = $gitinfo->toArray(); diff --git a/src/Psalm/Internal/FileManipulation/ClassDocblockManipulator.php b/src/Psalm/Internal/FileManipulation/ClassDocblockManipulator.php index 011d7927830..53b6509344b 100644 --- a/src/Psalm/Internal/FileManipulation/ClassDocblockManipulator.php +++ b/src/Psalm/Internal/FileManipulation/ClassDocblockManipulator.php @@ -120,7 +120,7 @@ public static function getManipulationsForFile(string $file_path): array $file_manipulations[$manipulator->docblock_start] = new FileManipulation( $manipulator->docblock_start, $manipulator->docblock_end, - $manipulator->getDocblock() + $manipulator->getDocblock(), ); } } diff --git a/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php b/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php index 96f1aa778bb..7bd147c06ec 100644 --- a/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php +++ b/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php @@ -105,9 +105,9 @@ public static function addForCodeLocation( new FileManipulation( $bounds[0], $bounds[1], - $replacement_text + $replacement_text, ), - ] + ], ); } @@ -161,9 +161,9 @@ public static function addVarAnnotationToRemove(DocblockTypeLocation $code_locat $comment_end, $comment_text, false, - $comment_text === '' + $comment_text === '', ), - ] + ], ); } @@ -186,7 +186,7 @@ public static function getMigrationManipulations(FileProvider $file_provider): a [$start_offset, $middle_offset] = self::getCodeOffsets( $code_migration->source_file_path, $code_migration->source_start, - $code_migration->source_end + $code_migration->source_end, ); if (!isset($code_migration_manipulations[$code_migration->source_file_path])) { @@ -200,7 +200,7 @@ public static function getMigrationManipulations(FileProvider $file_provider): a $delete_file_manipulation = new FileManipulation( $code_migration->source_start + $start_offset, $code_migration->source_end + $middle_offset, - '' + '', ); $code_migration_manipulations[$code_migration->source_file_path][] = $delete_file_manipulation; @@ -208,7 +208,7 @@ public static function getMigrationManipulations(FileProvider $file_provider): a [$destination_start_offset] = self::getCodeOffsets( $code_migration->destination_file_path, $code_migration->destination_start, - $code_migration->destination_start + $code_migration->destination_start, ); $manipulation = new FileManipulation( @@ -217,8 +217,8 @@ public static function getMigrationManipulations(FileProvider $file_provider): a "\n" . substr( $file_provider->getContents($code_migration->source_file_path), $delete_file_manipulation->start, - $delete_file_manipulation->end - $delete_file_manipulation->start - ) . "\n" + $delete_file_manipulation->end - $delete_file_manipulation->start, + ) . "\n", ); $code_migration_manipulations[$code_migration->destination_file_path][$manipulation->getKey()] diff --git a/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php b/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php index ca214d2759c..9608c2d4194 100644 --- a/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php +++ b/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php @@ -135,7 +135,7 @@ private function __construct(string $file_path, FunctionLike $stmt, ProjectAnaly if ($param->type) { $this->param_typehint_offsets[$param->var->name] = [ (int) $param->type->getAttribute('startFilePos'), - (int) $param->type->getAttribute('endFilePos') + (int) $param->type->getAttribute('endFilePos'), ]; } } @@ -394,7 +394,7 @@ private function getDocblock(): string fn(string $throwsClause, string $exception) => $throwsClause === '' ? $exception : $throwsClause.'|'.$exception, - '' + '', ); if (array_key_exists('throws', $parsed_docblock->tags)) { $parsed_docblock->tags['throws'][] = $inferredThrowsClause; @@ -458,13 +458,13 @@ public static function getManipulationsForFile(string $file_path): array $file_manipulations[$manipulator->return_typehint_start] = new FileManipulation( $manipulator->return_typehint_start, $manipulator->return_typehint_end, - $manipulator->new_php_return_type + $manipulator->new_php_return_type, ); } else { $file_manipulations[$manipulator->return_typehint_area_start] = new FileManipulation( $manipulator->return_typehint_area_start, $manipulator->return_typehint_area_start, - ': ' . $manipulator->new_php_return_type + ': ' . $manipulator->new_php_return_type, ); } } elseif ($manipulator->new_php_return_type === '' @@ -476,7 +476,7 @@ public static function getManipulationsForFile(string $file_path): array $file_manipulations[$manipulator->return_typehint_start] = new FileManipulation( $manipulator->return_typehint_colon_start, $manipulator->return_typehint_end, - '' + '', ); } @@ -488,7 +488,7 @@ public static function getManipulationsForFile(string $file_path): array $file_manipulations[$manipulator->docblock_start] = new FileManipulation( $manipulator->docblock_start, $manipulator->docblock_end, - $manipulator->getDocblock() + $manipulator->getDocblock(), ); } @@ -506,13 +506,13 @@ public static function getManipulationsForFile(string $file_path): array $file_manipulations[$typehint_offsets[0]] = new FileManipulation( $typehint_offsets[0], $typehint_offsets[1], - $new_php_param_type + $new_php_param_type, ); } else { $file_manipulations[$param_offset] = new FileManipulation( $param_offset, $param_offset, - $new_php_param_type . ' ' + $new_php_param_type . ' ', ); } } elseif ($new_php_param_type === '' @@ -521,7 +521,7 @@ public static function getManipulationsForFile(string $file_path): array $file_manipulations[$typehint_offsets[0]] = new FileManipulation( $typehint_offsets[0], $param_offset, - '' + '', ); } } diff --git a/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php b/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php index 009d5619a55..3894e4edf81 100644 --- a/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php +++ b/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php @@ -120,7 +120,7 @@ private function __construct( $preceding_space = substr( $file_contents, $preceding_semicolon_pos + 1, - $preceding_newline_pos - $preceding_semicolon_pos - 1 + $preceding_newline_pos - $preceding_semicolon_pos - 1, ); if (!substr_count($preceding_space, "\n")) { @@ -222,13 +222,13 @@ public static function getManipulationsForFile(string $file_path): array $file_manipulations[$manipulator->typehint_start] = new FileManipulation( $manipulator->typehint_start, $manipulator->typehint_end, - $manipulator->new_php_type + $manipulator->new_php_type, ); } else { $file_manipulations[$manipulator->typehint_area_start] = new FileManipulation( $manipulator->typehint_area_start, $manipulator->typehint_area_start, - ' ' . $manipulator->new_php_type + ' ' . $manipulator->new_php_type, ); } } elseif ($manipulator->new_php_type === '' @@ -239,7 +239,7 @@ public static function getManipulationsForFile(string $file_path): array $file_manipulations[$manipulator->typehint_start] = new FileManipulation( $manipulator->typehint_start, $manipulator->typehint_end, - '' + '', ); } @@ -252,7 +252,7 @@ public static function getManipulationsForFile(string $file_path): array - ($manipulator->add_newline ? strlen($manipulator->indentation) : 0), $manipulator->docblock_end, ($manipulator->add_newline ? "\n" . $manipulator->indentation : '') - . $manipulator->getDocblock() + . $manipulator->getDocblock(), ); } } diff --git a/src/Psalm/Internal/Fork/Pool.php b/src/Psalm/Internal/Fork/Pool.php index ef1f7ecd908..1d097b19123 100644 --- a/src/Psalm/Internal/Fork/Pool.php +++ b/src/Psalm/Internal/Fork/Pool.php @@ -123,7 +123,7 @@ public function __construct( assert( $pool_size > 1, - 'The pool size must be >= 2 to use the fork pool.' + 'The pool size must be >= 2 to use the fork pool.', ); if (!extension_loaded('pcntl') || !extension_loaded('posix')) { @@ -242,7 +242,7 @@ public function __construct( get_class($t) . ' ' . $t->getMessage() . "\n" . "Emitted in " . $t->getFile() . ":" . $t->getLine() . "\n" . "Stack trace in the forked worker:\n" . - $t->getTraceAsString() + $t->getTraceAsString(), ); } diff --git a/src/Psalm/Internal/LanguageServer/Client/TextDocument.php b/src/Psalm/Internal/LanguageServer/Client/TextDocument.php index 333ebab4e14..2bca92f50d6 100644 --- a/src/Psalm/Internal/LanguageServer/Client/TextDocument.php +++ b/src/Psalm/Internal/LanguageServer/Client/TextDocument.php @@ -62,14 +62,14 @@ static function () use ($textDocument) { /** @var Promise */ $promise = $this->handler->request( 'textDocument/xcontent', - ['textDocument' => $textDocument] + ['textDocument' => $textDocument], ); $result = yield $promise; /** @var TextDocumentItem */ return $this->mapper->map($result, new TextDocumentItem); - } + }, ); } } diff --git a/src/Psalm/Internal/LanguageServer/ClientHandler.php b/src/Psalm/Internal/LanguageServer/ClientHandler.php index bb16b365b28..2b3ee6e54ad 100644 --- a/src/Psalm/Internal/LanguageServer/ClientHandler.php +++ b/src/Psalm/Internal/LanguageServer/ClientHandler.php @@ -51,8 +51,8 @@ public function request(string $method, $params): Promise static function () use ($id, $method, $params): Generator { yield $this->protocolWriter->write( new Message( - new Request($id, $method, (object) $params) - ) + new Request($id, $method, (object) $params), + ), ); $deferred = new Deferred(); @@ -80,7 +80,7 @@ static function (Message $msg) use ($id, $deferred, &$listener): void { $this->protocolReader->on('message', $listener); return $deferred->promise(); - } + }, ); } @@ -94,8 +94,8 @@ public function notify(string $method, $params): void { $this->protocolWriter->write( new Message( - new Notification($method, (object)$params) - ) + new Notification($method, (object)$params), + ), ); } } diff --git a/src/Psalm/Internal/LanguageServer/LanguageClient.php b/src/Psalm/Internal/LanguageServer/LanguageClient.php index 83f6ac82e49..9a766dce050 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageClient.php +++ b/src/Psalm/Internal/LanguageServer/LanguageClient.php @@ -53,8 +53,8 @@ public function logMessage(string $message, int $type = 4, string $method = 'win $method, [ 'type' => $type, - 'message' => $message - ] + 'message' => $message, + ], ); } } diff --git a/src/Psalm/Internal/LanguageServer/LanguageServer.php b/src/Psalm/Internal/LanguageServer/LanguageServer.php index 3c4501763fa..9784cd40bd0 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageServer.php +++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php @@ -116,7 +116,7 @@ public function __construct( function (): void { $this->shutdown(); $this->exit(); - } + }, ); $this->protocolReader->on( 'message', @@ -152,7 +152,7 @@ function (Message $msg): Generator { (string) $e, ErrorCode::INTERNAL_ERROR, null, - $e + $e, ); } // Only send a Response for a Request @@ -169,15 +169,15 @@ function (Message $msg): Generator { } yield $this->protocolWriter->write(new Message($responseBody)); } - } - ) + }, + ), ); $this->protocolReader->on( 'readMessageGroup', function (): void { $this->doAnalysis(); - } + }, ); $this->client = new LanguageClient($reader, $writer); @@ -229,7 +229,7 @@ function (): Generator { $this->textDocument = new ServerTextDocument( $this, $codebase, - $this->project_analyzer + $this->project_analyzer, ); } @@ -237,7 +237,7 @@ function (): Generator { $this->workspace = new ServerWorkspace( $this, $codebase, - $this->project_analyzer + $this->project_analyzer, ); } @@ -289,7 +289,7 @@ function (): Generator { $this->verboseLog("Initializing: Complete."); $this->clientStatus('initialized'); return new InitializeResult($serverCapabilities); - } + }, ); } @@ -334,7 +334,7 @@ public function doAnalysis(): void $all_file_paths_to_analyze = array_keys($all_files_to_analyze); $codebase->analyzer->addFilesToAnalyze( - array_combine($all_file_paths_to_analyze, $all_file_paths_to_analyze) + array_combine($all_file_paths_to_analyze, $all_file_paths_to_analyze), ); $codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false); @@ -371,7 +371,7 @@ public function emitIssues(array $uris): void // Language server has 0 based lines and columns, phan has 1-based lines and columns. $range = new Range( new Position($start_line - 1, $start_column - 1), - new Position($end_line - 1, $end_column - 1) + new Position($end_line - 1, $end_column - 1), ); switch ($severity) { case Config::REPORT_INFO: @@ -387,7 +387,7 @@ public function emitIssues(array $uris): void $range, null, $diagnostic_severity, - 'Psalm' + 'Psalm', ); //$code = 'PS' . \str_pad((string) $issue_data->shortcode, 3, "0", \STR_PAD_LEFT); @@ -433,7 +433,7 @@ public function shutdown(): Promise $scanned_files = $codebase->scanner->getScannedFiles(); $codebase->file_reference_provider->updateReferenceCache( $codebase, - $scanned_files + $scanned_files, ); $this->clientStatus('closed'); return new Success(null); @@ -465,7 +465,7 @@ public function verboseLog(string $message, int $type = 4): void try { $this->client->logMessage( '[Psalm ' .PSALM_VERSION. ' - PHP Language Server] ' . $message, - $type + $type, ); } catch (Throwable $err) { // do nothing @@ -489,7 +489,7 @@ private function clientStatus(string $status, ?string $additional_info = null): $this->client->logMessage( $status . (!empty($additional_info) ? ': ' . $additional_info : ''), 3, - 'telemetry/event' + 'telemetry/event', ); } catch (Throwable $err) { // do nothing diff --git a/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php b/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php index b2867d8fa50..66ef9af9d1b 100644 --- a/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php +++ b/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php @@ -66,14 +66,14 @@ function () use ($input): Generator { } $this->emitClose(); - } + }, ); $this->on( 'close', static function () use ($input): void { $input->close(); - } + }, ); } diff --git a/src/Psalm/Internal/LanguageServer/Server/TextDocument.php b/src/Psalm/Internal/LanguageServer/Server/TextDocument.php index 45000fd7105..119e3612e8e 100644 --- a/src/Psalm/Internal/LanguageServer/Server/TextDocument.php +++ b/src/Psalm/Internal/LanguageServer/Server/TextDocument.php @@ -185,9 +185,9 @@ public function definition(TextDocumentIdentifier $textDocument, Position $posit LanguageServer::pathToUri($code_location->file_path), new Range( new Position($code_location->getLineNumber() - 1, $code_location->getColumn() - 1), - new Position($code_location->getEndLineNumber() - 1, $code_location->getEndColumn() - 1) - ) - ) + new Position($code_location->getEndLineNumber() - 1, $code_location->getEndColumn() - 1), + ), + ), ); } @@ -230,7 +230,7 @@ public function hover(TextDocumentIdentifier $textDocument, Position $position): } $contents = new MarkupContent( MarkupKind::MARKDOWN, - $content + $content, ); return new Success(new Hover($contents, $range)); @@ -290,7 +290,7 @@ public function completion(TextDocumentIdentifier $textDocument, Position $posit $completion_items = $this->codebase->getCompletionItemsForPartialSymbol( $recent_type, $offset, - $file_path + $file_path, ); } } else { @@ -360,7 +360,7 @@ public function codeAction(TextDocumentIdentifier $textDocument, Range $range): if ($offsetStart === $issue->from && $offsetEnd === $issue->to) { $snippetRange = new Range( new Position($issue->line_from-1), - new Position($issue->line_to) + new Position($issue->line_to), ); $indentation = ''; @@ -384,16 +384,16 @@ public function codeAction(TextDocumentIdentifier $textDocument, Range $range): "{$indentation}/**\n". "{$indentation} * @psalm-suppress {$issue->type}\n". "{$indentation} */\n". - "{$issue->snippet}\n" - ) - ] + "{$issue->snippet}\n", + ), + ], ]); //Suppress Ability $fixers["suppress.{$issue->type}"] = [ 'title' => "Suppress {$issue->type} for this line", 'kind' => 'quickfix', - 'edit' => $edit + 'edit' => $edit, ]; } } @@ -403,7 +403,7 @@ public function codeAction(TextDocumentIdentifier $textDocument, Range $range): } return new Success( - array_values($fixers) + array_values($fixers), ); } } diff --git a/src/Psalm/Internal/PhpTraverser/CustomTraverser.php b/src/Psalm/Internal/PhpTraverser/CustomTraverser.php index b2ddd40cdb0..0f6279770d6 100644 --- a/src/Psalm/Internal/PhpTraverser/CustomTraverser.php +++ b/src/Psalm/Internal/PhpTraverser/CustomTraverser.php @@ -53,7 +53,7 @@ protected function traverseNode(Node $node): Node break 2; } else { throw new LogicException( - 'enterNode() returned invalid value of type ' . gettype($return) + 'enterNode() returned invalid value of type ' . gettype($return), ); } } @@ -77,11 +77,11 @@ protected function traverseNode(Node $node): Node } elseif (is_array($return)) { throw new LogicException( 'leaveNode() may only return an array ' . - 'if the parent structure is an array' + 'if the parent structure is an array', ); } else { throw new LogicException( - 'leaveNode() returned invalid value of type ' . gettype($return) + 'leaveNode() returned invalid value of type ' . gettype($return), ); } } @@ -117,7 +117,7 @@ protected function traverseArray(array $nodes): array break 2; } else { throw new LogicException( - 'enterNode() returned invalid value of type ' . gettype($return) + 'enterNode() returned invalid value of type ' . gettype($return), ); } } @@ -147,11 +147,11 @@ protected function traverseArray(array $nodes): array } elseif (false === $return) { throw new LogicException( 'bool(false) return from leaveNode() no longer supported. ' . - 'Return NodeTraverser::REMOVE_NODE instead' + 'Return NodeTraverser::REMOVE_NODE instead', ); } else { throw new LogicException( - 'leaveNode() returned invalid value of type ' . gettype($return) + 'leaveNode() returned invalid value of type ' . gettype($return), ); } } diff --git a/src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php b/src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php index 61ecd73f45c..2f6e1567d1d 100644 --- a/src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php @@ -41,13 +41,13 @@ public function enterNode(PhpParser\Node $node): ?int $new_comments[] = new PhpParser\Comment\Doc( $c->getText(), $c->getStartLine() + $this->line_offset, - $c->getStartFilePos() + $this->file_offset + ($this->extra_offsets[$c->getStartFilePos()] ?? 0) + $c->getStartFilePos() + $this->file_offset + ($this->extra_offsets[$c->getStartFilePos()] ?? 0), ); } else { $new_comments[] = new PhpParser\Comment( $c->getText(), $c->getStartLine() + $this->line_offset, - $c->getStartFilePos() + $this->file_offset + ($this->extra_offsets[$c->getStartFilePos()] ?? 0) + $c->getStartFilePos() + $this->file_offset + ($this->extra_offsets[$c->getStartFilePos()] ?? 0), ); } } @@ -57,11 +57,11 @@ public function enterNode(PhpParser\Node $node): ?int $node->setAttribute( 'startFilePos', - $attrs['startFilePos'] + $this->file_offset + ($this->extra_offsets[$attrs['startFilePos']] ?? 0) + $attrs['startFilePos'] + $this->file_offset + ($this->extra_offsets[$attrs['startFilePos']] ?? 0), ); $node->setAttribute( 'endFilePos', - $attrs['endFilePos'] + $this->file_offset + ($this->extra_offsets[$attrs['endFilePos']] ?? 0) + $attrs['endFilePos'] + $this->file_offset + ($this->extra_offsets[$attrs['endFilePos']] ?? 0), ); $node->setAttribute('startLine', $attrs['startLine'] + $this->line_offset); diff --git a/src/Psalm/Internal/PhpVisitor/ParamReplacementVisitor.php b/src/Psalm/Internal/PhpVisitor/ParamReplacementVisitor.php index a16bd0e5415..11f1604b1a4 100644 --- a/src/Psalm/Internal/PhpVisitor/ParamReplacementVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ParamReplacementVisitor.php @@ -40,7 +40,7 @@ public function enterNode(PhpParser\Node $node): ?int $this->replacements[] = new FileManipulation( (int) $node->getAttribute('startFilePos') + 1, (int) $node->getAttribute('endFilePos') + 1, - $this->new_name + $this->new_name, ); } elseif ($node->name === $this->new_name) { if ($this->new_new_name_used) { @@ -51,7 +51,7 @@ public function enterNode(PhpParser\Node $node): ?int $this->replacements[] = new FileManipulation( (int) $node->getAttribute('startFilePos') + 1, (int) $node->getAttribute('endFilePos') + 1, - $this->new_name . '_new' + $this->new_name . '_new', ); $this->new_name_replaced = true; @@ -68,7 +68,7 @@ public function enterNode(PhpParser\Node $node): ?int ) { $parsed_docblock = DocblockParser::parse( $docblock->getText(), - $docblock->getStartFilePos() + $docblock->getStartFilePos(), ); $replaced = false; @@ -86,7 +86,7 @@ public function enterNode(PhpParser\Node $node): ?int $parsed_docblock->tags[$tag_name][$i] = str_replace( '$' . $this->old_name, '$' . $this->new_name, - $tag + $tag, ); $replaced = true; } @@ -100,7 +100,7 @@ public function enterNode(PhpParser\Node $node): ?int $docblock->getStartFilePos() + strlen($docblock->getText()), rtrim($parsed_docblock->render($parsed_docblock->first_line_padding)), false, - false + false, ); } } diff --git a/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php b/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php index 30069b36ed1..d1c09f32478 100644 --- a/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php @@ -149,7 +149,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) $method_contents = substr( $this->b_file_contents, $stmt_start_pos, - $stmt_end_pos - $stmt_start_pos + 1 + $stmt_end_pos - $stmt_start_pos + 1, ); if (!$method_contents) { @@ -189,7 +189,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) '/(->|::)(\n\s*(if|list)\s*\()/', $fake_class, $matches, - PREG_OFFSET_CAPTURE | PREG_SET_ORDER + PREG_OFFSET_CAPTURE | PREG_SET_ORDER, ); foreach ($matches as $match) { @@ -197,7 +197,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) $fake_class, $match[1][0] . ';' . $match[2][0], $match[0][1], - strlen($match[0][0]) + strlen($match[0][0]), ); $extra_characters[] = $match[2][1]; @@ -205,7 +205,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) $replacement_stmts = $this->parser->parse( $fake_class, - $error_handler + $error_handler, ) ?: []; if (!$replacement_stmts @@ -229,7 +229,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) if ($hacky_class_fix !== $fake_class) { $replacement_stmts = $this->parser->parse( $hacky_class_fix, - $error_handler + $error_handler, ) ?: []; } @@ -263,7 +263,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) $position_shifter = new OffsetShifterVisitor( $stmt_start_pos - 15, $current_line, - $extra_offsets + $extra_offsets, ); $renumbering_traverser->addVisitor($position_shifter); $replacement_stmts = $renumbering_traverser->traverse($replacement_stmts); @@ -279,7 +279,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) 'startFilePos' => $stmt_start_pos + $error_attrs['startFilePos'] - 15, 'endFilePos' => $stmt_start_pos + $error_attrs['endFilePos'] - 15, 'startLine' => $error->getStartLine() + $current_line + $line_offset, - ] + ], ); } @@ -311,7 +311,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) $stmt_inner_start_pos = strrpos( $this->a_file_contents, '{', - $stmt_inner_start_pos - $this->a_file_contents_length + $stmt_inner_start_pos - $this->a_file_contents_length, ) + 1; if ($stmt_inner_end_pos < $this->a_file_contents_length) { @@ -340,13 +340,13 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) $new_comments[] = new PhpParser\Comment\Doc( $c->getText(), $c->getStartLine() + $line_offset, - $c->getStartFilePos() + $start_offset + $c->getStartFilePos() + $start_offset, ); } else { $new_comments[] = new PhpParser\Comment( $c->getText(), $c->getStartLine() + $line_offset, - $c->getStartFilePos() + $start_offset + $c->getStartFilePos() + $start_offset, ); } } diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php index 16668569308..339d86229d0 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php @@ -51,14 +51,14 @@ public static function resolve( $aliases, null, [], - $fq_classlike_name + $fq_classlike_name, ); if (!$const_type) { $const_type = ExpressionResolver::getUnresolvedClassConstExpr( $arg_node->value, $aliases, - $fq_classlike_name + $fq_classlike_name, ); } @@ -69,7 +69,7 @@ public static function resolve( $args[] = new AttributeArg( $key, $const_type, - new CodeLocation($file_scanner, $arg_node->value) + new CodeLocation($file_scanner, $arg_node->value), ); } @@ -77,7 +77,7 @@ public static function resolve( $fq_type_string, $args, new CodeLocation($file_scanner, $stmt), - new CodeLocation($file_scanner, $stmt->name) + new CodeLocation($file_scanner, $stmt->name), ); } } diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php index 43325c41c27..4f9deaaceed 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php @@ -93,7 +93,7 @@ public static function parse( $template_modifier, implode(' ', $template_type), false, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ]; } else { $templates[$template_name][$source_prefix] = [ @@ -101,7 +101,7 @@ public static function parse( null, null, false, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ]; } } @@ -136,7 +136,7 @@ public static function parse( $template_modifier, implode(' ', $template_type), true, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ]; } else { $templates[$template_name][$source_prefix] = [ @@ -144,7 +144,7 @@ public static function parse( null, null, true, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ]; } } @@ -172,7 +172,7 @@ public static function parse( $info->extension_requirement = trim(preg_replace( '@^[ \t]*\*@m', '', - $extension_requirements[array_key_first($extension_requirements)] + $extension_requirements[array_key_first($extension_requirements)], )); } @@ -181,7 +181,7 @@ public static function parse( $info->implementation_requirements[] = trim(preg_replace( '@^[ \t]*\*@m', '', - $implementation_requirement + $implementation_requirement, )); } } @@ -287,11 +287,11 @@ public static function parse( $comment->getText(), "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ), 'start_offset' => $offset, 'end_offset' => $offset + strlen($imported_type_entry), - 'parts' => CommentAnalyzer::splitDocLine($imported_type_entry) + 'parts' => CommentAnalyzer::splitDocLine($imported_type_entry), ]; } @@ -326,7 +326,7 @@ public static function parse( $method_entry = preg_replace( '/array\(([0-9a-zA-Z_\'\" ]+,)*([0-9a-zA-Z_\'\" ]+)\)/', '[]', - $method_entry + $method_entry, ); $end_of_method_regex = '/(?create(); @@ -368,7 +368,7 @@ public static function parse( if (!$has_return) { $docblock_lines[] = '@return ' . TypeParser::getTypeFromTree( $method_tree->children[1], - $codebase + $codebase, )->toNamespacedString($aliases->namespace, $aliases->uses, null, false); } @@ -397,7 +397,7 @@ public static function parse( $param_type = TypeParser::getTypeFromTree($method_tree_child->children[0], $codebase); } catch (Exception $e) { throw new DocblockParseException( - 'Badly-formatted @method string ' . $method_entry . ' - ' . $e + 'Badly-formatted @method string ' . $method_entry . ' - ' . $e, ); } @@ -424,7 +424,7 @@ public static function parse( $statements = StatementsProvider::parseStatements( $php_string, $codebase->analysis_php_version_id, - $has_errors + $has_errors, ); } catch (Exception $e) { throw new DocblockParseException('Badly-formatted @method string ' . $method_entry); @@ -455,10 +455,10 @@ public static function parse( $comment->getText(), "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ), - $node_doc_comment->getStartFilePos() - ) + $node_doc_comment->getStartFilePos(), + ), ); } @@ -537,7 +537,7 @@ protected static function addMagicPropertyToInfo( $comment->getText(), "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ), 'tag' => $property_tag, 'start' => $offset, diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php index 293ea52234c..2b891ea1731 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php @@ -181,8 +181,8 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool . ($duplicate_storage->location ? ' in ' . $duplicate_storage->location->file_path : ''), - $name_location - ) + $name_location, + ), ); $this->file_storage->has_visitor_issues = true; @@ -233,8 +233,8 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool IssueBuffer::maybeAdd( new ParseError( 'Class name ' . $class_name . ' clashes with a use statement alias', - $name_location ?? $class_location - ) + $name_location ?? $class_location, + ), ); $storage->has_visitor_issues = true; @@ -261,7 +261,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $parent_fqcln = $this->codebase->classlikes->getUnAliasedName($parent_fqcln); $this->codebase->scanner->queueClassLikeForScanning( $parent_fqcln, - $this->file_scanner->will_analyze + $this->file_scanner->will_analyze, ); $parent_fqcln_lc = strtolower($parent_fqcln); $storage->parent_class = $parent_fqcln; @@ -298,7 +298,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $storage->appearing_method_ids['from'] = $storage->declaring_method_ids['from']; $storage->declaring_method_ids['tryfrom'] = new MethodIdentifier( 'BackedEnum', - 'tryfrom' + 'tryfrom', ); $storage->appearing_method_ids['tryfrom'] = $storage->declaring_method_ids['tryfrom']; } else { @@ -306,8 +306,8 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool new InvalidEnumBackingType( 'Enums cannot be backed by ' . $node->scalarType->name . ', string or int expected', new CodeLocation($this->file_scanner, $node->scalarType), - $fq_classlike_name - ) + $fq_classlike_name, + ), ); $this->file_storage->has_visitor_issues = true; $storage->has_visitor_issues = true; @@ -322,7 +322,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $storage->declaring_method_ids['cases'] = new MethodIdentifier( 'UnitEnum', - 'cases' + 'cases', ); $storage->appearing_method_ids['cases'] = $storage->declaring_method_ids['cases']; @@ -349,14 +349,14 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $docblock_info = ClassLikeDocblockParser::parse( $node, $doc_comment, - $this->aliases + $this->aliases, ); $this->type_aliases += $this->getImportedTypeAliases($docblock_info, $fq_classlike_name); } catch (DocblockParseException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $fq_classlike_name, - $name_location ?? $class_location + $name_location ?? $class_location, ); } } @@ -371,7 +371,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $comment, $this->aliases, $this->type_aliases, - $fq_classlike_name + $fq_classlike_name, ); foreach ($type_aliases as $type_alias) { @@ -387,7 +387,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool } catch (DocblockParseException | TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage(), - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); } } @@ -396,7 +396,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool if ($docblock_info->stub_override && !$is_classlike_overridden) { throw new InvalidClasslikeOverrideException( 'Class/interface/trait ' . $fq_classlike_name . ' is marked as stub override,' - . ' but no original counterpart found' + . ' but no original counterpart found', ); } @@ -419,16 +419,16 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $template_map[2], $this->aliases, $storage->template_types, - $this->type_aliases + $this->type_aliases, ), null, $storage->template_types, - $this->type_aliases + $this->type_aliases, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $fq_classlike_name, - $name_location ?? $class_location + $name_location ?? $class_location, ); continue; @@ -440,7 +440,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool } else { $storage->docblock_issues[] = new InvalidDocblock( 'Template missing as type', - $name_location ?? $class_location + $name_location ?? $class_location, ); } } else { @@ -468,7 +468,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $docblock_info->yield, $this->aliases, $storage->template_types, - $this->type_aliases + $this->type_aliases, ); $yield_type = TypeParser::parseTokens( @@ -476,13 +476,13 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool null, $storage->template_types ?: [], $this->type_aliases, - true + true, ); /** @psalm-suppress UnusedMethodCall */ $yield_type->queueClassLikesForScanning( $this->codebase, $this->file_storage, - $storage->template_types ?: [] + $storage->template_types ?: [], ); $storage->yield = $yield_type; @@ -497,11 +497,11 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $docblock_info->extension_requirement, $this->aliases, $this->class_template_types, - $this->type_aliases + $this->type_aliases, ), null, $this->class_template_types, - $this->type_aliases + $this->type_aliases, ); } @@ -511,11 +511,11 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $implementation_requirement, $this->aliases, $this->class_template_types, - $this->type_aliases + $this->type_aliases, ), null, $this->class_template_types, - $this->type_aliases + $this->type_aliases, ); } @@ -528,7 +528,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $property['type'], $this->aliases, $this->class_template_types, - $this->type_aliases + $this->type_aliases, ); try { @@ -537,13 +537,13 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool null, $this->class_template_types, $this->type_aliases, - true + true, ); /** @psalm-suppress UnusedMethodCall */ $pseudo_property_type->queueClassLikesForScanning( $this->codebase, $this->file_storage, - $storage->template_types ?: [] + $storage->template_types ?: [], ); if ($property['tag'] !== 'property-read' && $property['tag'] !== 'psalm-property-read') { @@ -556,7 +556,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $fq_classlike_name, - $name_location ?? $class_location + $name_location ?? $class_location, ); } } @@ -572,7 +572,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $this->aliases, $this->type_aliases, $this->storage, - [] + [], ); /** @var MethodStorage */ @@ -585,7 +585,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $storage->pseudo_methods[$lc_method_name] = $pseudo_method_storage; $storage->declaring_pseudo_method_ids[$lc_method_name] = new MethodIdentifier( $fq_classlike_name, - $lc_method_name + $lc_method_name, ); } @@ -634,19 +634,19 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $this->aliases, $this->class_template_types, $this->type_aliases, - $fq_classlike_name + $fq_classlike_name, ), null, $this->class_template_types, $this->type_aliases, - true + true, ); /** @psalm-suppress UnusedMethodCall */ $mixin_type->queueClassLikesForScanning( $this->codebase, $this->file_storage, - $storage->template_types ?: [] + $storage->template_types ?: [], ); if ($mixin_type->isSingle()) { @@ -689,7 +689,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $this->visitEnumDeclaration( $node_stmt, $storage, - $fq_classlike_name + $fq_classlike_name, ); } } @@ -708,7 +708,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool $this->file_storage, $this->aliases, $attr, - $this->storage->name ?? null + $this->storage->name ?? null, ); if ($attribute->fq_class_name === 'Psalm\\Deprecated' @@ -743,7 +743,7 @@ public function finish(PhpParser\Node\Stmt\ClassLike $node): ClassLikeStorage { if (!$this->storage) { throw new UnexpectedValueException( - 'Storage should exist in ' . $this->file_path . ' at ' . $node->getLine() + 'Storage should exist in ' . $this->file_path . ' at ' . $node->getLine(), ); } @@ -781,14 +781,14 @@ public function finish(PhpParser\Node\Stmt\ClassLike $node): ClassLikeStorage null, [], $this->type_aliases, - true + true, ); $converted_aliases[$key] = new ClassTypeAlias(array_values($union->getAtomicTypes())); } catch (Exception $e) { $classlike_storage->docblock_issues[] = new InvalidDocblock( '@psalm-type ' . $key . ' contains invalid references', - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); } } @@ -864,7 +864,7 @@ public function handleTraitUse(PhpParser\Node\Stmt\TraitUse $node): void $this->useTemplatedType( $storage, $node, - trim(preg_replace('@^[ \t]*\*@m', '', $template_line)) + trim(preg_replace('@^[ \t]*\*@m', '', $template_line)), ); } } @@ -876,7 +876,7 @@ public function handleTraitUse(PhpParser\Node\Stmt\TraitUse $node): void ) { $storage->docblock_issues[] = new InvalidDocblock( 'You must use @use or @template-use to parameterize traits', - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); } } @@ -890,7 +890,7 @@ private function extendTemplatedType( if (trim($extended_class_name) === '') { $storage->docblock_issues[] = new InvalidDocblock( 'Extended class cannot be empty in docblock for ' . $storage->name, - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -902,17 +902,17 @@ private function extendTemplatedType( $extended_class_name, $this->aliases, $this->class_template_types, - $this->type_aliases + $this->type_aliases, ), null, $this->class_template_types, $this->type_aliases, - true + true, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $storage->name, - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -921,7 +921,7 @@ private function extendTemplatedType( if (!$extended_union_type->isSingle()) { $storage->docblock_issues[] = new InvalidDocblock( '@template-extends cannot be a union type', - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); } @@ -929,14 +929,14 @@ private function extendTemplatedType( $extended_union_type->queueClassLikesForScanning( $this->codebase, $this->file_storage, - $storage->template_types ?: [] + $storage->template_types ?: [], ); foreach ($extended_union_type->getAtomicTypes() as $atomic_type) { if (!$atomic_type instanceof TGenericObject) { $storage->docblock_issues[] = new InvalidDocblock( '@template-extends has invalid class ' . $atomic_type->getId(), - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -950,7 +950,7 @@ private function extendTemplatedType( $storage->docblock_issues[] = new InvalidDocblock( '@template-extends must include the name of an extended class,' . ' got ' . $atomic_type->getId(), - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); } @@ -974,7 +974,7 @@ private function implementTemplatedType( if (trim($implemented_class_name) === '') { $storage->docblock_issues[] = new InvalidDocblock( 'Extended class cannot be empty in docblock for ' . $storage->name, - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -986,17 +986,17 @@ private function implementTemplatedType( $implemented_class_name, $this->aliases, $this->class_template_types, - $this->type_aliases + $this->type_aliases, ), null, $this->class_template_types, $this->type_aliases, - true + true, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $storage->name, - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1005,7 +1005,7 @@ private function implementTemplatedType( if (!$implemented_union_type->isSingle()) { $storage->docblock_issues[] = new InvalidDocblock( '@template-implements cannot be a union type', - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1015,14 +1015,14 @@ private function implementTemplatedType( $implemented_union_type->queueClassLikesForScanning( $this->codebase, $this->file_storage, - $storage->template_types ?: [] + $storage->template_types ?: [], ); foreach ($implemented_union_type->getAtomicTypes() as $atomic_type) { if (!$atomic_type instanceof TGenericObject) { $storage->docblock_issues[] = new InvalidDocblock( '@template-implements has invalid class ' . $atomic_type->getId(), - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1034,7 +1034,7 @@ private function implementTemplatedType( $storage->docblock_issues[] = new InvalidDocblock( '@template-implements must include the name of an implemented class,' . ' got ' . $atomic_type->getId(), - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1060,7 +1060,7 @@ private function useTemplatedType( if (trim($used_class_name) === '') { $storage->docblock_issues[] = new InvalidDocblock( 'Extended class cannot be empty in docblock for ' . $storage->name, - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1072,17 +1072,17 @@ private function useTemplatedType( $used_class_name, $this->aliases, $this->class_template_types, - $this->type_aliases + $this->type_aliases, ), null, $this->class_template_types, $this->type_aliases, - true + true, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $storage->name, - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1091,7 +1091,7 @@ private function useTemplatedType( if (!$used_union_type->isSingle()) { $storage->docblock_issues[] = new InvalidDocblock( '@template-use cannot be a union type', - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1101,14 +1101,14 @@ private function useTemplatedType( $used_union_type->queueClassLikesForScanning( $this->codebase, $this->file_storage, - $storage->template_types ?: [] + $storage->template_types ?: [], ); foreach ($used_union_type->getAtomicTypes() as $atomic_type) { if (!$atomic_type instanceof TGenericObject) { $storage->docblock_issues[] = new InvalidDocblock( '@template-use has invalid class ' . $atomic_type->getId(), - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1120,7 +1120,7 @@ private function useTemplatedType( $storage->docblock_issues[] = new InvalidDocblock( '@template-use must include the name of an used class,' . ' got ' . $atomic_type->getId(), - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); return; @@ -1156,7 +1156,7 @@ private static function registerEmptyConstructor(ClassLikeStorage $class_storage $class_storage->declaring_method_ids['__construct'] = new MethodIdentifier( $class_storage->name, - '__construct' + '__construct', ); $class_storage->inheritable_method_ids['__construct'] @@ -1196,19 +1196,19 @@ private function visitClassConstDeclaration( $this->file_scanner, $this->aliases, [], - $this->type_aliases + $this->type_aliases, ); $var_comment = array_pop($var_comments); } catch (IncorrectDocblockException $e) { $storage->docblock_issues[] = new MissingDocblockType( $e->getMessage(), - new CodeLocation($this->file_scanner, $stmt, null, true) + new CodeLocation($this->file_scanner, $stmt, null, true), ); } catch (DocblockParseException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage(), - new CodeLocation($this->file_scanner, $stmt, null, true) + new CodeLocation($this->file_scanner, $stmt, null, true), ); } } @@ -1220,7 +1220,7 @@ private function visitClassConstDeclaration( IssueBuffer::maybeAdd(new DuplicateConstant( 'Constant names should be unique', new CodeLocation($this->file_scanner, $const), - $fq_classlike_name + $fq_classlike_name, )); continue; } @@ -1232,7 +1232,7 @@ private function visitClassConstDeclaration( $this->aliases, null, $existing_constants, - $fq_classlike_name + $fq_classlike_name, ); $type_location = null; @@ -1249,7 +1249,7 @@ private function visitClassConstDeclaration( $this->file_scanner, $var_comment->type_start, $var_comment->type_end, - $var_comment->line_number + $var_comment->line_number, ); } } else { @@ -1265,7 +1265,7 @@ private function visitClassConstDeclaration( $this->file_storage, $this->aliases, $attr, - $this->storage->name ?? null + $this->storage->name ?? null, ); } } @@ -1284,7 +1284,7 @@ private function visitClassConstDeclaration( $const->value, $this->aliases, $fq_classlike_name, - $storage->parent_class + $storage->parent_class, ); if ($unresolved_const_expr) { @@ -1303,19 +1303,19 @@ private function visitClassConstDeclaration( : ClassLikeAnalyzer::VISIBILITY_PUBLIC), new CodeLocation( $this->file_scanner, - $const->name + $const->name, ), $type_location, new CodeLocation( $this->file_scanner, - $const + $const, ), $deprecated, $stmt->isFinal(), $unresolved_node, $attributes, $suppressed_issues, - $description + $description, ); if ($exists) { @@ -1333,7 +1333,7 @@ private function visitEnumDeclaration( IssueBuffer::maybeAdd(new DuplicateConstant( 'Constant names should be unique', new CodeLocation($this->file_scanner, $stmt), - $fq_classlike_name + $fq_classlike_name, )); return; } @@ -1350,7 +1350,7 @@ private function visitEnumDeclaration( $this->aliases, $this->file_scanner, $storage->constants, - $fq_classlike_name + $fq_classlike_name, ); if ($case_type) { @@ -1363,8 +1363,8 @@ private function visitEnumDeclaration( new InvalidEnumCaseValue( 'Case of a backed enum should have either string or int value', $case_location, - $fq_classlike_name - ) + $fq_classlike_name, + ), ); } } else { @@ -1376,7 +1376,7 @@ private function visitEnumDeclaration( if (!isset($storage->enum_cases[$stmt->name->name])) { $case = new EnumCaseStorage( $enum_value, - $case_location + $case_location, ); $attrs = $this->getAttributeStorageFromStatement( @@ -1385,7 +1385,7 @@ private function visitEnumDeclaration( $this->file_storage, $this->aliases, $stmt, - $this->storage->name ?? null + $this->storage->name ?? null, ); foreach ($attrs as $attribute) { @@ -1411,8 +1411,8 @@ private function visitEnumDeclaration( new DuplicateEnumCase( 'Enum case names should be unique', $case_location, - $fq_classlike_name - ) + $fq_classlike_name, + ), ); } } @@ -1438,7 +1438,7 @@ private function getAttributeStorageFromStatement( $file_storage, $aliases, $attr, - $fq_classlike_name + $fq_classlike_name, ); } } @@ -1469,7 +1469,7 @@ private function visitPropertyDeclaration( if (preg_match('/[ \t\*]+@property[ \t]+/', (string)$comment)) { $storage->docblock_issues[] = new InvalidDocblock( '@property is valid only in docblocks for class', - new CodeLocation($this->file_scanner, $stmt, null, true) + new CodeLocation($this->file_scanner, $stmt, null, true), ); } @@ -1479,19 +1479,19 @@ private function visitPropertyDeclaration( $this->file_scanner, $this->aliases, !$stmt->isStatic() ? $this->class_template_types : [], - $this->type_aliases + $this->type_aliases, ); $var_comment = array_pop($var_comments); } catch (IncorrectDocblockException $e) { $storage->docblock_issues[] = new MissingDocblockType( $e->getMessage(), - new CodeLocation($this->file_scanner, $stmt, null, true) + new CodeLocation($this->file_scanner, $stmt, null, true), ); } catch (DocblockParseException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage(), - new CodeLocation($this->file_scanner, $stmt, null, true) + new CodeLocation($this->file_scanner, $stmt, null, true), ); } } @@ -1508,7 +1508,7 @@ private function visitPropertyDeclaration( $parser_property_type, null, false, - CodeLocation::FUNCTION_RETURN_TYPE + CodeLocation::FUNCTION_RETURN_TYPE, ); $signature_type = TypeHintResolver::resolve( @@ -1518,7 +1518,7 @@ private function visitPropertyDeclaration( $this->file_storage, $this->storage, $this->aliases, - $this->codebase->analysis_php_version_id + $this->codebase->analysis_php_version_id, ); } @@ -1560,7 +1560,7 @@ private function visitPropertyDeclaration( $this->aliases, null, $existing_constants, - $fq_classlike_name + $fq_classlike_name, ); } @@ -1575,7 +1575,7 @@ private function visitPropertyDeclaration( $this->file_scanner, $var_comment->type_start, $var_comment->type_end, - $var_comment->line_number + $var_comment->line_number, ); } @@ -1649,7 +1649,7 @@ private function visitPropertyDeclaration( $this->file_storage, $this->aliases, $stmt, - $this->storage->name ?? null + $this->storage->name ?? null, ); foreach ($attrs as $attribute) { @@ -1686,7 +1686,7 @@ private function getImportedTypeAliases(ClassLikeDocblockComment $comment, strin $this->file_scanner, $import_type_entry['start_offset'], $import_type_entry['end_offset'], - $import_type_entry['line_number'] + $import_type_entry['line_number'], ); // There are two valid forms: // @psalm-import Thing from Something @@ -1697,7 +1697,7 @@ private function getImportedTypeAliases(ClassLikeDocblockComment $comment, strin 'Invalid import in docblock for ' . $fq_classlike_name . ', expecting " from ",' . ' got "' . implode(' ', $imported_type_data) . '" instead.', - $location + $location, ); continue; } @@ -1714,9 +1714,9 @@ private function getImportedTypeAliases(ClassLikeDocblockComment $comment, strin . ', expecting " from ", got "' . implode( ' ', - [$imported_type_data[0], $imported_type_data[1], $imported_type_data[2]] + [$imported_type_data[0], $imported_type_data[1], $imported_type_data[2]], ) . '" instead.', - $location + $location, ); continue; } @@ -1728,7 +1728,7 @@ private function getImportedTypeAliases(ClassLikeDocblockComment $comment, strin 'Invalid import in docblock for ' . $fq_classlike_name . ', expecting "as ", got "' . $imported_type_data[3] . ' ' . ($imported_type_data[4] ?? '') . '" instead.', - $location + $location, ); continue; } @@ -1738,7 +1738,7 @@ private function getImportedTypeAliases(ClassLikeDocblockComment $comment, strin $declaring_fq_classlike_name = Type::getFQCLNFromString( $declaring_classlike_name, - $this->aliases + $this->aliases, ); $this->codebase->scanner->queueClassLikeForScanning($declaring_fq_classlike_name); @@ -1750,7 +1750,7 @@ private function getImportedTypeAliases(ClassLikeDocblockComment $comment, strin $type_alias_name, $import_type_entry['line_number'], $import_type_entry['start_offset'], - $import_type_entry['end_offset'] + $import_type_entry['end_offset'], ); } @@ -1776,14 +1776,14 @@ public static function getTypeAliasesFromComment( $type_alias_comment_lines = array_merge( $parsed_docblock->tags['phpstan-type'] ?? [], - $parsed_docblock->tags['psalm-type'] ?? [] + $parsed_docblock->tags['psalm-type'] ?? [], ); return self::getTypeAliasesFromCommentLines( $type_alias_comment_lines, $aliases, $type_aliases, - $self_fqcln + $self_fqcln, ); } @@ -1855,7 +1855,7 @@ private static function getTypeAliasesFromCommentLines( $aliases, null, $type_alias_tokens + $type_aliases, - $self_fqcln + $self_fqcln, ); } catch (TypeParseTreeException $e) { throw new DocblockParseException($type_string . ' is not a valid type'); diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php index 11b1e4add92..021b8930895 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php @@ -53,14 +53,14 @@ public static function getUnresolvedClassConstExpr( $stmt->left, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); $right = self::getUnresolvedClassConstExpr( $stmt->right, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); if (!$left || !$right) { @@ -105,7 +105,7 @@ public static function getUnresolvedClassConstExpr( $stmt->cond, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); $if = null; @@ -115,7 +115,7 @@ public static function getUnresolvedClassConstExpr( $stmt->if, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); if ($if === null) { @@ -127,7 +127,7 @@ public static function getUnresolvedClassConstExpr( $stmt->else, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); if ($cond && $else && $if !== false) { @@ -155,7 +155,7 @@ public static function getUnresolvedClassConstExpr( return new Constant( implode('\\', $stmt->name->parts), - $stmt->name instanceof PhpParser\Node\Name\FullyQualified + $stmt->name instanceof PhpParser\Node\Name\FullyQualified, ); } @@ -168,14 +168,14 @@ public static function getUnresolvedClassConstExpr( $stmt->var, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); $right = self::getUnresolvedClassConstExpr( $stmt->dim, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); if ($left && $right) { @@ -199,7 +199,7 @@ public static function getUnresolvedClassConstExpr( } else { $const_fq_class_name = ClassLikeAnalyzer::getFQCLNFromNameObject( $stmt->class, - $aliases + $aliases, ); } } @@ -222,7 +222,7 @@ public static function getUnresolvedClassConstExpr( $stmt->expr, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); if (!$right) { @@ -231,7 +231,7 @@ public static function getUnresolvedClassConstExpr( return new UnresolvedAdditionOp( new ScalarValue(0), - $right + $right, ); } @@ -240,7 +240,7 @@ public static function getUnresolvedClassConstExpr( $stmt->expr, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); if (!$right) { @@ -249,7 +249,7 @@ public static function getUnresolvedClassConstExpr( return new UnresolvedSubtractionOp( new ScalarValue(0), - $right + $right, ); } @@ -266,7 +266,7 @@ public static function getUnresolvedClassConstExpr( $item->key, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); if (!$item_key_type) { @@ -280,7 +280,7 @@ public static function getUnresolvedClassConstExpr( $item->value, $aliases, $fq_classlike_name, - $parent_fq_class_name + $parent_fq_class_name, ); if (!$item_value_type) { @@ -408,7 +408,7 @@ private static function functionEvaluatesToTrue( if ($reflection_class->getFileName() !== $file_path) { $codebase->scanner->queueClassLikeForScanning( - $string_value + $string_value, ); return true; @@ -438,7 +438,7 @@ private static function functionEvaluatesToTrue( if ($reflection_class->getFileName() !== $file_path) { $codebase->scanner->queueClassLikeForScanning( - $string_value + $string_value, ); return true; @@ -470,7 +470,7 @@ private static function functionEvaluatesToTrue( if ($reflection_class->getFileName() !== $file_path) { $codebase->scanner->queueClassLikeForScanning( - $string_value + $string_value, ); return true; diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php index c9a268a260a..d37bd9a9141 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php @@ -51,7 +51,7 @@ public static function scan( $codebase, $file_storage, $node, - $file_scanner->will_analyze + $file_scanner->will_analyze, ); } elseif ($node instanceof PhpParser\Node\Expr\Yield_ || $node instanceof PhpParser\Node\Expr\YieldFrom) { if ($functionlike_storage) { @@ -75,7 +75,7 @@ public static function scan( false, !($node instanceof PhpParser\Node\Expr\ClassConstFetch) || !($node->name instanceof PhpParser\Node\Identifier) - || strtolower($node->name->name) !== 'class' + || strtolower($node->name->name) !== 'class', ); $file_storage->referenced_classlikes[strtolower($fq_classlike_name)] = $fq_classlike_name; } @@ -91,7 +91,7 @@ public static function scan( $function_id, $node, $functionlike_storage, - $skip_if_descendants + $skip_if_descendants, ); } } @@ -118,7 +118,7 @@ private static function registerClassMapFunctionCall( /** @psalm-suppress UnusedMethodCall */ $function_param->type->queueClassLikesForScanning( $codebase, - $file_storage + $file_storage, ); } } @@ -143,7 +143,7 @@ private static function registerClassMapFunctionCall( $first_arg_value, $type_provider, $codebase, - $aliases + $aliases, ); if ($const_name !== null) { @@ -151,7 +151,7 @@ private static function registerClassMapFunctionCall( $codebase, $type_provider, $second_arg_value, - $aliases + $aliases, ) ?? Type::getMixed(); $config = Config::getInstance(); @@ -185,7 +185,7 @@ private static function registerClassMapFunctionCall( ) { $mapping_function_ids = CallAnalyzer::getFunctionIdsFromCallableArg( $file_scanner, - $node_arg_value + $node_arg_value, ); } @@ -198,7 +198,7 @@ private static function registerClassMapFunctionCall( if (!in_array(strtolower($callable_fqcln), ['self', 'parent', 'static'], true)) { $codebase->scanner->queueClassLikeForScanning( - $callable_fqcln + $callable_fqcln, ); } } @@ -218,7 +218,7 @@ private static function registerClassMapFunctionCall( if ($second_arg instanceof PhpParser\Node\Scalar\String_) { $codebase->scanner->queueClassLikeForScanning( - $second_arg->value + $second_arg->value, ); } } @@ -264,7 +264,7 @@ private static function registerClassMapFunctionCall( $codebase->classlikes->addClassAlias( $first_arg_value, - $second_arg_value + $second_arg_value, ); $file_storage->classlike_aliases[$second_arg_value] = $first_arg_value; @@ -282,7 +282,7 @@ public static function visitInclude( if (!$config->allow_includes) { throw new FileIncludeException( - 'File includes are not allowed per your Psalm config - check the allowFileIncludes flag.' + 'File includes are not allowed per your Psalm config - check the allowFileIncludes flag.', ); } @@ -308,7 +308,7 @@ public static function visitInclude( null, null, $file_storage->file_path, - $config + $config, ); } diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockParser.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockParser.php index 6fb676f4bb7..639692a80d9 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockParser.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockParser.php @@ -64,7 +64,7 @@ public static function parse( $parsed_docblock->combined_tags['return'], $info, $code_location, - $cased_function_id + $cased_function_id, ); } @@ -102,7 +102,7 @@ public static function parse( $comment_text, "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ), 'start' => $offset, 'end' => $end, @@ -115,7 +115,7 @@ public static function parse( $info_param['description'] = preg_replace( '/\\n \\*\\s+/um', ' ', - $info_param['description'] + $info_param['description'], ); } @@ -125,8 +125,8 @@ public static function parse( IssueBuffer::maybeAdd( new InvalidDocblock( 'Badly-formatted @param in docblock for ' . $cased_function_id, - $code_location - ) + $code_location, + ), ); } } @@ -167,7 +167,7 @@ public static function parse( $comment_text, "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ), ]; } @@ -175,8 +175,8 @@ public static function parse( IssueBuffer::maybeAdd( new InvalidDocblock( 'Badly-formatted @param in docblock for ' . $cased_function_id, - $code_location - ) + $code_location, + ), ); } } @@ -196,7 +196,7 @@ public static function parse( $comment_text, "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ), ]; } @@ -223,7 +223,7 @@ public static function parse( $comment->getText(), "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ), ]; } @@ -367,7 +367,7 @@ public static function parse( $comment_text, "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ), ]; } @@ -375,8 +375,8 @@ public static function parse( IssueBuffer::maybeAdd( new InvalidDocblock( 'Badly-formatted @param in docblock for ' . $cased_function_id, - $code_location - ) + $code_location, + ), ); } } @@ -427,8 +427,8 @@ public static function parse( $comment->getText(), "\n", 0, - $offset - $comment->getStartFilePos() - ) + $offset - $comment->getStartFilePos(), + ), ]; } } @@ -469,7 +469,7 @@ public static function parse( $template_name, $template_modifier, implode(' ', $template_type), - false + false, ]; } else { $templates[$template_name][$source_prefix] = [$template_name, null, null, false]; @@ -628,7 +628,7 @@ private static function extractReturnType( $comment->getText(), "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ); $info->return_type_start = $offset; $info->return_type_end = $end; @@ -636,8 +636,8 @@ private static function extractReturnType( IssueBuffer::maybeAdd( new InvalidDocblock( 'Badly-formatted @param in docblock for ' . $cased_function_id, - $code_location - ) + $code_location, + ), ); } @@ -703,7 +703,7 @@ private static function checkUnexpectedTags( if (isset($parsed_docblock->tags['psalm-import-type'])) { $info->unexpected_tags['psalm-import-type']['lines'] = self::tagOffsetsToLines( array_keys($parsed_docblock->tags['psalm-import-type']), - $comment + $comment, ); } @@ -711,9 +711,9 @@ private static function checkUnexpectedTags( $info->unexpected_tags['var'] = [ 'lines' => self::tagOffsetsToLines( array_keys($parsed_docblock->combined_tags['var']), - $comment + $comment, ), - 'suggested_replacement' => 'param' + 'suggested_replacement' => 'param', ]; } @@ -721,7 +721,7 @@ private static function checkUnexpectedTags( $info->unexpected_tags['psalm-consistent-constructor'] = [ 'lines' => self::tagOffsetsToLines( array_keys($parsed_docblock->tags['psalm-consistent-constructor']), - $comment + $comment, ), 'suggested_replacement' => 'psalm-consistent-constructor on a class level', ]; @@ -747,7 +747,7 @@ private static function docblockLineNumber(PhpParser\Comment\Doc $comment, int $ $comment->getText(), "\n", 0, - $offset - $comment->getStartFilePos() + $offset - $comment->getStartFilePos(), ); } } diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php index f5f9d6e07f3..e69dbb8449d 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php @@ -164,7 +164,7 @@ public static function addDocblockInfo( if ($docblock_info->stub_override && !$is_functionlike_override) { throw new InvalidMethodOverrideException( 'Method ' . $cased_function_id . ' is marked as stub override,' - . ' but no original counterpart found' + . ' but no original counterpart found', ); } @@ -175,7 +175,7 @@ public static function addDocblockInfo( $file_scanner, $offset, $offset + strlen($throw), - $line + $line, ); foreach (explode('|', $throw) as $throw_class) { @@ -188,7 +188,7 @@ public static function addDocblockInfo( if ($throw_class !== 'self' && $throw_class !== 'static' && $throw_class !== 'parent') { $exception_fqcln = Type::getFQCLNFromString( $throw_class, - $aliases + $aliases, ); } else { $exception_fqcln = $throw_class; @@ -225,7 +225,7 @@ public static function addDocblockInfo( $type_aliases, $file_scanner, $stmt, - $cased_function_id + $cased_function_id, ); } @@ -240,7 +240,7 @@ public static function addDocblockInfo( $class_template_types, $function_template_types, $type_aliases, - $classlike_storage + $classlike_storage, ); foreach ($docblock_info->globals as $global) { @@ -250,14 +250,14 @@ public static function addDocblockInfo( $global['type'], $aliases, null, - $type_aliases + $type_aliases, ), - null + null, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $cased_function_id, - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); continue; @@ -278,14 +278,14 @@ public static function addDocblockInfo( $docblock_info->params, $stmt, $fake_method, - $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null + $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null, ); } if ($storage instanceof MethodStorage) { $storage->has_docblock_param_types = (bool) array_filter( $storage->params, - static fn(FunctionLikeParameter $p): bool => $p->type !== null && $p->has_docblock_type + static fn(FunctionLikeParameter $p): bool => $p->type !== null && $p->has_docblock_type, ); } @@ -301,7 +301,7 @@ public static function addDocblockInfo( $stmt, $storage, $codebase, - $file_storage + $file_storage, ); } @@ -313,11 +313,11 @@ public static function addDocblockInfo( $aliases, $function_template_types + $class_template_types, $type_aliases, - $classlike_storage ? $classlike_storage->name : null + $classlike_storage ? $classlike_storage->name : null, ), null, $function_template_types + $class_template_types, - $type_aliases + $type_aliases, ); $storage->self_out_type = $out_type; } @@ -330,11 +330,11 @@ public static function addDocblockInfo( $aliases, $function_template_types + $class_template_types, $type_aliases, - $classlike_storage ? $classlike_storage->name : null + $classlike_storage ? $classlike_storage->name : null, ), null, $function_template_types + $class_template_types, - $type_aliases + $type_aliases, ); $storage->if_this_is_type = $out_type; } @@ -353,7 +353,7 @@ public static function addDocblockInfo( if ($taint_source_type === 'input') { $storage->taint_source_types = array_merge( $storage->taint_source_types, - TaintKindGroup::ALL_INPUT + TaintKindGroup::ALL_INPUT, ); } else { $storage->taint_source_types[] = $taint_source_type; @@ -376,7 +376,7 @@ public static function addDocblockInfo( $classlike_storage, $cased_function_id, $file_storage, - $file_scanner + $file_scanner, ); } else { $storage->removed_taints[] = $removed_taint; @@ -410,7 +410,7 @@ public static function addDocblockInfo( $type_aliases, $classlike_storage, $cased_function_id, - $file_storage + $file_storage, ); } @@ -443,7 +443,7 @@ private static function getConditionalSanitizedTypeTokens( $aliases, $template_types, $type_aliases, - $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null + $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null, ); $param_type_mapping = []; @@ -481,8 +481,8 @@ private static function getConditionalSanitizedTypeTokens( new TTemplateParam( $template_name, $template_as_type, - $template_function_id - ) + $template_function_id, + ), ]); } } @@ -532,7 +532,7 @@ private static function getConditionalSanitizedTypeTokens( $template_name = 'TPhpVersionId'; $storage->template_types[$template_name] = [ - $template_function_id => Type::getInt() + $template_function_id => Type::getInt(), ]; $function_template_types[$template_name] @@ -610,16 +610,16 @@ private static function getAssertionParts( $type_aliases, $self_fqcln, null, - true + true, ), null, $template_types, - $type_aliases + $type_aliases, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( 'Invalid @psalm-assert union type ' . $e, - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); return null; @@ -630,7 +630,7 @@ private static function getAssertionParts( ) { $storage->docblock_issues[] = new InvalidDocblock( 'Docblock assertions cannot contain | characters together with a prefix', - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); return null; @@ -640,7 +640,7 @@ private static function getAssertionParts( $namespaced_type->queueClassLikesForScanning( $codebase, $file_storage, - $function_template_types + $class_template_types + $function_template_types + $class_template_types, ); $assertion_type_parts = []; @@ -734,7 +734,7 @@ private static function improveParamsFromDocblock( $file_scanner, $docblock_param['start'], $docblock_param['end'], - $docblock_param['line_number'] + $docblock_param['line_number'], ); } else { $docblock_type_location = new CodeLocation( @@ -743,7 +743,7 @@ private static function improveParamsFromDocblock( null, false, CodeLocation::FUNCTION_PHPDOC_METHOD, - null + null, ); } @@ -755,7 +755,7 @@ private static function improveParamsFromDocblock( true, CodeLocation::FUNCTION_PARAM_VAR, null, - $docblock_param['line_number'] + $docblock_param['line_number'], ); $unused_docblock_params[$param_name] = $param_location; @@ -774,7 +774,7 @@ private static function improveParamsFromDocblock( false, false, true, - null + null, ); $storage->addParam($storage_param); @@ -787,17 +787,17 @@ private static function improveParamsFromDocblock( $aliases, $function_template_types + $class_template_types, $type_aliases, - $fq_classlike_name + $fq_classlike_name, ), null, $function_template_types + $class_template_types, $type_aliases, - true + true, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $cased_method_id, - $docblock_type_location + $docblock_type_location, ); continue; @@ -809,7 +809,7 @@ private static function improveParamsFromDocblock( $new_param_type->queueClassLikesForScanning( $codebase, $file_storage, - $storage->template_types ?: [] + $storage->template_types ?: [], ); if ($storage->template_types) { @@ -942,7 +942,7 @@ private static function handleReturn( $file_scanner, $docblock_info->return_type_start, $docblock_info->return_type_end, - $docblock_info->return_type_line_number + $docblock_info->return_type_line_number, ); } else { $storage->return_type_location = new CodeLocation( @@ -956,7 +956,7 @@ private static function handleReturn( $docblock_info->return_type, $docblock_info->return_type_line_number && !$fake_method ? $docblock_info->return_type_line_number - : null + : null, ); } @@ -969,7 +969,7 @@ private static function handleReturn( $storage, $classlike_storage, $cased_function_id, - $function_template_types + $function_template_types, ); $storage->return_type = TypeParser::parseTokens( @@ -977,7 +977,7 @@ private static function handleReturn( null, $function_template_types + $class_template_types, $type_aliases, - true + true, ); if ($storage instanceof MethodStorage) { @@ -1018,7 +1018,7 @@ private static function handleReturn( UnionTypeComparator::isContainedBy( $codebase, $storage->return_type, - $storage->signature_return_type + $storage->signature_return_type, ) ) { $storage->return_type = $storage->return_type->getBuilder()->addType(new TNull())->freeze(); @@ -1031,7 +1031,7 @@ private static function handleReturn( } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $cased_function_id, - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); } @@ -1130,7 +1130,7 @@ private static function handleTaintFlow( $storage->proxy_calls[] = [ 'fqn' => $fully_qualified_name, 'params' => $call_params, - 'return' => isset($flow_parts[1]) && trim($flow_parts[1]) === 'return' + 'return' => isset($flow_parts[1]) && trim($flow_parts[1]) === 'return', ]; } } @@ -1166,14 +1166,14 @@ private static function handleRemovedTaint( $storage, $classlike_storage, $cased_function_id, - $function_template_types + $function_template_types, ); $removed_taint = TypeParser::parseTokens( array_values($fixed_type_tokens), null, $function_template_types + $class_template_types, - $type_aliases + $type_aliases, ); /** @psalm-suppress UnusedMethodCall */ @@ -1189,7 +1189,7 @@ private static function handleRemovedTaint( } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $cased_function_id, - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); } } @@ -1227,7 +1227,7 @@ private static function handleAssertions( $class_template_types, $function_template_types, $type_aliases, - $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null + $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null, ); if (!$assertion_type_parts) { @@ -1238,7 +1238,7 @@ private static function handleAssertions( if ($param->name === $assertion['param_name']) { $storage->assertions[] = new Possibilities( $i, - $assertion_type_parts + $assertion_type_parts, ); continue 2; } @@ -1246,7 +1246,7 @@ private static function handleAssertions( if (strpos($assertion['param_name'], $param->name.'->') === 0) { $storage->assertions[] = new Possibilities( str_replace($param->name, (string) $i, $assertion['param_name']), - $assertion_type_parts + $assertion_type_parts, ); continue 2; } @@ -1254,7 +1254,7 @@ private static function handleAssertions( $storage->assertions[] = new Possibilities( (strpos($assertion['param_name'], '$') === false ? '$' : '') . $assertion['param_name'], - $assertion_type_parts + $assertion_type_parts, ); } } @@ -1274,7 +1274,7 @@ private static function handleAssertions( $class_template_types, $function_template_types, $type_aliases, - $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null + $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null, ); if (!$assertion_type_parts) { @@ -1285,7 +1285,7 @@ private static function handleAssertions( if ($param->name === $assertion['param_name']) { $storage->if_true_assertions[] = new Possibilities( $i, - $assertion_type_parts + $assertion_type_parts, ); continue 2; } @@ -1293,7 +1293,7 @@ private static function handleAssertions( if (strpos($assertion['param_name'], $param->name.'->') === 0) { $storage->if_true_assertions[] = new Possibilities( str_replace($param->name, (string) $i, $assertion['param_name']), - $assertion_type_parts + $assertion_type_parts, ); continue 2; } @@ -1301,7 +1301,7 @@ private static function handleAssertions( $storage->if_true_assertions[] = new Possibilities( (strpos($assertion['param_name'], '$') === false ? '$' : '') . $assertion['param_name'], - $assertion_type_parts + $assertion_type_parts, ); } } @@ -1321,7 +1321,7 @@ private static function handleAssertions( $class_template_types, $function_template_types, $type_aliases, - $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null + $classlike_storage && !$classlike_storage->is_trait ? $classlike_storage->name : null, ); if (!$assertion_type_parts) { @@ -1332,7 +1332,7 @@ private static function handleAssertions( if ($param->name === $assertion['param_name']) { $storage->if_false_assertions[] = new Possibilities( $i, - $assertion_type_parts + $assertion_type_parts, ); continue 2; } @@ -1340,7 +1340,7 @@ private static function handleAssertions( if (strpos($assertion['param_name'], $param->name.'->') === 0) { $storage->if_false_assertions[] = new Possibilities( str_replace($param->name, (string) $i, $assertion['param_name']), - $assertion_type_parts + $assertion_type_parts, ); continue 2; } @@ -1348,7 +1348,7 @@ private static function handleAssertions( $storage->if_false_assertions[] = new Possibilities( (strpos($assertion['param_name'], '$') === false ? '$' : '') . $assertion['param_name'], - $assertion_type_parts + $assertion_type_parts, ); } } @@ -1381,16 +1381,16 @@ private static function handleParamOut( $docblock_param_out['type'], $aliases, $function_template_types + $class_template_types, - $type_aliases + $type_aliases, ), null, $function_template_types + $class_template_types, - $type_aliases + $type_aliases, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $cased_function_id, - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); return; @@ -1400,7 +1400,7 @@ private static function handleParamOut( $out_type->queueClassLikesForScanning( $codebase, $file_storage, - $storage->template_types ?: [] + $storage->template_types ?: [], ); foreach ($storage->params as $param_storage) { @@ -1438,16 +1438,16 @@ private static function handleTemplates( $template_map[2], $aliases, $storage->template_types + ($template_types ?: []), - $type_aliases + $type_aliases, ), null, $storage->template_types + ($template_types ?: []), - $type_aliases + $type_aliases, ); } catch (TypeParseTreeException $e) { $storage->docblock_issues[] = new InvalidDocblock( 'Template ' . $template_name . ' has invalid as type - ' . $e->getMessage(), - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); $template_type = Type::getMixed(); @@ -1455,7 +1455,7 @@ private static function handleTemplates( } else { $storage->docblock_issues[] = new InvalidDocblock( 'Template ' . $template_name . ' missing as type', - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); $template_type = Type::getMixed(); @@ -1468,7 +1468,7 @@ private static function handleTemplates( $storage->docblock_issues[] = new InvalidDocblock( 'Duplicate template param ' . $template_name . ' in docblock for ' . $cased_function_id, - new CodeLocation($file_scanner, $stmt, null, true) + new CodeLocation($file_scanner, $stmt, null, true), ); } else { $storage->template_types[$template_name] = [ @@ -1496,7 +1496,7 @@ private static function handleUnexpectedTags( true, null, null, - $line + $line, ); $message = 'Docblock tag @' . $tag . ' is not recognized in the function docblock ' diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index f6986f2e13f..ef659057ec0 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -145,7 +145,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $classlike_storage, $is_functionlike_override, $method_id, - $is_dupe + $is_dupe, ] = $functionlike_info; if ($is_dupe) { @@ -178,7 +178,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal if ($param->var instanceof PhpParser\Node\Expr\Error) { $storage->docblock_issues[] = new InvalidDocblock( 'Param' . ($i + 1) . ' of ' . $cased_function_id . ' has invalid syntax', - new CodeLocation($this->file_scanner, $param, null, true) + new CodeLocation($this->file_scanner, $param, null, true), ); ++$i; @@ -196,7 +196,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $this->file_storage, $this->aliases, $attr, - $this->classlike_storage->name ?? null + $this->classlike_storage->name ?? null, ); } } @@ -210,7 +210,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal if (isset($existing_params['$' . $param_storage->name])) { $storage->docblock_issues[] = new DuplicateParam( 'Duplicate param $' . $param_storage->name . ' in docblock for ' . $cased_function_id, - new CodeLocation($this->file_scanner, $param, null, true) + new CodeLocation($this->file_scanner, $param, null, true), ); ++$i; @@ -278,7 +278,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $function_stmt->stmts, null, [], - false + false, ); if ($final_actions !== [ScopeAnalyzer::ACTION_END]) { @@ -294,7 +294,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $function_stmt->cond, $this->classlike_storage->name ?? null, $this->file_scanner, - null + null, ); try { @@ -323,12 +323,12 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $var_assertions[] = new Possibilities( $param_offset, - $rule_part + $rule_part, ); } elseif (strpos($var_id, '$this->') === 0) { $var_assertions[] = new Possibilities( $var_id, - $rule_part + $rule_part, ); } } @@ -406,18 +406,18 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $original_type, new CodeLocation( $this->file_scanner, - $original_type + $original_type, ), $this->codebase, $this->file_storage, $this->classlike_storage, $this->aliases, - $this->codebase->analysis_php_version_id + $this->codebase->analysis_php_version_id, ); $storage->return_type_location = new CodeLocation( $this->file_scanner, - $original_type + $original_type, ); if ($stmt->returnsByRef()) { @@ -447,14 +447,14 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal } catch (IncorrectDocblockException $e) { $storage->docblock_issues[] = new MissingDocblockType( $e->getMessage() . ' in docblock for ' . $cased_function_id, - new CodeLocation($this->file_scanner, $stmt, null, true) + new CodeLocation($this->file_scanner, $stmt, null, true), ); $docblock_info = null; } catch (DocblockParseException $e) { $storage->docblock_issues[] = new InvalidDocblock( $e->getMessage() . ' in docblock for ' . $cased_function_id, - new CodeLocation($this->file_scanner, $stmt, null, true) + new CodeLocation($this->file_scanner, $stmt, null, true), ); $docblock_info = null; @@ -482,7 +482,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $docblock_info->templates = []; $storage->docblock_issues[] = new InvalidDocblock( 'Templated closures are not supported', - new CodeLocation($this->file_scanner, $stmt, null, true) + new CodeLocation($this->file_scanner, $stmt, null, true), ); } } @@ -500,7 +500,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $docblock_info, $is_functionlike_override, $fake_method, - $cased_function_id + $cased_function_id, ); } } @@ -578,8 +578,8 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal IssueBuffer::maybeAdd( new ParseError( 'Promoted property ' . $param_storage->name . ' clashes with an existing property', - $param_storage->location - ) + $param_storage->location, + ), ); $storage->has_visitor_issues = true; @@ -597,7 +597,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $this->file_scanner, $this->aliases, $this->existing_function_template_types ?: [], - $this->type_aliases + $this->type_aliases, ); $var_comment = array_pop($var_comments); @@ -615,8 +615,8 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal new InvalidDocblock( 'Param ' . $param_storage->name . ' of ' . $cased_function_id . ' should be documented as a param or a property, not both', - new CodeLocation($this->file_scanner, $param, null, true) - ) + new CodeLocation($this->file_scanner, $param, null, true), + ), )) { return false; } @@ -686,7 +686,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal $this->file_storage, $this->aliases, $attr, - $this->classlike_storage->name ?? null + $this->classlike_storage->name ?? null, ); if ($attribute->fq_class_name === 'Psalm\\Pure' @@ -812,13 +812,13 @@ private function getTranslatedFunctionParam( $param_typehint, new CodeLocation( $this->file_scanner, - $param_typehint + $param_typehint, ), $this->codebase, $this->file_storage, $this->classlike_storage, $this->aliases, - $this->codebase->analysis_php_version_id + $this->codebase->analysis_php_version_id, ); if ($is_nullable) { @@ -844,14 +844,14 @@ private function getTranslatedFunctionParam( $this->aliases, null, null, - $fq_classlike_name + $fq_classlike_name, ); if (!$default_type) { $default_type = ExpressionResolver::getUnresolvedClassConstExpr( $param->default, $this->aliases, - $fq_classlike_name + $fq_classlike_name, ); } } @@ -868,7 +868,7 @@ private function getTranslatedFunctionParam( false, !$fake_method ? CodeLocation::FUNCTION_PARAM_VAR - : CodeLocation::FUNCTION_PHPDOC_METHOD + : CodeLocation::FUNCTION_PHPDOC_METHOD, ), $param_typehint ? new CodeLocation( @@ -876,13 +876,13 @@ private function getTranslatedFunctionParam( $fake_method ? $stmt : $param, null, false, - CodeLocation::FUNCTION_PARAM_TYPE + CodeLocation::FUNCTION_PARAM_TYPE, ) : null, $is_optional, $is_nullable, $param->variadic, - $default_type + $default_type, ); } @@ -935,7 +935,7 @@ private function createStorageForFunctionLike( ) { $this->codebase->functions->addGlobalFunction( $function_id, - $this->file_storage->functions[$function_id] + $this->file_storage->functions[$function_id], ); $storage = $this->storage = $this->file_storage->functions[$function_id]; @@ -960,8 +960,8 @@ private function createStorageForFunctionLike( . ($duplicate_function_storage->location ? ' in ' . $duplicate_function_storage->location->file_path : ''), - new CodeLocation($this->file_scanner, $stmt, null, true) - ) + new CodeLocation($this->file_scanner, $stmt, null, true), + ), ); $this->file_storage->has_visitor_issues = true; @@ -981,8 +981,8 @@ private function createStorageForFunctionLike( IssueBuffer::maybeAdd( new DuplicateFunction( 'Method ' . $function_id . ' has already been defined as a core function', - new CodeLocation($this->file_scanner, $stmt, null, true) - ) + new CodeLocation($this->file_scanner, $stmt, null, true), + ), ); } } @@ -1013,8 +1013,8 @@ private function createStorageForFunctionLike( . ($duplicate_method_storage->location ? ' in ' . $duplicate_method_storage->location->file_path : ''), - new CodeLocation($this->file_scanner, $stmt, null, true) - ) + new CodeLocation($this->file_scanner, $stmt, null, true), + ), ); $this->file_storage->has_visitor_issues = true; @@ -1034,7 +1034,7 @@ private function createStorageForFunctionLike( $docblock_info = FunctionLikeDocblockParser::parse( $doc_comment, $code_location, - $cased_function_id + $cased_function_id, ); } catch (IncorrectDocblockException|DocblockParseException $e) { } @@ -1078,20 +1078,20 @@ private function createStorageForFunctionLike( $fq_classlike_name, '__construct', $fq_classlike_name, - $method_name_lc + $method_name_lc, ); $this->codebase->methods->setAppearingMethodId( $fq_classlike_name, '__construct', $fq_classlike_name, - $method_name_lc + $method_name_lc, ); } $method_id = new MethodIdentifier( $fq_classlike_name, - $method_name_lc + $method_name_lc, ); $storage->is_static = $stmt->isStatic(); @@ -1136,7 +1136,7 @@ private function createStorageForFunctionLike( $classlike_storage, $is_functionlike_override, $method_id, - false + false, ]; } } diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php index 7d422b74260..7ae1e78ee10 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php @@ -52,8 +52,8 @@ public static function resolve( IssueBuffer::maybeAdd( new ParseError( 'Union types are not supported in PHP < 8', - $code_location - ) + $code_location, + ), ); } @@ -65,7 +65,7 @@ public static function resolve( $file_storage, $classlike_storage, $aliases, - $analysis_php_version_id + $analysis_php_version_id, ); $type = Type::combineUnionTypes($resolved_type, $type); @@ -85,8 +85,8 @@ public static function resolve( IssueBuffer::maybeAdd( new ParseError( 'Intersection types are not supported in PHP < 8.1', - $code_location - ) + $code_location, + ), ); } @@ -98,15 +98,15 @@ public static function resolve( $file_storage, $classlike_storage, $aliases, - $analysis_php_version_id + $analysis_php_version_id, ); if ($resolved_type->hasScalarType()) { IssueBuffer::maybeAdd( new ParseError( 'Intersection types cannot contain scalar types', - $code_location - ) + $code_location, + ), ); } @@ -160,7 +160,7 @@ public static function resolve( $type = Type::parseString( $fq_type_string, $analysis_php_version_id, - [] + [], ); if ($type_string) { diff --git a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php index c6c67df44bc..4a4779d39f6 100644 --- a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php @@ -116,7 +116,7 @@ public function enterNode(PhpParser\Node $node): ?int $comment, $this->aliases, $this->type_aliases, - null + null, ); foreach ($type_aliases as $type_alias) { @@ -128,7 +128,7 @@ public function enterNode(PhpParser\Node $node): ?int } catch (DocblockParseException | TypeParseTreeException $e) { $this->file_storage->docblock_issues[] = new InvalidDocblock( $e->getMessage(), - new CodeLocation($this->file_scanner, $node, null, true) + new CodeLocation($this->file_scanner, $node, null, true), ); } } @@ -150,7 +150,7 @@ public function enterNode(PhpParser\Node $node): ?int $this->file_storage, $this->file_scanner, $this->aliases, - $this->namespace_name + $this->namespace_name, ); $this->classlike_node_scanners[] = $classlike_node_scanner; @@ -202,7 +202,7 @@ public function enterNode(PhpParser\Node $node): ?int $this->aliases, $this->type_aliases, $classlike_storage, - $functionlike_types + $functionlike_types, ); $functionlike_node_scanner->start($node); @@ -260,7 +260,7 @@ public function enterNode(PhpParser\Node $node): ?int $this->codebase, new NodeDataProvider(), $const->value, - $this->aliases + $this->aliases, ) ?? Type::getMixed(); $fq_const_name = Type::getFQCLNFromString($const->name->name, $this->aliases); @@ -279,7 +279,7 @@ public function enterNode(PhpParser\Node $node): ?int if (ExpressionResolver::enterConditional( $this->codebase, $this->file_path, - $this->exists_cond_expr + $this->exists_cond_expr, ) === false ) { // the else node should terminate the agreement @@ -295,7 +295,7 @@ public function enterNode(PhpParser\Node $node): ?int && ExpressionResolver::enterConditional( $this->codebase, $this->file_path, - $this->exists_cond_expr + $this->exists_cond_expr, ) === true ) { $this->skip_if_descendants = $node->getLine(); @@ -316,7 +316,7 @@ public function enterNode(PhpParser\Node $node): ?int $this->aliases, $node, $functionlike_storage, - $this->skip_if_descendants + $this->skip_if_descendants, ); } @@ -342,7 +342,7 @@ public function enterNode(PhpParser\Node $node): ?int $this->file_scanner, $this->aliases, $template_types, - $this->type_aliases + $this->type_aliases, ); } catch (DocblockParseException $e) { // do nothing @@ -395,7 +395,7 @@ private function handleNamespace(PhpParser\Node\Stmt\Namespace_ $node): void $this->aliases->constants, $this->aliases->uses_flipped, $this->aliases->functions_flipped, - $this->aliases->constants_flipped + $this->aliases->constants_flipped, ); $this->file_storage->namespace_aliases[(int) $node->getAttribute('startFilePos')] = $this->aliases; @@ -522,7 +522,7 @@ public function leaveNode(PhpParser\Node $node) $classlike_storage, $this, $this->codebase, - [] + [], ); $this->eventDispatcher->dispatchAfterClassLikeVisit($event); @@ -541,7 +541,7 @@ public function leaveNode(PhpParser\Node $node) } throw new UnexpectedValueException( - 'There should be function storages for line ' . $this->file_path . ':' . $node->getLine() + 'There should be function storages for line ' . $this->file_path . ':' . $node->getLine(), ); } @@ -567,7 +567,7 @@ public function leaveNode(PhpParser\Node $node) . $issue_type . ' - ' . $e->getShortLocationWithPrevious() . ':' . $e->code_location->getColumn() - . ' - ' . $message + . ' - ' . $message, ); } } diff --git a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php index be7e6daeb0f..d33c19d64e8 100644 --- a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php +++ b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php @@ -156,7 +156,7 @@ private function addAlias(Stmt\UseUse $use, int $type, ?Name $prefix = null): vo $name, (string) $use->getAlias(), $type, - $use->getAttributes() + $use->getAttributes(), ); } @@ -209,7 +209,7 @@ protected function resolveName(Name $name, int $type): Name $namespaceName = Name\FullyQualified::concat( $this->nameContext->getNamespace(), $name, - $name->getAttributes() + $name->getAttributes(), ); if ($namespaceName instanceof Name) { $name->setAttribute('namespacedName', $namespaceName->toString()); @@ -227,7 +227,7 @@ protected function addNamespacedName(Stmt\Class_ $node): void { $node->setAttribute('namespacedName', Name::concat( $this->nameContext->getNamespace(), - (string)$node->name + (string)$node->name, )); } diff --git a/src/Psalm/Internal/PhpVisitor/YieldTypeCollector.php b/src/Psalm/Internal/PhpVisitor/YieldTypeCollector.php index 0d01a34f970..4d9f075a5e7 100644 --- a/src/Psalm/Internal/PhpVisitor/YieldTypeCollector.php +++ b/src/Psalm/Internal/PhpVisitor/YieldTypeCollector.php @@ -46,8 +46,8 @@ public function enterNode(Node $node): ?int $key_type ? $key_type : Type::getInt(), $value_type, Type::getMixed(), - Type::getMixed() - ] + Type::getMixed(), + ], ); $this->yield_types []= new Union([$generator_type]); diff --git a/src/Psalm/Internal/PluginManager/Command/DisableCommand.php b/src/Psalm/Internal/PluginManager/Command/DisableCommand.php index 380ef4fbd99..c6b5dd1d89e 100644 --- a/src/Psalm/Internal/PluginManager/Command/DisableCommand.php +++ b/src/Psalm/Internal/PluginManager/Command/DisableCommand.php @@ -39,7 +39,7 @@ protected function configure(): void ->addArgument( 'pluginName', InputArgument::REQUIRED, - 'Plugin name (fully qualified class name or composer package name)' + 'Plugin name (fully qualified class name or composer package name)', ) ->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Path to Psalm config file') ->addUsage('vendor/plugin-package-name [-c path/to/psalm.xml]'); diff --git a/src/Psalm/Internal/PluginManager/Command/EnableCommand.php b/src/Psalm/Internal/PluginManager/Command/EnableCommand.php index 4778165a0ab..c520dac31b5 100644 --- a/src/Psalm/Internal/PluginManager/Command/EnableCommand.php +++ b/src/Psalm/Internal/PluginManager/Command/EnableCommand.php @@ -39,7 +39,7 @@ protected function configure(): void ->addArgument( 'pluginName', InputArgument::REQUIRED, - 'Plugin name (fully qualified class name or composer package name)' + 'Plugin name (fully qualified class name or composer package name)', ) ->addOption('config', 'c', InputOption::VALUE_REQUIRED, 'Path to Psalm config file') ->addUsage('vendor/plugin-package-name [-c path/to/psalm.xml]'); diff --git a/src/Psalm/Internal/PluginManager/Command/ShowCommand.php b/src/Psalm/Internal/PluginManager/Command/ShowCommand.php index 6ab5cd5024e..40ac6d0638b 100644 --- a/src/Psalm/Internal/PluginManager/Command/ShowCommand.php +++ b/src/Psalm/Internal/PluginManager/Command/ShowCommand.php @@ -69,8 +69,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int array_map( $formatRow, array_keys($enabled), - array_values($enabled) - ) + array_values($enabled), + ), ); } else { $io->note('No plugins enabled'); @@ -83,8 +83,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int array_map( $formatRow, array_keys($available), - array_values($available) - ) + array_values($available), + ), ); } else { $io->note('No plugins available'); diff --git a/src/Psalm/Internal/PluginManager/ComposerLock.php b/src/Psalm/Internal/PluginManager/ComposerLock.php index 8efe3c5818e..e9c36807c87 100644 --- a/src/Psalm/Internal/PluginManager/ComposerLock.php +++ b/src/Psalm/Internal/PluginManager/ComposerLock.php @@ -105,8 +105,8 @@ private function getAllPackages(): array $packages, array_merge( $composer_lock_contents['packages'], - $composer_lock_contents['packages-dev'] - ) + $composer_lock_contents['packages-dev'], + ), ); } diff --git a/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php b/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php index eb1ed14a5ff..7b03bb3e4e6 100644 --- a/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php +++ b/src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php @@ -166,7 +166,7 @@ private function getCacheLocationForClass( if (mkdir($parser_cache_directory, 0777, true) === false) { // any other error than directory already exists/permissions issue throw new RuntimeException( - 'Failed to create ' . $parser_cache_directory . ' cache directory for unknown reasons' + 'Failed to create ' . $parser_cache_directory . ' cache directory for unknown reasons', ); } } catch (RuntimeException $e) { diff --git a/src/Psalm/Internal/Provider/FileProvider.php b/src/Psalm/Internal/Provider/FileProvider.php index 4b6ec34b234..13fcf572092 100644 --- a/src/Psalm/Internal/Provider/FileProvider.php +++ b/src/Psalm/Internal/Provider/FileProvider.php @@ -134,7 +134,7 @@ public function getFilesInDir(string $dir_path, array $file_extensions, callable $iterator = new RecursiveDirectoryIterator( $dir_path, - FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS + FilesystemIterator::CURRENT_AS_PATHNAME | FilesystemIterator::SKIP_DOTS, ); if ($filter !== null) { @@ -149,7 +149,7 @@ static function (string $current, $_, RecursiveIterator $iterator) use ($filter) } return $filter($path); - } + }, ); } diff --git a/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php b/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php index 3ec71a97fbd..9f469a08ed2 100644 --- a/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php +++ b/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php @@ -941,12 +941,12 @@ public function getTypeCoverage() if ($this->config->use_igbinary) { /** @var array */ $type_coverage_cache = igbinary_unserialize( - Providers::safeFileGetContents($type_coverage_cache_location) + Providers::safeFileGetContents($type_coverage_cache_location), ); } else { /** @var array */ $type_coverage_cache = unserialize( - Providers::safeFileGetContents($type_coverage_cache_location) + Providers::safeFileGetContents($type_coverage_cache_location), ); } @@ -1009,7 +1009,7 @@ public function setConfigHashCache(string $hash = ''): void if (mkdir($cache_directory, 0777, true) === false) { // any other error than directory already exists/permissions issue throw new RuntimeException( - 'Failed to create ' . $cache_directory . ' cache directory for unknown reasons' + 'Failed to create ' . $cache_directory . ' cache directory for unknown reasons', ); } } catch (RuntimeException $e) { @@ -1027,7 +1027,7 @@ public function setConfigHashCache(string $hash = ''): void file_put_contents( $config_hash_cache_location, $hash, - LOCK_EX + LOCK_EX, ); } } diff --git a/src/Psalm/Internal/Provider/FileReferenceProvider.php b/src/Psalm/Internal/Provider/FileReferenceProvider.php index 5c79ebc0063..459447bbb94 100644 --- a/src/Psalm/Internal/Provider/FileReferenceProvider.php +++ b/src/Psalm/Internal/Provider/FileReferenceProvider.php @@ -211,7 +211,7 @@ public function addNonMethodReferencesToClasses(array $references): void if (isset(self::$nonmethod_references_to_classes[$key])) { self::$nonmethod_references_to_classes[$key] = array_merge( $reference, - self::$nonmethod_references_to_classes[$key] + self::$nonmethod_references_to_classes[$key], ); } else { self::$nonmethod_references_to_classes[$key] = $reference; @@ -290,7 +290,7 @@ public function addFileReferencesToClassMembers(array $references): void if (isset(self::$file_references_to_class_members[$key])) { self::$file_references_to_class_members[$key] = array_merge( $reference, - self::$file_references_to_class_members[$key] + self::$file_references_to_class_members[$key], ); } else { self::$file_references_to_class_members[$key] = $reference; @@ -307,7 +307,7 @@ public function addFileReferencesToClassProperties(array $references): void if (isset(self::$file_references_to_class_properties[$key])) { self::$file_references_to_class_properties[$key] = array_merge( $reference, - self::$file_references_to_class_properties[$key] + self::$file_references_to_class_properties[$key], ); } else { self::$file_references_to_class_properties[$key] = $reference; @@ -324,7 +324,7 @@ public function addFileReferencesToMethodReturns(array $references): void if (isset(self::$file_references_to_method_returns[$key])) { self::$file_references_to_method_returns[$key] = array_merge( $reference, - self::$file_references_to_method_returns[$key] + self::$file_references_to_method_returns[$key], ); } else { self::$file_references_to_method_returns[$key] = $reference; @@ -341,7 +341,7 @@ public function addFileReferencesToMissingClassMembers(array $references): void if (isset(self::$file_references_to_missing_class_members[$key])) { self::$file_references_to_missing_class_members[$key] = array_merge( $reference, - self::$file_references_to_missing_class_members[$key] + self::$file_references_to_missing_class_members[$key], ); } else { self::$file_references_to_missing_class_members[$key] = $reference; @@ -408,7 +408,7 @@ private function calculateFilesInheritingFile(Codebase $codebase, string $file): if (isset(self::$files_inheriting_classes[$file_class_lc])) { $referenced_files = [ ...$referenced_files, - ...array_keys(self::$files_inheriting_classes[$file_class_lc]) + ...array_keys(self::$files_inheriting_classes[$file_class_lc]), ]; } } @@ -680,15 +680,15 @@ public function updateReferenceCache(Codebase $codebase, array $visited_files): $all_file_references = array_unique( array_merge( self::$file_references[$file]['a'] ?? [], - $this->calculateFilesReferencingFile($codebase, $file) - ) + $this->calculateFilesReferencingFile($codebase, $file), + ), ); $inheritance_references = array_unique( array_merge( self::$file_references[$file]['i'] ?? [], - $this->calculateFilesInheritingFile($codebase, $file) - ) + $this->calculateFilesInheritingFile($codebase, $file), + ), ); self::$file_references[$file] = [ @@ -906,7 +906,7 @@ public function addMethodReferencesToClassMembers(array $references): void if (isset(self::$method_references_to_class_members[$key])) { self::$method_references_to_class_members[$key] = array_merge( $reference, - self::$method_references_to_class_members[$key] + self::$method_references_to_class_members[$key], ); } else { self::$method_references_to_class_members[$key] = $reference; @@ -923,7 +923,7 @@ public function addMethodDependencies(array $references): void if (isset(self::$method_dependencies[$key])) { self::$method_dependencies[$key] = array_merge( $reference, - self::$method_dependencies[$key] + self::$method_dependencies[$key], ); } else { self::$method_dependencies[$key] = $reference; @@ -940,7 +940,7 @@ public function addMethodReferencesToClassProperties(array $references): void if (isset(self::$method_references_to_class_properties[$key])) { self::$method_references_to_class_properties[$key] = array_merge( $reference, - self::$method_references_to_class_properties[$key] + self::$method_references_to_class_properties[$key], ); } else { self::$method_references_to_class_properties[$key] = $reference; @@ -957,7 +957,7 @@ public function addMethodReferencesToMethodReturns(array $references): void if (isset(self::$method_references_to_method_returns[$key])) { self::$method_references_to_method_returns[$key] = array_merge( $reference, - self::$method_references_to_method_returns[$key] + self::$method_references_to_method_returns[$key], ); } else { self::$method_references_to_method_returns[$key] = $reference; @@ -974,7 +974,7 @@ public function addMethodReferencesToClasses(array $references): void if (isset(self::$method_references_to_classes[$key])) { self::$method_references_to_classes[$key] = array_merge( $reference, - self::$method_references_to_classes[$key] + self::$method_references_to_classes[$key], ); } else { self::$method_references_to_classes[$key] = $reference; @@ -991,7 +991,7 @@ public function addMethodReferencesToMissingClassMembers(array $references): voi if (isset(self::$method_references_to_missing_class_members[$key])) { self::$method_references_to_missing_class_members[$key] = array_merge( $reference, - self::$method_references_to_missing_class_members[$key] + self::$method_references_to_missing_class_members[$key], ); } else { self::$method_references_to_missing_class_members[$key] = $reference; @@ -1010,7 +1010,7 @@ public function addMethodParamUses(array $references): void if (isset(self::$method_param_uses[$method_id][$offset])) { self::$method_param_uses[$method_id][$offset] = array_merge( self::$method_param_uses[$method_id][$offset], - $reference_map + $reference_map, ); } else { self::$method_param_uses[$method_id][$offset] = $reference_map; @@ -1127,7 +1127,7 @@ public function addClassMethodLocations(array $references): void if (isset(self::$class_method_locations[$referenced_member_id])) { self::$class_method_locations[$referenced_member_id] = [ ...self::$class_method_locations[$referenced_member_id], - ...$locations + ...$locations, ]; } else { self::$class_method_locations[$referenced_member_id] = $locations; @@ -1144,7 +1144,7 @@ public function addClassPropertyLocations(array $references): void if (isset(self::$class_property_locations[$referenced_member_id])) { self::$class_property_locations[$referenced_member_id] = [ ...self::$class_property_locations[$referenced_member_id], - ...$locations + ...$locations, ]; } else { self::$class_property_locations[$referenced_member_id] = $locations; @@ -1161,7 +1161,7 @@ public function addClassLocations(array $references): void if (isset(self::$class_locations[$referenced_member_id])) { self::$class_locations[$referenced_member_id] = [ ...self::$class_locations[$referenced_member_id], - ...$locations + ...$locations, ]; } else { self::$class_locations[$referenced_member_id] = $locations; diff --git a/src/Psalm/Internal/Provider/FileStorageCacheProvider.php b/src/Psalm/Internal/Provider/FileStorageCacheProvider.php index 03604f270f1..10f2ef1476e 100644 --- a/src/Psalm/Internal/Provider/FileStorageCacheProvider.php +++ b/src/Psalm/Internal/Provider/FileStorageCacheProvider.php @@ -166,7 +166,7 @@ private function getCacheLocationForPath(string $file_path, bool $create_directo if (mkdir($parser_cache_directory, 0777, true) === false) { // any other error than directory already exists/permissions issue throw new RuntimeException( - 'Failed to create ' . $parser_cache_directory . ' cache directory for unknown reasons' + 'Failed to create ' . $parser_cache_directory . ' cache directory for unknown reasons', ); } } catch (RuntimeException $e) { diff --git a/src/Psalm/Internal/Provider/FunctionExistenceProvider.php b/src/Psalm/Internal/Provider/FunctionExistenceProvider.php index 93e2fe53970..a3c2f7e17e5 100644 --- a/src/Psalm/Internal/Provider/FunctionExistenceProvider.php +++ b/src/Psalm/Internal/Provider/FunctionExistenceProvider.php @@ -63,7 +63,7 @@ public function doesFunctionExist( foreach (self::$handlers[strtolower($function_id)] ?? [] as $function_handler) { $event = new FunctionExistenceProviderEvent( $statements_source, - $function_id + $function_id, ); $function_exists = $function_handler($event); diff --git a/src/Psalm/Internal/Provider/FunctionParamsProvider.php b/src/Psalm/Internal/Provider/FunctionParamsProvider.php index 037812ad5b2..cd83b294ac6 100644 --- a/src/Psalm/Internal/Provider/FunctionParamsProvider.php +++ b/src/Psalm/Internal/Provider/FunctionParamsProvider.php @@ -73,7 +73,7 @@ public function getFunctionParams( $function_id, $call_args, $context, - $code_location + $code_location, ); $result = $class_handler($event); diff --git a/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php b/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php index c259752a44d..37bd7befa5b 100644 --- a/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php @@ -151,7 +151,7 @@ public function getReturnType( $function_id, $stmt, $context, - $code_location + $code_location, ); $return_type = $function_handler($event); diff --git a/src/Psalm/Internal/Provider/MethodExistenceProvider.php b/src/Psalm/Internal/Provider/MethodExistenceProvider.php index 136801794cf..6d3b9612980 100644 --- a/src/Psalm/Internal/Provider/MethodExistenceProvider.php +++ b/src/Psalm/Internal/Provider/MethodExistenceProvider.php @@ -64,7 +64,7 @@ public function doesMethodExist( $fq_classlike_name, $method_name_lowercase, $source, - $code_location + $code_location, ); $method_exists = $method_handler($event); diff --git a/src/Psalm/Internal/Provider/MethodParamsProvider.php b/src/Psalm/Internal/Provider/MethodParamsProvider.php index afecba495ba..a8faa312ccd 100644 --- a/src/Psalm/Internal/Provider/MethodParamsProvider.php +++ b/src/Psalm/Internal/Provider/MethodParamsProvider.php @@ -82,7 +82,7 @@ public function getMethodParams( $call_args, $statements_source, $context, - $code_location + $code_location, ); $result = $class_handler($event); diff --git a/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php b/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php index 83912100c12..30985199e9d 100644 --- a/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php @@ -97,7 +97,7 @@ public function getReturnType( $code_location, $template_type_parameters, $called_fq_classlike_name, - $called_method_name ? strtolower($called_method_name) : null + $called_method_name ? strtolower($called_method_name) : null, ); $result = $class_handler($event); diff --git a/src/Psalm/Internal/Provider/MethodVisibilityProvider.php b/src/Psalm/Internal/Provider/MethodVisibilityProvider.php index 9530095fe6e..276de010434 100644 --- a/src/Psalm/Internal/Provider/MethodVisibilityProvider.php +++ b/src/Psalm/Internal/Provider/MethodVisibilityProvider.php @@ -71,7 +71,7 @@ public function isMethodVisible( $fq_classlike_name, $method_name, $context, - $code_location + $code_location, ); $method_visible = $method_handler($event); diff --git a/src/Psalm/Internal/Provider/ParserCacheProvider.php b/src/Psalm/Internal/Provider/ParserCacheProvider.php index df13d799aff..17aa7e5e2a0 100644 --- a/src/Psalm/Internal/Provider/ParserCacheProvider.php +++ b/src/Psalm/Internal/Provider/ParserCacheProvider.php @@ -209,7 +209,7 @@ private function getExistingFileContentHashes(): array if (!is_array($hashes_decoded)) { throw new UnexpectedValueException( - 'File content hashes are of invalid type ' . gettype($hashes_decoded) + 'File content hashes are of invalid type ' . gettype($hashes_decoded), ); } @@ -288,7 +288,7 @@ public function saveFileContentHashes(): void file_put_contents( $file_hashes_path, json_encode($file_content_hashes, JSON_THROW_ON_ERROR), - LOCK_EX + LOCK_EX, ); } @@ -368,7 +368,7 @@ private function getCacheLocationForPath( if (mkdir($parser_cache_directory, 0777, true) === false) { // any other error than directory already exists/permissions issue throw new RuntimeException( - 'Failed to create ' . $parser_cache_directory . ' cache directory for unknown reasons' + 'Failed to create ' . $parser_cache_directory . ' cache directory for unknown reasons', ); } } catch (RuntimeException $e) { diff --git a/src/Psalm/Internal/Provider/PropertyExistenceProvider.php b/src/Psalm/Internal/Provider/PropertyExistenceProvider.php index 785a3913f31..9593ec3d183 100644 --- a/src/Psalm/Internal/Provider/PropertyExistenceProvider.php +++ b/src/Psalm/Internal/Provider/PropertyExistenceProvider.php @@ -73,7 +73,7 @@ public function doesPropertyExist( $read_mode, $source, $context, - $code_location + $code_location, ); $property_exists = $property_handler($event); diff --git a/src/Psalm/Internal/Provider/PropertyTypeProvider.php b/src/Psalm/Internal/Provider/PropertyTypeProvider.php index ba6df03b87f..9fc62b024ac 100644 --- a/src/Psalm/Internal/Provider/PropertyTypeProvider.php +++ b/src/Psalm/Internal/Provider/PropertyTypeProvider.php @@ -78,7 +78,7 @@ public function getPropertyType( $property_name, $read_mode, $source, - $context + $context, ); $property_type = $property_handler($event); diff --git a/src/Psalm/Internal/Provider/PropertyTypeProvider/DomDocumentPropertyTypeProvider.php b/src/Psalm/Internal/Provider/PropertyTypeProvider/DomDocumentPropertyTypeProvider.php index ae6419f83dc..d529abe1850 100644 --- a/src/Psalm/Internal/Provider/PropertyTypeProvider/DomDocumentPropertyTypeProvider.php +++ b/src/Psalm/Internal/Provider/PropertyTypeProvider/DomDocumentPropertyTypeProvider.php @@ -22,7 +22,7 @@ public static function getPropertyType(PropertyTypeProviderEvent $event): ?Union { if (strtolower($event->getPropertyName()) === 'documentelement') { self::$cache ??= new Union([new TNamedObject('DOMElement'), new TNull()], [ - 'ignore_nullable_issues' => true + 'ignore_nullable_issues' => true, ]); return self::$cache; diff --git a/src/Psalm/Internal/Provider/PropertyVisibilityProvider.php b/src/Psalm/Internal/Provider/PropertyVisibilityProvider.php index 58b32ffca78..099bf800733 100644 --- a/src/Psalm/Internal/Provider/PropertyVisibilityProvider.php +++ b/src/Psalm/Internal/Provider/PropertyVisibilityProvider.php @@ -69,7 +69,7 @@ public function isPropertyVisible( $property_name, $read_mode, $context, - $code_location + $code_location, ); $property_visible = $property_handler($event); diff --git a/src/Psalm/Internal/Provider/Providers.php b/src/Psalm/Internal/Provider/Providers.php index 57e0414dffc..57f5f848197 100644 --- a/src/Psalm/Internal/Provider/Providers.php +++ b/src/Psalm/Internal/Provider/Providers.php @@ -49,7 +49,7 @@ public function __construct( $this->statements_provider = new StatementsProvider( $file_provider, $parser_cache_provider, - $file_storage_cache_provider + $file_storage_cache_provider, ); $this->file_reference_provider = new FileReferenceProvider($file_reference_cache_provider); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayChunkReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayChunkReturnTypeProvider.php index b458eeda1d3..5e949bec3e1 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayChunkReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayChunkReturnTypeProvider.php @@ -44,8 +44,8 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev new Union([ $preserve_keys ? new TNonEmptyArray([$array_type->key, $array_type->value]) - : Type::getNonEmptyListAtomic($array_type->value) - ]) + : Type::getNonEmptyListAtomic($array_type->value), + ]), ); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php index a53cd915846..fa3dd6e62ae 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php @@ -96,7 +96,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $property, $statements_source, $context, - $code_location + $code_location, ); if (!$row_shape) { continue; @@ -145,7 +145,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev } $properties[$key] = $result_element_type->setPossiblyUndefined( - $property->possibly_undefined + $property->possibly_undefined, ); if (!$property->possibly_undefined @@ -164,7 +164,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $properties, null, $input_array->fallback_params, - $is_list + $is_list, )]); } } @@ -179,7 +179,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $row_type, $statements_source, $context, - $code_location + $code_location, ); $input_array_not_empty = $input_array instanceof TNonEmptyArray || @@ -239,7 +239,7 @@ private static function getRowShape( $row_type, $statements_source, $context, - $code_location + $code_location, ); } } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayCombineReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayCombineReturnTypeProvider.php index ecaff0a97a2..88125e398e3 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayCombineReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayCombineReturnTypeProvider.php @@ -107,9 +107,9 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev . 'number of elements as the values array ' . $values_type->getId(), $event->getCodeLocation(), - 'array_combine' + 'array_combine', ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); return $statements_source->getCodebase()->analysis_php_version_id >= 8_00_00 ? Type::getNever() @@ -118,7 +118,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $result = array_combine( $keys_array, - $values + $values, ); assert($result !== false); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillKeysReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillKeysReturnTypeProvider.php index 2ca005b4436..c40175a13ea 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillKeysReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillKeysReturnTypeProvider.php @@ -74,14 +74,14 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev return null; } $result[$key] = $second_arg_type->setPossiblyUndefined( - $key_k->possibly_undefined + $key_k->possibly_undefined, ); } return new Union([new TKeyedArray( $result, null, null, - $is_list + $is_list, )]); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php index 5fdda22cde6..f7f0cd248e9 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php @@ -70,7 +70,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $result, null, null, - $is_list + $is_list, )]); } if ($first_arg_type @@ -81,12 +81,12 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev && self::isPositiveNumericType($second_arg_type) ) { return Type::getNonEmptyList( - $value_type_from_third_arg + $value_type_from_third_arg, ); } return Type::getList( - $value_type_from_third_arg + $value_type_from_third_arg, ); } @@ -101,10 +101,10 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev new TNonEmptyArray([ new Union([new TIntRange( $first_arg_type->getSingleIntLiteral()->value, - $second_arg_type->getSingleIntLiteral()->value + $second_arg_type->getSingleIntLiteral()->value, )]), $value_type_from_third_arg, - ]) + ]), ]); } @@ -112,7 +112,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev new TNonEmptyArray([ Type::getInt(), $value_type_from_third_arg, - ]) + ]), ]); } @@ -120,7 +120,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev new TArray([ Type::getInt(), $value_type_from_third_arg, - ]) + ]), ]); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php index 166549f0f9d..4f2a81e1f47 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php @@ -96,12 +96,12 @@ static function ($keyed_type) use ($statements_source, $context) { $context->inside_loop, [], null, - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); return $keyed_type->setPossiblyUndefined(!$prev_keyed_type->isAlwaysTruthy()); }, - $first_arg_array->properties + $first_arg_array->properties, ), static fn($keyed_type) => !$keyed_type->isNever() ); @@ -114,7 +114,7 @@ static function ($keyed_type) use ($statements_source, $context) { $new_properties, null, $first_arg_array->fallback_params, - $first_arg_array->is_list && $had_one + $first_arg_array->is_list && $had_one, )]); } } @@ -128,7 +128,7 @@ static function ($keyed_type) use ($statements_source, $context) { $context->inside_loop, [], null, - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); if ($first_arg_array instanceof TKeyedArray @@ -137,7 +137,7 @@ static function ($keyed_type) use ($statements_source, $context) { && $key_type->getSingleIntLiteral()->value === 0 ) { return Type::getList( - $inner_type + $inner_type, ); } @@ -170,7 +170,7 @@ static function ($keyed_type) use ($statements_source, $context) { ) { $mapping_function_ids = CallAnalyzer::getFunctionIdsFromCallableArg( $statements_source, - $function_call_arg->value + $function_call_arg->value, ); if ($array_arg && $mapping_function_ids) { @@ -184,13 +184,13 @@ static function ($keyed_type) use ($statements_source, $context) { $function_call_arg, array_slice($call_args, 0, 1), $assertions, - $fake_var_discriminator + $fake_var_discriminator, ); $extended_var_id = ExpressionIdentifier::getExtendedVarId( $array_arg, null, - $statements_source + $statements_source, ); $assertion_id = $extended_var_id . "[\$__fake_{$fake_var_discriminator}_offset_var__]"; @@ -212,7 +212,7 @@ static function ($keyed_type) use ($statements_source, $context) { $statements_source, $statements_source->getTemplateTypeMap() ?: [], false, - new CodeLocation($statements_source, $function_call_arg->value) + new CodeLocation($statements_source, $function_call_arg->value), ); if (isset($reconciled_types['$inner_type'])) { @@ -234,9 +234,9 @@ static function ($keyed_type) use ($statements_source, $context) { IssueBuffer::maybeAdd( new InvalidReturnType( 'No return type could be found in the closure passed to array_filter', - $code_location + $code_location, ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); return Type::getArray(); @@ -266,7 +266,7 @@ static function ($keyed_type) use ($statements_source, $context) { $stmt->expr, $context->self, $statements_source, - $codebase + $codebase, ); } catch (ComplicatedExpressionException $e) { $filter_clauses = []; @@ -274,7 +274,7 @@ static function ($keyed_type) use ($statements_source, $context) { $assertions = Algebra::getTruthsFromFormula( $filter_clauses, - $cond_object_id + $cond_object_id, ); if (isset($assertions['$' . $first_param->var->name])) { @@ -292,7 +292,7 @@ static function ($keyed_type) use ($statements_source, $context) { $statements_source, $statements_source->getTemplateTypeMap() ?: [], false, - new CodeLocation($statements_source, $stmt) + new CodeLocation($statements_source, $stmt), ); if (isset($reconciled_types['$inner_type'])) { diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php index 97ed26b650d..92397ebb69f 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php @@ -116,11 +116,11 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev function (array $sub) use ($null) { $sub = array_map( fn(?Union $t) => $t ?? $null, - $sub + $sub, ); return new Union([new TKeyedArray($sub, null, null, true)]); }, - $array_arg_types + $array_arg_types, ); if (!$array_arg_types) { @@ -178,7 +178,7 @@ function (array $sub) use ($null) { ) { $mapping_function_ids = CallAnalyzer::getFunctionIdsFromCallableArg( $statements_source, - $function_call_arg->value + $function_call_arg->value, ); if ($mapping_function_ids) { @@ -187,7 +187,7 @@ function (array $sub) use ($null) { $mapping_function_ids, $context, $function_call_arg, - array_slice($call_args, 1) + array_slice($call_args, 1), ); } @@ -208,7 +208,7 @@ function (array $sub) use ($null) { $fake_method_call = new VirtualStaticCall( $function_call_arg->value->items[0]->value, $function_call_arg->value->items[1]->value->value, - [] + [], ); } } @@ -217,7 +217,7 @@ function (array $sub) use ($null) { $fake_method_return_type = self::executeFakeCall( $statements_source, $fake_method_call, - $context + $context, ); if ($fake_method_return_type) { @@ -233,15 +233,15 @@ function (array $sub) use ($null) { $atomic_type = new TKeyedArray( array_map( static fn(Union $in): Union => $mapping_return_type->setPossiblyUndefined( - $in->possibly_undefined + $in->possibly_undefined, ), - $array_arg_atomic_type->properties + $array_arg_atomic_type->properties, ), null, $array_arg_atomic_type->fallback_params === null ? null : [$array_arg_atomic_type->fallback_params[0], $mapping_return_type], - $array_arg_atomic_type->is_list + $array_arg_atomic_type->is_list, ); return new Union([$atomic_type]); @@ -252,12 +252,12 @@ function (array $sub) use ($null) { ) { if ($array_arg_atomic_type instanceof TKeyedArray && $array_arg_atomic_type->isNonEmpty()) { return Type::getNonEmptyList( - $mapping_return_type + $mapping_return_type, ); } return Type::getList( - $mapping_return_type + $mapping_return_type, ); } @@ -274,7 +274,7 @@ function (array $sub) use ($null) { new TArray([ $generic_key_type, $mapping_return_type, - ]) + ]), ]); } @@ -283,7 +283,7 @@ function (array $sub) use ($null) { new TArray([ $array_arg_type->key ?? Type::getArrayKey(), Type::getMixed(), - ]) + ]), ]) : Type::getList(); } @@ -319,19 +319,19 @@ private static function executeFakeCall( StaticCallAnalyzer::analyze( $statements_analyzer, $fake_call, - $context + $context, ); } elseif ($fake_call instanceof PhpParser\Node\Expr\MethodCall) { MethodCallAnalyzer::analyze( $statements_analyzer, $fake_call, - $context + $context, ); } elseif ($fake_call instanceof PhpParser\Node\Expr\FuncCall) { FunctionCallAnalyzer::analyze( $statements_analyzer, $fake_call, - $context + $context, ); } else { throw new UnexpectedValueException('UnrecognizedCall'); @@ -344,7 +344,7 @@ private static function executeFakeCall( $fake_call, null, $statements_analyzer, - $codebase + $codebase, ); $assertions = $anded_assertions[0] ?? []; @@ -406,13 +406,13 @@ public static function getReturnTypeFromMappingIds( $array_arg->value, new VirtualVariable( "__fake_{$fake_var_discriminator}_offset_var__", - $array_arg->value->getAttributes() + $array_arg->value->getAttributes(), ), - $array_arg->value->getAttributes() + $array_arg->value->getAttributes(), ), false, false, - $array_arg->getAttributes() + $array_arg->getAttributes(), ); } @@ -431,14 +431,14 @@ public static function getReturnTypeFromMappingIds( $fake_method_call = new VirtualMethodCall( new VirtualVariable( "__fake_{$fake_var_discriminator}_method_call_var__", - $function_call_arg->getAttributes() + $function_call_arg->getAttributes(), ), new VirtualIdentifier( $callable_method_name, - $function_call_arg->getAttributes() + $function_call_arg->getAttributes(), ), $fake_args, - $function_call_arg->getAttributes() + $function_call_arg->getAttributes(), ); $lhs_instance_type = null; @@ -463,14 +463,14 @@ public static function getReturnTypeFromMappingIds( $fake_method_call = new VirtualStaticCall( new VirtualFullyQualified( $callable_fq_class_name, - $function_call_arg->getAttributes() + $function_call_arg->getAttributes(), ), new VirtualIdentifier( $callable_method_name, - $function_call_arg->getAttributes() + $function_call_arg->getAttributes(), ), $fake_args, - $function_call_arg->getAttributes() + $function_call_arg->getAttributes(), ); $context->vars_in_scope["\$__fake_{$fake_var_discriminator}_offset_var__"] = Type::getMixed(); @@ -480,7 +480,7 @@ public static function getReturnTypeFromMappingIds( $statements_source, $fake_method_call, $context, - $assertions + $assertions, ); $function_id_return_type = $fake_method_return_type ?? Type::getMixed(); @@ -488,10 +488,10 @@ public static function getReturnTypeFromMappingIds( $fake_function_call = new VirtualFuncCall( new VirtualFullyQualified( $mapping_function_id_part, - $function_call_arg->getAttributes() + $function_call_arg->getAttributes(), ), $fake_args, - $function_call_arg->getAttributes() + $function_call_arg->getAttributes(), ); $context->vars_in_scope["\$__fake_{$fake_var_discriminator}_offset_var__"] = Type::getMixed(); @@ -500,7 +500,7 @@ public static function getReturnTypeFromMappingIds( $statements_source, $fake_function_call, $context, - $assertions + $assertions, ); $function_id_return_type = $fake_function_return_type ?? Type::getMixed(); @@ -516,7 +516,7 @@ public static function getReturnTypeFromMappingIds( $mapping_return_type = Type::combineUnionTypes( $function_id_return_type, $mapping_return_type, - $codebase + $codebase, ); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php index e66ed4a5c4f..4b369b193a3 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php @@ -102,7 +102,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev if ($unpacked_type_part instanceof TKeyedArray) { $max_keyed_array_size = max( $max_keyed_array_size, - count($unpacked_type_part->properties) + count($unpacked_type_part->properties), ); $added_inner_values = false; @@ -117,7 +117,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $added_inner_values = true; $inner_value_types = array_merge( $inner_value_types, - array_values($type->getAtomicTypes()) + array_values($type->getAtomicTypes()), ); } else { $generic_properties[] = $type; @@ -149,7 +149,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev false, true, 500, - $was_possibly_undefined + $was_possibly_undefined, ); } } @@ -167,11 +167,11 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $all_keyed_arrays = false; $inner_value_types = array_merge( $inner_value_types, - array_values($unpacked_type_part->fallback_params[1]->getAtomicTypes()) + array_values($unpacked_type_part->fallback_params[1]->getAtomicTypes()), ); $inner_key_types = array_merge( $inner_key_types, - array_values($unpacked_type_part->fallback_params[0]->getAtomicTypes()) + array_values($unpacked_type_part->fallback_params[0]->getAtomicTypes()), ); } @@ -196,7 +196,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $generic_properties[$key] = Type::combineUnionTypes( $keyed_type, $unpacked_type_part->type_params[1], - $codebase + $codebase, ); } @@ -216,11 +216,11 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $inner_key_types = array_merge( $inner_key_types, - array_values($unpacked_type_part->type_params[0]->getAtomicTypes()) + array_values($unpacked_type_part->type_params[0]->getAtomicTypes()), ); $inner_value_types = array_merge( $inner_value_types, - array_values($unpacked_type_part->type_params[1]->getAtomicTypes()) + array_values($unpacked_type_part->type_params[1]->getAtomicTypes()), ); } } @@ -250,7 +250,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $all_keyed_arrays || $inner_key_type === null || $inner_value_type === null ? null : [$inner_key_type, $inner_value_type], - $all_nonempty_lists || $all_int_offsets + $all_nonempty_lists || $all_int_offsets, ); return new Union([$objectlike]); @@ -260,7 +260,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev if ($all_int_offsets) { if ($any_nonempty) { return Type::getNonEmptyList( - $inner_value_type + $inner_value_type, ); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPadReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPadReturnTypeProvider.php index bfb014bc020..f818945d779 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPadReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPadReturnTypeProvider.php @@ -60,7 +60,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $can_return_empty ? new TArray([$key_type, $value_type]) : new TNonEmptyArray([$key_type, $value_type]) - ) + ), ]); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php index 88a362586b3..a9421acfa4c 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php @@ -113,7 +113,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $first_arg, null, $value_type, - $temp + $temp, ); return $value_type; diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php index e5ed237844a..9b4ee1dd53d 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php @@ -122,9 +122,9 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev IssueBuffer::maybeAdd( new InvalidArgument( 'The closure passed to array_reduce at least one parameter', - new CodeLocation($statements_source, $function_call_arg) + new CodeLocation($statements_source, $function_call_arg), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); return Type::getMixed(); @@ -138,14 +138,14 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev !UnionTypeComparator::isContainedBy( $codebase, $initial_type, - $carry_param->type + $carry_param->type, ) || ( !$reduce_return_type->hasMixed() && !UnionTypeComparator::isContainedBy( $codebase, $reduce_return_type, - $carry_param->type + $carry_param->type, ) ) ) @@ -155,9 +155,9 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev 'The first param of the closure passed to array_reduce must take ' . $reduce_return_type . ' but only accepts ' . $carry_param->type, $carry_param->type_location - ?: new CodeLocation($statements_source, $function_call_arg) + ?: new CodeLocation($statements_source, $function_call_arg), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); return Type::getMixed(); @@ -170,7 +170,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev && !UnionTypeComparator::isContainedBy( $codebase, $array_arg_atomic_type->type_params[1], - $item_param->type + $item_param->type, ) ) { IssueBuffer::maybeAdd( @@ -178,9 +178,9 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev 'The second param of the closure passed to array_reduce must take ' . $array_arg_atomic_type->type_params[1] . ' but only accepts ' . $item_param->type, $item_param->type_location - ?: new CodeLocation($statements_source, $function_call_arg) + ?: new CodeLocation($statements_source, $function_call_arg), ), - $statements_source->getSuppressedIssues() + $statements_source->getSuppressedIssues(), ); return Type::getMixed(); @@ -196,7 +196,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev ) { $mapping_function_ids = CallAnalyzer::getFunctionIdsFromCallableArg( $statements_source, - $function_call_arg + $function_call_arg, ); $call_map = InternalCallMapHandler::getCallMap(); @@ -214,7 +214,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $reduce_return_type = Type::combineUnionTypes( $reduce_return_type, - $mapped_function_return + $mapped_function_return, ); $part_match_found = true; @@ -240,7 +240,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $method_id = new MethodIdentifier( $callable_fq_class_name, - strtolower($method_name) + strtolower($method_name), ); if (!$codebase->methods->methodExists( @@ -252,10 +252,10 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $codebase->collect_locations ? new CodeLocation( $statements_source, - $function_call_arg + $function_call_arg, ) : null, null, - $statements_source->getFilePath() + $statements_source->getFilePath(), )) { continue; } @@ -266,12 +266,12 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $return_type = $codebase->methods->getMethodReturnType( $method_id, - $self_class + $self_class, ) ?? Type::getMixed(); } else { if (!$codebase->functions->functionExists( $statements_source, - strtolower($mapping_function_id_part) + strtolower($mapping_function_id_part), ) ) { return Type::getMixed(); @@ -281,7 +281,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $function_storage = $codebase->functions->getStorage( $statements_source, - strtolower($mapping_function_id_part) + strtolower($mapping_function_id_part), ); $return_type = $function_storage->return_type ?: Type::getMixed(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php index ecca2e0a764..4a77a7322cb 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php @@ -74,7 +74,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $first_arg_array->properties, null, $first_arg_array->fallback_params, - false + false, )]); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/BasenameReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/BasenameReturnTypeProvider.php index ff399e7cc37..72d54927170 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/BasenameReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/BasenameReturnTypeProvider.php @@ -40,7 +40,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev null, null, $statements_source->getFileName(), - $statements_source->getCodebase()->config + $statements_source->getCodebase()->config, ); if ($evaled_path === null) { diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php index ef2fe97d0c8..9d33e12ef57 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php @@ -45,7 +45,7 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) $atomic_type, null, $source, - true + true, ); if ($candidate_callable) { @@ -53,7 +53,7 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) 'Closure', $candidate_callable->params, $candidate_callable->return_type, - $candidate_callable->is_pure + $candidate_callable->is_pure, ); } else { return Type::getClosure(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/DirnameReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/DirnameReturnTypeProvider.php index e4ea0894c83..c8867999892 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/DirnameReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/DirnameReturnTypeProvider.php @@ -58,7 +58,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev null, null, $statements_source->getFileName(), - $statements_source->getCodebase()->config + $statements_source->getCodebase()->config, ); if ($evaled_path === null) { diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php index b1d51e03961..15512b6382a 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php @@ -42,7 +42,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $inner_type = new Union([ $second_arg_type && $second_arg_type->hasLowercaseString() ? new TLowercaseString() - : new TString + : new TString, ]); $can_return_empty = isset($call_args[2]) @@ -59,7 +59,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev return new Union([ $can_return_empty ? Type::getListAtomic($inner_type) - : Type::getNonEmptyListAtomic($inner_type) + : Type::getNonEmptyListAtomic($inner_type), ]); } @@ -80,10 +80,10 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $can_return_empty ? Type::getListAtomic($inner_type) : Type::getNonEmptyListAtomic($inner_type), - new TFalse + new TFalse, ], [ 'ignore_falsable_issues' => - $statements_source->getCodebase()->config->ignore_internal_falsable_issues + $statements_source->getCodebase()->config->ignore_internal_falsable_issues, ]); } else { $array_type = new Union([ diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php index f2bf6a3975e..cbc06baf8c8 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php @@ -101,7 +101,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev ) { $filter_type = Type::combineUnionTypes( $filter_type, - $options_array->properties['default'] + $options_array->properties['default'], ); } else { $filter_type = $filter_type->getBuilder()->addType(new TFalse)->freeze(); @@ -144,7 +144,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $function_id, $function_id, null, - $code_location + $code_location, ); $statements_source->data_flow_graph->addNode($function_return_sink); @@ -154,7 +154,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $function_id, 0, null, - $code_location + $code_location, ); $statements_source->data_flow_graph->addNode($function_param_sink); @@ -162,7 +162,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $statements_source->data_flow_graph->addPath( $function_param_sink, $function_return_sink, - 'arg' + 'arg', ); return $filter_type->setParentNodes([$function_return_sink->id => $function_return_sink]); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php index f7a5c63104a..25332b58215 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php @@ -42,7 +42,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev } return new Union([new TString, new TNull], [ - 'ignore_nullable_issues' => true + 'ignore_nullable_issues' => true, ]); } } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php index 541aa1a0172..8aae384cc07 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php @@ -89,13 +89,13 @@ public static function getGetObjectVarsReturnType( $statements_source, $location, $statements_source->getSuppressedIssues(), - false + false, ) === true) { $property_type = $codebase->properties->getPropertyType( $property_id, false, $statements_source, - $context + $context, ); if (!$property_type) { continue; @@ -107,7 +107,7 @@ public static function getGetObjectVarsReturnType( $property_type, $object_type, $class_storage, - $class_storage + $class_storage, ) : $property_type ; @@ -150,7 +150,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $first_arg_type, $statements_source, $event->getContext(), - $event->getCodeLocation() + $event->getCodeLocation(), )]); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php index 6884757d358..384f5572658 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php @@ -60,8 +60,8 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) 'r' => new Union([new TIntRange(0, 255)]), 'g' => new Union([new TIntRange(0, 255)]), 'b' => new Union([new TIntRange(0, 255)]), - 'a' => new Union([new TIntRange(0, 1)]) - ]) + 'a' => new Union([new TIntRange(0, 1)]), + ]), ]); } if (isset($formats[1])) { @@ -70,8 +70,8 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) 'r' => Type::getFloat(), 'g' => Type::getFloat(), 'b' => Type::getFloat(), - 'a' => Type::getFloat() - ]) + 'a' => Type::getFloat(), + ]), ]); } if (isset($formats[2])) { @@ -80,8 +80,8 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) 'r' => new Union([new TIntRange(0, 255)]), 'g' => new Union([new TIntRange(0, 255)]), 'b' => new Union([new TIntRange(0, 255)]), - 'a' => new Union([new TIntRange(0, 255)]) - ]) + 'a' => new Union([new TIntRange(0, 255)]), + ]), ]); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/InArrayReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/InArrayReturnTypeProvider.php index c621afe59aa..4e675915e8e 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/InArrayReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/InArrayReturnTypeProvider.php @@ -73,7 +73,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev if (UnionTypeComparator::canExpressionTypesBeIdentical( $event->getStatementsSource()->getCodebase(), $needle_type, - $haystack_item_type + $haystack_item_type, )) { return $bool; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php index 804a695b08a..94167577fb5 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php @@ -64,7 +64,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev && AtomicTypeComparator::isContainedBy( $codebase, $call_arg_atomic_type, - new TIterable([Type::getMixed(), Type::getMixed()]) + new TIterable([Type::getMixed(), Type::getMixed()]), ) ) { $has_valid_iterator = true; @@ -76,7 +76,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $context, $key_type, $value_type, - $has_valid_iterator + $has_valid_iterator, ); } } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php index 92b80af98d6..8eb1b7d2c02 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php @@ -40,7 +40,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $codebase = $statements_source->getCodebase(); return new Union([new TInt, new TFalse], [ - 'ignore_falsable_issues' => $codebase->config->ignore_internal_falsable_issues + 'ignore_falsable_issues' => $codebase->config->ignore_internal_falsable_issues, ]); } } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php index 96373ad09ba..bda2ab4f89e 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php @@ -77,7 +77,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev if (UnionTypeComparator::isContainedBy( $codebase, $component_type, - self::$acceptable_string_component_type + self::$acceptable_string_component_type, )) { self::$nullable_falsable_string ??= new Union([ new TString, @@ -95,7 +95,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev if (UnionTypeComparator::isContainedBy( $codebase, $component_type, - self::$acceptable_int_component_type + self::$acceptable_int_component_type, )) { self::$nullable_falsable_int ??= new Union([ new TInt, @@ -141,18 +141,18 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev 'query', 'fragment', ], - new Union([new TString()], ['possibly_undefined' => true]) + new Union([new TString()], ['possibly_undefined' => true]), ); $component_types['port'] = new Union([new TInt()], ['possibly_undefined' => true]); self::$return_type = new Union([ new TKeyedArray( $component_types, - null + null, ), new TFalse(), ], [ - 'ignore_falsable_issues' => $statements_source->getCodebase()->config->ignore_internal_falsable_issues + 'ignore_falsable_issues' => $statements_source->getCodebase()->config->ignore_internal_falsable_issues, ]); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php index 95f9a944d07..0e09aa85a7c 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php @@ -45,8 +45,8 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) Type::getString(), new Union([ new TScalar(), - new TNull() - ]) + new TNull(), + ]), ]), new TFalse(), ]); @@ -57,8 +57,8 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) Type::getArrayKey(), new Union([ new TScalar(), - new TNull() - ]) + new TNull(), + ]), ]), new TFalse(), ]); @@ -86,8 +86,8 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) Type::getString(), new Union([ new TScalar(), - Type::getListAtomic(Type::getScalar()) - ]) + Type::getListAtomic(Type::getScalar()), + ]), ]), new TFalse(), ]); @@ -97,8 +97,8 @@ public static function getMethodReturnType(MethodReturnTypeProviderEvent $event) Type::getListAtomic( new Union([ new TScalar(), - new TNull() - ]) + new TNull(), + ]), ), new TFalse(), ]); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementSetFetchMode.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementSetFetchMode.php index 75c6d475910..cfb060f8e0c 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementSetFetchMode.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementSetFetchMode.php @@ -38,7 +38,7 @@ public static function getMethodParams(MethodParamsProviderEvent $event): ?array || ExpressionAnalyzer::analyze( $statements_source, $call_args[0]->value, - $context + $context, ) === false ) { return null; @@ -55,7 +55,7 @@ public static function getMethodParams(MethodParamsProviderEvent $event): ?array Type::getInt(), null, null, - false + false, ), ]; @@ -70,7 +70,7 @@ public static function getMethodParams(MethodParamsProviderEvent $event): ?array Type::getInt(), null, null, - false + false, ); break; @@ -82,7 +82,7 @@ public static function getMethodParams(MethodParamsProviderEvent $event): ?array Type::getClassString(), null, null, - false + false, ); $params[] = new FunctionLikeParameter( @@ -92,7 +92,7 @@ public static function getMethodParams(MethodParamsProviderEvent $event): ?array Type::getArray(), null, null, - true + true, ); break; @@ -104,7 +104,7 @@ public static function getMethodParams(MethodParamsProviderEvent $event): ?array Type::getObject(), null, null, - false + false, ); break; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php index 56f202ee2a8..f56f82790d9 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php @@ -67,7 +67,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $function_id, $first_arg->getSingleStringLiteral()->value, $second_arg->getSingleStringLiteral()->value, - $subject_type->getSingleStringLiteral()->value + $subject_type->getSingleStringLiteral()->value, ); $return_type = Type::getString($replaced_string); } @@ -75,7 +75,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $codebase = $statements_source->getCodebase(); $return_type = new Union([new TString, new TNull()], [ - 'ignore_nullable_issues' => $codebase->config->ignore_internal_nullable_issues + 'ignore_nullable_issues' => $codebase->config->ignore_internal_nullable_issues, ]); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php index c5279e01fe8..721afd0713c 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php @@ -45,7 +45,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $function_id, $function_id, null, - $code_location + $code_location, ); $statements_source->data_flow_graph->addNode($function_return_sink); @@ -55,7 +55,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $function_id, $i, null, - $code_location + $code_location, ); $statements_source->data_flow_graph->addNode($function_param_sink); @@ -63,7 +63,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $statements_source->data_flow_graph->addPath( $function_param_sink, $function_return_sink, - 'arg' + 'arg', ); } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php index 82151bd1369..739d254caed 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php @@ -63,7 +63,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev if (UnionTypeComparator::isContainedBy( $codebase, $operator_type, - $acceptable_operator_type + $acceptable_operator_type, )) { return Type::getBool(); } diff --git a/src/Psalm/Internal/Provider/StatementsProvider.php b/src/Psalm/Internal/Provider/StatementsProvider.php index ab8ee607945..6393cd34cb0 100644 --- a/src/Psalm/Internal/Provider/StatementsProvider.php +++ b/src/Psalm/Internal/Provider/StatementsProvider.php @@ -151,7 +151,7 @@ public function getStatementsForFile( $stmts = $this->parser_cache_provider->loadStatementsFromCache( $file_path, $modified_time, - $file_content_hash + $file_content_hash, ); if ($stmts === null) { @@ -168,7 +168,7 @@ public function getStatementsForFile( $file_path, $file_content_hash, $existing_statements, - true + true, ); return $existing_statements; @@ -204,7 +204,7 @@ public function getStatementsForFile( $file_path, $existing_file_contents, $existing_statements_copy, - $file_changes + $file_changes, ); if ($existing_file_contents && $existing_statements && (!$has_errors || $stmts)) { @@ -213,7 +213,7 @@ public function getStatementsForFile( $existing_statements, $stmts, $existing_file_contents, - $file_contents + $file_contents, ); $unchanged_members = array_fill_keys($unchanged_members, true); @@ -230,7 +230,7 @@ static function (string $key) use ($file_path_hash): string { return $key; }, - $changed_members + $changed_members, ); $changed_members = array_fill_keys($changed_members, true); @@ -238,7 +238,7 @@ static function (string $key) use ($file_path_hash): string { if (isset($this->unchanged_members[$file_path])) { $this->unchanged_members[$file_path] = array_intersect_key( $this->unchanged_members[$file_path], - $unchanged_members + $unchanged_members, ); } else { $this->unchanged_members[$file_path] = $unchanged_members; @@ -247,7 +247,7 @@ static function (string $key) use ($file_path_hash): string { if (isset($this->unchanged_signature_members[$file_path])) { $this->unchanged_signature_members[$file_path] = array_intersect_key( $this->unchanged_signature_members[$file_path], - $unchanged_signature_members + $unchanged_signature_members, ); } else { $this->unchanged_signature_members[$file_path] = $unchanged_signature_members; @@ -256,7 +256,7 @@ static function (string $key) use ($file_path_hash): string { if (isset($this->changed_members[$file_path])) { $this->changed_members[$file_path] = array_merge( $this->changed_members[$file_path], - $changed_members + $changed_members, ); } else { $this->changed_members[$file_path] = $changed_members; @@ -430,7 +430,7 @@ public static function parseStatements( $error_handler, $file_changes, $existing_file_contents, - $file_contents + $file_contents, ); $clashing_traverser->addVisitor($offset_analyzer); $clashing_traverser->traverse($existing_statements); @@ -472,9 +472,9 @@ public static function parseStatements( $error, $file_contents, $file_path, - $config->shortenFileName($file_path) - ) - ) + $config->shortenFileName($file_path), + ), + ), ); } } @@ -485,7 +485,7 @@ public static function parseStatements( $resolving_traverser = new PhpParser\NodeTraverser; $name_resolver = new SimpleNameResolver( $error_handler, - $used_cached_statements ? $file_changes : [] + $used_cached_statements ? $file_changes : [], ); $resolving_traverser->addVisitor($name_resolver); $resolving_traverser->traverse($stmts); diff --git a/src/Psalm/Internal/Scanner/FileScanner.php b/src/Psalm/Internal/Scanner/FileScanner.php index 62b17bfc06c..4c1a7033927 100644 --- a/src/Psalm/Internal/Scanner/FileScanner.php +++ b/src/Psalm/Internal/Scanner/FileScanner.php @@ -51,7 +51,7 @@ public function scan( $stmts = $codebase->statements_provider->getStatementsForFile( $file_storage->file_path, $codebase->analysis_php_version_id, - $progress + $progress, ); foreach ($stmts as $stmt) { @@ -73,7 +73,7 @@ public function scan( $traverser = new NodeTraverser(); $traverser->addVisitor( - new ReflectorVisitor($codebase, $this, $file_storage) + new ReflectorVisitor($codebase, $this, $file_storage), ); $traverser->traverse($stmts); diff --git a/src/Psalm/Internal/Scanner/PhpStormMetaScanner.php b/src/Psalm/Internal/Scanner/PhpStormMetaScanner.php index d6a50313832..4ce013ac36c 100644 --- a/src/Psalm/Internal/Scanner/PhpStormMetaScanner.php +++ b/src/Psalm/Internal/Scanner/PhpStormMetaScanner.php @@ -58,7 +58,7 @@ public static function handleOverride(array $args, Codebase $codebase): void && strtolower($array_item->value->name->name) ) { $map[$array_item->key->value] = new Union([ - new TNamedObject(implode('\\', $array_item->value->class->parts)) + new TNamedObject(implode('\\', $array_item->value->class->parts)), ]); } elseif ($array_item->value instanceof PhpParser\Node\Scalar\String_) { $map[$array_item->key->value] = $array_item->value->value; @@ -140,7 +140,7 @@ static function ( if (strpos($mapped_type, '.') === false) { return new Union([ - new TNamedObject($mapped_type) + new TNamedObject($mapped_type), ]); } } @@ -148,7 +148,7 @@ static function ( } return null; - } + }, ); } elseif ($type_offset !== null) { $codebase->methods->return_type_provider->registerClosure( @@ -182,7 +182,7 @@ static function ( } return null; - } + }, ); } elseif ($element_type_offset !== null) { $codebase->methods->return_type_provider->registerClosure( @@ -226,7 +226,7 @@ static function ( } return null; - } + }, ); } } @@ -275,7 +275,7 @@ static function ( if (strpos($mapped_type, '.') === false) { return new Union([ - new TNamedObject($mapped_type) + new TNamedObject($mapped_type), ]); } } @@ -284,11 +284,11 @@ static function ( $storage = $statements_analyzer->getCodebase()->functions->getStorage( $statements_analyzer, - strtolower($function_id) + strtolower($function_id), ); return $storage->return_type ?: Type::getMixed(); - } + }, ); } elseif ($type_offset !== null) { $codebase->functions->return_type_provider->registerClosure( @@ -314,11 +314,11 @@ static function ( $storage = $statements_analyzer->getCodebase()->functions->getStorage( $statements_analyzer, - strtolower($function_id) + strtolower($function_id), ); return $storage->return_type ?: Type::getMixed(); - } + }, ); } elseif ($element_type_offset !== null) { $codebase->functions->return_type_provider->registerClosure( @@ -354,11 +354,11 @@ static function ( $storage = $statements_analyzer->getCodebase()->functions->getStorage( $statements_analyzer, - strtolower($function_id) + strtolower($function_id), ); return $storage->return_type ?: Type::getMixed(); - } + }, ); } } diff --git a/src/Psalm/Internal/Type/ArrayType.php b/src/Psalm/Internal/Type/ArrayType.php index afbce6d2f8f..6d96157067a 100644 --- a/src/Psalm/Internal/Type/ArrayType.php +++ b/src/Psalm/Internal/Type/ArrayType.php @@ -40,7 +40,7 @@ public static function infer(Atomic $type): ?self return new self( $type->getGenericKeyType(), $type->getGenericValueType(), - $type->is_list + $type->is_list, ); } @@ -48,7 +48,7 @@ public static function infer(Atomic $type): ?self return new self( $type->type_params[0], $type->type_params[1], - false + false, ); } diff --git a/src/Psalm/Internal/Type/AssertionReconciler.php b/src/Psalm/Internal/Type/AssertionReconciler.php index 5419b480624..c4bdd29553e 100644 --- a/src/Psalm/Internal/Type/AssertionReconciler.php +++ b/src/Psalm/Internal/Type/AssertionReconciler.php @@ -116,7 +116,7 @@ public static function reconcile( if ($existing_var_type === null) { return self::getMissingType( $assertion, - $inside_loop + $inside_loop, ); } @@ -133,7 +133,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $inside_loop + $inside_loop, ); } @@ -153,7 +153,7 @@ public static function reconcile( $key, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -167,7 +167,7 @@ public static function reconcile( $code_location, $key, $suppressed_issues, - $should_return + $should_return, ); if ($should_return) { @@ -185,7 +185,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $inside_loop + $inside_loop, ); if ($simply_reconciled_type) { @@ -220,7 +220,7 @@ public static function reconcile( $negated, $code_location, $suppressed_issues, - $failed_reconciliation + $failed_reconciliation, ); return TypeExpander::expandUnion( @@ -232,7 +232,7 @@ public static function reconcile( true, false, false, - true + true, ); } @@ -331,7 +331,7 @@ private static function refine( if (AtomicTypeComparator::isContainedBy( $codebase, $existing_var_type_part, - $new_as_atomic + $new_as_atomic, )) { $acceptable_atomic_types[] = $existing_var_type_part; } @@ -354,11 +354,11 @@ private static function refine( if ($existing_var_type_part instanceof TKeyedArray) { if (!array_intersect_key( $existing_var_type_part->properties, - $new_type_part->properties + $new_type_part->properties, )) { $acceptable_atomic_types[] = $existing_var_type_part->setProperties(array_merge( $existing_var_type_part->properties, - $new_type_part->properties + $new_type_part->properties, )); } } @@ -377,7 +377,7 @@ private static function refine( $codebase, new Union([$new_type_part]), $existing_var_type, - false + false, ) ) { $acceptable_atomic_types = []; @@ -386,7 +386,7 @@ private static function refine( if (AtomicTypeComparator::isContainedBy( $codebase, $existing_var_type_part, - $new_type_part + $new_type_part, )) { $acceptable_atomic_types[] = $existing_var_type_part; continue; @@ -427,7 +427,7 @@ private static function refine( false, null, false, - false + false, ) ) { self::triggerIssueForImpossible( @@ -438,7 +438,7 @@ private static function refine( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -446,7 +446,7 @@ private static function refine( $codebase, $existing_var_type, new Union([$new_type_part]), - $any_scalar_type_match_found + $any_scalar_type_match_found, ); if ($code_location @@ -460,9 +460,9 @@ private static function refine( 'Cannot resolve types for ' . $key . ' - docblock-defined type ' . $existing_var_type . ' does not contain null', $code_location, - $existing_var_type->getId() . ' null' + $existing_var_type->getId() . ' null', ), - $suppressed_issues + $suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -470,9 +470,9 @@ private static function refine( 'Cannot resolve types for ' . $key . ' - ' . $existing_var_type . ' does not contain null', $code_location, - $existing_var_type->getId() + $existing_var_type->getId(), ), - $suppressed_issues + $suppressed_issues, ); } } elseif (!($statements_analyzer->getSource()->getSource() instanceof TraitAnalyzer) @@ -486,9 +486,9 @@ private static function refine( 'Cannot resolve types for ' . $key . ' - docblock-defined type ' . $existing_var_type->getId() . ' does not contain ' . $new_type_part->getId(), $code_location, - $existing_var_type->getId() . ' ' . $new_type_part->getId() + $existing_var_type->getId() . ' ' . $new_type_part->getId(), ), - $suppressed_issues + $suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -496,9 +496,9 @@ private static function refine( 'Cannot resolve types for ' . $key . ' - ' . $existing_var_type->getId() . ' does not contain ' . $new_type_part->getId(), $code_location, - $existing_var_type->getId() . ' ' . $new_type_part->getId() + $existing_var_type->getId() . ' ' . $new_type_part->getId(), ), - $suppressed_issues + $suppressed_issues, ); } } @@ -533,7 +533,7 @@ private static function filterTypeWithAnother( $existing_type_part, $new_type_part, $codebase, - $any_scalar_type_match_found + $any_scalar_type_match_found, ); if ($matching_atomic_type) { @@ -576,7 +576,7 @@ private static function filterAtomicWithAnother( $type_1_atomic, !($type_1_atomic instanceof TNamedObject && $type_2_atomic instanceof TNamedObject), false, - $atomic_comparison_results + $atomic_comparison_results, ); if ($atomic_contained_by) { @@ -584,7 +584,7 @@ private static function filterAtomicWithAnother( $type_1_atomic, $type_2_atomic, $codebase, - $atomic_comparison_results->type_coerced ?? false + $atomic_comparison_results->type_coerced ?? false, ); } @@ -596,7 +596,7 @@ private static function filterAtomicWithAnother( $type_2_atomic, $type_1_atomic instanceof TClassString && $type_2_atomic instanceof TClassString, false, - $atomic_comparison_results + $atomic_comparison_results, ); if ($atomic_contained_by) { @@ -604,7 +604,7 @@ private static function filterAtomicWithAnother( $type_2_atomic, $type_1_atomic, $codebase, - $atomic_comparison_results->type_coerced ?? false + $atomic_comparison_results->type_coerced ?? false, ); } @@ -701,7 +701,7 @@ private static function filterAtomicWithAnother( $codebase, $type_1_param, $type_2_param, - $any_scalar_type_match_found + $any_scalar_type_match_found, ); if ($type_2_param === null) { @@ -715,7 +715,7 @@ private static function filterAtomicWithAnother( /** @psalm-suppress InvalidArgument */ $type_1_atomic = $type_1_atomic->setTypeParams( - $type_1_params + $type_1_params, ); $matching_atomic_type = $type_1_atomic; @@ -763,7 +763,7 @@ private static function filterAtomicWithAnother( $codebase, $type_1_param, $type_2_param, - $any_scalar_type_match_found + $any_scalar_type_match_found, ); if ($type_2_param === null) { @@ -787,7 +787,7 @@ private static function filterAtomicWithAnother( ) { $new_range = TIntRange::intersectIntRanges( $type_1_atomic, - $type_2_atomic + $type_2_atomic, ); } @@ -822,7 +822,7 @@ private static function refineContainedAtomicWithAnother( // this is a hack - it's not actually rigorous, as the params may be different return new TGenericObject( $type_2_atomic->value, - $type_1_atomic->type_params + $type_1_atomic->type_params, ); } elseif ($type_2_atomic instanceof TNamedObject && $type_1_atomic instanceof TTemplateParam @@ -832,7 +832,7 @@ private static function refineContainedAtomicWithAnother( $type_1_as = self::filterTypeWithAnother( $codebase, $type_1_as_init, - new Union([$type_2_atomic]) + new Union([$type_2_atomic]), ); if ($type_1_as === null) { @@ -871,7 +871,7 @@ private static function handleLiteralEquality( $existing_var_atomic_type->fq_classlike_name, null, true, - true + true, ); foreach ($expanded as $atomic_type) { @@ -893,7 +893,7 @@ private static function handleLiteralEquality( $var_id, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } elseif ($assertion_type instanceof TLiteralString) { return self::handleLiteralEqualityWithString( @@ -906,7 +906,7 @@ private static function handleLiteralEquality( $var_id, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } elseif ($assertion_type instanceof TLiteralFloat) { return self::handleLiteralEqualityWithFloat( @@ -919,7 +919,7 @@ private static function handleLiteralEquality( $var_id, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } else { $fq_enum_name = $assertion_type->value; @@ -966,7 +966,7 @@ private static function handleLiteralEquality( $can_be_equal, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -994,13 +994,13 @@ private static function handleLiteralEqualityWithInt( // we create the literal that is being asserted. We'll return this when we're sure this is the resulting type $literal_asserted_type = new Union([new TLiteralInt($value)], [ - 'from_docblock' => $existing_var_type->from_docblock + 'from_docblock' => $existing_var_type->from_docblock, ]); $compatible_int_type = self::getCompatibleIntType( $existing_var_type, $existing_var_atomic_types, $assertion_type, - $assertion instanceof IsLooselyEqual + $assertion instanceof IsLooselyEqual, ); if ($compatible_int_type !== null) { @@ -1025,7 +1025,7 @@ private static function handleLiteralEqualityWithInt( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } return $existing_var_type; @@ -1042,7 +1042,7 @@ private static function handleLiteralEqualityWithInt( $existing_var_type, $existing_var_atomic_type->as->getAtomicTypes(), $assertion_type, - $assertion instanceof IsLooselyEqual + $assertion instanceof IsLooselyEqual, ); if ($compatible_int_type !== null) { return $compatible_int_type; @@ -1058,8 +1058,8 @@ private static function handleLiteralEqualityWithInt( $var_id, $negated, $code_location, - $suppressed_issues - ) + $suppressed_issues, + ), ); return new Union([$existing_var_atomic_type]); @@ -1108,7 +1108,7 @@ private static function handleLiteralEqualityWithInt( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1135,14 +1135,14 @@ private static function handleLiteralEqualityWithString( // we create the literal that is being asserted. We'll return this when we're sure this is the resulting type $literal_asserted_type_string = new Union([$assertion_type], [ - 'from_docblock' => $existing_var_type->from_docblock + 'from_docblock' => $existing_var_type->from_docblock, ]); $compatible_string_type = self::getCompatibleStringType( $existing_var_type, $existing_var_atomic_types, $assertion_type, - $assertion instanceof IsLooselyEqual + $assertion instanceof IsLooselyEqual, ); if ($compatible_string_type !== null) { @@ -1163,7 +1163,7 @@ private static function handleLiteralEqualityWithString( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } return $existing_var_type; @@ -1181,7 +1181,7 @@ private static function handleLiteralEqualityWithString( $existing_var_type, $existing_var_atomic_type->as->getAtomicTypes(), $assertion_type, - $assertion instanceof IsLooselyEqual + $assertion instanceof IsLooselyEqual, ); if ($compatible_string_type !== null) { return $compatible_string_type; @@ -1201,8 +1201,8 @@ private static function handleLiteralEqualityWithString( $var_id, $negated, $code_location, - $suppressed_issues - ) + $suppressed_issues, + ), ); return new Union([$existing_var_atomic_type]); @@ -1251,7 +1251,7 @@ private static function handleLiteralEqualityWithString( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1278,14 +1278,14 @@ private static function handleLiteralEqualityWithFloat( // we create the literal that is being asserted. We'll return this when we're sure this is the resulting type $literal_asserted_type = new Union([new TLiteralFloat($value)], [ - 'from_docblock' => $existing_var_type->from_docblock + 'from_docblock' => $existing_var_type->from_docblock, ]); $compatible_float_type = self::getCompatibleFloatType( $existing_var_type, $existing_var_atomic_types, $assertion_type, - $assertion instanceof IsLooselyEqual + $assertion instanceof IsLooselyEqual, ); if ($compatible_float_type !== null) { @@ -1306,7 +1306,7 @@ private static function handleLiteralEqualityWithFloat( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } return $existing_var_type; @@ -1324,7 +1324,7 @@ private static function handleLiteralEqualityWithFloat( $existing_var_type, $existing_var_atomic_type->as->getAtomicTypes(), $assertion_type, - $assertion instanceof IsLooselyEqual + $assertion instanceof IsLooselyEqual, ); if ($compatible_float_type !== null) { return $compatible_float_type; @@ -1344,8 +1344,8 @@ private static function handleLiteralEqualityWithFloat( $var_id, $negated, $code_location, - $suppressed_issues - ) + $suppressed_issues, + ), ); return new Union([$existing_var_atomic_type]); @@ -1393,7 +1393,7 @@ private static function handleLiteralEqualityWithFloat( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1420,7 +1420,7 @@ private static function getCompatibleIntType( } return new Union([$assertion_type], [ - 'from_docblock' => $existing_var_type->from_docblock + 'from_docblock' => $existing_var_type->from_docblock, ]); } } @@ -1447,7 +1447,7 @@ private static function getCompatibleStringType( } return new Union([$assertion_type], [ - 'from_docblock' => $existing_var_type->from_docblock + 'from_docblock' => $existing_var_type->from_docblock, ]); } } @@ -1474,7 +1474,7 @@ private static function getCompatibleFloatType( } return new Union([$assertion_type], [ - 'from_docblock' => $existing_var_type->from_docblock + 'from_docblock' => $existing_var_type->from_docblock, ]); } } @@ -1509,7 +1509,7 @@ private static function handleIsA( if ($allow_string_comparison) { $types[] = new TClassString( $assertion_type->value, - $assertion_type + $assertion_type, ); } @@ -1525,7 +1525,7 @@ private static function handleIsA( return [new TTemplateParam( $assertion_type->param_name, new Union([$assertion_type->as_type ? $assertion_type->as_type : new TObject()]), - $assertion_type->defining_class + $assertion_type->defining_class, )]; } return [$assertion_type]; @@ -1537,9 +1537,9 @@ private static function handleIsA( new TypeDoesNotContainType( 'Cannot allow string comparison to object for ' . $key, $code_location, - "no string comparison to $key" + "no string comparison to $key", ), - $suppressed_issues + $suppressed_issues, ); return [new TMixed()]; @@ -1569,7 +1569,7 @@ private static function handleIsA( && !UnionTypeComparator::isContainedBy( $codebase, $existing_var_type, - $new_type + $new_type, ) ) || ( @@ -1577,7 +1577,7 @@ private static function handleIsA( && !UnionTypeComparator::isContainedBy( $codebase, $new_type, - $existing_var_type + $existing_var_type, ) ) ) { @@ -1603,7 +1603,7 @@ private static function handleIsA( if (AtomicTypeComparator::isContainedBy( $codebase, $existing_var_type_part, - $new_type_part + $new_type_part, )) { $acceptable_atomic_types[] = $existing_var_type_part; continue; diff --git a/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php index 0e0210a1605..7fac7954f14 100644 --- a/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php @@ -34,9 +34,9 @@ public static function isContainedBy( $is_empty_array = $input_type_part->equals( new TArray([ new Union([new TNever()]), - new Union([new TNever()]) + new Union([new TNever()]), ]), - false + false, ); if ($is_empty_array @@ -74,7 +74,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } } @@ -111,14 +111,14 @@ public static function isContainedBy( if ($input_type_part instanceof TClassStringMap) { $input_type_part = new TArray([ $input_type_part->getStandinKeyParam(), - $input_type_part->value_param + $input_type_part->value_param, ]); } if ($container_type_part instanceof TClassStringMap) { $container_type_part = new TArray([ $container_type_part->getStandinKeyParam(), - $container_type_part->value_param + $container_type_part->value_param, ]); } @@ -153,7 +153,7 @@ public static function isContainedBy( $input_param->ignore_nullable_issues, $input_param->ignore_falsable_issues, $param_comparison_result, - $allow_interface_equality + $allow_interface_equality, )) { if ($atomic_comparison_result) { $atomic_comparison_result->type_coerced diff --git a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php index 4d53b00b8d3..fd44ac82e66 100644 --- a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php @@ -77,7 +77,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -143,7 +143,7 @@ public static function isContainedBy( $container_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -155,7 +155,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -168,7 +168,7 @@ public static function isContainedBy( $codebase, $input_type_part, $container_type_part, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -178,7 +178,7 @@ public static function isContainedBy( $codebase, $input_type_part, $container_type_part, - $atomic_comparison_result + $atomic_comparison_result, ) === false ) { return false; @@ -197,7 +197,7 @@ public static function isContainedBy( $codebase, $input_type_part, $container_type_part, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -252,7 +252,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -279,7 +279,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -314,7 +314,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ) ) { if ($container_type_part instanceof TGenericObject || $container_type_part instanceof TIterable) { @@ -323,7 +323,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -360,7 +360,7 @@ public static function isContainedBy( return UnionTypeComparator::isContainedBy( $codebase, $input_type_part->as, - $container_type_part->as + $container_type_part->as, ); } @@ -377,7 +377,7 @@ public static function isContainedBy( $container_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, )) { return false; } @@ -394,7 +394,7 @@ public static function isContainedBy( return UnionTypeComparator::isContainedBy( $codebase, $input_type_part->as, - $container_type_part->as + $container_type_part->as, ); } @@ -411,7 +411,7 @@ public static function isContainedBy( $container_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, )) { return false; } @@ -428,7 +428,7 @@ public static function isContainedBy( false, false, $atomic_comparison_result, - $allow_interface_equality + $allow_interface_equality, ); } @@ -440,7 +440,7 @@ public static function isContainedBy( $container_as_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, )) { if ($allow_interface_equality) { return true; @@ -454,7 +454,7 @@ public static function isContainedBy( if ($container_type_part instanceof TConditional) { $atomic_types = array_merge( array_values($container_type_part->if_type->getAtomicTypes()), - array_values($container_type_part->else_type->getAtomicTypes()) + array_values($container_type_part->else_type->getAtomicTypes()), ); foreach ($atomic_types as $container_as_type_part) { @@ -464,7 +464,7 @@ public static function isContainedBy( $container_as_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, )) { return true; } @@ -482,7 +482,7 @@ public static function isContainedBy( $container_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, )) { return true; } @@ -496,7 +496,7 @@ public static function isContainedBy( $container_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, )) { return true; } @@ -508,7 +508,7 @@ public static function isContainedBy( if ($input_type_part instanceof TConditional) { $input_atomic_types = array_merge( array_values($input_type_part->if_type->getAtomicTypes()), - array_values($input_type_part->else_type->getAtomicTypes()) + array_values($input_type_part->else_type->getAtomicTypes()), ); foreach ($input_atomic_types as $input_as_type_part) { @@ -518,7 +518,7 @@ public static function isContainedBy( $container_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, )) { return true; } @@ -568,7 +568,7 @@ public static function isContainedBy( $input_param->ignore_nullable_issues, $input_param->ignore_falsable_issues, $array_comparison_result, - $allow_interface_equality + $allow_interface_equality, ) && !$array_comparison_result->type_coerced_from_scalar ) { @@ -613,8 +613,8 @@ public static function isContainedBy( if ($codebase->methods->methodExists( new MethodIdentifier( $input_type_part->value, - '__tostring' - ) + '__tostring', + ), )) { if ($atomic_comparison_result) { $atomic_comparison_result->to_string_cast = true; @@ -660,7 +660,7 @@ public static function isContainedBy( $codebase, $input_type_part, $container_type_part, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -675,7 +675,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -710,7 +710,7 @@ public static function isContainedBy( $codebase->classExists($container_type_part->value) && $codebase->classExtendsOrImplements( $container_type_part->value, - $input_type_part->value + $input_type_part->value, ) ) || @@ -718,7 +718,7 @@ public static function isContainedBy( $codebase->interfaceExists($container_type_part->value) && $codebase->interfaceExtends( $container_type_part->value, - $input_type_part->value + $input_type_part->value, ) ) ) @@ -784,7 +784,7 @@ public static function canBeIdentical( return UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $type1_part->fallback_params[1], - $type2_part->fallback_params[1] + $type2_part->fallback_params[1], ); } @@ -796,12 +796,12 @@ public static function canBeIdentical( return UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $type1_part->type_params[0], - $type2_part->type_params[0] + $type2_part->type_params[0], ) && UnionTypeComparator::canExpressionTypesBeIdentical( $codebase, $type1_part->type_params[1], - $type2_part->type_params[1] + $type2_part->type_params[1], ); } @@ -814,7 +814,7 @@ public static function canBeIdentical( $type2_part, $allow_interface_equality, false, - $first_comparison_result + $first_comparison_result, ) && !$first_comparison_result->to_string_cast ) || (self::isContainedBy( @@ -823,7 +823,7 @@ public static function canBeIdentical( $type1_part, $allow_interface_equality, false, - $second_comparison_result + $second_comparison_result, ) && !$second_comparison_result->to_string_cast ) || ($first_comparison_result->type_coerced diff --git a/src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php b/src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php index 08b255a27e9..fa3b5328974 100644 --- a/src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php @@ -95,7 +95,7 @@ public static function isContainedBy( $input_param->type ?: Type::getMixed(), false, false, - $atomic_comparison_result + $atomic_comparison_result, ) ) { return false; @@ -126,7 +126,7 @@ public static function isContainedBy( $container_type_part->return_type, false, false, - $atomic_comparison_result + $atomic_comparison_result, ) ) { return false; @@ -202,7 +202,7 @@ public static function isNotExplicitlyCallableTypeCallable( $codebase, $input_callable, $container_type_part, - $atomic_comparison_result + $atomic_comparison_result, ) === false ) { return false; @@ -233,7 +233,7 @@ public static function getCallableFromAtomic( try { $function_storage = $codebase->functions->getStorage( $statements_analyzer, - strtolower($input_type_part->value) + strtolower($input_type_part->value), ); if ($expand_callable) { @@ -252,8 +252,8 @@ public static function getCallableFromAtomic( true, false, false, - true - ) + true, + ), ); } @@ -273,7 +273,7 @@ public static function getCallableFromAtomic( true, false, false, - true + true, ); } } else { @@ -285,7 +285,7 @@ public static function getCallableFromAtomic( 'callable', $params, $return_type, - $function_storage->pure + $function_storage->pure, ); } catch (UnexpectedValueException $e) { if (InternalCallMapHandler::inCallMap($input_type_part->value)) { @@ -296,7 +296,7 @@ public static function getCallableFromAtomic( if ($container_type_part && $container_type_part->params) { foreach ($container_type_part->params as $i => $param) { $arg = new Arg( - new Variable('_' . $i) + new Variable('_' . $i), ); if ($param->type) { @@ -311,7 +311,7 @@ public static function getCallableFromAtomic( $codebase, $input_type_part->value, $args, - $nodes + $nodes, ); $must_use = false; @@ -321,7 +321,7 @@ public static function getCallableFromAtomic( $statements_analyzer->node_data ?? null, $input_type_part->value, null, - $must_use + $must_use, )); return $matching_callable; @@ -342,7 +342,7 @@ public static function getCallableFromAtomic( $method_storage->return_type, $method_fqcln, $method_fqcln, - null + null, ); } @@ -350,7 +350,7 @@ public static function getCallableFromAtomic( 'callable', $method_storage->params, $converted_return_type, - $method_storage->pure + $method_storage->pure, ); } catch (UnexpectedValueException $e) { // do nothing @@ -365,7 +365,7 @@ public static function getCallableFromAtomic( ) { $invoke_id = new MethodIdentifier( $input_type_part->value, - '__invoke' + '__invoke', ); if ($codebase->methods->methodExists($invoke_id)) { @@ -374,14 +374,14 @@ public static function getCallableFromAtomic( if ($input_type_part instanceof Atomic\TGenericObject) { $invokable_storage = $codebase->methods->getClassLikeStorageForMethod( - $declaring_method_id ?? $invoke_id + $declaring_method_id ?? $invoke_id, ); $type_params = []; foreach ($invokable_storage->template_types ?? [] as $template => $for_class) { foreach ($for_class as $type) { $type_params[] = new Type\Union([ - new TTemplateParam($template, $type, $input_type_part->value) + new TTemplateParam($template, $type, $input_type_part->value), ]); } } @@ -395,7 +395,7 @@ public static function getCallableFromAtomic( $template_result, $codebase, null, - new Type\Union([$input_type_part]) + new Type\Union([$input_type_part]), ); } } @@ -410,7 +410,7 @@ public static function getCallableFromAtomic( $method_storage->return_type, $method_fqcln, $method_fqcln, - null + null, ); } @@ -418,14 +418,14 @@ public static function getCallableFromAtomic( 'callable', $method_storage->params, $converted_return_type, - $method_storage->pure + $method_storage->pure, ); if ($template_result) { $callable = TemplateInferredTypeReplacer::replace( new Union([$callable]), $template_result, - $codebase + $codebase, )->getSingleAtomic(); } @@ -464,7 +464,7 @@ public static function getCallableMethodIdFromTKeyedArray( if ($lhs_atomic_type instanceof TNamedObject) { $codebase->analyzer->addMixedMemberName( strtolower($lhs_atomic_type->value) . '::', - $calling_method_id ?: $file_name + $calling_method_id ?: $file_name, ); } elseif ($lhs_atomic_type instanceof TTemplateParam) { $lhs_template_type = $lhs_atomic_type->as; @@ -481,7 +481,7 @@ public static function getCallableMethodIdFromTKeyedArray( /** @psalm-suppress PossiblyNullArgument Psalm bug */ $codebase->analyzer->addMixedMemberName( strtolower($member_id) . '::', - $calling_method_id ?: $file_name + $calling_method_id ?: $file_name, ); } } @@ -534,7 +534,7 @@ public static function getCallableMethodIdFromTKeyedArray( if ($codebase && ($calling_method_id || $file_name)) { $codebase->analyzer->addMixedMemberName( strtolower($method_name), - $calling_method_id ?: $file_name + $calling_method_id ?: $file_name, ); } @@ -543,7 +543,7 @@ public static function getCallableMethodIdFromTKeyedArray( return new MethodIdentifier( $class_name, - strtolower($method_name) + strtolower($method_name), ); } } diff --git a/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php b/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php index afc0d2c15f9..c074efd8596 100644 --- a/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php @@ -68,7 +68,7 @@ public static function isContainedBy( : new TNamedObject( $container_type_part instanceof TClassString ? $container_type_part->as - : $container_type_part->value + : $container_type_part->value, ); $fake_input_object = $input_type_part instanceof TClassString @@ -77,7 +77,7 @@ public static function isContainedBy( : new TNamedObject( $input_type_part instanceof TClassString ? $input_type_part->as - : $input_type_part->value + : $input_type_part->value, ); return AtomicTypeComparator::isContainedBy( @@ -86,7 +86,7 @@ public static function isContainedBy( $fake_container_object, $allow_interface_equality, false, - $atomic_comparison_result + $atomic_comparison_result, ); } } diff --git a/src/Psalm/Internal/Type/Comparator/GenericTypeComparator.php b/src/Psalm/Internal/Type/Comparator/GenericTypeComparator.php index 64028cdb42a..964ffdf0828 100644 --- a/src/Psalm/Internal/Type/Comparator/GenericTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/GenericTypeComparator.php @@ -33,7 +33,7 @@ public static function isContainedBy( ) { $container_type_part = new TGenericObject( 'Traversable', - $container_type_part->type_params + $container_type_part->type_params, ); $container_was_iterable = true; @@ -54,7 +54,7 @@ public static function isContainedBy( $codebase, $input_type_part, $container_type_part, - $container_type_params_covariant + $container_type_params_covariant, ); $atomic_comparison_result_type_params = null; @@ -91,7 +91,7 @@ public static function isContainedBy( $input_param->ignore_nullable_issues, $input_param->ignore_falsable_issues, $param_comparison_result, - $allow_interface_equality + $allow_interface_equality, )) { if ($input_type_part->value === 'Generator' && $i === 2 @@ -153,7 +153,7 @@ public static function isContainedBy( $container_param->ignore_nullable_issues, $container_param->ignore_falsable_issues, $param_comparison_result, - $allow_interface_equality + $allow_interface_equality, ) || $param_comparison_result->type_coerced ) { if ($container_param->hasStaticObject() diff --git a/src/Psalm/Internal/Type/Comparator/IntegerRangeComparator.php b/src/Psalm/Internal/Type/Comparator/IntegerRangeComparator.php index 6ade9af6b1b..e462143b563 100644 --- a/src/Psalm/Internal/Type/Comparator/IntegerRangeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/IntegerRangeComparator.php @@ -53,7 +53,7 @@ public static function isContainedByUnion( $reduced_range = new TIntRange( $input_type_part->min_bound, $input_type_part->max_bound, - $input_type_part->from_docblock + $input_type_part->from_docblock, ); if (isset($container_atomic_types['int'])) { @@ -106,7 +106,7 @@ private static function reduceRangeIncrementally(array &$container_atomic_types, //X-1 becomes the max of our reduced range if it was higher $reduced_range->max_bound = TIntRange::getNewLowestBound( $container_atomic_type->min_bound - 1, - $reduced_range->max_bound ?? $container_atomic_type->min_bound - 1 + $reduced_range->max_bound ?? $container_atomic_type->min_bound - 1, ); unset($container_atomic_types[$key]); //we don't need this one anymore continue; @@ -116,7 +116,7 @@ private static function reduceRangeIncrementally(array &$container_atomic_types, //X+1 becomes the min of our reduced range if it was lower $reduced_range->min_bound = TIntRange::getNewHighestBound( $container_atomic_type->max_bound + 1, - $reduced_range->min_bound ?? $container_atomic_type->max_bound + 1 + $reduced_range->min_bound ?? $container_atomic_type->max_bound + 1, ); unset($container_atomic_types[$key]); //we don't need this one anymore continue; diff --git a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php index 6346e31d1e1..1607f1c489b 100644 --- a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php +++ b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php @@ -82,7 +82,7 @@ public static function isContainedBy( $input_property_type->ignore_nullable_issues, $input_property_type->ignore_falsable_issues, $property_type_comparison, - $allow_interface_equality + $allow_interface_equality, ) && !$property_type_comparison->type_coerced_from_scalar ) { @@ -96,7 +96,7 @@ public static function isContainedBy( false, false, $inverse_property_type_comparison, - $allow_interface_equality + $allow_interface_equality, ) || $inverse_property_type_comparison->type_coerced_from_scalar ) { @@ -150,7 +150,7 @@ public static function isContainedByObjectWithProperties( if (!$codebase->properties->propertyExists( $input_type_part->value . '::$' . $property_name, - true + true, )) { $all_types_contain = false; @@ -159,7 +159,7 @@ public static function isContainedByObjectWithProperties( $property_declaring_class = (string) $codebase->properties->getDeclaringClassForProperty( $input_type_part . '::$' . $property_name, - true + true, ); $class_storage = $codebase->classlike_storage_provider->get($property_declaring_class); @@ -178,7 +178,7 @@ public static function isContainedByObjectWithProperties( false, false, $property_type_comparison, - $allow_interface_equality + $allow_interface_equality, ) && !$property_type_comparison->type_coerced_from_scalar ) { @@ -191,7 +191,7 @@ public static function isContainedByObjectWithProperties( false, false, $inverse_property_type_comparison, - $allow_interface_equality + $allow_interface_equality, ) || $inverse_property_type_comparison->type_coerced_from_scalar ) { diff --git a/src/Psalm/Internal/Type/Comparator/ObjectComparator.php b/src/Psalm/Internal/Type/Comparator/ObjectComparator.php index b775ae0f783..7d4101b8c1b 100644 --- a/src/Psalm/Internal/Type/Comparator/ObjectComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ObjectComparator.php @@ -48,8 +48,8 @@ public static function isShallowlyContainedBy( $intersection_container_type_lower = strtolower( $codebase->classlikes->getUnAliasedName( - $intersection_container_type->value - ) + $intersection_container_type->value, + ), ); } @@ -71,7 +71,7 @@ public static function isShallowlyContainedBy( $intersection_container_type_lower, $container_was_static, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, )) { $any_inputs_contained = true; } @@ -173,7 +173,7 @@ private static function isIntersectionShallowlyContainedBy( } $input_class_storage = $codebase->classlike_storage_provider->get( - $intersection_input_type->defining_class + $intersection_input_type->defining_class, ); if (isset($input_class_storage->template_extended_params @@ -211,7 +211,7 @@ private static function isIntersectionShallowlyContainedBy( false, false, $atomic_comparison_result, - $allow_interface_equality + $allow_interface_equality, ); } @@ -226,8 +226,8 @@ private static function isIntersectionShallowlyContainedBy( $intersection_input_type_lower = strtolower( $codebase->classlikes->getUnAliasedName( - $intersection_input_type->value - ) + $intersection_input_type->value, + ), ); } @@ -254,12 +254,12 @@ private static function isIntersectionShallowlyContainedBy( || ($codebase->classlikes->classExists($intersection_input_type_lower) && $codebase->classlikes->classImplements( $intersection_input_type_lower, - 'Traversable' + 'Traversable', )) || ($codebase->classlikes->interfaceExists($intersection_input_type_lower) && $codebase->classlikes->interfaceExtends( $intersection_input_type_lower, - 'Traversable' + 'Traversable', )) ) { return true; @@ -287,7 +287,7 @@ private static function isIntersectionShallowlyContainedBy( && $codebase->classOrInterfaceExists($intersection_container_type_lower) && $codebase->classExtendsOrImplements( $intersection_input_type_lower, - $intersection_container_type_lower + $intersection_container_type_lower, ) ) { if ($container_was_static && !$input_was_static) { @@ -304,7 +304,7 @@ private static function isIntersectionShallowlyContainedBy( if ($input_type_is_interface && $codebase->interfaceExtends( $intersection_input_type_lower, - $intersection_container_type_lower + $intersection_container_type_lower, ) ) { return true; diff --git a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php index c4f6e113ec9..b8941667156 100644 --- a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php @@ -177,7 +177,7 @@ public static function isContainedBy( $container_type_part = new TClassString( 'object', - $first_type instanceof TNamedObject ? $first_type : null + $first_type instanceof TNamedObject ? $first_type : null, ); } @@ -191,12 +191,12 @@ public static function isContainedBy( $first_type->param_name, $first_type->as->getId(), $object_type instanceof TNamedObject ? $object_type : null, - $first_type->defining_class + $first_type->defining_class, ); } else { $input_type_part = new TClassString( 'object', - $first_type instanceof TNamedObject ? $first_type : null + $first_type instanceof TNamedObject ? $first_type : null, ); } } @@ -341,7 +341,7 @@ public static function isContainedBy( if ($input_type_part instanceof TIntRange && $container_type_part instanceof TIntRange) { return IntegerRangeComparator::isContainedBy( $input_type_part, - $container_type_part + $container_type_part, ); } @@ -412,7 +412,7 @@ public static function isContainedBy( $input_type_part, $container_type_part, $allow_interface_equality, - $atomic_comparison_result + $atomic_comparison_result, ); } @@ -485,7 +485,7 @@ public static function isContainedBy( $codebase, $input_callable, $container_callable, - $atomic_comparison_result ?? new TypeComparisonResult() + $atomic_comparison_result ?? new TypeComparisonResult(), ) === false ) { return false; diff --git a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php index 484d6964b8d..c4465006f5b 100644 --- a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php @@ -119,7 +119,7 @@ public static function isContainedBy( if ($input_type_part instanceof TIntRange && $container_type->hasInt()) { if (IntegerRangeComparator::isContainedByUnion( $input_type_part, - $container_type + $container_type, )) { continue; } @@ -194,7 +194,7 @@ public static function isContainedBy( $container_type_part, $allow_interface_equality, $allow_float_int_equality, - $atomic_comparison_result + $atomic_comparison_result, ); if ($input_type_part instanceof TMixed @@ -229,7 +229,7 @@ public static function isContainedBy( $replacement = $union_comparison_result->replacement_union_type->getBuilder(); $replacement->removeType($input_type->getKey()); $replacement->addType( - $atomic_comparison_result->replacement_atomic_type + $atomic_comparison_result->replacement_atomic_type, ); $union_comparison_result->replacement_union_type = $replacement->freeze(); } @@ -434,7 +434,7 @@ public static function canBeContainedBy( $container_type_part, false, false, - $atomic_comparison_result + $atomic_comparison_result, ); if (($is_atomic_contained_by && !$atomic_comparison_result->to_string_cast) @@ -472,7 +472,7 @@ public static function canExpressionTypesBeIdentical( if ($type1_part instanceof TIntRange && $type2_part instanceof TIntRange) { $intersection_range = TIntRange::intersectIntRanges( $type1_part, - $type2_part + $type2_part, ); return $intersection_range !== null; } @@ -481,7 +481,7 @@ public static function canExpressionTypesBeIdentical( $codebase, $type1_part, $type2_part, - $allow_interface_equality + $allow_interface_equality, ); if ($either_contains) { @@ -520,7 +520,7 @@ private static function getTypeParts( $fq_classlike_name, null, true, - true + true, ); array_push($atomic_types, ...$expanded); diff --git a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php index df3b3c92cf8..a2ec64ed3fe 100644 --- a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php @@ -83,7 +83,7 @@ public static function reconcile( $key, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -100,7 +100,7 @@ public static function reconcile( $suppressed_issues, $failed_reconciliation, $is_equality, - $inside_loop + $inside_loop, ); if ($simple_negated_type) { @@ -174,7 +174,7 @@ public static function reconcile( ? Type::getArrayKey() : $iterable->type_params[0], $iterable->type_params[1], - ] + ], )); } elseif ($assertion_type !== null && get_class($assertion_type) === TInt::class && isset($existing_var_type->getAtomicTypes()['array-key']) @@ -224,7 +224,7 @@ public static function reconcile( $existing_var_type_part, $assertion_type, false, - false + false, )) { $existing_var_type->removeType($part_name); } elseif (AtomicTypeComparator::isContainedBy( @@ -232,7 +232,7 @@ public static function reconcile( $assertion_type, $existing_var_type_part, false, - false + false, )) { $existing_var_type->different = true; } @@ -254,7 +254,7 @@ public static function reconcile( && !UnionTypeComparator::canExpressionTypesBeIdentical( $statements_analyzer->getCodebase(), $existing_var_type, - $assertion_type + $assertion_type, ) ) { self::triggerIssueForImpossible( @@ -265,7 +265,7 @@ public static function reconcile( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -283,7 +283,7 @@ public static function reconcile( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -343,7 +343,7 @@ private static function handleLiteralNegatedEquality( ) { $existing_var_type->addType(new Type\Atomic\TIntRange( $literal_type->min_bound, - $assertion_type->value - 1 + $assertion_type->value - 1, )); } if ($literal_type->max_bound === null @@ -351,7 +351,7 @@ private static function handleLiteralNegatedEquality( ) { $existing_var_type->addType(new Type\Atomic\TIntRange( $assertion_type->value + 1, - $literal_type->max_bound + $literal_type->max_bound, )); } } @@ -449,7 +449,7 @@ private static function handleLiteralNegatedEquality( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } elseif ($scalar_var_type && $assertion instanceof IsNotIdentical @@ -459,7 +459,7 @@ private static function handleLiteralNegatedEquality( if (!UnionTypeComparator::canExpressionTypesBeIdentical( $statements_analyzer->getCodebase(), $existing_var_type, - new Union([$scalar_var_type]) + new Union([$scalar_var_type]), )) { self::triggerIssueForImpossible( $existing_var_type, @@ -469,7 +469,7 @@ private static function handleLiteralNegatedEquality( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } diff --git a/src/Psalm/Internal/Type/ParseTreeCreator.php b/src/Psalm/Internal/Type/ParseTreeCreator.php index 1049f804461..9a6c6ca5211 100644 --- a/src/Psalm/Internal/Type/ParseTreeCreator.php +++ b/src/Psalm/Internal/Type/ParseTreeCreator.php @@ -157,7 +157,7 @@ public function create(): ParseTree || $this->parse_tree instanceof KeyedArrayTree) ) { throw new TypeParseTreeException( - 'Unterminated bracket' + 'Unterminated bracket', ); } @@ -193,7 +193,7 @@ private function createMethodParam(array $current_token, ParseTree $current_pare $current_token[0], $byref, $variadic, - $current_parent + $current_parent, ); for ($j = $this->t + 1; $j < $this->type_token_count; ++$j) { @@ -292,7 +292,7 @@ private function handleOpenRoundBracket(): void $new_parent = !$this->current_leaf instanceof Root ? $this->current_leaf : null; $new_leaf = new EncapsulationTree( - $new_parent + $new_parent, ); if ($this->current_leaf instanceof Root) { @@ -573,7 +573,7 @@ private function handleQuestionMark(): void $new_leaf = new ConditionalTree( $this->current_leaf, - $this->current_leaf->parent + $this->current_leaf->parent, ); array_pop($current_parent->children); @@ -587,7 +587,7 @@ private function handleQuestionMark(): void } $new_leaf = new NullableTree( - $new_parent + $new_parent, ); if ($this->current_leaf instanceof Root) { @@ -659,7 +659,7 @@ private function handleAmpersand(): void { if ($this->current_leaf instanceof Root) { throw new TypeParseTreeException( - 'Unexpected &' + 'Unexpected &', ); } @@ -713,7 +713,7 @@ private function handleIsOrAs(array $type_token): void $this->current_leaf = new TemplateAsTree( $this->current_leaf->value, $next_token[0], - $current_parent + $current_parent, ); $current_parent->children[] = $this->current_leaf; @@ -721,7 +721,7 @@ private function handleIsOrAs(array $type_token): void } elseif ($this->current_leaf instanceof Value) { $this->current_leaf = new TemplateIsTree( $this->current_leaf->value, - $current_parent + $current_parent, ); if ($current_parent) { @@ -747,7 +747,7 @@ private function handleValue(array $type_token): void case '<': $new_leaf = new GenericTree( $type_token[0], - $new_parent + $new_parent, ); ++$this->t; break; @@ -755,7 +755,7 @@ private function handleValue(array $type_token): void case '{': $new_leaf = new KeyedArrayTree( $type_token[0], - $new_parent + $new_parent, ); ++$this->t; @@ -774,11 +774,11 @@ private function handleValue(array $type_token): void if (in_array( $type_token[0], ['callable', 'pure-callable', 'Closure', '\Closure', 'pure-Closure'], - true + true, )) { $new_leaf = new CallableTree( $type_token[0], - $new_parent + $new_parent, ); } elseif ($type_token[0] !== 'array' && $type_token[0][0] !== '\\' @@ -786,11 +786,11 @@ private function handleValue(array $type_token): void ) { $new_leaf = new MethodTree( $type_token[0], - $new_parent + $new_parent, ); } else { throw new TypeParseTreeException( - 'Parenthesis must be preceded by “Closure”, “callable”, "pure-callable" or a valid @method name' + 'Parenthesis must be preceded by “Closure”, “callable”, "pure-callable" or a valid @method name', ); } @@ -805,7 +805,7 @@ private function handleValue(array $type_token): void && strtolower($nexter_token[0]) !== 'class' ) { throw new TypeParseTreeException( - ':: in array key is only allowed for ::class' + ':: in array key is only allowed for ::class', ); } @@ -814,7 +814,7 @@ private function handleValue(array $type_token): void && strtolower($nexter_token[0]) !== 'class') ) { throw new TypeParseTreeException( - 'Invalid class constant ' . ($nexter_token[0] ?? '') + 'Invalid class constant ' . ($nexter_token[0] ?? ''), ); } @@ -823,7 +823,7 @@ private function handleValue(array $type_token): void $type_token[1], $type_token[1] + 2 + strlen($nexter_token[0]), $type_token[2] ?? null, - $new_parent + $new_parent, ); $this->t += 2; @@ -840,7 +840,7 @@ private function handleValue(array $type_token): void $type_token[1], $type_token[1] + strlen($type_token[0]), $type_token[2] ?? null, - $new_parent + $new_parent, ); break; } diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index f05ba1ef504..af7e1051dbd 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -127,7 +127,7 @@ public static function reconcile( $suppressed_issues, $failed_reconciliation, $assertion instanceof IsEqualIsset, - $inside_loop + $inside_loop, ); } @@ -144,14 +144,14 @@ public static function reconcile( $negated, $code_location, $suppressed_issues, - $failed_reconciliation + $failed_reconciliation, ); } if ($assertion instanceof HasArrayKey) { return self::reconcileHasArrayKey( $existing_var_type, - $assertion + $assertion, ); } @@ -164,7 +164,7 @@ public static function reconcile( $key, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -177,7 +177,7 @@ public static function reconcile( $key, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -190,7 +190,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - false + false, ); } @@ -204,7 +204,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -218,7 +218,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $inside_loop + $inside_loop, ); } @@ -232,7 +232,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $inside_loop + $inside_loop, ); } @@ -281,7 +281,7 @@ public static function reconcile( $negated, $code_location, $suppressed_issues, - $failed_reconciliation + $failed_reconciliation, ); } @@ -296,7 +296,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -309,7 +309,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -323,7 +323,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -340,7 +340,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -356,7 +356,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -377,7 +377,7 @@ public static function reconcile( $suppressed_issues, $failed_reconciliation, $is_equality, - $assertion_type->isNonEmpty() + $assertion_type->isNonEmpty(), ); } @@ -393,7 +393,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -406,7 +406,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -419,7 +419,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -432,7 +432,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -445,7 +445,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -458,7 +458,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -483,7 +483,7 @@ public static function reconcile( $negated, $code_location, $suppressed_issues, - $failed_reconciliation + $failed_reconciliation, ); } @@ -504,7 +504,7 @@ public static function reconcile( $codebase, $assertion_type, $existing_var_type, - $failed_reconciliation + $failed_reconciliation, ); } @@ -573,7 +573,7 @@ private static function reconcileIsset( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); if ($existing_var_type->isUnionEmpty()) { @@ -629,7 +629,7 @@ private static function reconcileNonEmptyCountable( $non_empty_array = new TNonEmptyArray( $array_atomic_type->type_params, null, - $assertion instanceof HasAtLeastCount ? $assertion->count : null + $assertion instanceof HasAtLeastCount ? $assertion->count : null, ); $existing_var_type->addType($non_empty_array); @@ -672,8 +672,8 @@ private static function reconcileNonEmptyCountable( $existing_var_type->addType($array_atomic_type->setProperties( array_map( fn(Union $union) => $union->setPossiblyUndefined(false), - $array_atomic_type->properties - ) + $array_atomic_type->properties, + ), )); $redundant = false; @@ -725,7 +725,7 @@ private static function reconcileNonEmptyCountable( $redundant, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -758,12 +758,12 @@ private static function reconcileExactlyCountable( ) { $non_empty_array = new TNonEmptyArray( $array_atomic_type->type_params, - $assertion->count + $assertion->count, ); $existing_var_type->removeType('array'); $existing_var_type->addType( - $non_empty_array + $non_empty_array, ); $redundant = false; @@ -792,8 +792,8 @@ private static function reconcileExactlyCountable( $existing_var_type->addType($array_atomic_type->setProperties( array_map( fn(Union $union) => $union->setPossiblyUndefined(false), - $array_atomic_type->properties - ) + $array_atomic_type->properties, + ), )); } elseif ($array_atomic_type->is_list) { $redundant = false; @@ -820,7 +820,7 @@ private static function reconcileExactlyCountable( $properties, null, null, - true + true, ); $existing_var_type->removeType('array'); $existing_var_type->addType($array_atomic_type); @@ -844,7 +844,7 @@ private static function reconcileExactlyCountable( $redundant, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -894,7 +894,7 @@ private static function reconcileHasMethod( if (!isset($extra_type->methods[strtolower($method_name)])) { unset($extra_types[$k]); $extra_type = $extra_type->setMethods(array_merge($extra_type->methods, [ - strtolower($method_name) => 'object::' . $method_name + strtolower($method_name) => 'object::' . $method_name, ])); $extra_types[$extra_type->getKey()] = $extra_type; $did_remove_type = true; @@ -905,7 +905,7 @@ private static function reconcileHasMethod( if (!$match_found) { $extra_type = new TObjectWithProperties( [], - [strtolower($method_name) => $type->value . '::' . $method_name] + [strtolower($method_name) => $type->value . '::' . $method_name], ); $extra_types[$extra_type->getKey()] = $extra_type; $did_remove_type = true; @@ -917,7 +917,7 @@ private static function reconcileHasMethod( } elseif ($type instanceof TObjectWithProperties) { if (!isset($type->methods[strtolower($method_name)])) { $type = $type->setMethods(array_merge($type->methods, [ - strtolower($method_name) => 'object::' . $method_name + strtolower($method_name) => 'object::' . $method_name, ])); $did_remove_type = true; } @@ -925,7 +925,7 @@ private static function reconcileHasMethod( } elseif ($type instanceof TObject || $type instanceof TMixed) { $object_types[] = new TObjectWithProperties( [], - [strtolower($method_name) => 'object::' . $method_name] + [strtolower($method_name) => 'object::' . $method_name], ); $did_remove_type = true; } elseif ($type instanceof TString) { @@ -950,7 +950,7 @@ private static function reconcileHasMethod( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1019,7 +1019,7 @@ private static function reconcileString( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $string_types[] = $type; @@ -1041,7 +1041,7 @@ private static function reconcileString( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1110,7 +1110,7 @@ private static function reconcileInt( false, null, $suppressed_issues, - $failed_reconciliation + $failed_reconciliation, )); $int_types[] = $type; @@ -1135,7 +1135,7 @@ private static function reconcileInt( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1192,7 +1192,7 @@ private static function reconcileBool( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $bool_types[] = $type; @@ -1214,7 +1214,7 @@ private static function reconcileBool( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1277,7 +1277,7 @@ private static function reconcileFalse( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $false_types[] = $type; @@ -1299,7 +1299,7 @@ private static function reconcileFalse( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1362,7 +1362,7 @@ private static function reconcileTrue( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $true_types[] = $type; @@ -1384,7 +1384,7 @@ private static function reconcileTrue( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1437,7 +1437,7 @@ private static function reconcileScalar( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $scalar_types[] = $type; @@ -1459,7 +1459,7 @@ private static function reconcileScalar( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1530,7 +1530,7 @@ private static function reconcileNumeric( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $numeric_types[] = $type; @@ -1552,7 +1552,7 @@ private static function reconcileNumeric( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1614,7 +1614,7 @@ private static function reconcileObject( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $object_types[] = $type; @@ -1627,7 +1627,7 @@ private static function reconcileObject( $object_types[] = new TGenericObject( 'Traversable', - $params + $params, ); $did_remove_type = true; @@ -1646,7 +1646,7 @@ private static function reconcileObject( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1704,7 +1704,7 @@ private static function reconcileResource( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1776,7 +1776,7 @@ private static function reconcileCountable( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1839,7 +1839,7 @@ private static function reconcileIterable( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -1888,7 +1888,7 @@ private static function reconcileInArray( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1919,14 +1919,14 @@ private static function reconcileHasArrayKey( $atomic_type = new TKeyedArray( array_merge( $atomic_type->properties, - [$assertion => Type::getMixed()] + [$assertion => Type::getMixed()], ), array_merge( $atomic_type->class_strings ?? [], - [$assertion => true] + [$assertion => true], ), $atomic_type->fallback_params, - $atomic_type->is_list + $atomic_type->is_list, ); } } @@ -1977,12 +1977,12 @@ private static function reconcileIsGreaterThan( } else { $min_bound = TIntRange::getNewHighestBound( $assertion_value, - $min_bound + $min_bound, ); } $existing_var_type->addType(new TIntRange( $min_bound, - $atomic_type->max_bound + $atomic_type->max_bound, )); } elseif ($atomic_type->isLesserThan($assertion_value)) { // if the range is lesser than the assertion, the type must be removed @@ -2024,7 +2024,7 @@ private static function reconcileIsGreaterThan( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -2038,7 +2038,7 @@ private static function reconcileIsGreaterThan( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } $existing_var_type->addType(new TNever()); @@ -2092,7 +2092,7 @@ private static function reconcileIsLessThan( } $existing_var_type->addType(new TIntRange( $atomic_type->min_bound, - $max_bound + $max_bound, )); } elseif ($atomic_type->isLesserThan($assertion_value)) { // if the range is lesser than the assertion, the check is redundant @@ -2134,7 +2134,7 @@ private static function reconcileIsLessThan( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -2148,7 +2148,7 @@ private static function reconcileIsLessThan( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } $existing_var_type->addType(new TNever()); @@ -2212,7 +2212,7 @@ private static function reconcileTraversable( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -2262,7 +2262,7 @@ private static function reconcileArray( } elseif ($type instanceof TCallable) { $array_types[] = new TCallableKeyedArray([ new Union([new TClassString, new TObject]), - Type::getString() + Type::getString(), ]); $did_remove_type = true; @@ -2282,7 +2282,7 @@ private static function reconcileArray( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $array_types[] = $type; @@ -2304,7 +2304,7 @@ private static function reconcileArray( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); if (!$did_remove_type) { @@ -2389,7 +2389,7 @@ private static function reconcileList( } elseif ($type instanceof TCallable) { $array_types[] = new TCallableKeyedArray([ new Union([new TClassString, new TObject]), - Type::getString() + Type::getString(), ]); $did_remove_type = true; @@ -2412,7 +2412,7 @@ private static function reconcileList( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); if (!$did_remove_type) { @@ -2489,7 +2489,7 @@ private static function reconcileStringArrayAccess( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -2550,7 +2550,7 @@ private static function reconcileIntArrayAccess( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -2634,7 +2634,7 @@ private static function reconcileCallable( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); } @@ -2656,7 +2656,7 @@ private static function reconcileCallable( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -2721,7 +2721,7 @@ private static function reconcileTruthyOrNonEmpty( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -2740,7 +2740,7 @@ private static function reconcileTruthyOrNonEmpty( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -2846,7 +2846,7 @@ private static function reconcileTruthyOrNonEmpty( $code_location, $suppressed_issues, $template_did_fail, - true + true, )); if (!$template_did_fail) { diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php index edeef3adb43..5ae0b004b6c 100644 --- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php @@ -105,18 +105,18 @@ public static function reconcile( 'Static property ' . $key . ' with type ' . $existing_var_type . ' has unexpected isset check — should it be nullable?', - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, ); } elseif ($existing_var_type->from_property) { IssueBuffer::maybeAdd( new RedundantPropertyInitializationCheck( 'Property ' . $key . ' with type ' . $existing_var_type . ' should already be set in the constructor', - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, ); } elseif ($existing_var_type->from_docblock) { IssueBuffer::maybeAdd( @@ -124,9 +124,9 @@ public static function reconcile( 'Cannot resolve types for ' . $key . ' with docblock-defined type ' . $existing_var_type . ' and !isset assertion', $code_location, - 'cannot resolve !isset '.$existing_var_type. ' ' . $key + 'cannot resolve !isset '.$existing_var_type. ' ' . $key, ), - $suppressed_issues + $suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -134,9 +134,9 @@ public static function reconcile( 'Cannot resolve types for ' . $key . ' with type ' . $existing_var_type . ' and !isset assertion', $code_location, - 'cannot resolve !isset '.$existing_var_type. ' ' . $key + 'cannot resolve !isset '.$existing_var_type. ' ' . $key, ), - $suppressed_issues + $suppressed_issues, ); } } @@ -159,7 +159,7 @@ public static function reconcile( $intersection = Type::intersectUnionTypes( $new_var_type, $existing_var_type, - $codebase + $codebase, ); if ($intersection === null) { @@ -172,7 +172,7 @@ public static function reconcile( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -191,7 +191,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - false + false, ); } @@ -204,7 +204,7 @@ public static function reconcile( $code_location, $suppressed_issues, $is_equality, - null + null, ); } @@ -217,7 +217,7 @@ public static function reconcile( $code_location, $suppressed_issues, $is_equality, - $assertion->count + $assertion->count, ); } @@ -234,7 +234,7 @@ public static function reconcile( $key, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -247,7 +247,7 @@ public static function reconcile( $key, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -262,7 +262,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -275,7 +275,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -288,7 +288,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -301,7 +301,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -314,7 +314,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -327,7 +327,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -340,7 +340,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -353,7 +353,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -370,7 +370,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -383,7 +383,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -396,7 +396,7 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } @@ -409,13 +409,13 @@ public static function reconcile( $code_location, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, ); } if ($assertion_type instanceof TCallable) { return self::reconcileCallable( - $existing_var_type + $existing_var_type, ); } @@ -492,7 +492,7 @@ private static function reconcileBool( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -573,7 +573,7 @@ private static function reconcileNotNonEmptyCountable( null, null, true, - $array_atomic_type->from_docblock + $array_atomic_type->from_docblock, )); } } @@ -592,7 +592,7 @@ private static function reconcileNotNonEmptyCountable( [ new Union([new TNever()]), new Union([new TNever()]), - ] + ], )); } } @@ -604,7 +604,7 @@ private static function reconcileNotNonEmptyCountable( [ new Union([new TNever()]), new Union([new TNever()]), - ] + ], )); } } @@ -622,7 +622,7 @@ private static function reconcileNotNonEmptyCountable( $redundant, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } } @@ -664,7 +664,7 @@ private static function reconcileNull( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); // $did_remove_type = $did_remove_type || $new !== $type; @@ -686,7 +686,7 @@ private static function reconcileNull( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -747,7 +747,7 @@ private static function reconcileFalse( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $did_remove_type = $did_remove_type || $new !== $type; @@ -766,7 +766,7 @@ private static function reconcileFalse( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -827,7 +827,7 @@ private static function reconcileTrue( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $did_remove_type = $did_remove_type || $new !== $type; @@ -846,7 +846,7 @@ private static function reconcileTrue( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -912,7 +912,7 @@ private static function reconcileFalsyOrEmpty( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -934,7 +934,7 @@ private static function reconcileFalsyOrEmpty( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -954,7 +954,7 @@ private static function reconcileFalsyOrEmpty( [ new Union([new TNever()]), new Union([new TNever()]), - ] + ], )); } @@ -1034,7 +1034,7 @@ private static function reconcileFalsyOrEmpty( $code_location, $suppressed_issues, $template_did_fail, - $recursive_check + $recursive_check, )); if (!$template_did_fail) { @@ -1081,7 +1081,7 @@ private static function reconcileScalar( null, $suppressed_issues, $template_did_fail, - $is_equality + $is_equality, )); $did_remove_type = true; @@ -1114,7 +1114,7 @@ private static function reconcileScalar( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1127,7 +1127,7 @@ private static function reconcileScalar( return new Union($non_scalar_types, [ 'ignore_falsable_issues' => $existing_var_type->ignore_falsable_issues, 'ignore_nullable_issues' => $existing_var_type->ignore_nullable_issues, - 'from_docblock' => $existing_var_type->from_docblock + 'from_docblock' => $existing_var_type->from_docblock, ]); } @@ -1169,7 +1169,7 @@ private static function reconcileObject( null, $suppressed_issues, $template_did_fail, - $is_equality + $is_equality, )); $did_remove_type = true; @@ -1184,7 +1184,7 @@ private static function reconcileObject( } elseif ($type instanceof TCallable) { $non_object_types[] = new TCallableArray([ Type::getArrayKey(), - Type::getMixed() + Type::getMixed(), ]); $non_object_types[] = new TCallableString(); $did_remove_type = true; @@ -1215,7 +1215,7 @@ private static function reconcileObject( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1271,7 +1271,7 @@ private static function reconcileNumeric( null, $suppressed_issues, $template_did_fail, - $is_equality + $is_equality, )); $did_remove_type = true; @@ -1307,7 +1307,7 @@ private static function reconcileNumeric( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1362,7 +1362,7 @@ private static function reconcileInt( null, $suppressed_issues, $template_did_fail, - $is_equality + $is_equality, )); $did_remove_type = true; @@ -1409,7 +1409,7 @@ private static function reconcileInt( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1464,7 +1464,7 @@ private static function reconcileFloat( null, $suppressed_issues, $template_did_fail, - $is_equality + $is_equality, )); $did_remove_type = true; @@ -1506,7 +1506,7 @@ private static function reconcileFloat( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1561,7 +1561,7 @@ private static function reconcileString( null, $suppressed_issues, $template_did_fail, - $is_equality + $is_equality, )); $did_remove_type = true; @@ -1579,7 +1579,7 @@ private static function reconcileString( } elseif ($type instanceof TCallable) { $non_string_types[] = new TCallableArray([ Type::getArrayKey(), - Type::getMixed() + Type::getMixed(), ]); $non_string_types[] = new TCallableObject(); $did_remove_type = true; @@ -1612,7 +1612,7 @@ private static function reconcileString( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1670,7 +1670,7 @@ private static function reconcileArray( null, $suppressed_issues, $template_did_fail, - $is_equality + $is_equality, )); $did_remove_type = true; @@ -1717,7 +1717,7 @@ private static function reconcileArray( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1774,7 +1774,7 @@ private static function reconcileResource( null, $suppressed_issues, $failed_reconciliation, - $is_equality + $is_equality, )); $did_remove_type = $new !== $type; @@ -1793,7 +1793,7 @@ private static function reconcileResource( !$did_remove_type, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1854,12 +1854,12 @@ private static function reconcileIsLessThanOrEqualTo( } else { $max_bound = TIntRange::getNewLowestBound( $assertion_value, - $atomic_type->max_bound + $atomic_type->max_bound, ); } $existing_var_type->addType(new TIntRange( $atomic_type->min_bound, - $max_bound + $max_bound, )); } elseif ($atomic_type->isLesserThan($assertion_value)) { // if the range is lesser than the assertion, the check is redundant @@ -1901,7 +1901,7 @@ private static function reconcileIsLessThanOrEqualTo( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -1915,7 +1915,7 @@ private static function reconcileIsLessThanOrEqualTo( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } $existing_var_type->addType(new TNever()); @@ -1968,7 +1968,7 @@ private static function reconcileIsGreaterThanOrEqualTo( } $existing_var_type->addType(new TIntRange( $min_bound, - $atomic_type->max_bound + $atomic_type->max_bound, )); } elseif ($atomic_type->isLesserThan($assertion_value)) { // if the range is lesser than the assertion, the type must be removed @@ -2010,7 +2010,7 @@ private static function reconcileIsGreaterThanOrEqualTo( true, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } @@ -2024,7 +2024,7 @@ private static function reconcileIsGreaterThanOrEqualTo( false, $negated, $code_location, - $suppressed_issues + $suppressed_issues, ); } $existing_var_type->addType(new TNever()); diff --git a/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php b/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php index fd61ef298d0..fc8573ab418 100644 --- a/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php +++ b/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php @@ -67,7 +67,7 @@ public static function replace( $codebase, $atomic_type, $inferred_lower_bounds, - $key + $key, ); if ($template_type) { @@ -85,7 +85,7 @@ public static function replace( $template_type = isset($inferred_lower_bounds[$atomic_type->param_name][$atomic_type->defining_class]) ? TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $inferred_lower_bounds[$atomic_type->param_name][$atomic_type->defining_class], - $codebase + $codebase, ) : null; @@ -100,7 +100,7 @@ public static function replace( } elseif ($template_type_part instanceof TNamedObject) { $class_template_type = new TClassString( $template_type_part->value, - $template_type_part + $template_type_part, ); } elseif ($template_type_part instanceof TTemplateParam) { $first_atomic_type = $template_type_part->as->getSingleAtomic(); @@ -109,7 +109,7 @@ public static function replace( $template_type_part->param_name, $template_type_part->as->getId(), $first_atomic_type instanceof TNamedObject ? $first_atomic_type : null, - $template_type_part->defining_class + $template_type_part->defining_class, ); } } @@ -130,13 +130,13 @@ public static function replace( $array_template_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $inferred_lower_bounds[$atomic_type->array_param_name][$atomic_type->defining_class], - $codebase + $codebase, ); $offset_template_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( array_values($inferred_lower_bounds[$atomic_type->offset_param_name])[0], - $codebase + $codebase, ); if ($array_template_type->isSingle() @@ -174,7 +174,7 @@ public static function replace( $new_type = self::replaceTemplateKeyOfValueOf( $codebase, $atomic_type, - $inferred_lower_bounds + $inferred_lower_bounds, ); if ($new_type) { @@ -185,7 +185,7 @@ public static function replace( $new_type = self::replaceTemplatePropertiesOf( $codebase, $atomic_type, - $inferred_lower_bounds + $inferred_lower_bounds, ); if ($new_type) { @@ -199,7 +199,7 @@ public static function replace( $template_result, $codebase, $atomic_type, - $inferred_lower_bounds + $inferred_lower_bounds, ); $should_set = false; @@ -221,8 +221,8 @@ public static function replace( return $union->getBuilder()->setTypes( TypeCombiner::combine( $new_types, - $codebase - )->getAtomicTypes() + $codebase, + )->getAtomicTypes(), )->freeze(); } @@ -234,8 +234,8 @@ public static function replace( return $union->getBuilder()->setTypes( TypeCombiner::combine( $atomic_types, - $codebase - )->getAtomicTypes() + $codebase, + )->getAtomicTypes(), )->freeze(); } @@ -255,7 +255,7 @@ private static function replaceTemplateParam( $atomic_type->param_name, $atomic_type->defining_class, [], - $codebase + $codebase, ); if ($traversed_type) { @@ -275,7 +275,7 @@ private static function replaceTemplateParam( ) { $types []= $atomic_template_type->setIntersectionTypes(array_merge( $atomic_type->extra_types, - $atomic_template_type->extra_types + $atomic_template_type->extra_types, )); } elseif ($atomic_template_type instanceof TObject) { $first_atomic_type = array_shift($atomic_type->extra_types); @@ -313,7 +313,7 @@ private static function replaceTemplateParam( $template_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $inferred_lower_bounds[$template_name][$template_class], - $codebase + $codebase, ); } } @@ -343,7 +343,7 @@ private static function replaceTemplateKeyOfValueOf( $template_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $inferred_lower_bounds[$atomic_type->param_name][$atomic_type->defining_class], - $codebase + $codebase, ); if ($atomic_type instanceof TTemplateKeyOf @@ -375,7 +375,7 @@ private static function replaceTemplatePropertiesOf( $template_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $inferred_lower_bounds[$atomic_type->param_name][$atomic_type->defining_class], - $codebase + $codebase, ); $classlike_type = $template_type->getSingleAtomic(); @@ -385,7 +385,7 @@ private static function replaceTemplatePropertiesOf( return new TPropertiesOf( $classlike_type, - $atomic_type->visibility_filter + $atomic_type->visibility_filter, ); } @@ -401,7 +401,7 @@ private static function replaceConditional( $template_type = isset($inferred_lower_bounds[$atomic_type->param_name][$atomic_type->defining_class]) ? TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $inferred_lower_bounds[$atomic_type->param_name][$atomic_type->defining_class], - $codebase + $codebase, ) : null; @@ -417,7 +417,7 @@ private static function replaceConditional( $as_type = self::replace( $as_type, $template_result, - $codebase + $codebase, ); if ($as_type->isNullable() && $template_type->isVoid()) { @@ -436,7 +436,7 @@ private static function replaceConditional( false, null, false, - false + false, ) && (!$candidate_atomic_type instanceof TInt || $conditional_type->getId() !== 'float') @@ -450,7 +450,7 @@ private static function replaceConditional( false, null, false, - false + false, )) { $matching_else_types[] = $candidate_atomic_type; } @@ -468,7 +468,7 @@ private static function replaceConditional( false, null, false, - false + false, ) ) { $if_template_type = $if_type; @@ -478,14 +478,14 @@ private static function replaceConditional( $refined_template_result->lower_bounds[$atomic_type->param_name][$atomic_type->defining_class] = [ new TemplateBound( - $if_candidate_type - ) + $if_candidate_type, + ), ]; $if_template_type = self::replace( $if_template_type, $refined_template_result, - $codebase + $codebase, ); } @@ -498,7 +498,7 @@ private static function replaceConditional( false, null, false, - false + false, ) ) { $else_template_type = $else_type; @@ -508,14 +508,14 @@ private static function replaceConditional( $refined_template_result->lower_bounds[$atomic_type->param_name][$atomic_type->defining_class] = [ new TemplateBound( - $else_candidate_type - ) + $else_candidate_type, + ), ]; $else_template_type = self::replace( $else_template_type, $refined_template_result, - $codebase + $codebase, ); } } @@ -524,25 +524,25 @@ private static function replaceConditional( $if_type = self::replace( $if_type, $template_result, - $codebase + $codebase, ); $else_type = self::replace( $else_type, $template_result, - $codebase + $codebase, ); $class_template_type = Type::combineUnionTypes( $if_type, $else_type, - $codebase + $codebase, ); } else { $class_template_type = Type::combineUnionTypes( $if_template_type, $else_template_type, - $codebase + $codebase, ); } @@ -550,7 +550,7 @@ private static function replaceConditional( $as_type, $conditional_type, $if_type, - $else_type + $else_type, ); return $class_template_type; diff --git a/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php b/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php index b3fae414c6a..e5a85dddaf3 100644 --- a/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php +++ b/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php @@ -84,7 +84,7 @@ public static function fillTemplateResult( $replace, $add_lower_bound, $bound_equality_classlike, - $depth + $depth, ); } /** @@ -150,7 +150,7 @@ public static function replace( $bound_equality_classlike, $depth, count($original_atomic_types) === 1, - $had_template + $had_template, )]; } @@ -166,12 +166,12 @@ public static function replace( if (count($atomic_types) > 1) { return TypeCombiner::combine( $atomic_types, - $codebase + $codebase, )->setProperties([ 'ignore_nullable_issues' => $union_type->ignore_nullable_issues, 'ignore_falsable_issues' => $union_type->ignore_falsable_issues, 'possibly_undefined' => $union_type->possibly_undefined, - 'had_template' => $had_template + 'had_template' => $had_template, ]); } @@ -179,7 +179,7 @@ public static function replace( 'ignore_nullable_issues' => $union_type->ignore_nullable_issues, 'ignore_falsable_issues' => $union_type->ignore_falsable_issues, 'possibly_undefined' => $union_type->possibly_undefined, - 'had_template' => $had_template + 'had_template' => $had_template, ]); } @@ -227,7 +227,7 @@ private static function handleAtomicStandin( $add_lower_bound, $bound_equality_classlike, $depth, - $had_template + $had_template, ); } @@ -267,7 +267,7 @@ private static function handleAtomicStandin( $offset_template_type = self::getMostSpecificTypeFromBounds( array_values($template_result->lower_bounds[$atomic_type->offset_param_name])[0], - $codebase + $codebase, ); if ($array_template_type->isSingle() @@ -377,7 +377,7 @@ private static function handleAtomicStandin( /** @psalm-suppress ReferenceConstraintViolation Psalm bug, $atomic_type is not a reference */ $atomic_type = new TPropertiesOf( $classlike_type, - $atomic_type->visibility_filter + $atomic_type->visibility_filter, ); return [$atomic_type]; } @@ -390,7 +390,7 @@ private static function handleAtomicStandin( $key, $codebase, $statements_analyzer, - $input_type + $input_type, ); } @@ -406,7 +406,7 @@ private static function handleAtomicStandin( $calling_function, $replace, $add_lower_bound, - $depth + 1 + $depth + 1, ); return [$atomic_type]; @@ -425,7 +425,7 @@ private static function handleAtomicStandin( $calling_function, $replace, $add_lower_bound, - $depth + 1 + $depth + 1, ); } @@ -508,8 +508,8 @@ private static function findMatchingAtomicTypesForTemplate( $base_type->as_type->value, new TGenericObject( $base_type->as_type->value, - array_values($classlike_storage->template_extended_params[$base_type->as_type->value]) - ) + array_values($classlike_storage->template_extended_params[$base_type->as_type->value]), + ), ); $matching_atomic_types[$atomic_input_type->getId()] = $atomic_input_type; @@ -525,7 +525,7 @@ private static function findMatchingAtomicTypesForTemplate( $codebase, $atomic_input_type, null, - $statements_analyzer + $statements_analyzer, ); if ($matching_atomic_type) { @@ -546,7 +546,7 @@ private static function findMatchingAtomicTypesForTemplate( $base_type = new TGenericObject( 'Traversable', - $base_type->type_params + $base_type->type_params, ); } @@ -564,7 +564,7 @@ private static function findMatchingAtomicTypesForTemplate( if (!empty($classlike_storage->template_extended_params[$base_type->value])) { $atomic_input_type = new TGenericObject( $atomic_input_type->value, - array_values($classlike_storage->template_extended_params[$base_type->value]) + array_values($classlike_storage->template_extended_params[$base_type->value]), ); $matching_atomic_types[$atomic_input_type->getId()] = $atomic_input_type; @@ -590,8 +590,8 @@ private static function findMatchingAtomicTypesForTemplate( $key, $codebase, $statements_analyzer, - $atomic_input_type->as - ) + $atomic_input_type->as, + ), ); continue; } @@ -655,7 +655,7 @@ private static function handleTemplateParamStandin( $replace, $add_lower_bound, $bound_equality_classlike, - $depth + 1 + $depth + 1, ); if ($extra_type->isSingle()) { @@ -687,7 +687,7 @@ private static function handleTemplateParamStandin( $replacement_type, $calling_class, $calling_class, - null + null, ); if ($depth < 10) { @@ -703,7 +703,7 @@ private static function handleTemplateParamStandin( true, $add_lower_bound, $bound_equality_classlike, - $depth + 1 + $depth + 1, ); } @@ -772,7 +772,7 @@ private static function handleTemplateParamStandin( $atomic_type->as, $calling_class, $calling_class, - null + null, ); $as = self::replace( @@ -787,7 +787,7 @@ private static function handleTemplateParamStandin( true, $add_lower_bound, $bound_equality_classlike, - $depth + 1 + $depth + 1, ); $atomic_type = $atomic_type->replaceAs($as); @@ -802,7 +802,7 @@ private static function handleTemplateParamStandin( $atomic_type->as, false, false, - $matching_input_keys + $matching_input_keys, ) ) ) { @@ -825,7 +825,7 @@ private static function handleTemplateParamStandin( $generic_param = $generic_param->setFromDocblock()->freeze(); if (isset( - $template_result->lower_bounds[$param_name_key][$atomic_type->defining_class] + $template_result->lower_bounds[$param_name_key][$atomic_type->defining_class], )) { $existing_lower_bounds = $template_result->lower_bounds [$param_name_key] @@ -855,7 +855,7 @@ private static function handleTemplateParamStandin( $generic_param, $depth, $input_arg_offset, - $bound_equality_classlike + $bound_equality_classlike, ); } } else { @@ -864,8 +864,8 @@ private static function handleTemplateParamStandin( $generic_param, $depth, $input_arg_offset, - $bound_equality_classlike - ) + $bound_equality_classlike, + ), ]; } } @@ -895,7 +895,7 @@ private static function handleTemplateParamStandin( $replacement_type, false, false, - $matching_input_keys + $matching_input_keys, ) ) { $generic_param = $input_type->getBuilder(); @@ -919,16 +919,16 @@ private static function handleTemplateParamStandin( if (!UnionTypeComparator::isContainedBy( $codebase, $upper_bound->type, - $generic_param + $generic_param, ) || !UnionTypeComparator::isContainedBy( $codebase, $generic_param, - $upper_bound->type + $upper_bound->type, )) { $intersection_type = Type::intersectUnionTypes( $upper_bound->type, $generic_param, - $codebase + $codebase, ); } else { $intersection_type = $generic_param; @@ -944,7 +944,7 @@ private static function handleTemplateParamStandin( } } else { $template_result->upper_bounds[$param_name_key][$atomic_type->defining_class] = new TemplateBound( - $generic_param + $generic_param, ); } } @@ -988,7 +988,7 @@ public static function handleTemplateParamClassStandin( false, false, [], - true + true, ); } elseif ($input_atomic_type instanceof TTemplateParamClass) { $valid_input_atomic_types[] = new TTemplateParam( @@ -1000,7 +1000,7 @@ public static function handleTemplateParamClassStandin( : Type::getMixed()), $input_atomic_type->defining_class, [], - true + true, ); } elseif ($input_atomic_type instanceof TClassString) { if ($input_atomic_type->as_type) { @@ -1011,7 +1011,7 @@ public static function handleTemplateParamClassStandin( false, false, [], - true + true, ); } else { $valid_input_atomic_types[] = new TObject(true); @@ -1044,7 +1044,7 @@ public static function handleTemplateParamClassStandin( $replace, $add_lower_bound, $bound_equality_classlike, - $depth + 1 + $depth + 1, ); $first = $as_type_union->getSingleAtomic(); @@ -1064,19 +1064,19 @@ public static function handleTemplateParamClassStandin( $generic_param, self::getMostSpecificTypeFromBounds( $template_result->lower_bounds[$atomic_type->param_name][$atomic_type->defining_class], - $codebase - ) + $codebase, + ), ), - $depth - ) + $depth, + ), ]; } else { $template_result->lower_bounds[$atomic_type->param_name][$atomic_type->defining_class] = [ new TemplateBound( $generic_param, $depth, - $input_arg_offset - ) + $input_arg_offset, + ), ]; } } @@ -1089,7 +1089,7 @@ public static function handleTemplateParamClassStandin( if ($template_atomic_type instanceof TNamedObject) { $atomic_types[] = new TClassString( $template_atomic_type->value, - $template_atomic_type + $template_atomic_type, ); } elseif ($template_atomic_type instanceof TObject) { $atomic_types[] = new TClassString(); @@ -1123,7 +1123,7 @@ public static function getRootTemplateType( if (isset($template_types[$param_name][$defining_class])) { $mapped_type = self::getMostSpecificTypeFromBounds( $template_types[$param_name][$defining_class], - $codebase + $codebase, ); $mapped_type_atomic_types = array_values($mapped_type->getAtomicTypes()); @@ -1141,7 +1141,7 @@ public static function getRootTemplateType( $first_template->param_name, $first_template->defining_class, $visited_classes + [$defining_class => true], - $codebase + $codebase, ) ?? $mapped_type; } @@ -1166,7 +1166,7 @@ public static function getMostSpecificTypeFromBounds(array $lower_bounds, ?Codeb usort( $lower_bounds, - static fn(TemplateBound $bound_a, TemplateBound $bound_b): int => $bound_b->appearance_depth <=> $bound_a->appearance_depth + static fn(TemplateBound $bound_a, TemplateBound $bound_b): int => $bound_b->appearance_depth <=> $bound_a->appearance_depth, ); $current_depth = null; @@ -1194,7 +1194,7 @@ public static function getMostSpecificTypeFromBounds(array $lower_bounds, ?Codeb $current_type = Type::combineUnionTypes( $current_type, $template_bound->type, - $codebase + $codebase, ); $last_arg_offset = $template_bound->arg_offset; @@ -1278,7 +1278,7 @@ public static function getMappedGenericTypeParams( if ($et instanceof TTemplateParam) { $ets = Methods::getExtendedTemplatedTypes( $et, - $template_extends + $template_extends, ); } else { $ets = []; @@ -1289,17 +1289,17 @@ public static function getMappedGenericTypeParams( && isset( $input_class_storage->template_types [$ets[0]->param_name] - [$ets[0]->defining_class] + [$ets[0]->defining_class], ) ) { $old_params_offset = (int) array_search( $ets[0]->param_name, - array_keys($input_class_storage->template_types) + array_keys($input_class_storage->template_types), ); $candidate_param_type = $input_type_params[$old_params_offset] ?? Type::getMixed(); $candidate_param_type = $candidate_param_type->setProperties([ - 'from_template_default' => true + 'from_template_default' => true, ]); } else { $candidate_param_type = new Union([$et], ['from_template_default' => true]); @@ -1307,14 +1307,14 @@ public static function getMappedGenericTypeParams( $new_input_param = Type::combineUnionTypes( $new_input_param, - $candidate_param_type + $candidate_param_type, ); } $new_input_param = TemplateInferredTypeReplacer::replace( $new_input_param, new TemplateResult([], $replacement_templates), - $codebase + $codebase, ); $new_input_params[] = $new_input_param; diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index f79e153a5f6..fe2a8f34dce 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -115,7 +115,7 @@ public static function combine( $codebase, $overwrite_empty_array, $allow_mixed_union, - $literal_limit + $literal_limit, ); if ($result) { @@ -196,7 +196,7 @@ public static function combine( unset( $combination->value_types['array'], $combination->named_object_types['Traversable'], - $combination->builtin_type_params['Traversable'] + $combination->builtin_type_params['Traversable'], ); } @@ -209,7 +209,7 @@ public static function combine( if ($combination->objectlike_entries) { $new_types = self::handleKeyedArrayEntries( $combination, - $overwrite_empty_array + $overwrite_empty_array, ); } @@ -224,7 +224,7 @@ public static function combine( $overwrite_empty_array, $allow_mixed_union, $type, - $combination->array_type_params + $combination->array_type_params, ); } @@ -232,7 +232,7 @@ public static function combine( /** @psalm-suppress PropertyTypeCoercion */ $combination->extra_types = self::combine( array_values($combination->extra_types), - $codebase + $codebase, )->getAtomicTypes(); } @@ -247,7 +247,7 @@ public static function combine( $generic_type_params, false, false, - $combination->extra_types + $combination->extra_types, ); $new_types[] = $generic_object; @@ -266,7 +266,7 @@ public static function combine( $generic_type_params, false, $combination->object_static[$generic_type] ?? false, - $combination->extra_types + $combination->extra_types, ); $new_types[] = $generic_object; @@ -288,7 +288,7 @@ public static function combine( if (!$has_non_specific_string) { $object_type = self::combine( array_values($combination->class_string_types), - $codebase + $codebase, ); foreach ($object_type->getAtomicTypes() as $object_atomic_type) { @@ -322,7 +322,7 @@ public static function combine( $combination->value_types['string'], $combination->value_types['int'], $combination->value_types['bool'], - $combination->value_types['float'] + $combination->value_types['float'], ); $combination->value_types['scalar'] = new TScalar; } @@ -477,7 +477,7 @@ private static function scrapeTypeProperties( /** @psalm-suppress PropertyTypeCoercion */ $combination->builtin_type_params['iterable'][$i] = Type::combineUnionTypes( $iterable_type_param, - $array_type_param + $array_type_param, ); } } @@ -498,7 +498,7 @@ private static function scrapeTypeProperties( /** @psalm-suppress PropertyTypeCoercion */ $combination->builtin_type_params['iterable'][$i] = Type::combineUnionTypes( $iterable_type_param, - $array_type_param + $array_type_param, ); } } else { @@ -508,7 +508,7 @@ private static function scrapeTypeProperties( /** @psalm-suppress PossiblyNullArrayAccess */ unset( $combination->named_object_types['Traversable'], - $combination->builtin_type_params['Traversable'] + $combination->builtin_type_params['Traversable'], ); } @@ -520,7 +520,7 @@ private static function scrapeTypeProperties( if ($type->extra_types) { $combination->extra_types = array_merge( $combination->extra_types, - $type->extra_types + $type->extra_types, ); } } @@ -545,7 +545,7 @@ private static function scrapeTypeProperties( $combination->array_type_params[$i] ?? null, $type_param, $codebase, - $overwrite_empty_array + $overwrite_empty_array, ); } @@ -593,7 +593,7 @@ private static function scrapeTypeProperties( $combination->array_type_params[$i] ?? null, $type_param, $codebase, - $overwrite_empty_array + $overwrite_empty_array, ); } @@ -618,7 +618,7 @@ private static function scrapeTypeProperties( $combination->builtin_type_params[$type_key][$i] ?? null, $type_param, $codebase, - $overwrite_empty_array + $overwrite_empty_array, ); } @@ -632,7 +632,7 @@ private static function scrapeTypeProperties( $combination->object_type_params[$type_key][$i] ?? null, $type_param, $codebase, - $overwrite_empty_array + $overwrite_empty_array, ); } @@ -654,13 +654,13 @@ private static function scrapeTypeProperties( $type->fallback_params[0], $combination->objectlike_key_type, $codebase, - $overwrite_empty_array + $overwrite_empty_array, ); $combination->objectlike_value_type = Type::combineUnionTypes( $type->fallback_params[1], $combination->objectlike_value_type, $codebase, - $overwrite_empty_array + $overwrite_empty_array, ); } @@ -678,7 +678,7 @@ private static function scrapeTypeProperties( $value_type, $candidate_property_type, $codebase, - $overwrite_empty_array + $overwrite_empty_array, ); if ((!$value_type->possibly_undefined || !$candidate_property_type->possibly_undefined) && $overwrite_empty_array @@ -707,8 +707,8 @@ private static function scrapeTypeProperties( $min_prop_count = count( array_filter( $type->properties, - static fn(Union $p): bool => !$p->possibly_undefined - ) + static fn(Union $p): bool => !$p->possibly_undefined, + ), ); $combination->array_min_counts[$min_prop_count] = true; } @@ -763,7 +763,7 @@ private static function scrapeTypeProperties( $existing_template_type = $existing_template_type->replaceAs(Type::combineUnionTypes( $type->as, $existing_template_type->as, - $codebase + $codebase, )); $combination->value_types[$type_key] = $existing_template_type; } @@ -845,7 +845,7 @@ private static function scrapeTypeProperties( $combination->value_types['bool'], $combination->value_types['true'], $combination->value_types['false'], - $combination->value_types['float'] + $combination->value_types['float'], ); if (!isset($combination->value_types[$type_key]) @@ -868,7 +868,7 @@ private static function scrapeTypeProperties( $combination->ints = null; unset( $combination->value_types['string'], - $combination->value_types['int'] + $combination->value_types['int'], ); $combination->value_types[$type_key] = $type; @@ -881,7 +881,7 @@ private static function scrapeTypeProperties( $type, $combination, $codebase, - $literal_limit + $literal_limit, ); return null; @@ -892,7 +892,7 @@ private static function scrapeTypeProperties( $type_key, $type, $combination, - $literal_limit + $literal_limit, ); return null; @@ -1140,7 +1140,7 @@ private static function scrapeIntProperties( $all_nonnegative = !array_filter( $combination->ints, - static fn($int): bool => $int->value < 0 + static fn($int): bool => $int->value < 0, ); if (isset($combination->value_types['int'])) { @@ -1152,11 +1152,11 @@ private static function scrapeIntProperties( if (!$current_int_type->contains($int->value)) { $min_bound = TIntRange::getNewLowestBound( $min_bound, - $int->value + $int->value, ); $max_bound = TIntRange::getNewHighestBound( $max_bound, - $int->value + $int->value, ); } } @@ -1165,7 +1165,7 @@ private static function scrapeIntProperties( ) { $combination->value_types['int'] = new TIntRange( $min_bound, - $max_bound + $max_bound, ); } } @@ -1333,7 +1333,7 @@ private static function handleKeyedArrayEntries( ) { $combination->objectlike_entries = array_filter( $combination->objectlike_entries, - static fn(Union $type): bool => !$type->possibly_undefined + static fn(Union $type): bool => !$type->possibly_undefined, ); } @@ -1370,7 +1370,7 @@ private static function handleKeyedArrayEntries( $sealed || $fallback_key_type === null || $fallback_value_type === null ? null : [$fallback_key_type, $fallback_value_type], - (bool)$combination->all_arrays_lists + (bool)$combination->all_arrays_lists, ); } else { $objectlike = new TKeyedArray( @@ -1379,7 +1379,7 @@ private static function handleKeyedArrayEntries( $sealed || $fallback_key_type === null || $fallback_value_type === null ? null : [$fallback_key_type, $fallback_value_type], - (bool)$combination->all_arrays_lists + (bool)$combination->all_arrays_lists, ); } @@ -1425,7 +1425,7 @@ private static function getArrayTypeFromGenericParams( $overwrite_empty_array, true, 500, - false + false, ); if (is_int($property_name)) { @@ -1445,7 +1445,7 @@ private static function getArrayTypeFromGenericParams( $overwrite_empty_array, true, 500, - false + false, ); } @@ -1455,7 +1455,7 @@ private static function getArrayTypeFromGenericParams( $combination->objectlike_key_type, $objectlike_key_type, $codebase, - $overwrite_empty_array + $overwrite_empty_array, ); $generic_type_params[0] = Type::combineUnionTypes( @@ -1463,7 +1463,7 @@ private static function getArrayTypeFromGenericParams( $objectlike_key_type, $codebase, $overwrite_empty_array, - $allow_mixed_union + $allow_mixed_union, ); if (!$generic_type_params[1]->isMixed()) { @@ -1472,7 +1472,7 @@ private static function getArrayTypeFromGenericParams( $objectlike_generic_type, $codebase, $overwrite_empty_array, - $allow_mixed_union + $allow_mixed_union, ); } } @@ -1495,7 +1495,7 @@ private static function getArrayTypeFromGenericParams( [$generic_type_params[1]], null, [Type::getInt(), $combination->array_type_params[1]], - true + true, ); } elseif ($combination->array_counts && count($combination->array_counts) === 1) { $cnt = array_keys($combination->array_counts)[0]; @@ -1508,7 +1508,7 @@ private static function getArrayTypeFromGenericParams( $properties, null, null, - true + true, ); } else { $cnt = $combination->array_min_counts @@ -1525,7 +1525,7 @@ private static function getArrayTypeFromGenericParams( $properties, null, [Type::getListKey(), $generic_type_params[1]], - true + true, ); } } else { @@ -1534,7 +1534,7 @@ private static function getArrayTypeFromGenericParams( $generic_type_params, $combination->array_min_counts ? min(array_keys($combination->array_min_counts)) - : null + : null, ); } } else { @@ -1545,7 +1545,7 @@ private static function getArrayTypeFromGenericParams( $array_type = new TClassStringMap( array_keys($combination->class_string_map_names)[0], array_values($combination->class_string_map_as_types)[0], - $generic_type_params[1] + $generic_type_params[1], ); } elseif ($combination->all_arrays_lists) { $array_type = Type::getListAtomic($generic_type_params[1]); diff --git a/src/Psalm/Internal/Type/TypeExpander.php b/src/Psalm/Internal/Type/TypeExpander.php index f87a16e66fd..6a521522222 100644 --- a/src/Psalm/Internal/Type/TypeExpander.php +++ b/src/Psalm/Internal/Type/TypeExpander.php @@ -104,7 +104,7 @@ public static function expandUnion( if ($had_split_values) { $fleshed_out_type = TypeCombiner::combine( $new_return_type_parts, - $codebase + $codebase, ); } else { $fleshed_out_type = new Union($new_return_type_parts); @@ -170,7 +170,7 @@ public static function expandAtomic( if ($extra_type instanceof TNamedObject && $extra_type->extra_types) { $new_intersection_types = array_merge( $new_intersection_types, - $extra_type->extra_types + $extra_type->extra_types, ); $extra_type = $extra_type->setIntersectionTypes([]); } @@ -189,7 +189,7 @@ public static function expandAtomic( $static_class_type, $parent_class, $final, - $expand_generic + $expand_generic, ); } } @@ -216,7 +216,7 @@ public static function expandAtomic( if ($new_as_type instanceof TNamedObject && $new_as_type !== $return_type->as_type) { $return_type = $return_type->setAs( $new_as_type->value, - $new_as_type + $new_as_type, ); } } elseif ($return_type instanceof TTemplateParam) { @@ -245,13 +245,13 @@ public static function expandAtomic( if ($self_class) { $return_type = $return_type->replaceClassLike( 'self', - $self_class + $self_class, ); } if (is_string($static_class_type) || $self_class) { $return_type = $return_type->replaceClassLike( 'static', - is_string($static_class_type) ? $static_class_type : $self_class + is_string($static_class_type) ? $static_class_type : $self_class, ); } @@ -265,7 +265,7 @@ public static function expandAtomic( if (strpos($return_type->const_name, '*') !== false) { $matching_constants = [ ...array_keys($class_storage->constants), - ...array_keys($class_storage->enum_cases) + ...array_keys($class_storage->enum_cases), ]; $const_name_part = substr($return_type->const_name, 0, -1); @@ -288,7 +288,7 @@ public static function expandAtomic( $class_constant = $codebase->classlikes->getClassConstantType( $return_type->fq_classlike_name, $matching_constant, - ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_PRIVATE, ); } catch (CircularReferenceException $e) { $class_constant = null; @@ -298,7 +298,7 @@ public static function expandAtomic( if ($class_constant->isSingle()) { $matching_constant_types = array_merge( array_values($class_constant->getAtomicTypes()), - $matching_constant_types + $matching_constant_types, ); } } @@ -317,7 +317,7 @@ public static function expandAtomic( $codebase, $return_type, $self_class, - $static_class_type + $static_class_type, ); } @@ -365,7 +365,7 @@ public static function expandAtomic( $recursively_fleshed_out_types = [ ...$more_recursively_fleshed_out_types, - ...$recursively_fleshed_out_types + ...$recursively_fleshed_out_types, ]; } @@ -386,7 +386,7 @@ public static function expandAtomic( $recursively_fleshed_out_types = [ ...$more_recursively_fleshed_out_types, - ...$recursively_fleshed_out_types + ...$recursively_fleshed_out_types, ]; } @@ -573,7 +573,7 @@ public static function expandAtomic( $return_type->class_strings, $fallback_params, $return_type->is_list, - $return_type->from_docblock + $return_type->from_docblock, ); } } @@ -642,7 +642,7 @@ public static function expandAtomic( $return_type = $return_type->replace( $params, - $sub_return_type + $sub_return_type, ); } @@ -670,7 +670,7 @@ private static function expandNamedObject( ) { $value = $codebase->classlikes->getUnAliasedName($return_type->value); $container_class_storage = $codebase->classlike_storage_provider->get( - $value + $value, ); if ($container_class_storage->template_types @@ -684,9 +684,9 @@ private static function expandNamedObject( array_values( array_map( static fn($type_map) => reset($type_map), - $container_class_storage->template_types - ) - ) + $container_class_storage->template_types, + ), + ), ); // we don't want to expand generic types recursively @@ -707,7 +707,7 @@ private static function expandNamedObject( $return_type = $return_type->setValueIsStatic( $static_class_type, $is_static, - $is_static_resolved + $is_static_resolved, ); } else { if ($return_type instanceof TGenericObject @@ -716,12 +716,12 @@ private static function expandNamedObject( $return_type = $return_type->setValueIsStatic( $static_class_type->value, $is_static, - $is_static_resolved + $is_static_resolved, ); } elseif ($static_class_type instanceof TNamedObject) { $return_type = $static_class_type->setIsStatic( $is_static, - $is_static_resolved + $is_static_resolved, ); } else { $return_type = $static_class_type; @@ -749,7 +749,7 @@ private static function expandNamedObject( } elseif ($return_type->is_static && is_string($static_class_type) && $final) { $return_type = $return_type->setValueIsStatic( $static_class_type, - false + false, ); } elseif ($self_class && $return_type_lc === 'self') { $return_type = $return_type->setValue($self_class); @@ -862,13 +862,13 @@ private static function expandConditional( if ($assertion && $return_type->param_name === (string) $return_type->if_type) { $if_conditional_return_type = TypeCombiner::combine( $if_conditional_return_types, - $codebase + $codebase, ); $if_conditional_return_type = SimpleAssertionReconciler::reconcile( $assertion, $codebase, - $if_conditional_return_type + $if_conditional_return_type, ); @@ -880,13 +880,13 @@ private static function expandConditional( if ($assertion && $return_type->param_name === (string) $return_type->else_type) { $else_conditional_return_type = TypeCombiner::combine( $else_conditional_return_types, - $codebase + $codebase, ); $else_conditional_return_type = SimpleNegatedAssertionReconciler::reconcile( $codebase, $assertion, - $else_conditional_return_type + $else_conditional_return_type, ); if ($else_conditional_return_type) { @@ -901,7 +901,7 @@ private static function expandConditional( if ($number_of_types > 1) { $all_conditional_return_types = array_filter( $all_conditional_return_types, - static fn(Atomic $atomic_type): bool => !$atomic_type instanceof TNever + static fn(Atomic $atomic_type): bool => !$atomic_type instanceof TNever, ); } @@ -910,7 +910,7 @@ private static function expandConditional( if ($number_of_types > 1) { $all_conditional_return_types = array_filter( $all_conditional_return_types, - static fn(Atomic $atomic_type): bool => !$atomic_type instanceof TVoid + static fn(Atomic $atomic_type): bool => !$atomic_type instanceof TVoid, ); if (count($all_conditional_return_types) !== $number_of_types) { @@ -921,7 +921,7 @@ private static function expandConditional( if ($all_conditional_return_types) { $combined = TypeCombiner::combine( array_values($all_conditional_return_types), - $codebase + $codebase, ); $return_type = $return_type->setTypes($new_as_type); @@ -970,7 +970,7 @@ private static function expandConditional( $expand_generic, $expand_templates, $throw_on_unresolvable_constant, - ) + ), ); return [$return_type]; } @@ -988,11 +988,11 @@ private static function expandPropertiesOf( if ($self_class) { $return_type = $return_type->replaceClassLike( 'self', - $self_class + $self_class, ); $return_type = $return_type->replaceClassLike( 'static', - is_string($static_class_type) ? $static_class_type : $self_class + is_string($static_class_type) ? $static_class_type : $self_class, ); } @@ -1040,7 +1040,7 @@ private static function expandPropertiesOf( $property->type, $return_type->classlike_type, $storage, - $storage + $storage, ) : $property->type ; @@ -1111,7 +1111,7 @@ private static function expandKeyOfValueOf( $constant_type = $codebase->classlikes->getClassConstantType( $type_param->fq_classlike_name, $type_param->const_name, - ReflectionProperty::IS_PRIVATE + ReflectionProperty::IS_PRIVATE, ); } catch (CircularReferenceException $e) { return [$return_type]; @@ -1136,7 +1136,7 @@ private static function expandKeyOfValueOf( $type_atomics = array_merge( $type_atomics, - array_values($constant_type->getAtomicTypes()) + array_values($constant_type->getAtomicTypes()), ); } if ($type_atomics === []) { diff --git a/src/Psalm/Internal/Type/TypeParser.php b/src/Psalm/Internal/Type/TypeParser.php index 552b94e054f..f255618d9fb 100644 --- a/src/Psalm/Internal/Type/TypeParser.php +++ b/src/Psalm/Internal/Type/TypeParser.php @@ -137,7 +137,7 @@ public static function parseTokens( 0, strlen($only_token[0]), isset($only_token[2]) && $only_token[2] !== $only_token[0] ? $only_token[2] : null, - $from_docblock + $from_docblock, ); return new Union([$atomic], ['from_docblock' => $from_docblock]); @@ -152,7 +152,7 @@ public static function parseTokens( $analysis_php_version_id, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); if (!($parsed_type instanceof Union)) { @@ -181,7 +181,7 @@ public static function getTypeFromTree( $codebase, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } @@ -191,7 +191,7 @@ public static function getTypeFromTree( $codebase, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } @@ -201,7 +201,7 @@ public static function getTypeFromTree( $codebase, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } @@ -211,7 +211,7 @@ public static function getTypeFromTree( $codebase, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } @@ -222,7 +222,7 @@ public static function getTypeFromTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); if (!$callable_type instanceof TCallable && !$callable_type instanceof TClosure) { @@ -239,7 +239,7 @@ public static function getTypeFromTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); $callable_type->return_type = $return_type instanceof Union @@ -256,7 +256,7 @@ public static function getTypeFromTree( $codebase, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } @@ -275,7 +275,7 @@ public static function getTypeFromTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } @@ -290,7 +290,7 @@ public static function getTypeFromTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); if ($non_nullable_type instanceof Union) { @@ -321,7 +321,7 @@ public static function getTypeFromTree( new Union([new TNamedObject($parse_tree->as)]), 'class-string-map', [], - $from_docblock + $from_docblock, ); return $result; } @@ -345,7 +345,7 @@ public static function getTypeFromTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); $if_type = self::getTypeFromTree( @@ -354,7 +354,7 @@ public static function getTypeFromTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); $else_type = self::getTypeFromTree( @@ -363,7 +363,7 @@ public static function getTypeFromTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); if ($conditional_type instanceof Atomic) { @@ -385,7 +385,7 @@ public static function getTypeFromTree( $conditional_type, $if_type, $else_type, - $from_docblock + $from_docblock, ); } @@ -407,7 +407,7 @@ public static function getTypeFromTree( $fq_classlike_name, $template_type_map[$fq_classlike_name][$first_class], $first_class, - $from_docblock + $from_docblock, ); } @@ -440,7 +440,7 @@ public static function getTypeFromTree( $parse_tree->offset_start, $parse_tree->offset_end, $parse_tree->text, - $from_docblock + $from_docblock, ); } @@ -456,13 +456,13 @@ private static function getGenericParamClass( 'object', null, $defining_class, - $from_docblock + $from_docblock, ); } if (!$as->isSingle()) { throw new TypeParseTreeException( - 'Invalid templated classname \'' . $as . '\'' + 'Invalid templated classname \'' . $as . '\'', ); } @@ -473,7 +473,7 @@ private static function getGenericParamClass( 'object', null, $defining_class, - $from_docblock + $from_docblock, ); } @@ -484,7 +484,7 @@ private static function getGenericParamClass( false, false, [], - $from_docblock + $from_docblock, ); $as = $as->getBuilder()->substitute(new Union([$t]), new Union([$traversable]))->freeze(); @@ -494,7 +494,7 @@ private static function getGenericParamClass( $traversable->value, $traversable, $defining_class, - $from_docblock + $from_docblock, ); } @@ -510,13 +510,13 @@ private static function getGenericParamClass( $t_atomic_type->value ?? 'object', $t_atomic_type, $t->defining_class, - $from_docblock + $from_docblock, ); } if (!$t instanceof TNamedObject) { throw new TypeParseTreeException( - 'Invalid templated classname \'' . $t->getId() . '\'' + 'Invalid templated classname \'' . $t->getId() . '\'', ); } @@ -525,7 +525,7 @@ private static function getGenericParamClass( $t->value, $t, $defining_class, - $from_docblock + $from_docblock, ); } @@ -560,7 +560,7 @@ public static function getComputedIntsFromMask(array $potential_ints, bool $from return array_map( static fn($int): TLiteralInt => new TLiteralInt($int, $from_docblock), - array_values($potential_values) + array_values($potential_values), ); } @@ -589,7 +589,7 @@ private static function getTypeFromGenericTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); if ($generic_type === 'class-string-map' @@ -620,7 +620,7 @@ private static function getTypeFromGenericTree( && in_array( $generic_type_value, ['iterable', 'Traversable', 'Iterator', 'IteratorAggregate', 'arraylike-object'], - true + true, ) ) { array_unshift($generic_params, new Union([new TMixed(false, $from_docblock)])); @@ -660,9 +660,9 @@ private static function getTypeFromGenericTree( false, [ $array_acccess->getKey() => $array_acccess, - $countable->getKey() => $countable + $countable->getKey() => $countable, ], - $from_docblock + $from_docblock, ); } @@ -706,7 +706,7 @@ private static function getTypeFromGenericTree( $class_name, $template_type_map[$class_name][$first_class], $first_class, - $from_docblock + $from_docblock, ); } @@ -726,7 +726,7 @@ private static function getTypeFromGenericTree( if (count($generic_params) !== 2) { throw new TypeParseTreeException( 'There should only be two params for class-string-map, ' - . count($generic_params) . ' provided' + . count($generic_params) . ' provided', ); } @@ -744,12 +744,12 @@ private static function getTypeFromGenericTree( if (!$template_as_type instanceof TNamedObject) { throw new TypeParseTreeException( - 'Unrecognised as type' + 'Unrecognised as type', ); } } else { throw new TypeParseTreeException( - 'Unrecognised class-string-map templated param' + 'Unrecognised class-string-map templated param', ); } @@ -757,7 +757,7 @@ private static function getTypeFromGenericTree( $template_param_name, $template_as_type, $generic_params[1], - $from_docblock + $from_docblock, ); } @@ -774,13 +774,13 @@ private static function getTypeFromGenericTree( $template_param = $generic_params[0]->getSingleAtomic(); if (!$template_param instanceof TTemplateParam) { throw new TypeParseTreeException( - $generic_type_value . '<' . $param_name . '> must be a TTemplateParam.' + $generic_type_value . '<' . $param_name . '> must be a TTemplateParam.', ); } if ($template_param->getIntersectionTypes()) { throw new TypeParseTreeException( $generic_type_value . '<' . $param_name . '> must be a TTemplateParam' - . ' with no intersection types.' + . ' with no intersection types.', ); } @@ -789,7 +789,7 @@ private static function getTypeFromGenericTree( $defining_class, $template_param, TPropertiesOf::filterForTokenName($generic_type_value), - $from_docblock + $from_docblock, ); } @@ -806,7 +806,7 @@ private static function getTypeFromGenericTree( return new TPropertiesOf( $param_union_types[0], TPropertiesOf::filterForTokenName($generic_type_value), - $from_docblock + $from_docblock, ); } @@ -820,13 +820,13 @@ private static function getTypeFromGenericTree( $param_name, $defining_class, $generic_params[0], - $from_docblock + $from_docblock, ); } if (!TKeyOf::isViableTemplateType($generic_params[0])) { throw new TypeParseTreeException( - 'Untemplated key-of param ' . $param_name . ' should be an array' + 'Untemplated key-of param ' . $param_name . ' should be an array', ); } @@ -843,13 +843,13 @@ private static function getTypeFromGenericTree( $param_name, $defining_class, $generic_params[0], - $from_docblock + $from_docblock, ); } if (!TValueOf::isViableTemplateType($generic_params[0])) { throw new TypeParseTreeException( - 'Untemplated value-of param ' . $param_name . ' should be an array' + 'Untemplated value-of param ' . $param_name . ' should be an array', ); } @@ -862,7 +862,7 @@ private static function getTypeFromGenericTree( foreach ($generic_params as $generic_param) { if (!$generic_param->isSingle()) { throw new TypeParseTreeException( - 'int-mask types must all be non-union' + 'int-mask types must all be non-union', ); } @@ -877,14 +877,14 @@ private static function getTypeFromGenericTree( if (!is_int($constant_value)) { throw new TypeParseTreeException( - 'int-mask types must all be integer values' + 'int-mask types must all be integer values', ); } $atomic_type = new TLiteralInt($constant_value, $from_docblock); } else { throw new TypeParseTreeException( - 'int-mask types must all be integer values' + 'int-mask types must all be integer values', ); } } @@ -894,7 +894,7 @@ private static function getTypeFromGenericTree( && strpos($atomic_type->const_name, '*') === false) ) { throw new TypeParseTreeException( - 'int-mask types must all be integer values or scalar class constants' + 'int-mask types must all be integer values or scalar class constants', ); } @@ -928,13 +928,13 @@ private static function getTypeFromGenericTree( && !$param_type instanceof TKeyOf ) { throw new TypeParseTreeException( - 'Invalid reference passed to int-mask-of' + 'Invalid reference passed to int-mask-of', ); } elseif ($param_type instanceof TClassConstant && strpos($param_type->const_name, '*') === false ) { throw new TypeParseTreeException( - 'Class constant passed to int-mask-of must be a wildcard type' + 'Class constant passed to int-mask-of must be a wildcard type', ); } @@ -956,7 +956,7 @@ private static function getTypeFromGenericTree( ) ) { throw new TypeParseTreeException( - "Invalid type \"{$generic_param->getId()}\" as int $bound_name boundary" + "Invalid type \"{$generic_param->getId()}\" as int $bound_name boundary", ); } @@ -973,13 +973,13 @@ private static function getTypeFromGenericTree( if (is_int($min_bound) && is_int($max_bound) && $min_bound > $max_bound) { throw new TypeParseTreeException( - "Min bound can't be greater than max bound, int<$min_bound, $max_bound> given" + "Min bound can't be greater than max bound, int<$min_bound, $max_bound> given", ); } if (is_int($min_bound) && is_int($max_bound) && $min_bound > $max_bound) { throw new TypeParseTreeException( - "Min bound can't be greater than max bound, int<$min_bound, $max_bound> given" + "Min bound can't be greater than max bound, int<$min_bound, $max_bound> given", ); } @@ -1024,7 +1024,7 @@ private static function getTypeFromUnionTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); $has_null = true; } else { @@ -1034,7 +1034,7 @@ private static function getTypeFromUnionTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } @@ -1055,7 +1055,7 @@ private static function getTypeFromUnionTree( if (!$atomic_types) { throw new TypeParseTreeException( - 'No atomic types found' + 'No atomic types found', ); } @@ -1083,12 +1083,12 @@ private static function getTypeFromIntersectionTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); if (!$atomic_type instanceof Atomic) { throw new TypeParseTreeException( - 'Intersection types cannot contain unions' + 'Intersection types cannot contain unions', ); } @@ -1140,14 +1140,14 @@ private static function getTypeFromIntersectionTree( $new_type = Type::intersectUnionTypes( $properties[$property], $property_type, - $codebase + $codebase, ); if ($new_type === null) { throw new TypeParseTreeException( 'Incompatible intersection types for "' . $property . '", ' . $properties[$property] . ' and ' . $property_type - . ' provided' + . ' provided', ); } $properties[$property] = $new_type; @@ -1174,7 +1174,7 @@ private static function getTypeFromIntersectionTree( null, $fallback_params, false, - $from_docblock + $from_docblock, ); } @@ -1185,7 +1185,7 @@ private static function getTypeFromIntersectionTree( if (!$intersection_type instanceof TTypeAlias) { throw new TypeParseTreeException( 'Intersection types with a type alias can only be comprised of other type aliases, ' - . get_class($intersection_type) . ' provided' + . get_class($intersection_type) . ' provided', ); } @@ -1206,7 +1206,7 @@ private static function getTypeFromIntersectionTree( ) { throw new TypeParseTreeException( 'Intersection types must be all objects, ' - . get_class($intersection_type) . ' provided' + . get_class($intersection_type) . ' provided', ); } @@ -1269,7 +1269,7 @@ private static function getTypeFromCallableTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } else { $tree_type = new TMixed(false, $from_docblock); @@ -1288,7 +1288,7 @@ private static function getTypeFromCallableTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); } @@ -1301,7 +1301,7 @@ private static function getTypeFromCallableTree( null, $is_optional, false, - $is_variadic + $is_variadic, ); $params[] = $param; @@ -1367,7 +1367,7 @@ private static function getTypeFromIndexAccessTree( $array_param_name, $offset_param_name, $array_defining_class, - $from_docblock + $from_docblock, ); } @@ -1405,7 +1405,7 @@ private static function getTypeFromKeyedArrayTree( if ($property_branch instanceof FieldEllipsis) { if ($i !== count($parse_tree->children) - 1) { throw new TypeParseTreeException( - 'Unexpected ...' + 'Unexpected ...', ); } @@ -1421,7 +1421,7 @@ private static function getTypeFromKeyedArrayTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); $property_maybe_undefined = false; $property_key = $i; @@ -1433,7 +1433,7 @@ private static function getTypeFromKeyedArrayTree( null, $template_type_map, $type_aliases, - $from_docblock + $from_docblock, ); $property_maybe_undefined = $property_branch->possibly_undefined; if (strpos($property_branch->value, '::')) { @@ -1465,7 +1465,7 @@ private static function getTypeFromKeyedArrayTree( } } else { throw new TypeParseTreeException( - 'Missing property type' + 'Missing property type', ); } @@ -1522,7 +1522,7 @@ private static function getTypeFromKeyedArrayTree( ? null : [$is_list ? Type::getInt() : Type::getArrayKey(), Type::getMixed()], $is_list, - $from_docblock + $from_docblock, ); } } diff --git a/src/Psalm/Internal/Type/TypeTokenizer.php b/src/Psalm/Internal/Type/TypeTokenizer.php index 044d9981d5f..813160cd619 100644 --- a/src/Psalm/Internal/Type/TypeTokenizer.php +++ b/src/Psalm/Internal/Type/TypeTokenizer.php @@ -369,7 +369,7 @@ public static function getFullyQualifiedTokens( [ '<', '>', '|', '?', ',', '{', '}', ':', '::', '[', ']', '(', ')', '&', '=', '...', 'as', 'is', ], - true + true, )) { continue; } @@ -496,7 +496,7 @@ public static function getFullyQualifiedTokens( } else { $type_tokens[$i][0] = Type::getFQCLNFromString( $string_type_token[0], - $aliases + $aliases, ); } } diff --git a/src/Psalm/Internal/TypeVisitor/ClasslikeReplacer.php b/src/Psalm/Internal/TypeVisitor/ClasslikeReplacer.php index 651251380ae..576f647cd3e 100644 --- a/src/Psalm/Internal/TypeVisitor/ClasslikeReplacer.php +++ b/src/Psalm/Internal/TypeVisitor/ClasslikeReplacer.php @@ -34,7 +34,7 @@ protected function enterNode(TypeNode &$type): ?int $type = new TClassConstant( $this->new, $type->const_name, - $type->from_docblock + $type->from_docblock, ); } } elseif ($type instanceof TClassString) { @@ -45,7 +45,7 @@ protected function enterNode(TypeNode &$type): ?int $type->is_loaded, $type->is_interface, $type->is_enum, - $type->from_docblock + $type->from_docblock, ); } } elseif ($type instanceof TNamedObject || $type instanceof TLiteralClassString) { diff --git a/src/Psalm/Internal/TypeVisitor/TemplateTypeCollector.php b/src/Psalm/Internal/TypeVisitor/TemplateTypeCollector.php index ecb07a50b0d..a6b2275a466 100644 --- a/src/Psalm/Internal/TypeVisitor/TemplateTypeCollector.php +++ b/src/Psalm/Internal/TypeVisitor/TemplateTypeCollector.php @@ -30,13 +30,13 @@ protected function enterNode(TypeNode $type): ?int $this->template_types[] = new TTemplateParam( $type->param_name, $extends ? new Union([$extends]) : Type::getMixed(), - $type->defining_class + $type->defining_class, ); } elseif ($type instanceof TConditional) { $this->template_types[] = new TTemplateParam( $type->param_name, Type::getMixed(), - $type->defining_class + $type->defining_class, ); } diff --git a/src/Psalm/Internal/TypeVisitor/TypeChecker.php b/src/Psalm/Internal/TypeVisitor/TypeChecker.php index 011d99c78ac..d135de1be72 100644 --- a/src/Psalm/Internal/TypeVisitor/TypeChecker.php +++ b/src/Psalm/Internal/TypeVisitor/TypeChecker.php @@ -139,7 +139,7 @@ private function checkNamedObject(TNamedObject $atomic): void $this->source->getFilePath(), $this->code_location->raw_file_start + $atomic->offset_start, $this->code_location->raw_file_start + $atomic->offset_end, - $atomic->value + $atomic->value, ); } @@ -149,7 +149,7 @@ private function checkNamedObject(TNamedObject $atomic): void $codebase->file_reference_provider->addMethodReferenceToClassMember( $this->calling_method_id, 'use:' . $atomic->text . ':' . md5($this->source->getFilePath()), - false + false, ); } @@ -161,7 +161,7 @@ private function checkNamedObject(TNamedObject $atomic): void $this->source->getFQCLN(), $this->calling_method_id, $this->suppressed_issues, - new ClassLikeNameOptions($this->inferred, false, true, true, $atomic->from_docblock) + new ClassLikeNameOptions($this->inferred, false, true, true, $atomic->from_docblock), ) === false ) { $this->has_errors = true; @@ -182,18 +182,18 @@ private function checkNamedObject(TNamedObject $atomic): void new DeprecatedInterface( 'Interface ' . $atomic->value . ' is marked as deprecated', $this->code_location, - $atomic->value + $atomic->value, ), - $this->source->getSuppressedIssues() + $this->suppressed_issues + $this->source->getSuppressedIssues() + $this->suppressed_issues, ); } else { IssueBuffer::maybeAdd( new DeprecatedClass( 'Class ' . $atomic->value . ' is marked as deprecated', $this->code_location, - $atomic->value + $atomic->value, ), - $this->source->getSuppressedIssues() + $this->suppressed_issues + $this->source->getSuppressedIssues() + $this->suppressed_issues, ); } } @@ -225,18 +225,18 @@ private function checkGenericParams(TGenericObject $atomic): void new MissingTemplateParam( $atomic->value . ' has missing template params, expecting ' . $template_type_count, - $this->code_location + $this->code_location, ), - $this->suppressed_issues + $this->suppressed_issues, ); } elseif ($template_type_count < $template_param_count) { IssueBuffer::maybeAdd( new TooManyTemplateParams( $atomic->getId(). ' has too many template params, expecting ' . $template_type_count, - $this->code_location + $this->code_location, ), - $this->suppressed_issues + $this->suppressed_issues, ); } @@ -256,7 +256,7 @@ private function checkGenericParams(TGenericObject $atomic): void $expected_type_param, $defining_class, null, - null + null, ); $type_param = TypeExpander::expandUnion( @@ -264,7 +264,7 @@ private function checkGenericParams(TGenericObject $atomic): void $type_param, $defining_class, null, - null + null, ); if (!UnionTypeComparator::isContainedBy($codebase, $type_param, $expected_type_param)) { @@ -275,9 +275,9 @@ private function checkGenericParams(TGenericObject $atomic): void . ' expects type ' . $expected_type_param->getId() . ', type ' . $type_param->getId() . ' given', - $this->code_location + $this->code_location, ), - $this->suppressed_issues + $this->suppressed_issues, ); } } @@ -302,7 +302,7 @@ public function checkScalarClassConstant(TClassConstant $atomic): void null, null, $this->suppressed_issues, - new ClassLikeNameOptions($this->inferred, false, true, true, $atomic->from_docblock) + new ClassLikeNameOptions($this->inferred, false, true, true, $atomic->from_docblock), ) === false ) { $this->has_errors = true; @@ -318,7 +318,7 @@ public function checkScalarClassConstant(TClassConstant $atomic): void $fq_classlike_name, null, true, - true + true, ); $is_defined = true; @@ -327,7 +327,7 @@ public function checkScalarClassConstant(TClassConstant $atomic): void $fq_classlike_name, $atomic->const_name, ReflectionProperty::IS_PRIVATE, - null + null, ); $is_defined = null !== $class_constant_type; @@ -337,9 +337,9 @@ public function checkScalarClassConstant(TClassConstant $atomic): void IssueBuffer::maybeAdd( new UndefinedConstant( 'Constant ' . $fq_classlike_name . '::' . $const_name . ' is not defined', - $this->code_location + $this->code_location, ), - $this->source->getSuppressedIssues() + $this->source->getSuppressedIssues(), ); } } @@ -375,9 +375,9 @@ public function checkTemplateParam(TTemplateParam $atomic): void new InvalidTemplateParam( 'Template param ' . $atomic->param_name . ' of ' . $atomic->defining_class . ' is marked covariant and cannot be used here', - $this->code_location + $this->code_location, ), - $this->source->getSuppressedIssues() + $this->source->getSuppressedIssues(), ); } } @@ -391,9 +391,9 @@ public function checkResource(TResource $atomic): void new ReservedWord( '\'resource\' is a reserved word', $this->code_location, - 'resource' + 'resource', ), - $this->source->getSuppressedIssues() + $this->source->getSuppressedIssues(), ); } } diff --git a/src/Psalm/Internal/TypeVisitor/TypeLocalizer.php b/src/Psalm/Internal/TypeVisitor/TypeLocalizer.php index 4bfb4ac5250..81ba6a0eb42 100644 --- a/src/Psalm/Internal/TypeVisitor/TypeLocalizer.php +++ b/src/Psalm/Internal/TypeVisitor/TypeLocalizer.php @@ -48,12 +48,12 @@ protected function enterNode(TypeNode &$type): ?int if (count($types) === 1 && $types[0] instanceof TNamedObject) { $type = $type->setAs( $type->as, - $types[0] + $types[0], ); } elseif ($type->as_type !== null) { $type = $type->setAs( $type->as, - null + null, ); } } @@ -75,7 +75,7 @@ protected function enterNode(TypeNode &$type): ?int ) { $types_to_add = Methods::getExtendedTemplatedTypes( $atomic_type, - $this->extends + $this->extends, ); if ($types_to_add) { diff --git a/src/Psalm/Internal/TypeVisitor/TypeScanner.php b/src/Psalm/Internal/TypeVisitor/TypeScanner.php index 7a844910e25..d840e7327c2 100644 --- a/src/Psalm/Internal/TypeVisitor/TypeScanner.php +++ b/src/Psalm/Internal/TypeVisitor/TypeScanner.php @@ -51,7 +51,7 @@ protected function enterNode(TypeNode $type): ?int $type->value, false, !$type->from_docblock, - $this->phantom_classes + $this->phantom_classes, ); if ($this->file_storage) { @@ -65,7 +65,7 @@ protected function enterNode(TypeNode $type): ?int $type->fq_classlike_name, false, !$type->from_docblock, - $this->phantom_classes + $this->phantom_classes, ); if ($this->file_storage) { @@ -80,7 +80,7 @@ protected function enterNode(TypeNode $type): ?int $type->value, false, !$type->from_docblock, - $this->phantom_classes + $this->phantom_classes, ); if ($this->file_storage) { diff --git a/src/Psalm/Issue/CodeIssue.php b/src/Psalm/Issue/CodeIssue.php index 0b8035efd09..08645794df6 100644 --- a/src/Psalm/Issue/CodeIssue.php +++ b/src/Psalm/Issue/CodeIssue.php @@ -99,11 +99,11 @@ public function toIssueData(string $severity): IssueData ? [ TaintedInput::nodeToDataFlowNodeData( $origin_location, - 'The type of ' . $location->getSelectedText() . ' is sourced from here' - ) + 'The type of ' . $location->getSelectedText() . ' is sourced from here', + ), ] : null, - $this->dupe_key + $this->dupe_key, ); } } diff --git a/src/Psalm/Issue/TaintedInput.php b/src/Psalm/Issue/TaintedInput.php index 66f09b226e1..15713c09335 100644 --- a/src/Psalm/Issue/TaintedInput.php +++ b/src/Psalm/Issue/TaintedInput.php @@ -74,7 +74,7 @@ public static function nodeToDataFlowNodeData( $selection_bounds[1], $snippet_bounds[0], $location->getColumn(), - $location->getEndColumn() + $location->getEndColumn(), ); } diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php index a3df2e8f19d..02c99b0885f 100644 --- a/src/Psalm/IssueBuffer.php +++ b/src/Psalm/IssueBuffer.php @@ -324,7 +324,7 @@ public static function add(CodeIssue $e, bool $is_fixable = false): bool $issue_type . ' - ' . $e->getShortLocationWithPrevious() . ':' . $e->code_location->getColumn() - . ' - ' . $message + . ' - ' . $message, ); } @@ -497,9 +497,9 @@ public static function processUnusedSuppressions(FileProvider $file_provider): v $file_path, $config->shortenFileName($file_path), $start, - $end - ) - ) + $end, + ), + ), ); } } @@ -559,7 +559,7 @@ public static function finish( if (self::$issues_data) { if (in_array( $project_analyzer->stdout_report_options->format, - [Report::TYPE_CONSOLE, Report::TYPE_PHP_STORM] + [Report::TYPE_CONSOLE, Report::TYPE_PHP_STORM], )) { echo "\n"; } @@ -593,7 +593,7 @@ public static function finish( $position = array_search( trim($issue_data->selected_text), $issue_baseline[$file][$type]['s'], - true + true, ); if ($position !== false) { @@ -617,7 +617,7 @@ public static function finish( echo self::getOutput( $issues_data, $project_analyzer->stdout_report_options, - $codebase->analyzer->getTotalTypeCoverage($codebase) + $codebase->analyzer->getTotalTypeCoverage($codebase), ); foreach ($issues_data as $file_issues) { @@ -646,7 +646,7 @@ public static function finish( $codebase, $issues_data, $build_info, - $source_control_info + $source_control_info, ); $codebase->config->eventDispatcher->dispatchAfterAnalysis($event); @@ -666,14 +666,14 @@ public static function finish( self::getOutput( $issues_data, $report_options, - $codebase->analyzer->getTotalTypeCoverage($codebase) - ) + $codebase->analyzer->getTotalTypeCoverage($codebase), + ), ); } if (in_array( $project_analyzer->stdout_report_options->format, - [Report::TYPE_CONSOLE, Report::TYPE_PHP_STORM] + [Report::TYPE_CONSOLE, Report::TYPE_PHP_STORM], )) { echo str_repeat('-', 30) . "\n"; @@ -858,7 +858,7 @@ public static function getOutput( self::$fixable_issue_counts, $report_options, $mixed_expression_count, - $total_expression_count + $total_expression_count, ); break; diff --git a/src/Psalm/Plugin/DynamicFunctionStorage.php b/src/Psalm/Plugin/DynamicFunctionStorage.php index 5d5256c7eef..b0f389a7c44 100644 --- a/src/Psalm/Plugin/DynamicFunctionStorage.php +++ b/src/Psalm/Plugin/DynamicFunctionStorage.php @@ -66,7 +66,7 @@ public function toFunctionStorage(string $function_cased_name): FunctionStorage foreach ($this->templates as $template) { $storage->template_types[$template->param_name] = [ - $template->defining_class => $template->as + $template->defining_class => $template->as, ]; } } diff --git a/src/Psalm/Plugin/Shepherd.php b/src/Psalm/Plugin/Shepherd.php index 9cc1467abe2..dce9e8779e2 100644 --- a/src/Psalm/Plugin/Shepherd.php +++ b/src/Psalm/Plugin/Shepherd.php @@ -64,7 +64,7 @@ public static function afterAnalysis( if ($build_info) { $normalized_data = $issues === [] ? [] : array_filter( array_merge(...array_values($issues)), - static fn(IssueData $i): bool => $i->severity === 'error' + static fn(IssueData $i): bool => $i->severity === 'error', ); $data = [ @@ -72,7 +72,7 @@ public static function afterAnalysis( 'git' => $source_control_data, 'issues' => $normalized_data, 'coverage' => $codebase->analyzer->getTotalTypeCoverage($codebase), - 'level' => Config::getInstance()->level + 'level' => Config::getInstance()->level, ]; $payload = json_encode($data, JSON_THROW_ON_ERROR); @@ -97,7 +97,7 @@ public static function afterAnalysis( [ 'Content-Type: application/json', 'Content-Length: ' . strlen($payload), - ] + ], ); // Submit the POST request diff --git a/src/Psalm/PluginFileExtensionsSocket.php b/src/Psalm/PluginFileExtensionsSocket.php index 9d5e9c03537..1e698e89cc5 100644 --- a/src/Psalm/PluginFileExtensionsSocket.php +++ b/src/Psalm/PluginFileExtensionsSocket.php @@ -50,9 +50,9 @@ public function addFileTypeScanner(string $fileExtension, string $className): vo sprintf( 'Class %s must be of type %s', $className, - FileScanner::class + FileScanner::class, ), - 1_622_727_271 + 1_622_727_271, ); } if (!empty($this->config->getFiletypeScanners()[$fileExtension]) @@ -60,7 +60,7 @@ public function addFileTypeScanner(string $fileExtension, string $className): vo ) { throw new LogicException( sprintf('Cannot redeclare scanner for file-type %s', $fileExtension), - 1_622_727_272 + 1_622_727_272, ); } $this->additionalFileTypeScanners[$fileExtension] = $className; @@ -86,9 +86,9 @@ public function addFileTypeAnalyzer(string $fileExtension, string $className): v sprintf( 'Class %s must be of type %s', $className, - FileAnalyzer::class + FileAnalyzer::class, ), - 1_622_727_281 + 1_622_727_281, ); } if (!empty($this->config->getFiletypeAnalyzers()[$fileExtension]) @@ -96,7 +96,7 @@ public function addFileTypeAnalyzer(string $fileExtension, string $className): v ) { throw new LogicException( sprintf('Cannot redeclare analyzer for file-type %s', $fileExtension), - 1_622_727_282 + 1_622_727_282, ); } $this->additionalFileTypeAnalyzers[$fileExtension] = $className; diff --git a/src/Psalm/Progress/DefaultProgress.php b/src/Psalm/Progress/DefaultProgress.php index 7308a919b8a..f00717c1c58 100644 --- a/src/Psalm/Progress/DefaultProgress.php +++ b/src/Psalm/Progress/DefaultProgress.php @@ -41,7 +41,7 @@ public function taskDone(int $level): void $inner_progress = self::renderInnerProgressBar( self::NUMBER_OF_COLUMNS, - $this->progress / $this->number_of_tasks + $this->progress / $this->number_of_tasks, ); $this->write($inner_progress . ' ' . $this->getOverview() . "\r"); diff --git a/src/Psalm/Progress/LongProgress.php b/src/Psalm/Progress/LongProgress.php index 0ff13f136ac..6600d7ce55c 100644 --- a/src/Psalm/Progress/LongProgress.php +++ b/src/Psalm/Progress/LongProgress.php @@ -99,7 +99,7 @@ protected function getOverview(): string str_repeat(' ', $leadingSpaces), $this->progress, $this->number_of_tasks, - $percentage + $percentage, ); } diff --git a/src/Psalm/Report.php b/src/Psalm/Report.php index 98350d1e1de..a7b9268dc6a 100644 --- a/src/Psalm/Report.php +++ b/src/Psalm/Report.php @@ -74,7 +74,7 @@ public function __construct( if (!$report_options->show_info) { $this->issues_data = array_filter( $issues_data, - static fn(IssueData $issue_data): bool => $issue_data->severity !== Config::REPORT_INFO + static fn(IssueData $issue_data): bool => $issue_data->severity !== Config::REPORT_INFO, ); } else { $this->issues_data = $issues_data; diff --git a/src/Psalm/Report/CheckstyleReport.php b/src/Psalm/Report/CheckstyleReport.php index 080194dc4f2..d862923b663 100644 --- a/src/Psalm/Report/CheckstyleReport.php +++ b/src/Psalm/Report/CheckstyleReport.php @@ -18,7 +18,7 @@ public function create(): string $message = sprintf( '%s: %s', $issue_data->type, - $issue_data->message + $issue_data->message, ); $output .= '' . "\n"; diff --git a/src/Psalm/Report/CodeClimateReport.php b/src/Psalm/Report/CodeClimateReport.php index a6163ec6708..3cc6fd8bc5b 100644 --- a/src/Psalm/Report/CodeClimateReport.php +++ b/src/Psalm/Report/CodeClimateReport.php @@ -27,7 +27,7 @@ public function create(): string $issues_data = array_map( [$this, 'mapToNewStructure'], - $this->issues_data + $this->issues_data, ); return Json::encode(array_values($issues_data), $options) . "\n"; diff --git a/src/Psalm/Report/EmacsReport.php b/src/Psalm/Report/EmacsReport.php index 185f4a494e1..675c19890b5 100644 --- a/src/Psalm/Report/EmacsReport.php +++ b/src/Psalm/Report/EmacsReport.php @@ -19,7 +19,7 @@ public function create(): string $issue_data->line_from, $issue_data->column_from, ($issue_data->severity === Config::REPORT_ERROR ? 'error' : 'warning'), - $issue_data->message + $issue_data->message, ) . "\n"; } diff --git a/src/Psalm/Report/GithubActionsReport.php b/src/Psalm/Report/GithubActionsReport.php index 8545b41aa11..71a7a0f6c19 100644 --- a/src/Psalm/Report/GithubActionsReport.php +++ b/src/Psalm/Report/GithubActionsReport.php @@ -20,7 +20,7 @@ public function create(): string $this->escapeProperty($issue_data->file_name), $this->escapeProperty($issue_data->line_from), $this->escapeProperty($issue_data->column_from), - $this->escapeProperty($issue_data->type) + $this->escapeProperty($issue_data->type), ); $data = $this->escapeData(sprintf( @@ -29,14 +29,14 @@ public function create(): string $issue_data->line_from, $issue_data->column_from, $issue_data->type, - $issue_data->message . $issue_reference + $issue_data->message . $issue_reference, )); $output .= sprintf( '::%1$s %2$s::%3$s', ($issue_data->severity === Config::REPORT_ERROR ? 'error' : 'warning'), $properties, - $data + $data, ) . "\n"; } @@ -51,7 +51,7 @@ private function escapeData(string $data): string '%' => '%25', "\r" => '%0D', "\n" => '%0A', - ] + ], ); } @@ -66,7 +66,7 @@ private function escapeProperty($value): string "\n" => '%0A', ':' => '%3A', ',' => '%2C', - ] + ], ); } } diff --git a/src/Psalm/Report/JsonReport.php b/src/Psalm/Report/JsonReport.php index a6eed4cb1c9..ab258fdd329 100644 --- a/src/Psalm/Report/JsonReport.php +++ b/src/Psalm/Report/JsonReport.php @@ -21,7 +21,7 @@ static function (IssueData $issue_data): array { unset($issue_data['dupe_key']); return $issue_data; }, - $this->issues_data + $this->issues_data, ); return Json::encode(array_values($issues_data), $options) . "\n"; diff --git a/src/Psalm/Report/PylintReport.php b/src/Psalm/Report/PylintReport.php index 1fa45b296ba..d7e07a8a259 100644 --- a/src/Psalm/Report/PylintReport.php +++ b/src/Psalm/Report/PylintReport.php @@ -25,7 +25,7 @@ private function format(IssueData $issue_data): string $message = sprintf( '%s: %s', $issue_data->type, - $issue_data->message + $issue_data->message, ); if ($issue_data->severity === Config::REPORT_ERROR) { @@ -43,7 +43,7 @@ private function format(IssueData $issue_data): string $issue_data->file_name, $issue_data->line_from, $code, - $message + $message, ); } } diff --git a/src/Psalm/Report/SarifReport.php b/src/Psalm/Report/SarifReport.php index c94be96cb53..1ab249e9aee 100644 --- a/src/Psalm/Report/SarifReport.php +++ b/src/Psalm/Report/SarifReport.php @@ -80,7 +80,7 @@ public function create(): string 'endColumn' => $issue_data->column_to, ], ], - ] + ], ], ]; @@ -95,7 +95,7 @@ public function create(): string 'locations' => [], ], ], - ] + ], ]; foreach ($issue_data->taint_trace as $trace) { diff --git a/src/Psalm/Report/TextReport.php b/src/Psalm/Report/TextReport.php index b8081097378..d2fa2382bf4 100644 --- a/src/Psalm/Report/TextReport.php +++ b/src/Psalm/Report/TextReport.php @@ -20,7 +20,7 @@ public function create(): string $issue_data->column_from, ($issue_data->severity === Config::REPORT_ERROR ? 'error' : 'warning'), $issue_data->type, - $issue_data->message + $issue_data->message, ) . "\n"; } diff --git a/src/Psalm/Report/XmlReport.php b/src/Psalm/Report/XmlReport.php index 7b200ff2878..0e1622e5830 100644 --- a/src/Psalm/Report/XmlReport.php +++ b/src/Psalm/Report/XmlReport.php @@ -24,7 +24,7 @@ static function (IssueData $issue_data): array { if (null !== $issue_data['taint_trace']) { $issue_data['taint_trace'] = array_map( static fn($trace): array => (array) $trace, - $issue_data['taint_trace'] + $issue_data['taint_trace'], ); } @@ -34,7 +34,7 @@ static function (IssueData $issue_data): array { if (null !== $issue_data['other_references']) { $issue_data['other_references'] = array_map( static fn(DataFlowNodeData $reference): array => (array) $reference, - $issue_data['other_references'] + $issue_data['other_references'], ); } @@ -43,14 +43,14 @@ static function (IssueData $issue_data): array { return $issue_data; }, - $this->issues_data - ) + $this->issues_data, + ), ], 'report', true, 'UTF-8', '1.0', - ['preserveWhiteSpace' => false, 'formatOutput' => true] + ['preserveWhiteSpace' => false, 'formatOutput' => true], ); return $xml; diff --git a/src/Psalm/Storage/FunctionLikeStorage.php b/src/Psalm/Storage/FunctionLikeStorage.php index 736dc31c830..8e029d7521e 100644 --- a/src/Psalm/Storage/FunctionLikeStorage.php +++ b/src/Psalm/Storage/FunctionLikeStorage.php @@ -252,8 +252,8 @@ public function getSignature(bool $allow_newlines): string ($newlines ? ' ' : '') . ($param->type ? $param->type->getId(false) : 'mixed') . ' $' . $param->name, - $this->params - ) + $this->params, + ), ) . ($newlines ? "\n" : '') . ') : ' diff --git a/src/Psalm/Storage/Possibilities.php b/src/Psalm/Storage/Possibilities.php index 15ec483918b..70eb35287b4 100644 --- a/src/Psalm/Storage/Possibilities.php +++ b/src/Psalm/Storage/Possibilities.php @@ -48,7 +48,7 @@ public function getUntemplatedCopy( $union = TemplateInferredTypeReplacer::replace( $union, $template_result, - $codebase + $codebase, ); foreach ($union->getAtomicTypes() as $atomic_type) { @@ -64,7 +64,7 @@ public function getUntemplatedCopy( is_string($this->var_id) && $this_var_id ? str_replace('$this->', $this_var_id . '->', $this->var_id) : $this->var_id, - $assertion_rules + $assertion_rules, ); } } diff --git a/src/Psalm/Type.php b/src/Psalm/Type.php index 46552de0710..74d6ae45a90 100644 --- a/src/Psalm/Type.php +++ b/src/Psalm/Type.php @@ -79,10 +79,10 @@ public static function parseString( ): Union { return TypeParser::parseTokens( TypeTokenizer::tokenize( - $type_string + $type_string, ), $analysis_php_version_id, - $template_type_map + $template_type_map, ); } @@ -143,7 +143,7 @@ public static function getStringFromFQCLN( $candidate = preg_replace( '/^' . preg_quote($namespace . '\\') . '/i', '', - $value + $value, ); $candidate_parts = explode('\\', $candidate); @@ -181,11 +181,11 @@ public static function getInt(bool $from_calculation = false, ?int $value = null { if ($value !== null) { return new Union([new TLiteralInt($value)], [ - 'from_calculation' => $from_calculation + 'from_calculation' => $from_calculation, ]); } return new Union([new TInt()], [ - 'from_calculation' => $from_calculation + 'from_calculation' => $from_calculation, ]); } @@ -296,7 +296,7 @@ public static function getClassString(string $extends = 'object'): Union $extends, $extends === 'object' ? null - : new TNamedObject($extends) + : new TNamedObject($extends), ), ]); } @@ -413,7 +413,7 @@ public static function getArray(): Union [ new Union([new TArrayKey]), new Union([new TMixed]), - ] + ], ); return new Union([$type]); @@ -436,7 +436,7 @@ public static function getEmptyArrayAtomic(): TArray [ new Union([new TNever()]), new Union([new TNever()]), - ] + ], ); } @@ -466,7 +466,7 @@ public static function getListAtomic(Union $of, bool $from_docblock = false): TK null, [self::getListKey(), $of], true, - $from_docblock + $from_docblock, ); } @@ -480,7 +480,7 @@ public static function getNonEmptyListAtomic(Union $of, bool $from_docblock = fa null, [self::getListKey(), $of], true, - $from_docblock + $from_docblock, ); } @@ -601,25 +601,25 @@ public static function combineUnionTypes( } else { return $type_2->setProperties([ 'parent_nodes' => array_merge($type_2->parent_nodes, $type_1->parent_nodes), - 'possibly_undefined' => $possibly_undefined ?? $type_2->possibly_undefined + 'possibly_undefined' => $possibly_undefined ?? $type_2->possibly_undefined, ]); } } elseif ($type_2->failed_reconciliation) { return $type_1->setProperties([ 'parent_nodes' => array_merge($type_1->parent_nodes, $type_2->parent_nodes), - 'possibly_undefined' => $possibly_undefined ?? $type_1->possibly_undefined + 'possibly_undefined' => $possibly_undefined ?? $type_1->possibly_undefined, ]); } $combined_type = TypeCombiner::combine( array_merge( array_values($type_1->getAtomicTypes()), - array_values($type_2->getAtomicTypes()) + array_values($type_2->getAtomicTypes()), ), $codebase, $overwrite_empty_array, $allow_mixed_union, - $literal_limit + $literal_limit, ); if (!$type_1->initialized || !$type_2->initialized) { @@ -739,7 +739,7 @@ public static function intersectUnionTypes( $type_1_atomic, $type_2_atomic, $codebase, - $intersection_performed + $intersection_performed, ); if (null !== $intersection_atomic) { @@ -838,7 +838,7 @@ private static function intersectAtomicTypes( if ($type_1_atomic instanceof TInt && $type_2_atomic instanceof TInt) { $int_intersection = TIntRange::intersectIntRanges( TIntRange::convertToIntRange($type_1_atomic), - TIntRange::convertToIntRange($type_2_atomic) + TIntRange::convertToIntRange($type_2_atomic), ); if ($int_intersection && ($int_intersection->min_bound !== null || $int_intersection->max_bound !== null) @@ -857,7 +857,7 @@ private static function intersectAtomicTypes( if (AtomicTypeComparator::isContainedBy( $codebase, $type_2_atomic, - $type_1_atomic + $type_1_atomic, )) { $intersection_atomic = $type_2_atomic; $wider_type = $type_1_atomic; @@ -865,7 +865,7 @@ private static function intersectAtomicTypes( } elseif (AtomicTypeComparator::isContainedBy( $codebase, $type_1_atomic, - $type_2_atomic + $type_2_atomic, )) { $intersection_atomic = $type_1_atomic; $wider_type = $type_2_atomic; @@ -905,7 +905,7 @@ private static function intersectAtomicTypes( throw new LogicException( '$intersection_atomic and $wider_type should be both set or null.' .' Check the preceding code for errors.' - .' Did you forget to assign one of the variables?' + .' Did you forget to assign one of the variables?', ); } if (!self::mayHaveIntersection($intersection_atomic, $codebase) @@ -913,7 +913,7 @@ private static function intersectAtomicTypes( ) { throw new LogicException( '$intersection_atomic and $wider_type should be both support intersection.' - .' Check the preceding code for errors.' + .' Check the preceding code for errors.', ); } @@ -923,7 +923,7 @@ private static function intersectAtomicTypes( $final_intersection = array_merge( [$wider_type_clone->getKey() => $wider_type_clone], - $intersection_atomic->getIntersectionTypes() + $intersection_atomic->getIntersectionTypes(), ); $wider_type_intersection_types = $wider_type->getIntersectionTypes(); diff --git a/src/Psalm/Type/Atomic.php b/src/Psalm/Type/Atomic.php index 7e76f674f07..f8de4d373df 100644 --- a/src/Psalm/Type/Atomic.php +++ b/src/Psalm/Type/Atomic.php @@ -141,7 +141,7 @@ public function replaceClassLike(string $old, string $new): self /** @psalm-suppress ImpureMethodCall ClasslikeReplacer will always clone */ (new ClasslikeReplacer( $old, - $new + $new, ))->traverse($type); return $type; } @@ -244,19 +244,19 @@ private static function createInner( case 'associative-array': return new TArray([ new Union([new TArrayKey($from_docblock)]), - new Union([new TMixed(false, $from_docblock)]) + new Union([new TMixed(false, $from_docblock)]), ]); case 'non-empty-array': return new TNonEmptyArray([ new Union([new TArrayKey($from_docblock)]), - new Union([new TMixed(false, $from_docblock)]) + new Union([new TMixed(false, $from_docblock)]), ]); case 'callable-array': return new TCallableArray([ new Union([new TArrayKey($from_docblock)]), - new Union([new TMixed(false, $from_docblock)]) + new Union([new TMixed(false, $from_docblock)]), ]); case 'list': @@ -394,7 +394,7 @@ private static function createInner( return new TTemplateParam( $value, $template_type_map[$value][$first_class], - $first_class + $first_class, ); } @@ -524,10 +524,10 @@ public function hasTraversableInterface(Codebase $codebase): bool || ($codebase->classOrInterfaceExists($this->value) && ($codebase->classExtendsOrImplements( $this->value, - 'Traversable' + 'Traversable', ) || $codebase->interfaceExtends( $this->value, - 'Traversable' + 'Traversable', ))) || ( $this->extra_types @@ -547,10 +547,10 @@ public function hasCountableInterface(Codebase $codebase): bool || ($codebase->classOrInterfaceExists($this->value) && ($codebase->classExtendsOrImplements( $this->value, - 'Countable' + 'Countable', ) || $codebase->interfaceExtends( $this->value, - 'Countable' + 'Countable', ))) || ( $this->extra_types @@ -585,10 +585,10 @@ public function hasArrayAccessInterface(Codebase $codebase): bool || ($codebase->classOrInterfaceExists($this->value) && ($codebase->classExtendsOrImplements( $this->value, - 'ArrayAccess' + 'ArrayAccess', ) || $codebase->interfaceExtends( $this->value, - 'ArrayAccess' + 'ArrayAccess', ))) || ( $this->extra_types diff --git a/src/Psalm/Type/Atomic/CallableTrait.php b/src/Psalm/Type/Atomic/CallableTrait.php index f53d3734217..90f70aadfcf 100644 --- a/src/Psalm/Type/Atomic/CallableTrait.php +++ b/src/Psalm/Type/Atomic/CallableTrait.php @@ -148,7 +148,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - false + false, ) . ($return_type_multiple ? ')' : ''); } @@ -247,7 +247,7 @@ protected function replaceCallableTemplateTypesWithStandins( $replace, !$add_lower_bound, null, - $depth + $depth, )); $replaced = $replaced || $new_param !== $param; $params[$offset] = $new_param; @@ -268,7 +268,7 @@ protected function replaceCallableTemplateTypesWithStandins( $calling_class, $calling_function, $replace, - $add_lower_bound + $add_lower_bound, ); $replaced = $replaced || $this->return_type !== $return_type; } @@ -296,7 +296,7 @@ protected function replaceCallableTemplateTypesWithArgTypes( $new_param = $param->setType(TemplateInferredTypeReplacer::replace( $param->type, $template_result, - $codebase + $codebase, )); $replaced = $replaced || $new_param !== $param; $params[$k] = $new_param; @@ -309,7 +309,7 @@ protected function replaceCallableTemplateTypesWithArgTypes( $return_type = TemplateInferredTypeReplacer::replace( $return_type, $template_result, - $codebase + $codebase, ); $replaced = $replaced || $return_type !== $this->return_type; } diff --git a/src/Psalm/Type/Atomic/GenericTrait.php b/src/Psalm/Type/Atomic/GenericTrait.php index 843fe8f93e6..aa3e5d9e048 100644 --- a/src/Psalm/Type/Atomic/GenericTrait.php +++ b/src/Psalm/Type/Atomic/GenericTrait.php @@ -54,8 +54,8 @@ public function getId(bool $exact = true, bool $nested = false): string '&', array_map( static fn(Atomic $type): string => $type->getId($exact, true), - $this->extra_types - ) + $this->extra_types, + ), ); } @@ -138,8 +138,8 @@ public function toNamespacedString( array_map( static fn(Atomic $extra_type): string => $extra_type->toNamespacedString($namespace, $aliased_classes, $this_class, false), - $this->extra_types - ) + $this->extra_types, + ), ); } @@ -150,8 +150,8 @@ public function toNamespacedString( array_map( static fn(Union $type_param): string => $type_param->toNamespacedString($namespace, $aliased_classes, $this_class, false), - $type_params - ) + $type_params, + ), ) . '>' . $extra_types; } @@ -186,7 +186,7 @@ protected function replaceTypeParamsTemplateTypesWithStandins( $codebase, $input_type, $this, - $container_type_params_covariant + $container_type_params_covariant, ); } @@ -228,7 +228,7 @@ protected function replaceTypeParamsTemplateTypesWithStandins( && $this instanceof TGenericObject ? $this->value : null, - $depth + 1 + $depth + 1, ); } @@ -247,7 +247,7 @@ protected function replaceTypeParamsTemplateTypesWithArgTypes( $type_param = TemplateInferredTypeReplacer::replace( $type_param, $template_result, - $codebase + $codebase, ); if ($this instanceof TArray && $offset === 0 && $type_param->isMixed()) { diff --git a/src/Psalm/Type/Atomic/HasIntersectionTrait.php b/src/Psalm/Type/Atomic/HasIntersectionTrait.php index 306e49f1f16..c5a88d55f99 100644 --- a/src/Psalm/Type/Atomic/HasIntersectionTrait.php +++ b/src/Psalm/Type/Atomic/HasIntersectionTrait.php @@ -45,10 +45,10 @@ private function getNamespacedIntersectionTypes( $namespace, $aliased_classes, $this_class, - $use_phpdoc_format + $use_phpdoc_format, ), - $this->extra_types - ) + $this->extra_types, + ), ); } @@ -60,7 +60,7 @@ public function addIntersectionType(Atomic $type): self { return $this->setIntersectionTypes(array_merge( $this->extra_types, - [$type->getKey() => $type] + [$type->getKey() => $type], )); } @@ -105,7 +105,7 @@ protected function replaceIntersectionTemplateTypesWithArgTypes( ) { $template_type = TemplateStandinTypeReplacer::getMostSpecificTypeFromBounds( $template_result->lower_bounds[$extra_type->param_name][$extra_type->defining_class], - $codebase + $codebase, ); foreach ($template_type->getAtomicTypes() as $template_type_part) { @@ -154,7 +154,7 @@ protected function replaceIntersectionTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); $new_types[$type->getKey()] = $type; } diff --git a/src/Psalm/Type/Atomic/TArray.php b/src/Psalm/Type/Atomic/TArray.php index ca379dab691..b3941efb2ea 100644 --- a/src/Psalm/Type/Atomic/TArray.php +++ b/src/Psalm/Type/Atomic/TArray.php @@ -131,7 +131,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); if ($type_params) { $cloned = clone $this; @@ -148,7 +148,7 @@ public function replaceTemplateTypesWithArgTypes(TemplateResult $template_result { $type_params = $this->replaceTypeParamsTemplateTypesWithArgTypes( $template_result, - $codebase + $codebase, ); if ($type_params) { $cloned = clone $this; diff --git a/src/Psalm/Type/Atomic/TCallable.php b/src/Psalm/Type/Atomic/TCallable.php index 71da1ee5be3..7266f17e573 100644 --- a/src/Psalm/Type/Atomic/TCallable.php +++ b/src/Psalm/Type/Atomic/TCallable.php @@ -51,7 +51,7 @@ public function replaceTemplateTypesWithArgTypes(TemplateResult $template_result $this->value, $replaced[0], $replaced[1], - $this->is_pure + $this->is_pure, ); } /** @@ -79,7 +79,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); if (!$replaced) { return $this; @@ -88,7 +88,7 @@ public function replaceTemplateTypesWithStandins( $this->value, $replaced[0], $replaced[1], - $this->is_pure + $this->is_pure, ); } diff --git a/src/Psalm/Type/Atomic/TCallableList.php b/src/Psalm/Type/Atomic/TCallableList.php index c0321d22073..8ff15012028 100644 --- a/src/Psalm/Type/Atomic/TCallableList.php +++ b/src/Psalm/Type/Atomic/TCallableList.php @@ -23,7 +23,7 @@ public function getKeyedArray(): TKeyedArray null, [Type::getListKey(), $this->type_param], true, - $this->from_docblock + $this->from_docblock, ); } if ($this->count) { @@ -32,7 +32,7 @@ public function getKeyedArray(): TKeyedArray null, null, true, - $this->from_docblock + $this->from_docblock, ); } return new TCallableKeyedArray( @@ -40,7 +40,7 @@ public function getKeyedArray(): TKeyedArray null, [Type::getListKey(), $this->type_param], true, - $this->from_docblock + $this->from_docblock, ); } } diff --git a/src/Psalm/Type/Atomic/TClassString.php b/src/Psalm/Type/Atomic/TClassString.php index ff90a1e7e09..ff611d08746 100644 --- a/src/Psalm/Type/Atomic/TClassString.php +++ b/src/Psalm/Type/Atomic/TClassString.php @@ -129,7 +129,7 @@ public function toNamespacedString( return 'class-string<' . preg_replace( '/^' . preg_quote($namespace . '\\') . '/i', '', - $this->as + $this->as, ) . '>'; } @@ -193,7 +193,7 @@ public function replaceTemplateTypesWithStandins( $replace, $add_lower_bound, null, - $depth + $depth, ); $as_type_types = array_values($as_type->getAtomicTypes()); diff --git a/src/Psalm/Type/Atomic/TClassStringMap.php b/src/Psalm/Type/Atomic/TClassStringMap.php index cf2f71fadff..9cd2510926c 100644 --- a/src/Psalm/Type/Atomic/TClassStringMap.php +++ b/src/Psalm/Type/Atomic/TClassStringMap.php @@ -76,7 +76,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - true + true, ); } @@ -89,7 +89,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - false + false, ) . '>'; } @@ -171,7 +171,7 @@ public function replaceTemplateTypesWithStandins( $replace, $add_lower_bound, null, - $depth + 1 + $depth + 1, ); if ($offset === 1 && ($cloned || $this->value_param !== $value_param)) { @@ -193,7 +193,7 @@ public function replaceTemplateTypesWithArgTypes( $value_param = TemplateInferredTypeReplacer::replace( $this->value_param, $template_result, - $codebase + $codebase, ); if ($value_param === $this->value_param) { return $this; @@ -201,7 +201,7 @@ public function replaceTemplateTypesWithArgTypes( return new static( $this->param_name, $this->as_type, - $value_param + $value_param, ); } @@ -235,8 +235,8 @@ public function getStandinKeyParam(): Union $this->param_name, $this->as_type->value ?? 'object', $this->as_type, - 'class-string-map' - ) + 'class-string-map', + ), ]); } } diff --git a/src/Psalm/Type/Atomic/TClosure.php b/src/Psalm/Type/Atomic/TClosure.php index 0865e9e3c77..3ccabeeb3eb 100644 --- a/src/Psalm/Type/Atomic/TClosure.php +++ b/src/Psalm/Type/Atomic/TClosure.php @@ -69,7 +69,7 @@ public function replaceTemplateTypesWithArgTypes( $replaced[1] ?? $this->return_type, $this->is_pure, $this->byref_uses, - $intersection ?? $this->extra_types + $intersection ?? $this->extra_types, ); } @@ -98,7 +98,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); $intersection = $this->replaceIntersectionTemplateTypesWithStandins( $template_result, @@ -110,7 +110,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); if (!$replaced && !$intersection) { return $this; @@ -121,7 +121,7 @@ public function replaceTemplateTypesWithStandins( $replaced[1] ?? $this->return_type, $this->is_pure, $this->byref_uses, - $intersection ?? $this->extra_types + $intersection ?? $this->extra_types, ); } diff --git a/src/Psalm/Type/Atomic/TConditional.php b/src/Psalm/Type/Atomic/TConditional.php index 116d40c761d..84e0747b5c1 100644 --- a/src/Psalm/Type/Atomic/TConditional.php +++ b/src/Psalm/Type/Atomic/TConditional.php @@ -154,7 +154,7 @@ public function replaceTemplateTypesWithArgTypes( $conditional = TemplateInferredTypeReplacer::replace( $this->conditional_type, $template_result, - $codebase + $codebase, ); if ($conditional === $this->conditional_type) { return $this; @@ -165,7 +165,7 @@ public function replaceTemplateTypesWithArgTypes( $this->as_type, $conditional, $this->if_type, - $this->else_type + $this->else_type, ); } } diff --git a/src/Psalm/Type/Atomic/TGenericObject.php b/src/Psalm/Type/Atomic/TGenericObject.php index 51080e93714..388ed91aa34 100644 --- a/src/Psalm/Type/Atomic/TGenericObject.php +++ b/src/Psalm/Type/Atomic/TGenericObject.php @@ -152,7 +152,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); $intersection = $this->replaceIntersectionTemplateTypesWithStandins( $template_result, @@ -164,7 +164,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); if (!$types && !$intersection) { return $this; @@ -174,7 +174,7 @@ public function replaceTemplateTypesWithStandins( $types ?? $this->type_params, $this->remapped_params, $this->is_static, - $intersection ?? $this->extra_types + $intersection ?? $this->extra_types, ); } @@ -185,11 +185,11 @@ public function replaceTemplateTypesWithArgTypes(TemplateResult $template_result { $type_params = $this->replaceTypeParamsTemplateTypesWithArgTypes( $template_result, - $codebase + $codebase, ); $intersection = $this->replaceIntersectionTemplateTypesWithArgTypes( $template_result, - $codebase + $codebase, ); if (!$type_params && !$intersection) { return $this; @@ -199,7 +199,7 @@ public function replaceTemplateTypesWithArgTypes(TemplateResult $template_result $type_params ?? $this->type_params, true, $this->is_static, - $intersection ?? $this->extra_types + $intersection ?? $this->extra_types, ); } } diff --git a/src/Psalm/Type/Atomic/TIterable.php b/src/Psalm/Type/Atomic/TIterable.php index e6d5ce74022..da9fce58683 100644 --- a/src/Psalm/Type/Atomic/TIterable.php +++ b/src/Psalm/Type/Atomic/TIterable.php @@ -135,15 +135,15 @@ public function replaceTemplateTypesWithArgTypes(TemplateResult $template_result { $type_params = $this->replaceTypeParamsTemplateTypesWithArgTypes( $template_result, - $codebase + $codebase, ); $intersection = $this->replaceIntersectionTemplateTypesWithArgTypes( $template_result, - $codebase + $codebase, ); return new static( $type_params ?? $this->type_params, - $intersection ?? $this->extra_types + $intersection ?? $this->extra_types, ); } @@ -172,7 +172,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); $intersection = $this->replaceIntersectionTemplateTypesWithStandins( $template_result, @@ -184,14 +184,14 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); if (!$types && !$intersection) { return $this; } return new static( $types ?? $this->type_params, - $intersection ?? $this->extra_types + $intersection ?? $this->extra_types, ); } } diff --git a/src/Psalm/Type/Atomic/TKeyOf.php b/src/Psalm/Type/Atomic/TKeyOf.php index 691228179d2..56fdf8f95ed 100644 --- a/src/Psalm/Type/Atomic/TKeyOf.php +++ b/src/Psalm/Type/Atomic/TKeyOf.php @@ -87,7 +87,7 @@ public static function getArrayKeyType( } else { $array_key_atomics = static::getArrayKeyType( $atomic_type->as, - $keep_template_params + $keep_template_params, ); if ($array_key_atomics === null) { continue; @@ -99,7 +99,7 @@ public static function getArrayKeyType( $key_types = array_merge( $key_types, - array_values($array_key_atomics->getAtomicTypes()) + array_values($array_key_atomics->getAtomicTypes()), ); } diff --git a/src/Psalm/Type/Atomic/TKeyedArray.php b/src/Psalm/Type/Atomic/TKeyedArray.php index f0f898040c3..df48a09e3f6 100644 --- a/src/Psalm/Type/Atomic/TKeyedArray.php +++ b/src/Psalm/Type/Atomic/TKeyedArray.php @@ -183,7 +183,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - true + true, ); } @@ -214,7 +214,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - false + false, ); continue; } @@ -231,7 +231,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - false + false, ); } @@ -309,7 +309,7 @@ public function getGenericValueType(bool $possibly_undefined = false): Union false, true, 500, - $possibly_undefined + $possibly_undefined, ); } @@ -489,7 +489,7 @@ public function replaceTemplateTypesWithStandins( $replace, $add_lower_bound, null, - $depth + $depth, ); } @@ -516,7 +516,7 @@ public function replaceTemplateTypesWithStandins( $replace, $add_lower_bound, null, - $depth + $depth, ); } @@ -543,7 +543,7 @@ public function replaceTemplateTypesWithArgTypes( $properties[$offset] = TemplateInferredTypeReplacer::replace( $property, $template_result, - $codebase + $codebase, ); } $fallback_params = $this->fallback_params; @@ -551,7 +551,7 @@ public function replaceTemplateTypesWithArgTypes( $fallback_params[$offset] = TemplateInferredTypeReplacer::replace( $property, $template_result, - $codebase + $codebase, ); } if ($properties !== $this->properties || $fallback_params !== $this->fallback_params) { diff --git a/src/Psalm/Type/Atomic/TList.php b/src/Psalm/Type/Atomic/TList.php index 6d7548ffabd..e21ca39cc0b 100644 --- a/src/Psalm/Type/Atomic/TList.php +++ b/src/Psalm/Type/Atomic/TList.php @@ -83,7 +83,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - true + true, ); } @@ -93,7 +93,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - false + false, ) . '>'; } @@ -174,7 +174,7 @@ public function replaceTemplateTypesWithStandins( $replace, $add_lower_bound, null, - $depth + 1 + $depth + 1, ); if ($offset === 1 && ($cloned || $this->type_param !== $type_param)) { @@ -196,7 +196,7 @@ public function replaceTemplateTypesWithArgTypes( return $this->setTypeParam(TemplateInferredTypeReplacer::replace( $this->type_param, $template_result, - $codebase + $codebase, )); } diff --git a/src/Psalm/Type/Atomic/TLiteralClassString.php b/src/Psalm/Type/Atomic/TLiteralClassString.php index 199af5bd28f..c5483511c9e 100644 --- a/src/Psalm/Type/Atomic/TLiteralClassString.php +++ b/src/Psalm/Type/Atomic/TLiteralClassString.php @@ -89,7 +89,7 @@ public function toNamespacedString( return preg_replace( '/^' . preg_quote($namespace . '\\') . '/i', '', - $this->value + $this->value, ) . '::class'; } diff --git a/src/Psalm/Type/Atomic/TNamedObject.php b/src/Psalm/Type/Atomic/TNamedObject.php index ab1634d9fe9..87712cbf592 100644 --- a/src/Psalm/Type/Atomic/TNamedObject.php +++ b/src/Psalm/Type/Atomic/TNamedObject.php @@ -133,8 +133,8 @@ public function getId(bool $exact = true, bool $nested = false): string '&', array_map( static fn(Atomic $type): string => $type->getId($exact, true), - $this->extra_types - ) + $this->extra_types, + ), ); } @@ -158,7 +158,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - $use_phpdoc_format + $use_phpdoc_format, ); return Type::getStringFromFQCLN( @@ -167,7 +167,7 @@ public function toNamespacedString( $aliased_classes, $this_class, true, - $this->is_static + $this->is_static, ) . $intersection_types; } @@ -242,7 +242,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); if ($intersection) { $cloned = clone $this; diff --git a/src/Psalm/Type/Atomic/TNonEmptyList.php b/src/Psalm/Type/Atomic/TNonEmptyList.php index c110f4f1690..832363a6474 100644 --- a/src/Psalm/Type/Atomic/TNonEmptyList.php +++ b/src/Psalm/Type/Atomic/TNonEmptyList.php @@ -61,7 +61,7 @@ public function getKeyedArray(): TKeyedArray null, null, true, - $this->from_docblock + $this->from_docblock, ); } return new TKeyedArray( @@ -69,7 +69,7 @@ public function getKeyedArray(): TKeyedArray null, [Type::getListKey(), $this->type_param], true, - $this->from_docblock + $this->from_docblock, ); } diff --git a/src/Psalm/Type/Atomic/TObjectWithProperties.php b/src/Psalm/Type/Atomic/TObjectWithProperties.php index 42e1443789d..1755d10b776 100644 --- a/src/Psalm/Type/Atomic/TObjectWithProperties.php +++ b/src/Psalm/Type/Atomic/TObjectWithProperties.php @@ -111,8 +111,8 @@ public function getId(bool $exact = true, bool $nested = false): string static fn($name, Union $type): string => $name . ($type->possibly_undefined ? '?' : '') . ':' . $type->getId($exact), array_keys($this->properties), - $this->properties - ) + $this->properties, + ), ); $methods_string = implode( @@ -122,8 +122,8 @@ public function getId(bool $exact = true, bool $nested = false): string * @psalm-pure */ static fn(string $name): string => $name . '()', - array_keys($this->methods) - ) + array_keys($this->methods), + ), ); return 'object{' @@ -161,11 +161,11 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - false + false, ), array_keys($this->properties), - $this->properties - ) + $this->properties, + ), ) . '}'; } @@ -252,7 +252,7 @@ public function replaceTemplateTypesWithStandins( $replace, $add_lower_bound, null, - $depth + $depth, ); } @@ -266,7 +266,7 @@ public function replaceTemplateTypesWithStandins( $calling_function, $replace, $add_lower_bound, - $depth + $depth, ); if ($properties === $this->properties && !$intersection) { return $this; @@ -286,12 +286,12 @@ public function replaceTemplateTypesWithArgTypes( $properties[$offset] = TemplateInferredTypeReplacer::replace( $property, $template_result, - $codebase + $codebase, ); } $intersection = $this->replaceIntersectionTemplateTypesWithArgTypes( $template_result, - $codebase + $codebase, ); if ($properties === $this->properties && !$intersection) { return $this; @@ -299,7 +299,7 @@ public function replaceTemplateTypesWithArgTypes( return new static( $properties, $this->methods, - $intersection ?? $this->extra_types + $intersection ?? $this->extra_types, ); } diff --git a/src/Psalm/Type/Atomic/TPropertiesOf.php b/src/Psalm/Type/Atomic/TPropertiesOf.php index ce0283a6a34..425a477a7d9 100644 --- a/src/Psalm/Type/Atomic/TPropertiesOf.php +++ b/src/Psalm/Type/Atomic/TPropertiesOf.php @@ -35,7 +35,7 @@ public static function tokenNames(): array 'properties-of', 'public-properties-of', 'protected-properties-of', - 'private-properties-of' + 'private-properties-of', ]; } diff --git a/src/Psalm/Type/Atomic/TTemplateKeyOf.php b/src/Psalm/Type/Atomic/TTemplateKeyOf.php index a4c1ad2cac6..34bc10011b8 100644 --- a/src/Psalm/Type/Atomic/TTemplateKeyOf.php +++ b/src/Psalm/Type/Atomic/TTemplateKeyOf.php @@ -95,7 +95,7 @@ public function replaceTemplateTypesWithArgTypes( $as = TemplateInferredTypeReplacer::replace( $this->as, $template_result, - $codebase + $codebase, ); if ($as === $this->as) { return $this; @@ -103,7 +103,7 @@ public function replaceTemplateTypesWithArgTypes( return new static( $this->param_name, $this->defining_class, - $as + $as, ); } } diff --git a/src/Psalm/Type/Atomic/TTemplateParam.php b/src/Psalm/Type/Atomic/TTemplateParam.php index 25b4e8e4a42..33af6d198bd 100644 --- a/src/Psalm/Type/Atomic/TTemplateParam.php +++ b/src/Psalm/Type/Atomic/TTemplateParam.php @@ -122,7 +122,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - true + true, ); } @@ -130,7 +130,7 @@ public function toNamespacedString( $namespace, $aliased_classes, $this_class, - false + false, ); return $this->param_name . $intersection_types; diff --git a/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php b/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php index 563d69f4c39..e29e37108a7 100644 --- a/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php +++ b/src/Psalm/Type/Atomic/TTemplatePropertiesOf.php @@ -94,7 +94,7 @@ public function replaceTemplateTypesWithArgTypes( $template_result, $codebase, ), - $this->as->defining_class + $this->as->defining_class, ); if ($param->as === $this->as->as) { return $this; @@ -103,7 +103,7 @@ public function replaceTemplateTypesWithArgTypes( $this->param_name, $this->defining_class, $param, - $this->visibility_filter + $this->visibility_filter, ); } } diff --git a/src/Psalm/Type/Atomic/TTemplateValueOf.php b/src/Psalm/Type/Atomic/TTemplateValueOf.php index d0924f07805..f8c29e58b04 100644 --- a/src/Psalm/Type/Atomic/TTemplateValueOf.php +++ b/src/Psalm/Type/Atomic/TTemplateValueOf.php @@ -95,7 +95,7 @@ public function replaceTemplateTypesWithArgTypes( $as = TemplateInferredTypeReplacer::replace( $this->as, $template_result, - $codebase + $codebase, ); if ($as === $this->as) { return $this; @@ -103,7 +103,7 @@ public function replaceTemplateTypesWithArgTypes( return new static( $this->param_name, $this->defining_class, - $as + $as, ); } } diff --git a/src/Psalm/Type/Atomic/TTypeAlias.php b/src/Psalm/Type/Atomic/TTypeAlias.php index 8174ba7ac23..06ac86cf511 100644 --- a/src/Psalm/Type/Atomic/TTypeAlias.php +++ b/src/Psalm/Type/Atomic/TTypeAlias.php @@ -43,7 +43,7 @@ public function setIntersectionTypes(?array $extra_types): self return new self( $this->declaring_fq_classlike_name, $this->alias_name, - $extra_types + $extra_types, ); } @@ -59,8 +59,8 @@ public function getId(bool $exact = true, bool $nested = false): string '&', array_map( static fn(Atomic $type): string => $type->getId($exact, true), - $this->extra_types - ) + $this->extra_types, + ), ); } diff --git a/src/Psalm/Type/Atomic/TValueOf.php b/src/Psalm/Type/Atomic/TValueOf.php index af609ed5d94..34d28c92a0e 100644 --- a/src/Psalm/Type/Atomic/TValueOf.php +++ b/src/Psalm/Type/Atomic/TValueOf.php @@ -94,7 +94,7 @@ public static function getValueType( $value_atomics = static::getValueType( $atomic_type->as, $codebase, - $keep_template_params + $keep_template_params, ); if ($value_atomics === null) { continue; diff --git a/src/Psalm/Type/MutableUnion.php b/src/Psalm/Type/MutableUnion.php index a1a08cd7ee0..e23576b4635 100644 --- a/src/Psalm/Type/MutableUnion.php +++ b/src/Psalm/Type/MutableUnion.php @@ -322,7 +322,7 @@ public function removeType(string $type_string): bool unset( $this->literal_string_types[$type_string], $this->literal_int_types[$type_string], - $this->literal_float_types[$type_string] + $this->literal_float_types[$type_string], ); } diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 7e3068c4803..9bf4d261d63 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -218,7 +218,7 @@ public static function reconcileKeyedTypes( $has_inverted_isset, $has_empty, $inside_loop, - $has_object_array_access + $has_object_array_access, ); if ($result_type && $result_type->isUnionEmpty()) { @@ -255,7 +255,7 @@ public static function reconcileKeyedTypes( $template_type_map, $inside_loop, $code_location, - $nested_negated + $nested_negated, ); $new_type_part_part = $nested_negated ? new Falsy() : new Truthy(); @@ -275,7 +275,7 @@ public static function reconcileKeyedTypes( : null, $suppressed_issues, $failed_reconciliation, - $negated + $negated, ); if ($result_type_candidate->isUnionEmpty()) { @@ -285,7 +285,7 @@ public static function reconcileKeyedTypes( $orred_type = Type::combineUnionTypes( $result_type_candidate, $orred_type, - $codebase + $codebase, ); } @@ -310,8 +310,8 @@ public static function reconcileKeyedTypes( } elseif (!$did_type_exist && $code_location) { $result_type = $result_type->setParentNodes( $statements_analyzer->getParentNodesForPossiblyUndefinedVariable( - $key - ) + $key, + ), ); } } @@ -334,7 +334,7 @@ public static function reconcileKeyedTypes( $key_parts, $existing_types, $changed_var_ids, - $result_type + $result_type, ); } elseif ($key !== '$this') { foreach ($existing_types as $new_key => $_) { @@ -486,7 +486,7 @@ private static function addNestedAssertions(array $new_types, array $existing_ty $new_types[$base_key] = [ [new IsNotLooselyEqual(new TBool())], [new IsNotLooselyEqual(new TInt())], - [new IsEqualIsset()] + [new IsEqualIsset()], ]; } else { $new_types[$base_key][] = [new IsNotLooselyEqual(new TBool())]; @@ -668,7 +668,7 @@ private static function getValueForKey( $fq_class_name, $const_name, ReflectionProperty::IS_PRIVATE, - null + null, ); if ($class_constant) { @@ -782,7 +782,7 @@ private static function getValueForKey( $new_base_type = Type::combineUnionTypes( $new_base_type, $new_base_type_candidate, - $codebase + $codebase, ); $existing_keys[$new_base_key] = $new_base_type; @@ -822,7 +822,7 @@ private static function getValueForKey( if (substr($property_name, -2) === '()') { $method_id = new MethodIdentifier( $existing_key_type_part->value, - strtolower(substr($property_name, 0, -2)) + strtolower(substr($property_name, 0, -2)), ); if (!$codebase->methods->methodExists($method_id)) { @@ -830,7 +830,7 @@ private static function getValueForKey( } $declaring_method_id = $codebase->methods->getDeclaringMethodId( - $method_id + $method_id, ); if ($declaring_method_id === null) { @@ -843,7 +843,7 @@ private static function getValueForKey( $method_id, $declaring_class, null, - null + null, ); if ($method_return_type) { @@ -852,7 +852,7 @@ private static function getValueForKey( $method_return_type, $declaring_class, $declaring_class, - null + null, ); } else { $class_property_type = Type::getMixed(); @@ -861,7 +861,7 @@ private static function getValueForKey( $class_property_type = self::getPropertyType( $codebase, $existing_key_type_part->value, - $property_name + $property_name, ); if (!$class_property_type) { @@ -876,7 +876,7 @@ private static function getValueForKey( $new_base_type = Type::combineUnionTypes( $new_base_type, $class_property_type, - $codebase + $codebase, ); $existing_keys[$new_base_key] = $new_base_type; @@ -894,8 +894,8 @@ private static function getValueForKey( IssueBuffer::add( new PsalmInternalError( 'Unknown key ' . $base_key, - $code_location - ) + $code_location, + ), ); } @@ -914,7 +914,7 @@ private static function getPropertyType( if (!$codebase->properties->propertyExists($property_id, true)) { $declaring_class_storage = $codebase->classlike_storage_provider->get( - $fq_class_name + $fq_class_name, ); if (isset($declaring_class_storage->pseudo_property_get_types['$' . $property_name])) { @@ -926,7 +926,7 @@ private static function getPropertyType( $declaring_property_class = $codebase->properties->getDeclaringClassForProperty( $property_id, - true + true, ); if ($declaring_property_class === null) { @@ -937,11 +937,11 @@ private static function getPropertyType( $property_id, false, null, - null + null, ); $declaring_class_storage = $codebase->classlike_storage_provider->get( - $declaring_property_class + $declaring_property_class, ); if ($class_property_type) { @@ -950,7 +950,7 @@ private static function getPropertyType( $class_property_type, $declaring_class_storage->name, $declaring_class_storage->name, - null + null, ); } @@ -1006,18 +1006,18 @@ protected static function triggerIssueForImpossible( 'Static property ' . $key . ' with type ' . $old_var_type_string . ' has unexpected isset check — should it be nullable?', - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, ); } else { IssueBuffer::maybeAdd( new RedundantPropertyInitializationCheck( 'Property ' . $key . ' with type ' . $old_var_type_string . ' should already be set in the constructor', - $code_location + $code_location, ), - $suppressed_issues + $suppressed_issues, ); } } elseif ($from_docblock) { @@ -1027,9 +1027,9 @@ protected static function triggerIssueForImpossible( . ' for ' . $key . ' is ' . ($not ? 'never ' : 'always ') . $assertion_string, $code_location, - $old_var_type_string . ' ' . $assertion_string + $old_var_type_string . ' ' . $assertion_string, ), - $suppressed_issues + $suppressed_issues, ); } else { IssueBuffer::maybeAdd( @@ -1038,9 +1038,9 @@ protected static function triggerIssueForImpossible( . ' for ' . $key . ' is ' . ($not ? 'never ' : 'always ') . $assertion_string, $code_location, - $old_var_type_string . ' ' . $assertion_string + $old_var_type_string . ' ' . $assertion_string, ), - $suppressed_issues + $suppressed_issues, ); } } else { @@ -1051,9 +1051,9 @@ protected static function triggerIssueForImpossible( . ' for ' . $key . ' is ' . ($not ? 'always ' : 'never ') . $assertion_string, $code_location, - $old_var_type_string . ' ' . $assertion_string + $old_var_type_string . ' ' . $assertion_string, ), - $suppressed_issues + $suppressed_issues, ); } else { if ($assertion_string === 'null' && !$not) { @@ -1062,7 +1062,7 @@ protected static function triggerIssueForImpossible( . ' for ' . $key . ' is never ' . $assertion_string, $code_location, - $old_var_type_string . ' ' . $assertion_string + $old_var_type_string . ' ' . $assertion_string, ); } else { $issue = new TypeDoesNotContainType( @@ -1070,13 +1070,13 @@ protected static function triggerIssueForImpossible( . ' for ' . $key . ' is ' . ($not ? 'always ' : 'never ') . $assertion, $code_location, - $old_var_type_string . ' ' . $assertion + $old_var_type_string . ' ' . $assertion, ); } IssueBuffer::maybeAdd( $issue, - $suppressed_issues + $suppressed_issues, ); } } @@ -1130,7 +1130,7 @@ private static function adjustTKeyedArrayType( $array_key_offset => $result_type, ], null, - $fallback_key_type->isNever() ? null : [$fallback_key_type, $fallback_value_type] + $fallback_key_type->isNever() ? null : [$fallback_key_type, $fallback_value_type], ); } elseif ($base_atomic_type instanceof TClassStringMap) { // do nothing @@ -1146,7 +1146,7 @@ private static function adjustTKeyedArrayType( ) { if ($base_atomic_type->fallback_params && is_numeric($array_key_offset)) { $fallback = $base_atomic_type->fallback_params[1]->setPossiblyUndefined( - $result_type->isNever() + $result_type->isNever(), ); for ($x = 0; $x < $array_key_offset; $x++) { $properties[$x] ??= $fallback; @@ -1160,7 +1160,7 @@ private static function adjustTKeyedArrayType( null, $base_atomic_type->fallback_params, false, - $base_atomic_type->from_docblock + $base_atomic_type->from_docblock, ); } } else { @@ -1177,7 +1177,7 @@ private static function adjustTKeyedArrayType( $key_parts, $existing_types, $changed_var_ids, - $new_base_type + $new_base_type, ); } diff --git a/src/Psalm/Type/UnionTrait.php b/src/Psalm/Type/UnionTrait.php index df57af1cce1..bd7a1bdb5f5 100644 --- a/src/Psalm/Type/UnionTrait.php +++ b/src/Psalm/Type/UnionTrait.php @@ -330,7 +330,7 @@ public function toPhpString( $namespace, $aliased_classes, $this_class, - $analysis_php_version_id + $analysis_php_version_id, ); if (!$php_type) { @@ -445,8 +445,8 @@ public function isTemplatedClassString(): bool && count( array_filter( $this->types, - static fn($type): bool => $type instanceof TTemplateParamClass - ) + static fn($type): bool => $type instanceof TTemplateParamClass, + ), ) === 1; } @@ -477,7 +477,7 @@ public function getCallableTypes(): array { return array_filter( $this->types, - static fn($type): bool => $type instanceof TCallable + static fn($type): bool => $type instanceof TCallable, ); } @@ -489,7 +489,7 @@ public function getClosureTypes(): array { return array_filter( $this->types, - static fn($type): bool => $type instanceof TClosure + static fn($type): bool => $type instanceof TClosure, ); } @@ -746,7 +746,7 @@ public function hasTemplate(): bool && $type->extra_types && array_filter( $type->extra_types, - static fn($t): bool => $t instanceof TTemplateParam + static fn($t): bool => $t instanceof TTemplateParam, ) ) ); @@ -759,7 +759,7 @@ public function hasConditional(): bool { return (bool) array_filter( $this->types, - static fn(Atomic $type): bool => $type instanceof TConditional + static fn(Atomic $type): bool => $type instanceof TConditional, ); } @@ -776,7 +776,7 @@ public function hasTemplateOrStatic(): bool || ($type->extra_types && array_filter( $type->extra_types, - static fn($t): bool => $t instanceof TTemplateParam + static fn($t): bool => $t instanceof TTemplateParam, ) ) ) @@ -981,7 +981,7 @@ public function isInt(bool $check_templates = false): bool && $type instanceof TTemplateParam && $type->as->isInt() ) - ) + ), ) === count($this->types); } @@ -1012,7 +1012,7 @@ public function isString(bool $check_templates = false): bool && $type instanceof TTemplateParam && $type->as->isString() ) - ) + ), ) === count($this->types); } @@ -1262,7 +1262,7 @@ public function check( $inferred, $inherited, $prevent_template_covariance, - $calling_method_id + $calling_method_id, ); $checker->traverseArray($this->types); @@ -1284,7 +1284,7 @@ public function queueClassLikesForScanning( $scanner_visitor = new TypeScanner( $codebase->scanner, $file_storage, - $phantom_classes + $phantom_classes, ); /** @psalm-suppress ImpureMethodCall */ @@ -1313,7 +1313,7 @@ public function replaceClassLike(string $old, string $new): self $type = $this; (new ClasslikeReplacer( $old, - $new + $new, ))->traverse($type); return $type; } diff --git a/tests/AlgebraTest.php b/tests/AlgebraTest.php index a4b7eb8085e..e3ec6254ac6 100644 --- a/tests/AlgebraTest.php +++ b/tests/AlgebraTest.php @@ -63,10 +63,10 @@ public function testNegateFormula(): void new Clause( [ '$a' => [(string)$a1 => $a1, (string)$a2 => $a2], - '$b' => ['truthy' => new Truthy()] + '$b' => ['truthy' => new Truthy()], ], 1, - 1 + 1, ), ]; @@ -118,7 +118,7 @@ public function testCombinatorialExpansion(): void spl_object_id($dnf_stmt->expr), $dnf_stmt->expr, null, - $statements_analyzer + $statements_analyzer, ); $this->assertCount(6_561, $dnf_clauses); @@ -137,16 +137,16 @@ public function testContainsClause(): void '$b' => ['truthy' => new Truthy()], ], 1, - 1 + 1, ))->contains( new Clause( [ '$a' => ['truthy' => new Truthy()], ], 1, - 1 - ) - ) + 1, + ), + ), ); $this->assertFalse( @@ -155,7 +155,7 @@ public function testContainsClause(): void '$a' => ['truthy' => new Truthy()], ], 1, - 1 + 1, ))->contains( new Clause( [ @@ -163,9 +163,9 @@ public function testContainsClause(): void '$b' => ['truthy' => new Truthy()], ], 1, - 1 - ) - ) + 1, + ), + ), ); } @@ -232,28 +232,28 @@ public function testGroupImpossibilities(): void $clause1 = (new Clause( [ - '$a' => [(string)$a1 => $a1] + '$a' => [(string)$a1 => $a1], ], 1, 2, false, true, true, - [] + [], ))->calculateNegation(); $a2 = new IsIsset(); $clause2 = (new Clause( [ - '$b' => [(string)$a2 => $a2] + '$b' => [(string)$a2 => $a2], ], 1, 2, false, true, true, - [] + [], ))->calculateNegation(); $result_clauses = Algebra::groupImpossibilities([$clause1, $clause2]); diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index 17f97c8aef2..45cb565f5f3 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -35,7 +35,7 @@ public function testLessSpecificImplementedReturnTypeWithDocblockOnMultipleLines * @method int test() * @method \DateTime modify($modify) */ - class WTF extends \DateTime { }' + class WTF extends \DateTime { }', ); $this->analyzeFile('somefile.php', new Context()); @@ -66,7 +66,7 @@ public function execute() */ class BreakingThings extends ParentClass { - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -87,7 +87,7 @@ public function testLessSpecificImplementedReturnTypeWithDescription(): void * * @method \DateTime modify($modify) */ - class WTF extends \DateTime { }' + class WTF extends \DateTime { }', ); $this->analyzeFile('somefile.php', new Context()); @@ -105,7 +105,7 @@ public function testInvalidParamDefault(): void * @param array $arr * @return void */ - function foo($arr = false) {}' + function foo($arr = false) {}', ); $this->analyzeFile('somefile.php', new Context()); @@ -124,7 +124,7 @@ public function testInvalidParamDefaultButAllowedInConfig(): void */ function foo($_arr = false) {} foo(false); - foo(["hello"]);' + foo(["hello"]);', ); $this->analyzeFile('somefile.php', new Context()); @@ -140,7 +140,7 @@ public function testInvalidTypehintParamDefaultButAllowedInConfig(): void $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', new Context()); @@ -496,7 +496,7 @@ class A {}', * @return array{d:Exception} * @psalm-suppress InvalidReturnType */ - function f() {}' + function f() {}', ], 'slashAfter?' => [ 'code' => ' [ 'code' => ', 1:list} */ $bar = [[], []]; - foo($bar);' + foo($bar);', ], 'allowResourceInList' => [ 'code' => ' $_s */ - function foo(array $_s) : void { }' + function foo(array $_s) : void { }', ], 'possiblyUndefinedObjectProperty' => [ 'code' => 'value ?? "");' + consume($data->value ?? "");', ], 'throwSelf' => [ 'code' => ' [ 'code' => ' 1, "b" => "two"]; - }' + }', ], 'falsableFunctionAllowedWhenBooleanExpected' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'arrayWithKeySlashesAndNewline' => [ 'code' => ' "literal"];', 'assertions' => [ - '$_arr' => 'array{\'foo\\\\bar\nbaz\': string}' - ] + '$_arr' => 'array{\'foo\\\\bar\nbaz\': string}', + ], ], 'doubleSpaceBeforeAt' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'format("Y");' + echo $obj->format("Y");', ], 'intMaskWithClassConstants' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'getConfig()[0]??"");' + echo (string)($a->getConfig()[0]??"");', ], 'promotedPropertiesDocumentationEitherForParamOrForProperty' => [ 'code' => ' [ 'code' => ' 'ImplementedReturnTypeMismatch' + 'error_message' => 'ImplementedReturnTypeMismatch', ], 'unexpectedImportType' => [ 'code' => ' [ - '$a' => 'non-empty-list' - ] + '$a' => 'non-empty-list', + ], ], 'iterableSplat' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'useNamedVariadicArguments' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'useUnpackedNamedVariadicArguments' => [ 'code' => ' 5]);', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'variadicArgsOptional' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'variadicArgumentWithNoNamedArgumentsIsList' => [ 'code' => ' 'PossiblyNullArgument' + 'error_message' => 'PossiblyNullArgument', ], 'useInvalidNamedArgument' => [ 'code' => ' 'InvalidNamedArgument' + 'error_message' => 'InvalidNamedArgument', ], 'usePositionalArgAfterNamed' => [ 'code' => ' 'InvalidNamedArgument' + 'error_message' => 'InvalidNamedArgument', ], 'useUnpackedInvalidNamedArgument' => [ 'code' => ' 'InvalidNamedArgument', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'noNamedArgsMethod' => [ 'code' => ' 'MixedArgument', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'arrayWithoutAllNamedParametersSuppressMixed' => [ 'code' => ' 'TooFewArguments', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'wrongTypeVariadicArguments' => [ 'code' => ' 'InvalidScalarArgument', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'byrefVarSetsPossible' => [ 'code' => ' 'InvalidNamedArgument', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'overwriteOrderedNamedParam' => [ 'code' => ' 'InvalidNamedArgument', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'overwriteOrderedWithUnpackedNamedParam' => [ 'code' => ' 2]);', 'error_message' => 'InvalidNamedArgument', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'variadicArgumentIsNotList' => [ 'code' => ' 'PossiblyInvalidArgument' + 'error_message' => 'PossiblyInvalidArgument', ], 'SKIPPED-preventUnpackingPossiblyArray' => [ 'code' => ' 'PossiblyInvalidArgument' + 'error_message' => 'PossiblyInvalidArgument', ], 'noNamedArguments' => [ 'code' => ' $arr */ function takesArrayIteratorOfString(array $arr): void { echo $arr["hello"]; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -50,7 +50,7 @@ function takesArrayIteratorOfString(array $arr): void { if (isset($arr["hello"])) { echo $arr["hello"]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -68,7 +68,7 @@ function takesString(string $s): void {} /** @param array $arr */ function takesArrayIteratorOfString(array $arr): void { echo $arr["hello"]; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -84,7 +84,7 @@ public function testEnsureArrayOffsetsExistWithIssetCheckFollowedByIsArray(): vo /** @param array $s */ function foo(array $s) : void { if (isset($s["a"]) && \is_array($s["a"])) {} - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -102,7 +102,7 @@ public function testComplainAfterFirstIsset(): void 'analyzeFile('somefile.php', new Context()); @@ -123,7 +123,7 @@ function takesString(string $s): void {} /** @param array $arr */ function takesArrayIteratorOfString(array $arr): void { echo $arr[4]; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -139,7 +139,7 @@ public function testNoIssueWhenUsingArrayValuesOnNonEmptyArray(): void /** @param string[][] $arr */ function foo(array $arr) : void { if (count($arr) === 1 && count(array_values($arr)[0]) === 1) {} - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -162,7 +162,7 @@ function f(array $a) { ) { return $a[1][2]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -180,7 +180,7 @@ function takesList(array $arr) : void { if ($arr) { echo $arr[0]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -203,7 +203,7 @@ function takesList(array $arr) : void { array_pop($arr); echo $arr[0]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -218,7 +218,7 @@ public function testEnsureOffsetExistsAfterArrayPush(): void 'analyzeFile('somefile.php', new Context()); } @@ -240,7 +240,7 @@ class A { function test(array $value): int { return isset($value["a"]->foo) ? $value["a"]->foo : 0; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -290,7 +290,7 @@ function takesList(array $arr) : void { echo $arr[1]; echo $arr[2]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -311,7 +311,7 @@ function bar(array $list) : void { if (count($list) > 1) { echo $list[1]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -335,7 +335,7 @@ function bar(array $list) : void { } echo $list[1]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -359,7 +359,7 @@ function bar(array $list) : void { if (count($list) > 1) { echo $list[2]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -382,7 +382,7 @@ function takesList(array $arr) : void { echo $arr[1]; echo $arr[2]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -405,7 +405,7 @@ function takesList(array $arr) : void { echo $arr[1]; echo $arr[2]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -424,7 +424,7 @@ public function testDontWorryWhenUnionedWithPositiveInt(): void */ function foo(array $a, int $b): void { echo $a[$b]; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -574,7 +574,7 @@ function f(array $p): void '$x1===' => 'array', '$x2===' => "array{b: 'value'}", '$x3===' => "array{b: 'value'}", - ] + ], ], 'domNodeListAccessible' => [ 'code' => ' [ '$c' => 'C|null|scalar', - ] + ], ], 'singleLetterOffset' => [ 'code' => 'b, $this->c] = $popped; } - }' + }', ], 'simpleXmlArrayFetch' => [ 'code' => 'foo(); - }' + }', ], 'assignmentListCheckForNull' => [ 'code' => ' $foo] = bar(0); - if ($foo !== null) {}' + if ($foo !== null) {}', ], 'SKIPPED-accessKnownArrayWithPositiveInt' => [ 'code' => ' [ 'code' => ' [ 'code' => ' $a */ function foo(?ArrayAccess $a) : void { echo $a[0] ?? "default"; - }' + }', ], 'allowUnsettingNested' => [ 'code' => ' $test]; - unset($a[$test->value]);' + unset($a[$test->value]);', ], 'arrayAssertionShouldNotBeNull' => [ 'code' => ' [ 'code' => ' [ '$_arr1===' => 'non-empty-array<1, 5>', '$_arr2===' => 'array{1: 5}', - ] + ], ], 'accessArrayWithSingleStringLiteralOffset' => [ 'code' => ' $p */ function f($p): int { return $p["name"]; - }' + }', ], 'unsetListKeyedArrayDisableListFlag' => [ 'code' => ' ['$a===' => "array{1: 'b'}"] + 'assertions' => ['$a===' => "array{1: 'b'}"], ], ]; } @@ -1370,7 +1370,7 @@ function foo(array $context): void { $context["c"]; } }', - 'error_message' => 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'destructureNullable' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'arrayOpenByDefault' => [ 'code' => ' 0.5, "b" => 1.5, "c" => new Exception()]);', - 'error_message' => 'InvalidArgument' - ] + 'error_message' => 'InvalidArgument', + ], ]; } } diff --git a/tests/ArrayAssignmentTest.php b/tests/ArrayAssignmentTest.php index 4a47e7fedb9..6a9cc79cae4 100644 --- a/tests/ArrayAssignmentTest.php +++ b/tests/ArrayAssignmentTest.php @@ -19,7 +19,7 @@ public function testConditionalAssignment(): void 'arr) {} } - }' + }', ], 'arrayAssignmentAddsTypePossibilities' => [ 'code' => ' 0]; if (is_int($value["a"])) {} - }' + }', ], 'coercePossiblyNullKeyToEmptyString' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ - '$a' => 'list{int, int}' + '$a' => 'list{int, int}', ], ], 'listTakesEmptyArray' => [ @@ -1127,7 +1127,7 @@ function takesList(array $arr) : void {} takesList($a);', 'assertions' => [ - '$a' => 'array' + '$a' => 'array', ], ], 'listCreatedInSingleStatementUsedAsArray' => [ @@ -1217,7 +1217,7 @@ final class Values public function set(int ...$ints): void { $this->ints = $ints; } - }' + }', ], 'assignStringFirstChar' => [ 'code' => ' [ 'code' => ' 'list{int, int, int, int, int, int, int, int}', '$arr2' => 'list{int, int, int}', '$arr3' => 'array{1: int, 2: int, 3: int, 4: int}', - ] + ], ], 'arraySpreadWithString' => [ 'code' => ' 'array{a: 1, b: 2}', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'listPropertyAssignmentAfterIsset' => [ 'code' => 'baz[rand(0, 1) ? 0 : 1] = $str; } - }' + }', ], 'propertyAssignmentToTKeyedArrayStringKeys' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$arr' => 'array', - ] + ], ], 'dontUpdateMixedArrayWithStringKey' => [ 'code' => ' [ - '$options[\'b\']' => 'mixed' - ] + '$options[\'b\']' => 'mixed', + ], ], 'assignWithLiteralStringKey' => [ 'code' => ' [ 'code' => ' new RuntimeException()];', 'assertions' => [ '$a' => 'array{c: RuntimeException, e: RuntimeException}', - ] + ], ], 'mergeArrayKeysProperly' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' ['$_a===' => 'array{16: 16, 17: 17, 18: 18}'] + 'assertions' => ['$_a===' => 'array{16: 16, 17: 17, 18: 18}'], ], 'unpackTypedIterableWithStringKeysIntoArray' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'unpackTypedTraversableWithStringKeysIntoArray' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'unpackArrayWithArrayKeyIntoArray' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'unpackArrayWithTwoTypesNotObjectLike' => [ 'code' => ' 'null|string', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'allowsArrayAccessNullOffset' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$a===' => 'list{0, 1, 2}', - '$b===' => 'list{0, 1, 2}' - ] - ] + '$b===' => 'list{0, 1, 2}', + ], + ], ]; } @@ -2257,40 +2257,40 @@ function getTwoPartsLocale(array $cache, string $a, string $b) : string 'code' => ' "a"]; ', - 'error_message' => 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'ArrayDimOffsetObject' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'ArrayCreateOffsetResource' => [ 'code' => ' "a"]; ', - 'error_message' => 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'ArrayDimOffsetResource' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'ArrayCreateOffsetBool' => [ 'code' => ' "a"]; ', - 'error_message' => 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'ArrayDimOffsetBool' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'ArrayCreateOffsetStringable' => [ 'code' => ' 5]; return $arr; }', - 'error_message' => 'MixedArrayOffset' + 'error_message' => 'MixedArrayOffset', ], 'falseArrayAssignment' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'TemplateAsKey' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'unpackTypedIterableWithStringKeysIntoArray' => [ 'code' => ' "1", "b" => $anyInt, "c" => $positiveOne, "d" => $d, "f" => $f]); - }' + }', ], 'arrayFilterAdvanced' => [ 'code' => ' $statusList */ $statusList = [Baz::STATUS_FOO, Baz::STATUS_QUX]; - $statusList = array_filter($statusList, [Baz::class, "isStatus"]);' + $statusList = array_filter($statusList, [Baz::class, "isStatus"]);', ], 'arrayKeysNonEmpty' => [ 'code' => ' [ '$b' => 'array{a?: int}', '$d' => 'array{a: int}', - ] + ], ], 'arrayMergeIntArrays' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [ - 'MissingClosureParamType' + 'MissingClosureParamType', ], ], 'arrayMapTKeyedArrayListAndClosure' => [ @@ -1091,7 +1091,7 @@ function mapdef(string $_a, int $_b = 0): string { '$c===' => 'array{-2: 0, 0: 0, 1: 0}', ], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'arrayFillLiteral80' => [ 'code' => ' 'array{-1: 0, -2: 0, 0: 0}', ], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'implodeMultiDimensionalArray' => [ 'code' => ' [ '$a===' => 'non-empty-literal-string', '$b===' => 'non-empty-literal-string', - ] + ], ], 'implodeArrayOfNonEmptyStringAndEmptyString' => [ 'code' => ' [ '$a===' => 'non-empty-literal-string', '$b===' => 'non-empty-string', - ] + ], ], 'implodeEmptyArrayAndString' => [ 'code' => ' [ '$a===' => 'string', '$b===' => 'string', - ] + ], ], 'key' => [ 'code' => ' 1, "two" => 3]; } $a = []; $b = array_key_first($a);', 'assertions' => [ - '$b' => 'null' + '$b' => 'null', ], ], 'arrayKeyLast' => [ @@ -1314,7 +1314,7 @@ function makeArray(): array { return ["one" => 1, "two" => 3]; } $a = []; $b = array_key_last($a);', 'assertions' => [ - '$b' => 'null' + '$b' => 'null', ], ], 'arrayResetNonEmptyArray' => [ @@ -1324,7 +1324,7 @@ function makeArray(): array { return ["one" => 1, "two" => 3]; } $a = makeArray(); $b = reset($a);', 'assertions' => [ - '$b' => 'int' + '$b' => 'int', ], ], 'arrayResetNonEmptyList' => [ @@ -1334,7 +1334,7 @@ function makeArray(): array { return [1, 3]; } $a = makeArray(); $b = reset($a);', 'assertions' => [ - '$b' => 'int' + '$b' => 'int', ], ], 'arrayResetNonEmptyTKeyedArray' => [ @@ -1342,7 +1342,7 @@ function makeArray(): array { return [1, 3]; } $a = ["one" => 1, "two" => 3]; $b = reset($a);', 'assertions' => [ - '$b' => 'int' + '$b' => 'int', ], ], 'arrayResetEmptyArray' => [ @@ -1350,7 +1350,7 @@ function makeArray(): array { return [1, 3]; } $a = []; $b = reset($a);', 'assertions' => [ - '$b' => 'false' + '$b' => 'false', ], ], 'arrayResetEmptyList' => [ @@ -1360,7 +1360,7 @@ function makeArray(): array { return []; } $a = makeArray(); $b = reset($a);', 'assertions' => [ - '$b' => 'false' + '$b' => 'false', ], ], 'arrayResetMaybeEmptyArray' => [ @@ -1370,7 +1370,7 @@ function makeArray(): array { return ["one" => 1, "two" => 3]; } $a = makeArray(); $b = reset($a);', 'assertions' => [ - '$b' => 'false|int' + '$b' => 'false|int', ], ], 'arrayResetMaybeEmptyList' => [ @@ -1380,7 +1380,7 @@ function makeArray(): array { return []; } $a = makeArray(); $b = reset($a);', 'assertions' => [ - '$b' => 'false|int' + '$b' => 'false|int', ], ], 'arrayResetMaybeEmptyTKeyedArray' => [ @@ -1390,7 +1390,7 @@ function makeArray(): array { return []; } $a = makeArray(); $b = reset($a);', 'assertions' => [ - '$b' => 'false|int' + '$b' => 'false|int', ], ], 'arrayEndNonEmptyArray' => [ @@ -1400,7 +1400,7 @@ function makeArray(): array { return ["one" => 1, "two" => 3]; } $a = makeArray(); $b = end($a);', 'assertions' => [ - '$b' => 'int' + '$b' => 'int', ], ], 'arrayEndNonEmptyList' => [ @@ -1410,7 +1410,7 @@ function makeArray(): array { return [1, 3]; } $a = makeArray(); $b = end($a);', 'assertions' => [ - '$b' => 'int' + '$b' => 'int', ], ], 'arrayEndNonEmptyTKeyedArray' => [ @@ -1418,7 +1418,7 @@ function makeArray(): array { return [1, 3]; } $a = ["one" => 1, "two" => 3]; $b = end($a);', 'assertions' => [ - '$b' => 'int' + '$b' => 'int', ], ], 'arrayEndEmptyArray' => [ @@ -1426,7 +1426,7 @@ function makeArray(): array { return [1, 3]; } $a = []; $b = end($a);', 'assertions' => [ - '$b' => 'false' + '$b' => 'false', ], ], 'arrayEndEmptyList' => [ @@ -1436,7 +1436,7 @@ function makeArray(): array { return []; } $a = makeArray(); $b = end($a);', 'assertions' => [ - '$b' => 'false' + '$b' => 'false', ], ], 'arrayEndMaybeEmptyArray' => [ @@ -1446,7 +1446,7 @@ function makeArray(): array { return ["one" => 1, "two" => 3]; } $a = makeArray(); $b = end($a);', 'assertions' => [ - '$b' => 'false|int' + '$b' => 'false|int', ], ], 'arrayEndMaybeEmptyList' => [ @@ -1456,7 +1456,7 @@ function makeArray(): array { return []; } $a = makeArray(); $b = end($a);', 'assertions' => [ - '$b' => 'false|int' + '$b' => 'false|int', ], ], 'arrayEndMaybeEmptyTKeyedArray' => [ @@ -1466,7 +1466,7 @@ function makeArray(): array { return []; } $a = makeArray(); $b = end($a);', 'assertions' => [ - '$b' => 'false|int' + '$b' => 'false|int', ], ], 'arrayColumnInference' => [ @@ -1599,7 +1599,7 @@ function makeKeyedArray(): array { return []; } '$i===' => "array{a: 0, b?: 1}", '$j===' => "array{0: array{k: 0, v: 'a'}, 1?: array{k: 1, v: 'b'}, 2: array{k: 2, v: 'c'}}", '$k===' => "list{0: array{k: 0, v: 'a'}, 1: array{k: 1, v: 'b'}, 2?: array{k: 2, v: 'c'}}", - ] + ], ], 'splatArrayIntersect' => [ 'code' => ' [ - '$e' => 'list' + '$e' => 'list', ], ], 'arraySpliceOtherType' => [ @@ -2003,7 +2003,7 @@ function getSize(): int { return random_int(1, 10); } */ function foo(array $strings): array { return array_map("intval", $strings); - }' + }', ], 'SKIPPED-arrayMapZip' => [ 'code' => ' [ 'code' => ' [ 'code' => ' */ function makeAList(int $ofThisInteger): array { return array_filter([$ofThisInteger]); - }' + }', ], 'arrayMapWithEmptyArrayReturn' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ - '$a' => 'list' + '$a' => 'list', ], ], 'arrayReplaceTwoExplicitLists' => [ @@ -2195,7 +2195,7 @@ function foo(array $foo) : void {} $foo1 = [1, 2, 3]; $foo2 = [1, 4, 5]; - foo(array_replace($foo1, $foo2));' + foo(array_replace($foo1, $foo2));', ], 'arrayReplaceTwoPossiblyFalse' => [ 'code' => ' [ - '$a' => 'list' + '$a' => 'list', ], ], 'arrayMapPossiblyFalseIgnored' => [ @@ -2226,7 +2226,7 @@ function takesString(string $string): void {} $d = array_map(null, $a, $b, $c);', 'assertions' => [ - '$d===' => "list{list{1, 'one', 'uno'}, list{2, 'two', 'dos'}, list{3, 'three', 'tres'}, list{4, 'four', 'cuatro'}, list{5, 'five', 'cinco'}, list{null, null, 'seis'}}" + '$d===' => "list{list{1, 'one', 'uno'}, list{2, 'two', 'dos'}, list{3, 'three', 'tres'}, list{4, 'four', 'cuatro'}, list{5, 'five', 'cinco'}, list{null, null, 'seis'}}", ], 'ignored_issues' => [], 'php_version' => '7.4', @@ -2266,13 +2266,13 @@ function takesString(string $string): void {} function bar(array $elements, int $index, string $element) : array { array_splice($elements, $index, 0, [$element]); return $elements; - }' + }', ], 'arrayChangeKeyCaseWithNonStringKeys' => [ 'code' => ' 42]; - echo array_change_key_case($a, CASE_LOWER)[0];' + echo array_change_key_case($a, CASE_LOWER)[0];', ], 'mapInterfaceMethod' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'TypeDoesNotContainType' + 'error_message' => 'TypeDoesNotContainType', ], 'arrayFilterTooFewArgs' => [ 'code' => ' [ 'code' => ' 42, "bar" => 42]); } - ' + ', ], 'arrayKeysOfLiteralListConformsToCorrectLiteralOffsets' => [ 'code' => ' [ 'code' => ' [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'arrayKeysOfStringKeyedArrayDoesntConformToIntList' => [ 'code' => ' 42, "bar" => 42]); } ', - 'error_message' => 'InvalidReturnStatement' - ] + 'error_message' => 'InvalidReturnStatement', + ], ]; } } diff --git a/tests/AssertAnnotationTest.php b/tests/AssertAnnotationTest.php index 43c5c04b9d6..0cadd524cea 100644 --- a/tests/AssertAnnotationTest.php +++ b/tests/AssertAnnotationTest.php @@ -46,7 +46,7 @@ function assertBarNotNull(Foo $foo): bool } function requiresString(string $str): void {} - ' + ', ); $this->analyzeFile('somefile.php', new Context()); @@ -84,7 +84,7 @@ function assertBarNotNull(Foo $foo): bool } function requiresString(string $_str): void {} - ' + ', ); $this->analyzeFile('somefile.php', new Context()); @@ -171,7 +171,7 @@ function removeNullable($foo): string { abort_if(is_null($foo)); return $foo; - }' + }', ], 'sortOfReplacementForAssert' => [ 'code' => 'isFoo(); $t->bar(); - }' + }', ], 'assertThisTypeIfTrue' => [ 'code' => 'isFoo()) { $t->bar(); } - }' + }', ], 'assertThisTypeCombined' => [ 'code' => 'assertBar(); $t->foo(); $t->bar(); - }' + }', ], 'assertThisTypeCombinedInsideMethod' => [ 'code' => ' [ 'code' => 'assertBar(); $t->foo(); $t->bar(); - }' + }', ], 'assertThisTypeIfTrueCombined' => [ 'code' => 'foo(); $t->bar(); } - }' + }', ], 'assertThisTypeSimpleAndIfTrueCombined' => [ 'code' => 'foo(); } $t->bar(); - }' + }', ], 'assertThisTypeSwitchTrue' => [ 'code' => 'isFoo(): $t->bar(); } - }' + }', ], 'assertNotArray' => [ 'code' => ' [ 'code' => 'a !== null; } - }' + }', ], 'assertIfFalseOnProperty' => [ 'code' => 'a !== null; } - }' + }', ], 'assertIfTrueOnPropertyNegated' => [ 'code' => 'a !== null; } - }' + }', ], 'assertIfFalseOnPropertyNegated' => [ 'code' => 'a !== null; } - }' + }', ], 'assertPropertyVisibleOutside' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'hasArray()) { echo count($a->b->arr); } - }' + }', ], 'assertOnNestedMethod' => [ 'code' => 'hasArray()) { echo count($a->b->getArray()); } - }' + }', ], 'assertOnThisMethod' => [ 'code' => 'getArray()); - }' + }', ], 'preventErrorWhenAssertingOnArrayUnion' => [ 'code' => ' $data */ - function validate(array $data): void {}' + function validate(array $data): void {}', ], 'nonEmptyList' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'assertStaticSelf' => [ 'code' => '' + ?>', ], 'assertIfTrueStaticSelf' => [ 'code' => '' + ?>', ], 'assertIfFalseStaticSelf' => [ 'code' => '' + ?>', ], 'assertStaticByInheritedMethod' => [ 'code' => '' + ?>', ], 'assertInheritedStatic' => [ 'code' => '' + ?>', ], 'assertStaticOnUnrelatedClass' => [ 'code' => '' + ?>', ], 'implicitComplexAssertionNoCrash' => [ 'code' => ' [ 'code' => ' [ 'code' => ' $class * @psalm-assert iterable $value */ - function allIsInstanceOf($value, $class): void {}' + function allIsInstanceOf($value, $class): void {}', ], 'implicitReflectionPropertyAssertion' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'onPropertyOfImmutableArgument' => [ 'code' => ' [ '$a' => 'int', '$B' => 'int', - ] + ], ], ]; } diff --git a/tests/AttributeTest.php b/tests/AttributeTest.php index e6517be09fe..b98715f60b0 100644 --- a/tests/AttributeTest.php +++ b/tests/AttributeTest.php @@ -23,14 +23,14 @@ class Attr {} #[Attr] class Foo {} - ' + ', ); $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', new Context()); @@ -114,7 +114,7 @@ function foo(string $s) : void { }', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'testReflectingAllAttributes' => [ 'code' => ' 'list>', ], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'convertKeyedArray' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.1' + 'php_version' => '7.1', ], 'returnTypeWillChange8.1' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'allowDynamicProperties' => [ 'code' => 'hello = 5 } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -37,7 +37,7 @@ public function testClassMethodWithNoStmts(): void 'analyzeFile('somefile.php', new Context()); @@ -52,7 +52,7 @@ public function testInterfaceWithProperties(): void 'analyzeFile('somefile.php', new Context()); @@ -71,7 +71,7 @@ protected function _getCollaborators(User $user, User $cur_user = null) : { return $a; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -88,7 +88,7 @@ public function testOverriddenUse(): void use A\B; - interface B {}' + interface B {}', ); $this->analyzeFile('somefile.php', new Context()); @@ -101,7 +101,7 @@ public function testBadArray(): void $this->addFile( 'somefile.php', 'analyzeFile('somefile.php', new Context()); diff --git a/tests/BinaryOperationTest.php b/tests/BinaryOperationTest.php index dfa9f0940ae..c6d12c55d3a 100644 --- a/tests/BinaryOperationTest.php +++ b/tests/BinaryOperationTest.php @@ -41,7 +41,7 @@ public function testGMPOperations(): void $q = $a * 6; $r = $a / 6; $s = $a ** 6; - $t = $a % 6;' + $t = $a % 6;', ); $assertions = [ @@ -106,7 +106,7 @@ public function testDecimalOperations(): void $q = $a * 6; $r = $a / 6; $s = $a ** 6; - $t = $a % 6;' + $t = $a % 6;', ); $assertions = [ @@ -166,7 +166,7 @@ class b {} $obj instanceof a => 123, $obj instanceof b => 321, }; - ' + ', ); $assertions = [ @@ -204,7 +204,7 @@ function returnsABool(): bool { if (returnsABool() === true) { echo "hi!"; - }' + }', ); $this->expectException(CodeException::class); @@ -227,7 +227,7 @@ function returnsABool(): bool { if (returnsABool() !== false) { echo "hi!"; - }' + }', ); $this->expectException(CodeException::class); @@ -244,7 +244,7 @@ public function testDifferingNumericLiteralTypesAdditionInStrictMode(): void $this->addFile( 'somefile.php', 'expectException(CodeException::class); @@ -263,7 +263,7 @@ public function testDifferingNumericTypesAdditionInStrictMode(): void 'expectException(CodeException::class); @@ -280,7 +280,7 @@ public function testConcatenationWithNumberInStrictMode(): void $this->addFile( 'somefile.php', 'expectException(CodeException::class); @@ -304,7 +304,7 @@ public function __toString(); function takesI(I $i): void { $a = $i . "hello"; - }' + }', ); $this->expectException(CodeException::class); @@ -366,7 +366,7 @@ public function providerValidCodeParse(): iterable $a = 7 . 5;', 'assertions' => [ '$a' => 'string',//will contain "75" - ] + ], ], 'concatenationWithTwoInt' => [ 'code' => ' 5]; - }' + }', ], 'addIntToZero' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $b); - }' + }', ], 'notAlwaysPositiveBitOperations' => [ 'code' => ' [ 'code' => ' [ - '$a' => 'float' + '$a' => 'float', ], ], 'IntOverflowPow' => [ 'code' => ' [ - '$a' => 'float' + '$a' => 'float', ], ], 'IntOverflowPlus' => [ @@ -742,14 +742,14 @@ function foo($a, $b): void { 'code' => ' [ - '$a' => 'float' + '$a' => 'float', ], ], 'IntOverflowSub' => [ 'code' => ' [ - '$a' => 'float' + '$a' => 'float', ], ], 'literalConcatCreatesLiteral' => [ diff --git a/tests/ByIssueLevelAndTypeReportTest.php b/tests/ByIssueLevelAndTypeReportTest.php index 671e63f4419..28e495028ec 100644 --- a/tests/ByIssueLevelAndTypeReportTest.php +++ b/tests/ByIssueLevelAndTypeReportTest.php @@ -91,7 +91,7 @@ private function issueData(int $errorLevel, string $type): IssueData 1, 1, 0, - $errorLevel + $errorLevel, ); } } diff --git a/tests/CallableTest.php b/tests/CallableTest.php index 05605dd8432..1f1c07409fc 100644 --- a/tests/CallableTest.php +++ b/tests/CallableTest.php @@ -1104,7 +1104,7 @@ function foo($c) : void { function f($p): array { return []; } - f("#b::a");' + f("#b::a");', ], 'removeCallableAssertionAfterReassignment' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$classOrObject' => 'class-string|object', - '$method' => 'string' - ] + '$method' => 'string', + ], ], 'callableInterface' => [ 'code' => ' [ 'code' => ' "ASC", "start_time" => "ASC"]);' + f(["instance_date" => "ASC", "start_time" => "ASC"]);', ], 'callOnInvokableOrCallable' => [ 'code' => ' [ 'code' => 'takesACall(function() {return $this;}); } - }' + }', ], 'returnClosureReturningStatic' => [ 'code' => ' [ 'code' => ' [ 'code' => ' 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'noFatalErrorOnMissingClassWithoutSlash' => [ 'code' => ' 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'preventStringDocblockType' => [ 'code' => ' 'MixedArgumentTypeCoercion' + 'error_message' => 'MixedArgumentTypeCoercion', ], 'undefinedVarInBareCallable' => [ 'code' => ' 'InvalidArgument', - ] + ], ]; } } diff --git a/tests/ClassLikeStringTest.php b/tests/ClassLikeStringTest.php index b12e73a8323..1e7f5b9eaab 100644 --- a/tests/ClassLikeStringTest.php +++ b/tests/ClassLikeStringTest.php @@ -26,7 +26,7 @@ class A {} $a = "A"; - new $a();' + new $a();', ); $this->analyzeFile('somefile.php', new Context()); @@ -47,7 +47,7 @@ public static function foo() : void {} $a = "A"; - $a::foo();' + $a::foo();', ); $this->analyzeFile('somefile.php', new Context()); @@ -474,7 +474,7 @@ public function go(object $object): ?stdClass { } return null; } - }' + }', ], 'returnTemplatedClassString' => [ 'code' => ' $className */ - function takesExampleClassString(string $className): void {}' + function takesExampleClassString(string $className): void {}', ], 'noCrashOnPolyfill' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'bar = TypeOne::class; $foo->bar = TypeOne::class; $foo->baz = TypeTwo::class; - $foo->baz = TypeTwo::class;' - ] + $foo->baz = TypeTwo::class;', + ], ]; } diff --git a/tests/ClassScopeTest.php b/tests/ClassScopeTest.php index 3f6b950308b..ca4565c54a5 100644 --- a/tests/ClassScopeTest.php +++ b/tests/ClassScopeTest.php @@ -145,7 +145,7 @@ class B extends A { protected static function foo(): void { echo "here"; } - }' + }', ], ]; } diff --git a/tests/ClassTest.php b/tests/ClassTest.php index 25288267227..a5938138a8a 100644 --- a/tests/ClassTest.php +++ b/tests/ClassTest.php @@ -35,7 +35,7 @@ public function real_escape_string(string $string) { return "escaped"; } - }' + }', ); } @@ -436,7 +436,7 @@ function specifyString(string $className): void{ return; } new ReflectionClass($className); - }' + }', ], 'classExistsWithFalseArgInside' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'mock(); return $b; - }' + }', ], 'preventDoubleStaticResolution1' => [ 'code' => 'ret(); $a = $a->stabilize();', 'assertions' => [ - '$a===' => 'iter' - ] + '$a===' => 'iter', + ], ], 'preventDoubleStaticResolution2' => [ 'code' => 'ret(); $a = $a->stabilize();', 'assertions' => [ - '$a===' => 'iter' - ] + '$a===' => 'iter', + ], ], 'preventDoubleStaticResolution3' => [ 'code' => 'ret(); $a = $a->stabilize();', 'assertions' => [ - '$a===' => 'iter' - ] + '$a===' => 'iter', + ], ], 'allowTraversableImplementationAlongWithIteratorAggregate' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'varReturnType' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'correctParamType' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'returnsTypedClosureWithClasses' => [ 'code' => ' [ '$closure' => 'pure-Closure(string):int<0, max>', - ] + ], ], 'allowClosureWithNarrowerReturn' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'annotateShortClosureReturn' => [ 'code' => ' /** @var bool */ returnsBool();', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'rememberParentAssertions' => [ 'code' => 'a->foo(); }; } - }' + }', ], 'CallableWithArrayMap' => [ 'code' => ' [ - '$result' => 'list{stdClass}' + '$result' => 'list{stdClass}', ], ], 'CallableWithArrayReduce' => [ @@ -575,7 +575,7 @@ function maker() { $maker = maker(); $result = array_reduce([1, 2, 3], $maker, 0);', 'assertions' => [ - '$result' => 'int' + '$result' => 'int', ], ], 'FirstClassCallable:NamedFunction:is_int' => [ @@ -588,7 +588,7 @@ function maker() { '$result' => 'bool', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:NamedFunction:strlen' => [ 'code' => ' 'int<0, max>', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:InstanceMethod:UserDefined' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:InstanceMethod:Expr' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:InstanceMethod:BuiltIn' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:StaticMethod' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:StaticMethod:Expr' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:InvokableObject' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:FromClosure' => [ 'code' => ' 'pure-Closure(string):int<0, max>', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:MagicInstanceMethod' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:MagicStaticMethod' => [ 'code' => ' 'int', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:InheritedStaticMethod' => [ 'code' => ' $_ */ function takesIntToHolder(\Closure $_): void {} - takesIntToHolder(C::create(...));' + takesIntToHolder(C::create(...));', ], 'FirstClassCallable:WithArrayMap' => [ 'code' => ' 'list{int, int, int}', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:array_map' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'arrowFunctionReturnsNeverExplictly' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'unknownFirstClassCallable' => [ 'code' => ' 'MixedReturnStatement' + 'error_message' => 'MixedReturnStatement', ], 'noCrashWhenComparingIllegitimateCallable' => [ 'code' => ' 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'undefinedVariableInEncapsedString' => [ 'code' => ' 'UndefinedVariable', 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'undefinedVariableInStringCast' => [ 'code' => ' 'UndefinedVariable', 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'forbidTemplateAnnotationOnClosure' => [ 'code' => ' 'InvalidDocblock', 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'closureInvalidArg' => [ 'code' => ' 'UndefinedMethod', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:UndefinedMagicInstanceMethod' => [ 'code' => ' 'UndefinedMagicMethod', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'FirstClassCallable:UndefinedMagicStaticMethod' => [ 'code' => 'codebase->isTypeContainedByType($input, $container), 'Expected ' . $input->getId() . ($expected ? ' ' : ' not ') - . 'to be contained in ' . $container->getId() + . 'to be contained in ' . $container->getId(), ); } @@ -74,7 +74,7 @@ public function canTypeBeContainedByType(string $input, string $container, bool $expected, $this->codebase->canTypeBeContainedByType($input, $container), 'Expected ' . $input->getId() . ($expected ? ' ' : ' not ') - . 'to be contained in ' . $container->getId() + . 'to be contained in ' . $container->getId(), ); } @@ -105,13 +105,13 @@ public function getKeyValueParamsForTraversableObject(string $input, array $expe $this->assertTrue( $expected_key_type->equals($actual[0]), 'Expected ' . $input->getId() . ' to have ' . $expected_key_type - . ' but got ' . $actual[0]->getId() + . ' but got ' . $actual[0]->getId(), ); $this->assertTrue( $expected_value_type->equals($actual[1]), 'Expected ' . $input->getId() . ' to have ' . $expected_value_type - . ' but got ' . $actual[1]->getId() + . ' but got ' . $actual[1]->getId(), ); } @@ -141,7 +141,7 @@ class C extends A implements I /** @return void */ public function m(int $_i = 1) {} } - ' + ', ); $hook = new class implements AfterClassLikeVisitInterface { /** @@ -160,7 +160,7 @@ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) : ''; $storage->custom_metadata['implements'] = array_map( fn(Name $aspect): string => (string)$aspect->getAttribute('resolvedName'), - $stmt->implements + $stmt->implements, ); $storage->custom_metadata['a'] = 'b'; $storage->methods['m']->custom_metadata['c'] = 'd'; @@ -220,7 +220,7 @@ function invalidReturnType(int $value): string return $value; } echo invalidReturnType(123); - ' + ', ); $eventHandler = new class implements BeforeAddIssueInterface diff --git a/tests/CommandFunctions/GetMemoryLimitInBytesTest.php b/tests/CommandFunctions/GetMemoryLimitInBytesTest.php index 2ca629e6908..fee4bae2d21 100644 --- a/tests/CommandFunctions/GetMemoryLimitInBytesTest.php +++ b/tests/CommandFunctions/GetMemoryLimitInBytesTest.php @@ -48,7 +48,7 @@ public function testGetMemoryLimitInBytes( $this->assertSame( $expectedBytes, CliUtils::convertMemoryLimitToBytes((string)$setting), - 'Memory limit in bytes does not fit setting' + 'Memory limit in bytes does not fit setting', ); } } diff --git a/tests/ComposerLockTest.php b/tests/ComposerLockTest.php index 5a727e4ba99..a17225c6a2e 100644 --- a/tests/ComposerLockTest.php +++ b/tests/ComposerLockTest.php @@ -24,9 +24,9 @@ public function packageIsPsalmPlugin(): void 'type' => 'psalm-plugin', 'extra' => [ 'psalm' => [ - 'pluginClass' => 'Some\Class' - ] - ] + 'pluginClass' => 'Some\Class', + ], + ], ]), 'Non-plugin should not be considered a plugin'); $this->assertTrue($lock->isPlugin([ @@ -34,18 +34,18 @@ public function packageIsPsalmPlugin(): void 'type' => 'library', 'extra' => [ 'psalm' => [ - 'pluginClass' => 'Some\Class' - ] - ] + 'pluginClass' => 'Some\Class', + ], + ], ]), 'Non-plugin should not be considered a plugin'); $this->assertTrue($lock->isPlugin([ 'name' => 'vendor/package', 'extra' => [ 'psalm' => [ - 'pluginClass' => 'Some\Class' - ] - ] + 'pluginClass' => 'Some\Class', + ], + ], ]), 'Non-plugin should not be considered a plugin'); // counterexamples @@ -191,7 +191,7 @@ public function mergesMultipleComposerLockFiles(): void 'vendor/packageC' => 'Vendor\PackageC\PluginClass', 'vendor/packageD' => 'Vendor\PackageD\PluginClass', ], - $lock->getPlugins() + $lock->getPlugins(), ); } diff --git a/tests/Config/ConfigFileTest.php b/tests/Config/ConfigFileTest.php index 0b5e5ac321f..a198a41c87d 100644 --- a/tests/Config/ConfigFileTest.php +++ b/tests/Config/ConfigFileTest.php @@ -60,7 +60,7 @@ public function addCanAddPluginClassToExistingPluginsNode(): void name="bar" > - ' . PHP_EOL + ' . PHP_EOL, ); $config_file = new ConfigFile((string)getcwd(), $this->file_path); @@ -73,7 +73,7 @@ public function addCanAddPluginClassToExistingPluginsNode(): void > ', - file_get_contents($this->file_path) + file_get_contents($this->file_path), )); } @@ -85,7 +85,7 @@ public function addCanCreateMissingPluginsNode(): void file_put_contents( $this->file_path, ' - ' . PHP_EOL + ' . PHP_EOL, ); $config_file = new ConfigFile((string)getcwd(), $this->file_path); @@ -94,7 +94,7 @@ public function addCanCreateMissingPluginsNode(): void $this->assertTrue(static::compareContentWithTemplateAndTrailingLineEnding( ' ', - file_get_contents($this->file_path) + file_get_contents($this->file_path), )); } @@ -113,7 +113,7 @@ public function removeDoesNothingWhenThereIsNoPluginsNode(): void $this->assertSame( $noPlugins, - file_get_contents($this->file_path) + file_get_contents($this->file_path), ); } @@ -137,7 +137,7 @@ public function removeKillsEmptyPluginsNode(): void $this->assertXmlStringEqualsXmlString( $noPlugins, - file_get_contents($this->file_path) + file_get_contents($this->file_path), ); } @@ -163,7 +163,7 @@ public function removeKillsSpecifiedPlugin(): void $this->assertXmlStringEqualsXmlString( $noPlugins, - file_get_contents($this->file_path) + file_get_contents($this->file_path), ); } @@ -198,7 +198,7 @@ public function removeKillsSpecifiedPluginWithOneRemaining(): void $this->assertXmlStringEqualsXmlString( $noPlugins, - file_get_contents($this->file_path) + file_get_contents($this->file_path), ); } diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php index 0c1645e5889..75457a8398a 100644 --- a/tests/Config/ConfigTest.php +++ b/tests/Config/ConfigTest.php @@ -77,8 +77,8 @@ private function getProjectAnalyzerWithConfig(Config $config): ProjectAnalyzer $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $p->setPhpVersion('7.3', 'tests'); @@ -96,8 +96,8 @@ public function testBarebonesConfig(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -119,8 +119,8 @@ public function testIgnoreProjectDirectory(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -143,8 +143,8 @@ public function testIgnoreMissingProjectDirectory(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -189,8 +189,8 @@ public function testIgnoreSymlinkedProjectDirectory(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -217,7 +217,7 @@ public function testIgnoreSymlinkedProjectDirectory(): void 0, $last_error['type'], $last_error['file'], - $last_error['line'] + $last_error['line'], ); } } @@ -236,8 +236,8 @@ public function testIgnoreWildcardProjectDirectory(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -261,8 +261,8 @@ public function testIgnoreWildcardFiles(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -288,8 +288,8 @@ public function testIgnoreWildcardFilesInWildcardFolder(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -316,8 +316,8 @@ public function testIgnoreWildcardFilesInAllPossibleWildcardFolders(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -343,8 +343,8 @@ public function testIssueHandler(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -372,14 +372,14 @@ public function testGlobalUndefinedFunctionSuppression(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); $this->assertSame( Config::REPORT_SUPPRESS, - $config->getReportingLevelForFunction('UndefinedFunction', 'Some\Namespace\zzz') + $config->getReportingLevelForFunction('UndefinedFunction', 'Some\Namespace\zzz'), ); } @@ -401,8 +401,8 @@ public function testMultipleIssueHandlers(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -477,8 +477,8 @@ public function testIssueHandlerWithCustomErrorLevels(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -487,148 +487,148 @@ public function testIssueHandlerWithCustomErrorLevels(): void 'info', $config->getReportingLevelForFile( 'MissingReturnType', - realpath('src/Psalm/Type.php') - ) + realpath('src/Psalm/Type.php'), + ), ); $this->assertSame( 'error', $config->getReportingLevelForFile( 'MissingReturnType', - realpath('src/Psalm/Internal/Analyzer/FileAnalyzer.php') - ) + realpath('src/Psalm/Internal/Analyzer/FileAnalyzer.php'), + ), ); $this->assertSame( 'error', $config->getReportingLevelForFile( 'PossiblyInvalidArgument', - realpath('src/psalm.php') - ) + realpath('src/psalm.php'), + ), ); $this->assertSame( 'info', $config->getReportingLevelForFile( 'PossiblyInvalidArgument', - realpath('examples/TemplateChecker.php') - ) + realpath('examples/TemplateChecker.php'), + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\Badger' - ) + 'Psalm\Badger', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\BadActor' - ) + 'Psalm\BadActor', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\GoodActor' - ) + 'Psalm\GoodActor', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\MagicFactory' - ) + 'Psalm\MagicFactory', + ), ); $this->assertNull( $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\Bodger' - ) + 'Psalm\Bodger', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedMethod', - 'Psalm\Bodger::find1' - ) + 'Psalm\Bodger::find1', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedMethod', - 'Psalm\Bodger::find2' - ) + 'Psalm\Bodger::find2', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedMethod', - 'Psalm\Badger::find2' - ) + 'Psalm\Badger::find2', + ), ); $this->assertNull( $config->getReportingLevelForProperty( 'UndefinedMethod', - 'Psalm\Bodger::$find3' - ) + 'Psalm\Bodger::$find3', + ), ); $this->assertNull( $config->getReportingLevelForProperty( 'UndefinedMethod', - 'Psalm\Bodger::$find4' - ) + 'Psalm\Bodger::$find4', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedFunction', - 'fooBar' - ) + 'fooBar', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedFunction', - 'foobar' - ) + 'foobar', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForVariable( 'UndefinedGlobalVariable', - 'a' - ) + 'a', + ), ); $this->assertNull( $config->getReportingLevelForVariable( 'UndefinedGlobalVariable', - 'b' - ) + 'b', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClassConstant( 'InvalidConstantAssignmentValue', - 'Psalm\Bodger::FOO' - ) + 'Psalm\Bodger::FOO', + ), ); } @@ -643,20 +643,20 @@ public function testIssueHandlerSetDynamically(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); $config->setAdvancedErrorLevel('MissingReturnType', [ [ 'type' => 'suppress', - 'directory' => [['name' => 'tests']] + 'directory' => [['name' => 'tests']], ], [ 'type' => 'error', - 'directory' => [['name' => 'src/Psalm/Internal/Analyzer']] - ] + 'directory' => [['name' => 'src/Psalm/Internal/Analyzer']], + ], ], 'info'); $config->setAdvancedErrorLevel('UndefinedClass', [ [ @@ -665,8 +665,8 @@ public function testIssueHandlerSetDynamically(): void ['name' => 'Psalm\Badger'], ['name' => 'Psalm\*Actor'], ['name' => '*MagicFactory'], - ] - ] + ], + ], ]); $config->setAdvancedErrorLevel('UndefinedMethod', [ [ @@ -674,186 +674,186 @@ public function testIssueHandlerSetDynamically(): void 'referencedMethod' => [ ['name' => 'Psalm\Bodger::find1'], ['name' => '*::find2'], - ] - ] + ], + ], ]); $config->setAdvancedErrorLevel('UndefinedFunction', [ [ 'type' => 'suppress', 'referencedFunction' => [ - ['name' => 'fooBar'] - ] - ] + ['name' => 'fooBar'], + ], + ], ]); $config->setAdvancedErrorLevel('PossiblyInvalidArgument', [ [ 'type' => 'suppress', 'directory' => [ ['name' => 'tests'], - ] + ], ], [ 'type' => 'info', 'directory' => [ ['name' => 'examples'], - ] - ] + ], + ], ]); $config->setAdvancedErrorLevel('UndefinedPropertyFetch', [ [ 'type' => 'suppress', 'referencedProperty' => [ - ['name' => 'Psalm\Bodger::$find3'] - ] - ] + ['name' => 'Psalm\Bodger::$find3'], + ], + ], ]); $config->setAdvancedErrorLevel('UndefinedGlobalVariable', [ [ 'type' => 'suppress', 'referencedVariable' => [ - ['name' => 'a'] - ] - ] + ['name' => 'a'], + ], + ], ]); $this->assertSame( 'info', $config->getReportingLevelForFile( 'MissingReturnType', - realpath('src/Psalm/Type.php') - ) + realpath('src/Psalm/Type.php'), + ), ); $this->assertSame( 'error', $config->getReportingLevelForFile( 'MissingReturnType', - realpath('src/Psalm/Internal/Analyzer/FileAnalyzer.php') - ) + realpath('src/Psalm/Internal/Analyzer/FileAnalyzer.php'), + ), ); $this->assertSame( 'error', $config->getReportingLevelForFile( 'PossiblyInvalidArgument', - realpath('src/psalm.php') - ) + realpath('src/psalm.php'), + ), ); $this->assertSame( 'info', $config->getReportingLevelForFile( 'PossiblyInvalidArgument', - realpath('examples/TemplateChecker.php') - ) + realpath('examples/TemplateChecker.php'), + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\Badger' - ) + 'Psalm\Badger', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\BadActor' - ) + 'Psalm\BadActor', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\GoodActor' - ) + 'Psalm\GoodActor', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\MagicFactory' - ) + 'Psalm\MagicFactory', + ), ); $this->assertNull( $config->getReportingLevelForClass( 'UndefinedClass', - 'Psalm\Bodger' - ) + 'Psalm\Bodger', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedMethod', - 'Psalm\Bodger::find1' - ) + 'Psalm\Bodger::find1', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedMethod', - 'Psalm\Bodger::find2' - ) + 'Psalm\Bodger::find2', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedMethod', - 'Psalm\Badger::find2' - ) + 'Psalm\Badger::find2', + ), ); $this->assertNull( $config->getReportingLevelForProperty( 'UndefinedMethod', - 'Psalm\Bodger::$find3' - ) + 'Psalm\Bodger::$find3', + ), ); $this->assertNull( $config->getReportingLevelForProperty( 'UndefinedMethod', - 'Psalm\Bodger::$find4' - ) + 'Psalm\Bodger::$find4', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedFunction', - 'fooBar' - ) + 'fooBar', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForMethod( 'UndefinedFunction', - 'foobar' - ) + 'foobar', + ), ); $this->assertSame( 'suppress', $config->getReportingLevelForVariable( 'UndefinedGlobalVariable', - 'a' - ) + 'a', + ), ); $this->assertNull( $config->getReportingLevelForVariable( 'UndefinedGlobalVariable', - 'b' - ) + 'b', + ), ); } @@ -867,8 +867,8 @@ public function testAllPossibleIssues(): void * @return string */ fn($issue_name): string => '<' . $issue_name . ' errorLevel="suppress" />' . "\n", - IssueHandler::getAllIssueTypes() - ) + IssueHandler::getAllIssueTypes(), + ), ); $this->project_analyzer = $this->getProjectAnalyzerWithConfig( @@ -883,8 +883,8 @@ public function testAllPossibleIssues(): void ' . $all_possible_handlers . ' - ' - ) + ', + ), ); } @@ -904,8 +904,8 @@ public function testImpossibleIssue(): void - ' - ) + ', + ), ); } @@ -922,8 +922,8 @@ public function testThing(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -935,7 +935,7 @@ class MyMockClass {} $a = new MyMockClass(); $a->foo($b = 5); - echo $b;' + echo $b;', ); $this->analyzeFile($file_path, new Context()); @@ -957,8 +957,8 @@ public function testValidThrowInvalidCatch(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -983,7 +983,7 @@ function handleThrow(I $e) : void { foo(); } catch (I $e) { handleThrow($e); - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -1005,8 +1005,8 @@ public function testInvalidThrowValidCatch(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1031,7 +1031,7 @@ function handleThrow(I $e) : void { foo(); } catch (I $e) { handleThrow($e); - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -1056,8 +1056,8 @@ public function testValidThrowValidCatch(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1082,7 +1082,7 @@ function handleThrow(I $e) : void { foo(); } catch (I $e) { handleThrow($e); - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -1095,9 +1095,9 @@ public function testModularConfig(): void $this->assertEquals( [ realpath($root . '/Bar.php'), - realpath($root . '/Bat.php') + realpath($root . '/Bat.php'), ], - $config->getProjectFiles() + $config->getProjectFiles(), ); } @@ -1129,8 +1129,8 @@ public function testGlobals(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1207,7 +1207,7 @@ function example4(): void { ord($glob1 ?: "str"); ord($_GET["str"] ?? "str"); } - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -1227,8 +1227,8 @@ public function testIgnoreExceptions(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1271,7 +1271,7 @@ function example() : void { throwsExc1(); throwsExc3(); throwsExc6(); - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -1293,8 +1293,8 @@ public function testNotIgnoredException(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1306,7 +1306,7 @@ class Exc2 extends Exception {} function example() : void { throw new Exc2(); - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -1323,8 +1323,8 @@ public function testGetPossiblePsr4Path(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -1337,7 +1337,7 @@ public function testGetPossiblePsr4Path(): void . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'composer' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Psalm', - ] + ], ); $classloader->addPsr4( @@ -1347,19 +1347,19 @@ public function testGetPossiblePsr4Path(): void . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'composer' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tests', - ] + ], ); $config->setComposerClassLoader($classloader); $this->assertSame( dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Psalm' . DIRECTORY_SEPARATOR . 'Foo.php', - $config->getPotentialComposerFilePathForClassLike('Psalm\\Foo') + $config->getPotentialComposerFilePathForClassLike('Psalm\\Foo'), ); $this->assertSame( dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'Foo.php', - $config->getPotentialComposerFilePathForClassLike('Psalm\\Tests\\Foo') + $config->getPotentialComposerFilePathForClassLike('Psalm\\Tests\\Foo'), ); } @@ -1367,7 +1367,7 @@ public function testTakesPhpVersionFromConfigFile(): void { $cfg = Config::loadFromXML( dirname(__DIR__, 2), - '' + '', ); $this->assertSame('7.1', $cfg->getPhpVersion()); } @@ -1390,8 +1390,8 @@ public function testSetsUsePhpStormMetaPath(): void dirname(__DIR__, 2), ' - ' - ) + ', + ), ); $this->assertFalse($this->project_analyzer->getConfig()->use_phpstorm_meta_path); @@ -1407,8 +1407,8 @@ public function testSetsUniversalObjectCrates(): void - ' - ) + ', + ), ); $this->assertContains('datetime', $this->project_analyzer->getConfig()->getUniversalObjectCrates()); @@ -1418,7 +1418,7 @@ public function testInferPropertyTypesFromConstructorIsRead(): void { $cfg = Config::loadFromXML( dirname(__DIR__, 2), - '' + '', ); $this->assertFalse($cfg->infer_property_types_from_constructor); } @@ -1464,12 +1464,12 @@ public function pluginRegistersScannerAndAnalyzer(int $flags, ?int $expectedExce $xml = sprintf( ' ', - FileTypeSelfRegisteringPlugin::class + FileTypeSelfRegisteringPlugin::class, ); try { $projectAnalyzer = $this->getProjectAnalyzerWithConfig( - TestConfig::loadFromXML(dirname(__DIR__, 2), $xml) + TestConfig::loadFromXML(dirname(__DIR__, 2), $xml), ); $config = $projectAnalyzer->getConfig(); $config->initializePlugins($projectAnalyzer); @@ -1480,7 +1480,7 @@ public function pluginRegistersScannerAndAnalyzer(int $flags, ?int $expectedExce self::assertSame( $expectedExceptionCode, $actualExceptionCode, - 'Exception code did not match.' + 'Exception code did not match.', ); return; } @@ -1508,8 +1508,8 @@ public function testTypeStatsForFileReporting(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -1541,8 +1541,8 @@ public function testStrictTypesForFileReporting(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); @@ -1574,7 +1574,7 @@ public function testConfigFileWithXIncludeWithoutFallbackShouldThrowException(): - ' + ', ); } @@ -1602,8 +1602,8 @@ public function testConfigFileWithXIncludeWithFallback(): void - ' - ) + ', + ), ); $config = $this->project_analyzer->getConfig(); diff --git a/tests/Config/CreatorTest.php b/tests/Config/CreatorTest.php index 6be60df3988..23bd7d6ee0d 100644 --- a/tests/Config/CreatorTest.php +++ b/tests/Config/CreatorTest.php @@ -28,7 +28,7 @@ public function testDiscoverLibDirectory(): void . DIRECTORY_SEPARATOR . 'files_in_lib', null, 1, - 'vendor' + 'vendor', ); $this->assertSame(' diff --git a/tests/Config/Plugin/Hook/CustomArrayMapFunctionStorageProvider.php b/tests/Config/Plugin/Hook/CustomArrayMapFunctionStorageProvider.php index d62055f381a..a491d9ecf1b 100644 --- a/tests/Config/Plugin/Hook/CustomArrayMapFunctionStorageProvider.php +++ b/tests/Config/Plugin/Hook/CustomArrayMapFunctionStorageProvider.php @@ -62,9 +62,9 @@ function (TCallable $expected, int $offset) { return $param; }, $all_expected_callables, - array_keys($all_expected_callables) + array_keys($all_expected_callables), ), - self::createLastArrayMapParam($input_array_type) + self::createLastArrayMapParam($input_array_type), ]; return $custom_array_map_storage; @@ -79,7 +79,7 @@ private static function createLastArrayMapParam(Union $input_array_type): Functi $input_array_type, null, null, - false + false, ); } @@ -114,8 +114,8 @@ private static function createExpectedCallable( 'callable', [new FunctionLikeParameter('a', false, $input_type, $input_type)], new Union([ - $template_provider->createTemplate('T' . $return_template_offset) - ]) + $template_provider->createTemplate('T' . $return_template_offset), + ]), ); } @@ -131,10 +131,10 @@ private static function createRestCallables( for ($template_offset = 0; $template_offset < $expected_callable_args_count - 1; $template_offset++) { $rest_callable_params[] = self::createExpectedCallable( new Union([ - $template_provider->createTemplate('T' . $template_offset) + $template_provider->createTemplate('T' . $template_offset), ]), $template_provider, - $template_offset + 1 + $template_offset + 1, ); } diff --git a/tests/Config/PluginTest.php b/tests/Config/PluginTest.php index 7bb95644a47..130fd2d3304 100644 --- a/tests/Config/PluginTest.php +++ b/tests/Config/PluginTest.php @@ -67,9 +67,9 @@ private function getProjectAnalyzerWithConfig(Config $config): ProjectAnalyzer $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() + new FakeParserCacheProvider(), ), - new ReportOptions() + new ReportOptions(), ); } @@ -90,8 +90,8 @@ public function testStringAnalyzerPlugin(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -101,7 +101,7 @@ public function testStringAnalyzerPlugin(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -124,8 +124,8 @@ public function testStringAnalyzerPluginWithClassConstant(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -139,7 +139,7 @@ class A { const C = [ "foo" => "Psalm\Internal\Analyzer\ProjectAnalyzer", ]; - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -162,8 +162,8 @@ public function testStringAnalyzerPluginWithClassConstantConcat(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -179,7 +179,7 @@ class A { const C = [ "foo" => \Psalm\Internal\Analyzer\ProjectAnalyzer::class . "::foo", ]; - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -200,8 +200,8 @@ public function testEchoAnalyzerPluginWithJustHtml(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -210,7 +210,7 @@ public function testEchoAnalyzerPluginWithJustHtml(): void $this->addFile( $file_path, - '

This is a header

' + '

This is a header

', ); $this->analyzeFile($file_path, new Context()); @@ -238,8 +238,8 @@ public function testEchoAnalyzerPluginWithUnescapedConcatenatedString(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -248,7 +248,7 @@ public function testEchoAnalyzerPluginWithUnescapedConcatenatedString(): void $this->addFile( $file_path, - '' + '', ); $this->analyzeFile($file_path, new Context()); @@ -275,8 +275,8 @@ public function testEchoAnalyzerPluginWithUnescapedString(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -285,7 +285,7 @@ public function testEchoAnalyzerPluginWithUnescapedString(): void $this->addFile( $file_path, - '' + '', ); $this->analyzeFile($file_path, new Context()); @@ -308,8 +308,8 @@ public function testFileAnalyzerPlugin(): void - ' - ) + ', + ), ); $codebase = $this->project_analyzer->getCodebase(); @@ -325,7 +325,7 @@ public function testFileAnalyzerPlugin(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -335,7 +335,7 @@ public function testFileAnalyzerPlugin(): void 'before-analysis' => true, 'after-analysis' => true, ], - $file_storage->custom_metadata + $file_storage->custom_metadata, ); } @@ -356,8 +356,8 @@ public function testFloatCheckerPlugin(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -368,7 +368,7 @@ public function testFloatCheckerPlugin(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -394,8 +394,8 @@ public function testFloatCheckerPluginIssueSuppressionByConfig(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -406,7 +406,7 @@ public function testFloatCheckerPluginIssueSuppressionByConfig(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -427,8 +427,8 @@ public function testFloatCheckerPluginIssueSuppressionByDocblock(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -440,7 +440,7 @@ public function testFloatCheckerPluginIssueSuppressionByDocblock(): void 'analyzeFile($file_path, new Context()); @@ -463,14 +463,14 @@ public function testInheritedHookHandlersAreCalled(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); $this->assertContains( 'ExtendingPlugin', - $this->project_analyzer->getCodebase()->config->eventDispatcher->after_function_checks + $this->project_analyzer->getCodebase()->config->eventDispatcher->after_function_checks, ); } @@ -486,8 +486,8 @@ public function testAfterCodebasePopulatedHookIsLoaded(): void - ' - ) + ', + ), ); $hook = new class implements AfterCodebasePopulatedInterface { @@ -508,7 +508,7 @@ public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event $this->assertContains( get_class($hook), - $this->project_analyzer->getCodebase()->config->eventDispatcher->after_codebase_populated + $this->project_analyzer->getCodebase()->config->eventDispatcher->after_codebase_populated, ); } @@ -529,8 +529,8 @@ public function testPropertyProviderHooks(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -545,7 +545,7 @@ public function testPropertyProviderHooks(): void class Foo {} $foo = new Foo(); - echo $foo->magic_property;' + echo $foo->magic_property;', ); $this->analyzeFile($file_path, new Context()); @@ -568,8 +568,8 @@ public function testMethodProviderHooksValidArg(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -606,7 +606,7 @@ function i(I $i): void {} $foo2 = $foo->magicMethod2("test"); $foo2->id(); i($foo2); - echo $foo2->id();' + echo $foo2->id();', ); $this->analyzeFile($file_path, new Context()); @@ -629,8 +629,8 @@ public function testFunctionProviderHooks(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -640,7 +640,7 @@ public function testFunctionProviderHooks(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -665,8 +665,8 @@ public function testPropertyProviderHooksInvalidAssignment(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -681,7 +681,7 @@ public function testPropertyProviderHooksInvalidAssignment(): void class Foo {} $foo = new Foo(); - $foo->magic_property = 5;' + $foo->magic_property = 5;', ); $this->analyzeFile($file_path, new Context()); @@ -706,8 +706,8 @@ public function testMethodProviderHooksInvalidArg(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -724,7 +724,7 @@ public function __call(string $method_name, array $args) {} } $foo = new Foo(); - echo strlen($foo->magicMethod(5));' + echo strlen($foo->magicMethod(5));', ); $this->analyzeFile($file_path, new Context()); @@ -749,8 +749,8 @@ public function testFunctionProviderHooksInvalidArg(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -760,7 +760,7 @@ public function testFunctionProviderHooksInvalidArg(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -783,8 +783,8 @@ public function testAfterAnalysisHooks(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -813,10 +813,10 @@ public function testPluginFilenameCanBeAbsolute(): void ', - __DIR__ . '/../..' + __DIR__ . '/../..', ); $this->project_analyzer = $this->getProjectAnalyzerWithConfig( - TestConfig::loadFromXML(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR, $xml) + TestConfig::loadFromXML(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR, $xml), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -839,10 +839,10 @@ public function testPluginInvalidAbsoluteFilenameThrowsException(): void ', - __DIR__ . '/..' + __DIR__ . '/..', ); $this->project_analyzer = $this->getProjectAnalyzerWithConfig( - TestConfig::loadFromXML(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR, $xml) + TestConfig::loadFromXML(dirname(__DIR__, 2) . DIRECTORY_SEPARATOR, $xml), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -856,8 +856,8 @@ public function testAfterEveryFunctionPluginIsCalledInAllCases(): void ' ' - ) + >', + ), ); $mock = $this->getMockBuilder(stdClass::class)->setMethods(['check'])->getMock(); @@ -867,7 +867,7 @@ public function testAfterEveryFunctionPluginIsCalledInAllCases(): void [$this->equalTo('b')], [$this->equalTo('array_map')], [$this->equalTo('fopen')], - [$this->equalTo('a')] + [$this->equalTo('a')], ); $plugin = new class($mock) implements AfterEveryFunctionCallAnalysisInterface { private static MockObject $m; @@ -900,7 +900,7 @@ function b(int $e): int { return $e; } array_map("b", [1,3,3]); fopen("/tmp/foo.dat", "r"); a(); - ' + ', ); $this->analyzeFile($file_path, new Context()); @@ -922,8 +922,8 @@ public function testRemoveTaints(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -944,7 +944,7 @@ function output(array $build) {} "safe_key" => $_GET["input"], ], ]; - output($build);' + output($build);', ); $this->project_analyzer->trackTaintedInputs(); @@ -966,7 +966,7 @@ function output(array $build) {} "a" => $_GET["input"], ], ]; - output($build);' + output($build);', ); $this->project_analyzer->trackTaintedInputs(); @@ -994,8 +994,8 @@ public function testFunctionDynamicStorageProviderHook(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); @@ -1025,7 +1025,7 @@ function acceptsList(array $_list): void { } $list ); - acceptsList($tuples);' + acceptsList($tuples);', ); $this->analyzeFile($file_path, new Context()); diff --git a/tests/ConstantTest.php b/tests/ConstantTest.php index 70b33cc5c7a..54673fc8e0d 100644 --- a/tests/ConstantTest.php +++ b/tests/ConstantTest.php @@ -59,7 +59,7 @@ public function testUseObjectConstant(): void final class Bar {} const bar = new Bar(); - ' + ', ); $this->addFile( @@ -76,7 +76,7 @@ function bar(): Bar { return bar; } - ' + ', ); $this->analyzeFile($file1, new Context()); @@ -621,7 +621,7 @@ final class A { public static function foo(): void { print_r(explode(",", static::STRING)); } - }' + }', ], 'allowChecksAfterDefined' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'number; } - }' + }', ], 'lowercaseStringAccessClassConstant' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$c' => 'int', - ] + ], ], 'bitwiseAndClassConstant' => [ 'code' => ' [ '$c' => 'int', - ] + ], ], 'bitwiseXorClassConstant' => [ 'code' => ' [ '$c' => 'int', - ] + ], ], 'bitwiseNotClassConstant' => [ 'code' => ' [ '$a' => 'int', '$b' => 'string', - ] + ], ], 'booleanNotClassConstant' => [ 'code' => ' [ '$a' => 'false', '$b' => 'true', - ] + ], ], 'protectedClassConstantAccessibilitySameNameInChild' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'level; } - }' + }', ], 'dirAndFileInConstInitializersAreNonEmptyString' => [ 'code' => ' [ '$dir===' => 'non-empty-string', '$file===' => 'non-empty-string', - ] + ], ], 'lineInConstInitializersIsInt' => [ 'code' => ' [ '$line' => 'int', - ] + ], ], 'classMethodTraitAndFunctionInConstInitializersAreStrings' => [ 'code' => ' 'string', '$trt' => 'string', '$fcn' => 'string', - ] + ], ], 'concatWithMagicInConstInitializersIsNoEmptyString' => [ 'code' => ' [ '$dir===' => 'non-empty-string', '$file===' => 'non-empty-string', - ] + ], ], 'noCrashWithStaticInDocblock' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ - '$c===' => 'enum(E::Z)' + '$c===' => 'enum(E::Z)', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'classConstWithParamOut' => [ 'code' => ' [ - '$a===' => "'baz'" + '$a===' => "'baz'", ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'finalConstInterface' => [ 'code' => ' [ - '$a===' => "'baz'" + '$a===' => "'baz'", ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], ]; } @@ -1650,7 +1650,7 @@ class B { class C { const FOO = A::FOO; }', - 'error_message' => 'CircularReference' + 'error_message' => 'CircularReference', ], 'keyOfBadValue' => [ 'code' => ' 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'wildcardEnumAnyTemplateExtendConstantBadValue' => [ 'code' => 'foo(5); ', - 'error_message' => 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'correctMessage' => [ 'code' => ' "a", 2 => "b"][$s]; }', - 'error_message' => "offset value of '1|0" + 'error_message' => "offset value of '1|0", ], 'constantWithMissingClass' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$period' => 'DatePeriod', - '$dt' => 'DateTimeInterface|null' + '$dt' => 'DateTimeInterface|null', ], 'ignored_issues' => [], 'php_version' => '7.3', @@ -63,7 +63,7 @@ public function providerValidCodeParse(): iterable }', 'assertions' => [ '$period' => 'DatePeriod', - '$dt' => 'DateTimeImmutable|null' + '$dt' => 'DateTimeImmutable|null', ], 'ignored_issues' => [], 'php_version' => '8.0', @@ -78,7 +78,7 @@ public function providerValidCodeParse(): iterable }', 'assertions' => [ '$period' => 'DatePeriod', - '$dt' => 'DateTime|null' + '$dt' => 'DateTime|null', ], 'ignored_issues' => [], 'php_version' => '8.0', diff --git a/tests/DeprecatedAnnotationTest.php b/tests/DeprecatedAnnotationTest.php index 1accf441645..adcf30e5b17 100644 --- a/tests/DeprecatedAnnotationTest.php +++ b/tests/DeprecatedAnnotationTest.php @@ -47,7 +47,7 @@ public static function barBar(): void { 'annotationOnStatement' => [ 'code' => ' [ 'code' => ' [ 'code' => ' 'bool', ], - ] + ], ); $expectedDoc = '/** @@ -71,7 +71,7 @@ public function testNewLineIsNotAddedBetweenAnnotationsIfDisabled(): void [ 0 => 'bool', ], - ] + ], ); $expectedDoc = '/** @@ -107,7 +107,7 @@ public function testNewLineIsAddedBetweenAnnotationsIfEnabled(): void [ 0 => 'bool', ], - ] + ], ); $expectedDoc = '/** @@ -141,7 +141,7 @@ public function testParsingRoundtrip(): void */ '; $docComment = DocComment::parsePreservingLength( - new Doc($expectedDoc) + new Doc($expectedDoc), ); $this->assertSame($expectedDoc, $docComment->render('')); @@ -163,7 +163,7 @@ public function testParsingWithIndentation(): void */ '; $docComment = DocComment::parsePreservingLength( - new Doc($expectedDoc) + new Doc($expectedDoc), ); $this->assertSame($expectedDoc, $docComment->render(' ')); @@ -187,7 +187,7 @@ public function testParsingWithCommonPrefixes(): void */ '; $docComment = DocComment::parsePreservingLength( - new Doc($expectedDoc) + new Doc($expectedDoc), ); $this->assertSame($expectedDoc, $docComment->render('')); diff --git a/tests/DocblockInheritanceTest.php b/tests/DocblockInheritanceTest.php index bf5306244e8..3a09ad9a353 100644 --- a/tests/DocblockInheritanceTest.php +++ b/tests/DocblockInheritanceTest.php @@ -76,7 +76,7 @@ class Baz extends Bar { public function aa() { return []; } - }' + }', ], 'inheritTwiceWithArrayType' => [ 'code' => ' [ 'code' => 'map(); - }' + }', ], 'inheritCorrectReturnTypeOnClass' => [ 'code' => 'map(); - }' + }', ], ]; } diff --git a/tests/DocumentationTest.php b/tests/DocumentationTest.php index bb67c71bb65..b15dc0bec1b 100644 --- a/tests/DocumentationTest.php +++ b/tests/DocumentationTest.php @@ -139,8 +139,8 @@ public function setUp(): void new TestConfig(), new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $this->project_analyzer->setPhpVersion('8.0', 'tests'); @@ -317,7 +317,7 @@ public function providerInvalidCodeParse(): array strpos($issue_name, 'Unused') !== false || strpos($issue_name, 'Unevaluated') !== false || strpos($issue_name, 'Unnecessary') !== false, - $php_version + $php_version, ]; } @@ -344,7 +344,7 @@ public function testShortcodesAreUnique(): void $this->assertEquals( [], $duplicate_shortcodes, - "Duplicate shortcodes found: \n" . var_export($duplicate_shortcodes, true) + "Duplicate shortcodes found: \n" . var_export($duplicate_shortcodes, true), ); } @@ -360,7 +360,7 @@ public function testAllAnnotationsAreDocumented(string $annotation): void $this->assertThat( self::$docContents, $this->conciseExpected($this->stringContains('@psalm-' . $annotation)), - "'@psalm-$annotation' is not present in the docs" + "'@psalm-$annotation' is not present in the docs", ); } diff --git a/tests/EndToEnd/PsalmEndToEndTest.php b/tests/EndToEnd/PsalmEndToEndTest.php index 8933d0d9ae1..3a9d3e74019 100644 --- a/tests/EndToEnd/PsalmEndToEndTest.php +++ b/tests/EndToEnd/PsalmEndToEndTest.php @@ -67,7 +67,7 @@ public function setUp(): void @unlink(self::$tmpDir . '/psalm.xml'); copy( __DIR__ . '/../fixtures/DummyProjectWithErrors/src/FileWithErrors.php', - self::$tmpDir . '/src/FileWithErrors.php' + self::$tmpDir . '/src/FileWithErrors.php', ); parent::setUp(); } @@ -89,7 +89,7 @@ public function testInit(): void { $this->assertStringStartsWith( 'Calculating best config level based on project files', - $this->runPsalmInit()['STDOUT'] + $this->runPsalmInit()['STDOUT'], ); $this->assertFileExists(self::$tmpDir . '/psalm.xml'); } @@ -100,7 +100,7 @@ public function testAlter(): void $this->assertStringContainsString( 'No errors found!', - $this->runPsalm(['--alter', '--issues=all'], self::$tmpDir, false, true)['STDOUT'] + $this->runPsalm(['--alter', '--issues=all'], self::$tmpDir, false, true)['STDOUT'], ); $this->assertSame(0, $this->runPsalm([], self::$tmpDir)['CODE']); @@ -119,7 +119,7 @@ public function testPsalm(): void $result = $this->runPsalm([], self::$tmpDir, true); $this->assertStringContainsString( 'Target PHP version: 7.1 (inferred from composer.json)', - $result['STDERR'] + $result['STDERR'], ); $this->assertStringContainsString('UnusedParam', $result['STDOUT']); $this->assertStringContainsString('InvalidReturnType', $result['STDOUT']); @@ -134,7 +134,7 @@ public function testPsalmWithPHPVersionOverride(): void $result = $this->runPsalm(['--php-version=8.0'], self::$tmpDir, true); $this->assertStringContainsString( 'Target PHP version: 8.0 (set by CLI argument)', - $result['STDERR'] + $result['STDERR'], ); } @@ -144,7 +144,7 @@ public function testPsalmWithPHPVersionFromConfig(): void $result = $this->runPsalm([], self::$tmpDir, true); $this->assertStringContainsString( 'Target PHP version: 7.4 (set by config file)', - $result['STDERR'] + $result['STDERR'], ); } @@ -205,13 +205,13 @@ public function testTaintGraphDumping(): void '--dump-taint-graph='.self::$tmpDir.'/taints.dot', ], self::$tmpDir, - true + true, ); $this->assertSame(2, $result['CODE']); $this->assertFileEquals( __DIR__ . '/../fixtures/expected_taint_graph.dot', - self::$tmpDir.'/taints.dot' + self::$tmpDir.'/taints.dot', ); } @@ -251,7 +251,7 @@ private function runPsalmInit(?int $level = null, ?string $php_version = null): 'errorLevel="1" ' . 'cacheDirectory="' . self::$tmpDir . '/cache" ' . ($php_version ? ('phpVersion="' . $php_version . '"') : ''), - $psalm_config_contents + $psalm_config_contents, ); file_put_contents(self::$tmpDir . '/psalm.xml', $psalm_config_contents); diff --git a/tests/EnumTest.php b/tests/EnumTest.php index 00489ac4740..646ad0aa328 100644 --- a/tests/EnumTest.php +++ b/tests/EnumTest.php @@ -50,7 +50,7 @@ function deal(Suit $s): void { Suit::Diamonds->shape();', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'enumValue' => [ 'code' => 'value === "h") {}', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'enumCases' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'literalExpressionAsCaseValue' => [ 'code' => ' '1|2', ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'namePropertyFromOutside' => [ 'code' => ' "'DRAFT'", ], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'namePropertyFromInside' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'valuePropertyFromInside' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'wildcardEnumAsParam' => [ 'code' => 'value === "a") {}', 'error_message' => 'TypeDoesNotContainType', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'enumValueNotBacked' => [ 'code' => 'value;', 'error_message' => 'UndefinedPropertyFetch', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'badSuit' => [ 'code' => ' 'UndefinedConstant', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'cantCompareToSuitTwice' => [ 'code' => ' 'RedundantCondition', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'insufficientMatches' => [ 'code' => ' 'UnhandledMatchCondition', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'insufficientMatchesForCases' => [ 'code' => ' 'UnhandledMatchCondition', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'invalidBackingType' => [ 'code' => 'bar
- ' + ', ); $expectedParsedBaseline = [ @@ -63,7 +63,7 @@ public function testLoadShouldParseXmlBaselineToPhpArray(): void $this->assertSame( $expectedParsedBaseline, - ErrorBaseline::read($this->fileProvider, $baselineFilePath) + ErrorBaseline::read($this->fileProvider, $baselineFilePath), ); } @@ -80,7 +80,7 @@ public function testLoadShouldIgnoreLineEndingsInIssueSnippet(): void foo\r
- " + ", ); $expectedParsedBaseline = [ @@ -91,7 +91,7 @@ public function testLoadShouldIgnoreLineEndingsInIssueSnippet(): void $this->assertSame( $expectedParsedBaseline, - ErrorBaseline::read($this->fileProvider, $baselineFilePath) + ErrorBaseline::read($this->fileProvider, $baselineFilePath), ); } @@ -106,7 +106,7 @@ public function testLoadShouldThrowExceptionWhenFilesAreNotDefinedInBaselineFile ' - ' + ', ); ErrorBaseline::read($this->fileProvider, $baselineFile); @@ -167,7 +167,7 @@ public function testCreateShouldAggregateIssuesPerFile(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'error', @@ -184,7 +184,7 @@ public function testCreateShouldAggregateIssuesPerFile(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'error', @@ -201,7 +201,7 @@ public function testCreateShouldAggregateIssuesPerFile(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'error', @@ -218,7 +218,7 @@ public function testCreateShouldAggregateIssuesPerFile(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'info', @@ -235,7 +235,7 @@ public function testCreateShouldAggregateIssuesPerFile(): void 0, 0, 0, - 0 + 0, ), ], 'sample/sample-file2.php' => [ @@ -254,7 +254,7 @@ public function testCreateShouldAggregateIssuesPerFile(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'error', @@ -271,7 +271,7 @@ public function testCreateShouldAggregateIssuesPerFile(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'error', @@ -288,11 +288,11 @@ public function testCreateShouldAggregateIssuesPerFile(): void 0, 0, 0, - 0 + 0, ), ], ], - false + false, ); $this->fileProvider->shouldHaveReceived() @@ -319,13 +319,13 @@ public function testCreateShouldAggregateIssuesPerFile(): void $this->assertSame( '3', $file1Issues[0]->getAttribute('occurrences'), - 'MixedAssignment should have occured 3 times' + 'MixedAssignment should have occured 3 times', ); $this->assertSame('MixedOperand', $file1Issues[1]->tagName); $this->assertSame( '1', $file1Issues[1]->getAttribute('occurrences'), - 'MixedOperand should have occured 1 time' + 'MixedOperand should have occured 1 time', ); $this->assertSame('MixedAssignment', $file2Issues[0]->tagName); @@ -338,11 +338,11 @@ public function testCreateShouldAggregateIssuesPerFile(): void $this->assertSame( '1', $file2Issues[1]->getAttribute('occurrences'), - 'TypeCoercion should have occured 1 time' + 'TypeCoercion should have occured 1 time', ); return true; - }) + }), ); } @@ -368,7 +368,7 @@ public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void - ' + ', ); $this->fileProvider->allows()->setContents(Mockery::andAnyOtherArgs()); @@ -390,7 +390,7 @@ public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'error', @@ -407,7 +407,7 @@ public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'error', @@ -424,7 +424,7 @@ public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void 0, 0, 0, - 0 + 0, ), new IssueData( 'error', @@ -441,7 +441,7 @@ public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void 0, 0, 0, - 0 + 0, ), ], 'sample/sample-file2.php' => [ @@ -460,7 +460,7 @@ public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void 0, 0, 0, - 0 + 0, ), ], ]; @@ -469,7 +469,7 @@ public function testUpdateShouldRemoveExistingIssuesWithoutAddingNewOnes(): void $this->fileProvider, $baselineFile, $newIssues, - false + false, ); $this->assertSame([ @@ -506,7 +506,7 @@ public function testAddingACommentInBaselineDoesntTriggerNotice(): void bar
- ' + ', ); $expectedParsedBaseline = [ @@ -521,7 +521,7 @@ public function testAddingACommentInBaselineDoesntTriggerNotice(): void $this->assertSame( $expectedParsedBaseline, - ErrorBaseline::read($this->fileProvider, $baselineFilePath) + ErrorBaseline::read($this->fileProvider, $baselineFilePath), ); } } diff --git a/tests/ExtendsFinalClassTest.php b/tests/ExtendsFinalClassTest.php index a6ad592ed88..c2f18288763 100644 --- a/tests/ExtendsFinalClassTest.php +++ b/tests/ExtendsFinalClassTest.php @@ -21,7 +21,7 @@ final class A {} /** * @psalm-suppress InvalidExtendClass */ - class B extends A {}' + class B extends A {}', ], 'suppressingIssueWhenUsedWithAnnotation' => [ 'code' => 'addFile( @@ -32,7 +32,7 @@ class MyBaseClass { } /** @psalm-require-extends MyAliasedBaseClass */ trait ImposesExtensionRequirements { } - ' + ', ); } @@ -47,8 +47,8 @@ public function providerValidCodeParse(): iterable class Valid extends MyBaseClass { use ImposesExtensionRequirements; } - ' - ] + ', + ], ]; } @@ -63,8 +63,8 @@ class Invalid { use ImposesExtensionRequirements; } ', - 'error_message' => 'requires using class to extend' - ] + 'error_message' => 'requires using class to extend', + ], ]; } } diff --git a/tests/FileDiffTest.php b/tests/FileDiffTest.php index 278142d39b2..5071174c00f 100644 --- a/tests/FileDiffTest.php +++ b/tests/FileDiffTest.php @@ -42,17 +42,17 @@ public function testCode( $this->assertSame( $same_methods, - $diff[0] + $diff[0], ); $this->assertSame( $same_signatures, - $diff[1] + $diff[1], ); $this->assertSame( $changed_methods, - $diff[2] + $diff[2], ); $this->assertSame(count($diff_map_offsets), count($diff[3])); @@ -63,7 +63,7 @@ public function testCode( * @return array{0: int, 1: int} */ fn(array $arr): array => [$arr[2], $arr[3]], - $diff[3] + $diff[3], ); $this->assertSame($diff_map_offsets, $found_offsets); @@ -113,17 +113,17 @@ public function testPartialAstDiff( $this->assertSame( $same_methods, - $diff[0] + $diff[0], ); $this->assertSame( $same_signatures, - $diff[1] + $diff[1], ); $this->assertSame( $changed_methods, - $diff[2] + $diff[2], ); $this->assertSame(count($diff_map_offsets), count($diff[3])); @@ -134,7 +134,7 @@ public function testPartialAstDiff( * @return array{0: int, 1: int} */ fn(array $arr): array => [$arr[2], $arr[3]], - $diff[3] + $diff[3], ); $this->assertSame($diff_map_offsets, $found_offsets); @@ -173,7 +173,7 @@ private function assertTreesEqual(array $a, array $b): void $this->assertSame( $a_stmt->getAttribute('startFilePos'), - $b_stmt->getAttribute('startFilePos') + $b_stmt->getAttribute('startFilePos'), ); $this->assertSame( $a_stmt->getAttribute('endFilePos'), @@ -181,7 +181,7 @@ private function assertTreesEqual(array $a, array $b): void ($a_stmt instanceof PhpParser\Node\Stmt\Expression ? get_class($a_stmt->expr) : get_class($a_stmt)) - . ' on line ' . $a_stmt->getLine() + . ' on line ' . $a_stmt->getLine(), ); $this->assertSame($a_stmt->getLine(), $b_stmt->getLine()); diff --git a/tests/FileManipulation/ClassConstantMoveTest.php b/tests/FileManipulation/ClassConstantMoveTest.php index 4c4e7152a63..f06239abb0a 100644 --- a/tests/FileManipulation/ClassConstantMoveTest.php +++ b/tests/FileManipulation/ClassConstantMoveTest.php @@ -44,8 +44,8 @@ public function testValidCode( $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $context = new Context(); @@ -54,7 +54,7 @@ public function testValidCode( $this->addFile( $file_path, - $input_code + $input_code, ); $codebase = $this->project_analyzer->getCodebase(); diff --git a/tests/FileManipulation/ClassMoveTest.php b/tests/FileManipulation/ClassMoveTest.php index 614d4abdb12..e49e0cf87f8 100644 --- a/tests/FileManipulation/ClassMoveTest.php +++ b/tests/FileManipulation/ClassMoveTest.php @@ -44,8 +44,8 @@ public function testValidCode( $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $context = new Context(); @@ -54,7 +54,7 @@ public function testValidCode( $this->addFile( $file_path, - $input_code + $input_code, ); $codebase = $this->project_analyzer->getCodebase(); diff --git a/tests/FileManipulation/FileManipulationTestCase.php b/tests/FileManipulation/FileManipulationTestCase.php index b0f24142020..de361f6ffd2 100644 --- a/tests/FileManipulation/FileManipulationTestCase.php +++ b/tests/FileManipulation/FileManipulationTestCase.php @@ -47,8 +47,8 @@ public function testValidCode( $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); if (empty($issues_to_fix)) { @@ -62,7 +62,7 @@ public function testValidCode( $this->addFile( $file_path, - $input_code + $input_code, ); $this->project_analyzer->setPhpVersion($php_version, 'tests'); @@ -76,7 +76,7 @@ public function testValidCode( $this->project_analyzer->setIssuesToFix($keyed_issues_to_fix); $this->project_analyzer->alterCodeAfterCompletion( false, - $safe_types + $safe_types, ); $this->project_analyzer->getCodebase()->allow_backwards_incompatible_changes = $allow_backwards_incompatible_changes; $this->project_analyzer->getConfig()->check_for_throws_docblock = true; diff --git a/tests/FileManipulation/MethodMoveTest.php b/tests/FileManipulation/MethodMoveTest.php index aacef2b9c9a..4e97bb863db 100644 --- a/tests/FileManipulation/MethodMoveTest.php +++ b/tests/FileManipulation/MethodMoveTest.php @@ -44,8 +44,8 @@ public function testValidCode( $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $context = new Context(); @@ -54,7 +54,7 @@ public function testValidCode( $this->addFile( $file_path, - $input_code + $input_code, ); $codebase = $this->project_analyzer->getCodebase(); diff --git a/tests/FileManipulation/NamespaceMoveTest.php b/tests/FileManipulation/NamespaceMoveTest.php index 9853909285c..11920d2d6c5 100644 --- a/tests/FileManipulation/NamespaceMoveTest.php +++ b/tests/FileManipulation/NamespaceMoveTest.php @@ -44,8 +44,8 @@ public function testValidCode( $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $context = new Context(); @@ -54,7 +54,7 @@ public function testValidCode( $this->addFile( $file_path, - $input_code + $input_code, ); $codebase = $this->project_analyzer->getCodebase(); diff --git a/tests/FileManipulation/PropertyMoveTest.php b/tests/FileManipulation/PropertyMoveTest.php index df2ec1f01ac..b485cbb7cae 100644 --- a/tests/FileManipulation/PropertyMoveTest.php +++ b/tests/FileManipulation/PropertyMoveTest.php @@ -44,8 +44,8 @@ public function testValidCode( $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $context = new Context(); @@ -54,7 +54,7 @@ public function testValidCode( $this->addFile( $file_path, - $input_code + $input_code, ); $codebase = $this->project_analyzer->getCodebase(); diff --git a/tests/FileManipulation/ReturnTypeManipulationTest.php b/tests/FileManipulation/ReturnTypeManipulationTest.php index 3591cb60f47..aeb430117a8 100644 --- a/tests/FileManipulation/ReturnTypeManipulationTest.php +++ b/tests/FileManipulation/ReturnTypeManipulationTest.php @@ -957,7 +957,7 @@ function ret(): container1&container2 { 'issues_to_fix' => ['MissingReturnType'], 'safe_types' => false, 'allow_backwards_incompatible_changes' => true, - ] + ], ]; } } diff --git a/tests/FileReferenceTest.php b/tests/FileReferenceTest.php index e8661e2328e..a17172d8628 100644 --- a/tests/FileReferenceTest.php +++ b/tests/FileReferenceTest.php @@ -27,8 +27,8 @@ public function setUp(): void new TestConfig(), new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $this->project_analyzer->getCodebase()->collectLocations(); @@ -68,7 +68,7 @@ public function testReferenceLocations(string $input_code, string $symbol, array $this->assertSame( $expected_location, $actual_location->getLineNumber() . ':' . $actual_location->getColumn() - . ':' . $actual_location->getSelectedText() + . ':' . $actual_location->getSelectedText(), ); } } @@ -398,7 +398,7 @@ class C { }', [ 'use:A:d7863b8594fe57f85cb8183fe55a6c15' => [ - 'ns\c::bar' => true + 'ns\c::bar' => true, ], 'ns\a::foo' => [ 'ns\c::bar' => true, diff --git a/tests/FileUpdates/AnalyzedMethodTest.php b/tests/FileUpdates/AnalyzedMethodTest.php index 5ac02a8e447..e965084ae2b 100644 --- a/tests/FileUpdates/AnalyzedMethodTest.php +++ b/tests/FileUpdates/AnalyzedMethodTest.php @@ -34,12 +34,12 @@ public function setUp(): void null, null, new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); } @@ -87,7 +87,7 @@ public function testValidInclude( $this->assertSame( $initial_analyzed_methods, $codebase->analyzer->getAnalyzedMethods(), - 'initial analyzed methods are not the same' + 'initial analyzed methods are not the same', ); foreach ($end_files as $file_path => $contents) { @@ -101,7 +101,7 @@ public function testValidInclude( $this->assertSame( $unaffected_analyzed_methods, $codebase->analyzer->getAnalyzedMethods(), - 'unaffected analyzed methods are not the same' + 'unaffected analyzed methods are not the same', ); } @@ -1218,7 +1218,7 @@ public function bar() : void { 'unaffected_analyzed_methods' => [ getcwd() . DIRECTORY_SEPARATOR . 'A.php' => [ 'foo\a::__construct' => 2, - 'foo\a::bar' => 1 + 'foo\a::bar' => 1, ], ], ], @@ -1260,7 +1260,7 @@ public function bar() : void { 'unaffected_analyzed_methods' => [ getcwd() . DIRECTORY_SEPARATOR . 'A.php' => [ 'foo\a::__construct' => 2, - 'foo\a::bar' => 1 + 'foo\a::bar' => 1, ], ], ], @@ -1319,7 +1319,7 @@ class AChild extends A { getcwd() . DIRECTORY_SEPARATOR . 'A.php' => [ 'foo\a::__construct' => 2, ], - getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => [] + getcwd() . DIRECTORY_SEPARATOR . 'AChild.php' => [], ], ], ]; diff --git a/tests/FileUpdates/CachedStorageTest.php b/tests/FileUpdates/CachedStorageTest.php index 14ffbbea654..08936b6085b 100644 --- a/tests/FileUpdates/CachedStorageTest.php +++ b/tests/FileUpdates/CachedStorageTest.php @@ -35,12 +35,12 @@ public function setUp(): void new FileStorageInstanceCacheProvider(), new ClassLikeStorageInstanceCacheProvider(), new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); } diff --git a/tests/FileUpdates/ErrorAfterUpdateTest.php b/tests/FileUpdates/ErrorAfterUpdateTest.php index 804705ae7b8..2698c80a701 100644 --- a/tests/FileUpdates/ErrorAfterUpdateTest.php +++ b/tests/FileUpdates/ErrorAfterUpdateTest.php @@ -36,12 +36,12 @@ public function setUp(): void null, null, new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); } diff --git a/tests/FileUpdates/ErrorFixTest.php b/tests/FileUpdates/ErrorFixTest.php index ea9d24626de..875ecdabdaa 100644 --- a/tests/FileUpdates/ErrorFixTest.php +++ b/tests/FileUpdates/ErrorFixTest.php @@ -36,12 +36,12 @@ public function setUp(): void null, null, new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); } @@ -420,14 +420,14 @@ function hasMethod(object $input, string $method): bool { class A { protected int $x; protected int $y; - }' + }', ], [ getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => ' [2, 1], @@ -443,7 +443,7 @@ abstract class A { class B extends A { public function __construct() {} - }' + }', ], [ getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => ' ' [2, 1, 0], diff --git a/tests/FileUpdates/TemporaryUpdateTest.php b/tests/FileUpdates/TemporaryUpdateTest.php index c33377d2d1e..732955deba9 100644 --- a/tests/FileUpdates/TemporaryUpdateTest.php +++ b/tests/FileUpdates/TemporaryUpdateTest.php @@ -39,12 +39,12 @@ public function setUp(): void null, null, new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); } @@ -109,7 +109,7 @@ public function testErrorFix( foreach ($file_stage as $file_path => $contents) { $codebase->addTemporaryFileChanges( $file_path, - $contents + $contents, ); } @@ -1728,7 +1728,7 @@ class B {}', 'error_positions' => [[84], [84]], 'ignored_issues' => [], 'test_save' => false, - 'check_unused_code' => true + 'check_unused_code' => true, ], 'stillUnusedMethod' => [ [ @@ -1765,7 +1765,7 @@ public function bar() : void {} 'error_positions' => [[201], [234]], 'ignored_issues' => [], 'test_save' => false, - 'check_unused_code' => true + 'check_unused_code' => true, ], 'usedMethodWithNoAffectedConstantChanges' => [ [ @@ -1824,7 +1824,7 @@ public function doFoo() : void { 'error_positions' => [[], []], 'ignored_issues' => [], 'test_save' => false, - 'check_unused_code' => true + 'check_unused_code' => true, ], 'syntaxErrorFixed' => [ [ diff --git a/tests/ForbiddenCodeTest.php b/tests/ForbiddenCodeTest.php index d4c248daad3..2fc49931c9e 100644 --- a/tests/ForbiddenCodeTest.php +++ b/tests/ForbiddenCodeTest.php @@ -76,8 +76,8 @@ public function testAllowedEchoFunction(): void TestConfig::loadFromXML( dirname(__DIR__, 2), ' - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -85,7 +85,7 @@ public function testAllowedEchoFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -103,8 +103,8 @@ public function testForbiddenCodeFunctionViaFunctions(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -112,7 +112,7 @@ public function testForbiddenCodeFunctionViaFunctions(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -124,8 +124,8 @@ public function testAllowedPrintFunction(): void TestConfig::loadFromXML( dirname(__DIR__, 2), ' - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -133,7 +133,7 @@ public function testAllowedPrintFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -151,8 +151,8 @@ public function testForbiddenPrintFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -160,7 +160,7 @@ public function testForbiddenPrintFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -172,8 +172,8 @@ public function testAllowedVarExportFunction(): void TestConfig::loadFromXML( dirname(__DIR__, 2), ' - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -182,7 +182,7 @@ public function testAllowedVarExportFunction(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -200,8 +200,8 @@ public function testForbiddenVarExportFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -210,7 +210,7 @@ public function testForbiddenVarExportFunction(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -228,8 +228,8 @@ public function testForbiddenEmptyFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -237,7 +237,7 @@ public function testForbiddenEmptyFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -255,8 +255,8 @@ public function testForbiddenExitFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -265,7 +265,7 @@ public function testForbiddenExitFunction(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -283,8 +283,8 @@ public function testForbiddenDieFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -293,7 +293,7 @@ public function testForbiddenDieFunction(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -311,8 +311,8 @@ public function testForbiddenEvalExpression(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -321,7 +321,7 @@ public function testForbiddenEvalExpression(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -333,8 +333,8 @@ private function getProjectAnalyzerWithConfig(Config $config): ProjectAnalyzer $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $p->setPhpVersion('7.4', 'tests'); diff --git a/tests/FunctionCallTest.php b/tests/FunctionCallTest.php index e2495965fe9..71afb79e99e 100644 --- a/tests/FunctionCallTest.php +++ b/tests/FunctionCallTest.php @@ -59,7 +59,7 @@ public function providerValidCodeParse(): iterable '$fCount===' => '1', '$gCount===' => 'int<1, 2>', '$hCount===' => 'int<1, max>', - ] + ], ], 'preg_grep' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'compactDefinedVariable' => [ 'code' => ' [ 'code' => ' [ '$a' => 'int', - ] + ], ], 'callUserFuncArray' => [ 'code' => ' [ '$a' => 'int', - ] + ], ], 'dateTest' => [ 'code' => ' 'numeric-string', '$F2===' => 'string', '$F3===' => 'false|string', - ] + ], ], 'sscanfReturnTypeWithTwoParameters' => [ 'code' => ' [ '$data' => 'list|null', - ] + ], ], 'sscanfReturnTypeWithMoreThanTwoParameters' => [ 'code' => ' [ 'code' => ' [ 'code' => ' $two */ function collectCommit(array $one, array $two) : void { if ($one && array_values($one) === array_values($two)) {} - }' + }', ], 'pregMatchAll' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'pregSplit' => [ 'code' => ' [ 'code' => ' */ function foo(string $s) { return preg_split("/ /", $s, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); - }' + }', ], 'mbConvertEncodingWithArray' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'getTypeDoubleThenInt' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'maxWithFloats' => [ 'code' => ' [ 'code' => ' 'NullableReturnStatement' + 'error_message' => 'NullableReturnStatement', ], 'noCrashWithPattern' => [ 'code' => ' 'UndefinedGlobalVariable' + 'error_message' => 'UndefinedGlobalVariable', ], 'parseUrlPossiblyUndefined' => [ 'code' => ' 'RedundantCondition', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'maxCallWithArray' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'maxWithMixed' => [ 'code' => ' 'MixedAssignment' + 'error_message' => 'MixedAssignment', ], 'literalFalseArgument' => [ 'code' => ' 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'getClassWithoutArgsOutsideClass' => [ 'code' => ' 'InvalidReturnType' + 'error_message' => 'InvalidReturnType', ], 'shouldReturnNeverNotStringCaller' => [ 'code' => ' 'InvalidReturnType' + 'error_message' => 'InvalidReturnType', ], 'shouldReturnNeverNotStringNoDocblockCaller' => [ 'code' => ' 'InvalidReturnType' + 'error_message' => 'InvalidReturnType', ], ]; } @@ -2669,7 +2669,7 @@ function returnsNever(): void { */ function returnsNeverOrBool(int $i) { return trigger_error("", $i); - }' + }', ); //will only pass if no exception is thrown @@ -2693,7 +2693,7 @@ function returnsNever1(): void { /** @return never */ function returnsNever2(): void { trigger_error("", E_USER_ERROR); - }' + }', ); //will only pass if no exception is thrown @@ -2717,7 +2717,7 @@ function returnsTrue1(): bool { /** @return true */ function returnsTrue2(): bool { return trigger_error("", E_USER_ERROR); - }' + }', ); //will only pass if no exception is thrown diff --git a/tests/FunctionLikeDocblockParserTest.php b/tests/FunctionLikeDocblockParserTest.php index e8e2e4365d2..9574ba63e78 100644 --- a/tests/FunctionLikeDocblockParserTest.php +++ b/tests/FunctionLikeDocblockParserTest.php @@ -29,14 +29,14 @@ public function setUp(): void $providers = new Providers( $file_provider, - new FakeParserCacheProvider() + new FakeParserCacheProvider(), ); $test_config = new TestConfig(); $project_analyzer = new ProjectAnalyzer( $test_config, - $providers + $providers, ); $file_analyzer = new FileAnalyzer($project_analyzer, 'none/none.php', 'none.php'); @@ -62,7 +62,7 @@ public function testDocblockDescription(): void $function_docblock = FunctionLikeDocblockParser::parse( $php_parser_doc, $this->test_code_location, - $this->test_cased_function_id + $this->test_cased_function_id, ); $this->assertSame('Some Description', $function_docblock->description); @@ -86,7 +86,7 @@ public function testDocblockParamDescription(): void $function_docblock = FunctionLikeDocblockParser::parse( $php_parser_doc, $this->test_code_location, - $this->test_cased_function_id + $this->test_cased_function_id, ); $this->assertTrue(isset($function_docblock->params[0]['description'])); @@ -108,7 +108,7 @@ public function testMisplacedVariableOnNextLine(): void FunctionLikeDocblockParser::parse( $php_parser_doc, $this->test_code_location, - $this->test_cased_function_id + $this->test_cased_function_id, ); } @@ -123,7 +123,7 @@ public function testPreferPsalmPrefixedAnnotationsOverPhpstanOnes(): void $function_docblock = FunctionLikeDocblockParser::parse( $php_parser_doc, $this->test_code_location, - $this->test_cased_function_id + $this->test_cased_function_id, ); $this->assertSame([['T', 'of', 'string', false]], $function_docblock->templates); } @@ -140,7 +140,7 @@ public function testReturnsUnexpectedTags(): void $function_docblock = FunctionLikeDocblockParser::parse( $php_parser_doc, $this->test_code_location, - $this->test_cased_function_id + $this->test_cased_function_id, ); $this->assertEquals( [ @@ -148,10 +148,10 @@ public function testReturnsUnexpectedTags(): void 'var' => ['lines' => [2], 'suggested_replacement' => 'param'], 'psalm-consistent-constructor' => [ 'lines' => [3], - 'suggested_replacement' => 'psalm-consistent-constructor on a class level' - ] + 'suggested_replacement' => 'psalm-consistent-constructor on a class level', + ], ], - $function_docblock->unexpected_tags + $function_docblock->unexpected_tags, ); } } diff --git a/tests/GeneratorTest.php b/tests/GeneratorTest.php index e0a8cd65248..d744e271aa5 100644 --- a/tests/GeneratorTest.php +++ b/tests/GeneratorTest.php @@ -208,14 +208,14 @@ function gen(): Generator { $foo = 4; return $foo; - }' + }', ], 'echoYield' => [ 'code' => ' */ function gen(): Generator { echo yield; - }' + }', ], 'yieldFromTwiceWithVoidSend' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [], - 'ignored_issues' => ['UndefinedClass'] + 'ignored_issues' => ['UndefinedClass'], ], 'fillTemplatesForIteratorFromGenerator' => [ 'code' => ' [ '$iterator' => 'NoRewindIterator>', - ] + ], ], 'detectYieldInNew' => [ 'code' => ' [ '$_a' => 'pure-Closure():Generator', - ] + ], ], 'detectYieldInArray' => [ 'code' => ' [ '$_a' => 'pure-Closure():Generator', - ] + ], ], ]; } diff --git a/tests/IfThisIsTest.php b/tests/IfThisIsTest.php index ae9a973d7b3..5b41fd7dd3f 100644 --- a/tests/IfThisIsTest.php +++ b/tests/IfThisIsTest.php @@ -40,7 +40,7 @@ public function test() {} $f = new F(); $f->convert(); $f->test(); - ' + ', ], 'withTemplate' => [ 'code' => 'set("asd", 10); - ' + ', ], 'subclass' => [ 'code' => 'test(); - ' + ', ], 'ifThisIsWithSelfAlias' => [ 'code' => ' */ $app = new App(); $app->start(); - ' + ', ], 'ifThisIsAndThisOutAtTheSameTime' => [ 'code' => ' */ $app = new App(); $app->start(); - ' + ', ], 'ifThisIsChangeThisTypeInsideMethod' => [ 'code' => 'compact(); ', 'assertions' => [ - '$numbers' => 'ArrayList' + '$numbers' => 'ArrayList', ], ], 'ifThisIsResolveTemplateParams' => [ @@ -280,7 +280,7 @@ public function compact(): ArrayList $numbers = $list->compact(); ', 'assertions' => [ - '$numbers' => 'ArrayList' + '$numbers' => 'ArrayList', ], ], ]; @@ -319,7 +319,7 @@ public function test(): void { $i = new a("test"); $i->test(); ', - 'error_message' => 'IfThisIsMismatch' + 'error_message' => 'IfThisIsMismatch', ], 'failsWithWrongTemplate2' => [ 'code' => 'freeze(); $g->set("asd", 20); // Fails ', - 'error_message' => 'IfThisIsMismatch' + 'error_message' => 'IfThisIsMismatch', ], 'failWithInvalidTemplateConstraint' => [ 'code' => ' $list */ $list = new ArrayList(); $numbers = $list->compact();', - 'error_message' => 'IfThisIsMismatch' + 'error_message' => 'IfThisIsMismatch', ], ]; } diff --git a/tests/ImmutableAnnotationTest.php b/tests/ImmutableAnnotationTest.php index afe1005eb02..1aa481b2a03 100644 --- a/tests/ImmutableAnnotationTest.php +++ b/tests/ImmutableAnnotationTest.php @@ -110,7 +110,7 @@ public static function fromString(string $id): self { return new self($id . rand(0, 1)); } - }' + }', ], 'allowPropertySetOnNewInstance' => [ 'code' => ' [ 'code' => ' [ 'code' => 'data; } - }' + }', ], 'allowPropertyAssignmentInMagicUnserialize' => [ 'code' => 'data; } - }' + }', ], 'allowMethodOverriding' => [ 'code' => 'getError()) { takesString($dto->getError()); - }' + }', ], 'allowConstructorPrivateUnusedMethods' => [ 'code' => ' [ 'code' => ' [ 'code' => 'format("Y-m-d");' + echo (new DateTimeImmutable("now", new DateTimeZone("UTC")))->format("Y-m-d");', ], 'allowPassingCloneOfMutableIntoImmutable' => [ 'code' => 'getValue() === TestEnum::TEST && $e->getValue() === TestEnum::TEST ) {} - }' + }', ], 'allowMutablePropertyFetch' => [ 'code' => ' 'MutableDependency' + 'error_message' => 'MutableDependency', ], 'preventImmutableClassInheritingMutableParent' => [ 'code' => ' 'MutableDependency' + 'error_message' => 'MutableDependency', ], 'mutationInPropertyAssignment' => [ 'code' => 'addFile( @@ -37,7 +37,7 @@ interface B { } * @psalm-require-implements MyAliasedInterfaceB */ trait ImposesImplementationRequirements { } - ' + ', ); } @@ -53,8 +53,8 @@ public function providerValidCodeParse(): iterable class Valid implements A, B { use ImposesImplementationRequirements; } - ' - ] + ', + ], ]; } @@ -69,7 +69,7 @@ class Invalid { use ImposesImplementationRequirements; } ', - 'error_message' => 'requires using class to implement' + 'error_message' => 'requires using class to implement', ], 'onlyImplementsOneRequirement' => [ 'code' => ' 'requires using class to implement' - ] + 'error_message' => 'requires using class to implement', + ], ]; } } diff --git a/tests/IntRangeTest.php b/tests/IntRangeTest.php index 1a9b78a6124..8a189c2854f 100644 --- a/tests/IntRangeTest.php +++ b/tests/IntRangeTest.php @@ -69,7 +69,7 @@ function getInt(): int{return 0;} '$a===' => 'int<500, 4999>', '$b===' => 'int<-5000, -502>', '$c===' => 'int<-499, -61>', - ] + ], ], 'complexAssertions' => [ 'code' => ' [ '$a===' => 'int<500, 4999>', - ] + ], ], 'negatedAssertions' => [ 'code' => ' 'int<-9, max>', '$o===' => 'int', '$p===' => 'int', - ] + ], ], 'intOperations' => [ 'code' => ' 'int<0, 9>', '$c===' => 'int<1, max>', '$d===' => 'int<495, 4994>', - '$e===' => 'int<500, 4999>' - ] + '$e===' => 'int<500, 4999>', + ], ], 'mod' => [ 'code' => ' 'never', '$aa===' => 'int<-2, 2>', '$ab===' => 'int<-2, 2>', - ] + ], ], 'pow' => [ 'code' => ' '1', '$aa===' => 'int<1, max>', '$ab===' => 'float', - ] + ], ], 'multiplications' => [ 'code' => ' 'int<4, max>', '$y===' => 'int', '$z===' => 'int<-4, 4>', - ] + ], ], 'SKIPPED-intLoopPositive' => [ 'code' => ' [ - '$i===' => 'int<0, 9>' - ] + '$i===' => 'int<0, 9>', + ], ], 'SKIPPED-intLoopNegative' => [ 'code' => ' [ - '$i===' => 'int<2, 10>' - ] + '$i===' => 'int<2, 10>', + ], ], 'integrateExistingArrayPositive' => [ 'code' => ' [ - '$_arr===' => "non-empty-array, 'a'|'b'|'c'|12>" - ] + '$_arr===' => "non-empty-array, 'a'|'b'|'c'|12>", + ], ], 'integrateExistingArrayNegative' => [ 'code' => ' [ - '$_arr===' => "non-empty-array, 'a'|'b'|'c'|12>" - ] + '$_arr===' => "non-empty-array, 'a'|'b'|'c'|12>", + ], ], 'SKIPPED-statementsInLoopAffectsEverything' => [ 'code' => ' [ - '$remainder===' => 'int' - ] + '$remainder===' => 'int', + ], ], 'SKIPPED-IntRangeRestrictWhenUntouched' => [ 'code' => ' */ function getArray(): array { return []; - }' + }', ], 'IntRangeContainedInMultipleInt' => [ 'code' => ' $j */ $j = 0; - echo $_arr[$j];' + echo $_arr[$j];', ], 'modulo' => [ 'code' => ' [ '$b===' => 'int<-9, 9>', '$c===' => 'int<0, 9>', - '$d===' => 'int<0, max>' + '$d===' => 'int<0, max>', ], ], 'minus' => [ @@ -825,7 +825,7 @@ function matches($key, int $expected): bool { } return true; - }' + }', ], 'literalArrayUnpack' => [ 'code' => 'm()->m(); - }' + }', ], 'dontModifyAfterUnnecessaryAssertion' => [ 'code' => ' [ 'code' => ' 'MissingReturnType' + 'error_message' => 'MissingReturnType', ], 'missingParamType' => [ 'code' => ' 'MissingParamType' + 'error_message' => 'MissingParamType', ], 'missingTemplateExtendsInterface' => [ 'code' => ' include 'dictionaries/CallMap_historical.php', 'changed' => [], 'removed' => [], - ] + ], ] + $deltaFiles; foreach ($deltaFiles as $name => $deltaFile) { @@ -192,11 +192,11 @@ public function testSignatureKeysAreZeroOrStringAndValuesAreTypes(array $mainCal foreach (['old', 'new'] as $section) { self::assertArrayKeysAreZeroOrString( $diff[$section], - "'" . $section . "' function " . $function . " in 'changed' of delta file " . $name . " has invalid keys" + "'" . $section . "' function " . $function . " in 'changed' of delta file " . $name . " has invalid keys", ); self::assertArrayValuesAreStrings( $diff[$section], - "'" . $section . "' function " . $function . " in 'changed' of delta file " . $name . " has non-string values" + "'" . $section . "' function " . $function . " in 'changed' of delta file " . $name . " has non-string values", ); } } @@ -231,7 +231,7 @@ public function testTypesAreParsable(array $mainCallMap, array $deltaFiles): voi foreach ($signature as $type) { self::assertStringIsParsableType( $type, - "Function " . $function . " in '" . $section . "' of delta file " . $name . " contains invalid type declaration " . $type + "Function " . $function . " in '" . $section . "' of delta file " . $name . " contains invalid type declaration " . $type, ); } } @@ -241,7 +241,7 @@ public function testTypesAreParsable(array $mainCallMap, array $deltaFiles): voi foreach ($diff[$section] as $type) { self::assertStringIsParsableType( $type, - "'" . $section . "' function " . $function . " in 'changed' of delta file " . $name . " contains invalid type declaration " . $type + "'" . $section . "' function " . $function . " in 'changed' of delta file " . $name . " contains invalid type declaration " . $type, ); } } @@ -275,13 +275,13 @@ public function testChangedAndRemovedFunctionsMustExist(array $deltaFiles): arra self::assertEquals( array_values($nonExistingChangedFunctions), [], // Compare against empty array to get handy diff in output - "Deltafile " . $name . " tries to change non-existing functions" + "Deltafile " . $name . " tries to change non-existing functions", ); self::assertEquals( array_values($nonExistingRemovedFunctions), [], // Compare against empty array to get handy diff in output - "Deltafile " . $name . " tries to remove non-existing functions" + "Deltafile " . $name . " tries to remove non-existing functions", ); $newFunctions = array_diff($newFunctions, $removedFunctions); @@ -315,7 +315,7 @@ public function testExistingFunctionsCanNotBeAdded(array $deltaFiles): array self::assertEquals( array_values($alreadyExistingFunctions), [], // Compare against empty array to get handy diff in output - "Deltafile " . $name . " adds already existing functions" + "Deltafile " . $name . " adds already existing functions", ); $newFunctions = array_diff_key($newFunctions, $deltaFile['removed']); @@ -351,17 +351,17 @@ public function testFunctionsCanNotBeInMoreThanOneSection(array $deltaFiles): vo self::assertEquals( array_values($overlapAddedChanged), [], // Compare against empty array to get handy diff in output - "Deltafile " . $name . " adds and changes the same functions" + "Deltafile " . $name . " adds and changes the same functions", ); self::assertEquals( array_values($overlapAddedRemoved), [], // Compare against empty array to get handy diff in output - "Deltafile " . $name . " adds and removes the same functions. Move them to the 'changed' section" + "Deltafile " . $name . " adds and removes the same functions. Move them to the 'changed' section", ); self::assertEquals( array_values($overlapChangedRemoved), [], // Compare against empty array to get handy diff in output - "Deltafile " . $name . " changes and removes the same function" + "Deltafile " . $name . " changes and removes the same function", ); } } @@ -380,7 +380,7 @@ public function testFunctionsAddedInDeltaFilesArePresentInMainCallmap(array $mai self::assertEquals( array_values($missingNewFunctions), [], // Compare against empty array to get handy diff in output - "Not all functions added in delta files are present in main CallMap file" + "Not all functions added in delta files are present in main CallMap file", ); return $newFunctions; @@ -400,7 +400,7 @@ public function testFunctionsPresentInMainCallmapAreAddedInDeltaFiles(array $mai self::assertEquals( [], // Compare against empty array to get handy diff in output array_values($strayNewFunctions), - "Not all functions present in main CallMap file are added in delta files" + "Not all functions present in main CallMap file are added in delta files", ); } @@ -418,7 +418,7 @@ public function testFunctionsRemovedInDeltaFilesAreAbsentFromMainCallmap(array $ self::assertEquals( [], // Compare against empty array to get handy diff in output array_values($stillPresentRemovedFunctions), - "Not all functions removed in delta files are absent in main CallMap file" + "Not all functions removed in delta files are absent in main CallMap file", ); } @@ -438,7 +438,7 @@ public function testMainCallmapSignaturesMustMatchMostRecentIncomingSignatures(a self::assertEquals( $newFunctions, $existingFunctions, - "Signatures in CallMap file don't match most recent signatures in delta files" + "Signatures in CallMap file don't match most recent signatures in delta files", ); } @@ -476,7 +476,7 @@ public function testOutgoingSignaturesMustMatchMostRecentIncomingSignatures(arra self::assertEquals( $overlapOutgoing, $overlapIncoming, - "Outgoing signatures in " . $deltaFileNames[$i] . " don't match corresponding incoming signatures in " . $deltaFileNames[$j] + "Outgoing signatures in " . $deltaFileNames[$i] . " don't match corresponding incoming signatures in " . $deltaFileNames[$j], ); // Don't check what has already been matched diff --git a/tests/Internal/CliUtilsTest.php b/tests/Internal/CliUtilsTest.php index af54350e23d..6246474c860 100644 --- a/tests/Internal/CliUtilsTest.php +++ b/tests/Internal/CliUtilsTest.php @@ -69,7 +69,7 @@ public function provideGetPathsToCheck(): iterable __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR. 'fixtures' - . DIRECTORY_SEPARATOR . 'DummyProject' + . DIRECTORY_SEPARATOR . 'DummyProject', ); $currentDir = (string)realpath('.'); @@ -111,13 +111,13 @@ public function provideGetPathsToCheck(): iterable yield 'withFpathToCurrentDir' => [ [$currentDir], [$psalm, '-f', '.'], - ['.'] + ['.'], ]; yield 'withFpathToProjectDir' => [ [$dummyProjectDir], [$psalm, '-f', $dummyProjectDir], - [$dummyProjectDir] + [$dummyProjectDir], ]; } diff --git a/tests/Internal/Codebase/ClassConstantByWildcardResolverTest.php b/tests/Internal/Codebase/ClassConstantByWildcardResolverTest.php index 8519a296277..7ad4ce9724d 100644 --- a/tests/Internal/Codebase/ClassConstantByWildcardResolverTest.php +++ b/tests/Internal/Codebase/ClassConstantByWildcardResolverTest.php @@ -31,7 +31,7 @@ class Foo const PREFIX_BAZ = \'baz\'; const PREFIX_QOO = Foo::PREFIX_BAR; } - ' + ', ); $this->project_analyzer->getCodebase()->scanFiles(); $resolved = $this->resolver->resolve('ReconciliationTest\\Foo', '*'); @@ -55,7 +55,7 @@ class Foo const BAZ = \'baz\'; const QOO = \'qoo\'; } - ' + ', ); $this->project_analyzer->getCodebase()->scanFiles(); $resolved = $this->resolver->resolve('ReconciliationTest\\Foo', 'BA*'); diff --git a/tests/Internal/Codebase/InternalCallMapHandlerTest.php b/tests/Internal/Codebase/InternalCallMapHandlerTest.php index fa613deee99..72c07a1d0e7 100644 --- a/tests/Internal/Codebase/InternalCallMapHandlerTest.php +++ b/tests/Internal/Codebase/InternalCallMapHandlerTest.php @@ -1291,8 +1291,8 @@ public static function setUpBeforeClass(): void new TestConfig(), new Providers( new FakeFileProvider(), - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); self::$codebase = $project_analyzer->getCodebase(); } @@ -1340,8 +1340,8 @@ public function callMapEntryProvider(): iterable new TestConfig(), new Providers( new FakeFileProvider(), - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $callMap = InternalCallMapHandler::getCallMap(); foreach ($callMap as $function => $entry) { diff --git a/tests/InternalAnnotationTest.php b/tests/InternalAnnotationTest.php index 3c31b09592e..7d0341e8d0c 100644 --- a/tests/InternalAnnotationTest.php +++ b/tests/InternalAnnotationTest.php @@ -604,7 +604,7 @@ public function baz(): void } } } - ' + ', ], ]; } diff --git a/tests/IssueBufferTest.php b/tests/IssueBufferTest.php index 7da31f16a64..cf876901cf4 100644 --- a/tests/IssueBufferTest.php +++ b/tests/IssueBufferTest.php @@ -38,8 +38,8 @@ public function testFinishDoesNotCorruptInternalState(): void 0, 0, 0, - 0 - ) + 0, + ), ], '/path/two.php' => [ new IssueData( @@ -57,8 +57,8 @@ public function testFinishDoesNotCorruptInternalState(): void 0, 0, 0, - 0 - ) + 0, + ), ], '/path/three.php' => [ new IssueData( @@ -76,8 +76,8 @@ public function testFinishDoesNotCorruptInternalState(): void 0, 0, 0, - 0 - ) + 0, + ), ], ]); $baseline = [ diff --git a/tests/IssueSuppressionTest.php b/tests/IssueSuppressionTest.php index f8ef6835849..beeb66bfe80 100644 --- a/tests/IssueSuppressionTest.php +++ b/tests/IssueSuppressionTest.php @@ -42,7 +42,7 @@ class A { public function b() { B::fooFoo()->barBar()->bat()->baz()->bam()->bas()->bee()->bet()->bes()->bis(); } - }' + }', ); $this->analyzeFile(getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'somefile.php', new Context()); @@ -57,7 +57,7 @@ public function testIssueSuppressedOnStatement(): void getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'somefile.php', 'analyzeFile(getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'somefile.php', new Context()); @@ -75,7 +75,7 @@ public function testUnusedSuppressAllOnFunction(): void /** @psalm-suppress all */ function foo(): string { return "foo"; - }' + }', ); $this->analyzeFile(getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'somefile.php', new Context()); @@ -90,7 +90,7 @@ public function testUnusedSuppressAllOnStatement(): void getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'somefile.php', 'analyzeFile(getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'somefile.php', new Context()); } @@ -112,7 +112,7 @@ function example1 (): void { function example2 (): void { throw new Exception(); } - }' + }', ); $context = new Context(); @@ -132,7 +132,7 @@ public function testMissingThrowsDocblockSuppressedWithoutThrow(): void /** @psalm-suppress MissingThrowsDocblock */ if (rand(0, 1)) { function example (): void {} - }' + }', ); $context = new Context(); @@ -153,7 +153,7 @@ public function testMissingThrowsDocblockSuppressedDuplicate(): void function example1 (): void { /** @psalm-suppress MissingThrowsDocblock */ throw new Exception(); - }' + }', ); $context = new Context(); @@ -180,7 +180,7 @@ public function testUncaughtThrowInGlobalScopeSuppressed(): void } /** @psalm-suppress UncaughtThrowInGlobalScope */ - throw new Exception();' + throw new Exception();', ); $context = new Context(); @@ -198,7 +198,7 @@ public function testUncaughtThrowInGlobalScopeSuppressedWithoutThrow(): void getcwd() . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'somefile.php', 'analyzeFile($file_path, new Context(), false); @@ -242,7 +242,7 @@ class Foo { } $_foo = new Foo(); - ' + ', ); $this->analyzeFile($file_path, new Context(), false); diff --git a/tests/JsonOutputTest.php b/tests/JsonOutputTest.php index 1ab0c0457d4..c20d7b9d721 100644 --- a/tests/JsonOutputTest.php +++ b/tests/JsonOutputTest.php @@ -33,9 +33,9 @@ public function setUp(): void $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() + new FakeParserCacheProvider(), ), - $stdout_report_options + $stdout_report_options, ); $this->project_analyzer->getCodebase()->reportUnusedCode(); @@ -63,7 +63,7 @@ public function testJsonOutputErrors( $this->assertSame($line_number, $issue_data->line_from); $this->assertSame( $error, - substr($code, $issue_data->from, $issue_data->to - $issue_data->from) + substr($code, $issue_data->from, $issue_data->to - $issue_data->from), ); } diff --git a/tests/KeyOfArrayTest.php b/tests/KeyOfArrayTest.php index f22727dde60..efd7cf66fff 100644 --- a/tests/KeyOfArrayTest.php +++ b/tests/KeyOfArrayTest.php @@ -26,7 +26,7 @@ public function getKey() { return 0; } } - ' + ', ], 'keyOfAssociativeArrayClassConstant' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'keyOfArrayLiteral' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'onlyIntAllowedForKeyOfList' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'noStringAllowedInKeyOfIntFloatArray' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'noLiteralCAllowedInKeyOfUnionListAndKeyedArray' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], ]; } diff --git a/tests/LanguageServer/CompletionTest.php b/tests/LanguageServer/CompletionTest.php index ce44833a224..fd5f95fccc9 100644 --- a/tests/LanguageServer/CompletionTest.php +++ b/tests/LanguageServer/CompletionTest.php @@ -32,12 +32,12 @@ public function setUp(): void null, null, new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); $this->project_analyzer->getCodebase()->store_node_types = true; @@ -61,7 +61,7 @@ class A { public function foo() { $this-> } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -91,7 +91,7 @@ public function foo() : self { $a = "foo"; } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -121,7 +121,7 @@ public function foo() : self { if(rand(0, 1)) {} } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -142,7 +142,7 @@ public function foo() : self { if(rand(0, 1)) {} } - }' + }', ); $codebase->reloadFiles($this->project_analyzer, ['somefile.php']); $codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false); @@ -170,7 +170,7 @@ public function foo() : self { if(rand(0, 1)) {} } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -191,7 +191,7 @@ public function foo() : self { if(rand(0, 1)) {} } - }' + }', ); $codebase->reloadFiles($this->project_analyzer, ['somefile.php']); $codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false); @@ -219,7 +219,7 @@ public function foo() : self { list($a, $b) = $c; } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -240,7 +240,7 @@ public function foo() : self { list($a, $b) = $c; } - }' + }', ); $codebase->reloadFiles($this->project_analyzer, ['somefile.php']); $codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false); @@ -274,7 +274,7 @@ public function __construct() { public function foo() : void { $this->cee_me-> } - }' + }', ); $codebase = $this->project_analyzer->getCodebase(); @@ -312,7 +312,7 @@ public function __construct() { public function foo() : void { $this->cee_me->o } - }' + }', ); $codebase = $this->project_analyzer->getCodebase(); @@ -350,7 +350,7 @@ public function __construct() { public function foo() : void { $this->cee_me->ot } - }' + }', ); $codebase = $this->project_analyzer->getCodebase(); @@ -397,7 +397,7 @@ public function __construct() { public function foo() : void { $this->cee_me-> } - }' + }', ); $codebase = $this->project_analyzer->getCodebase(); @@ -434,7 +434,7 @@ public function foo() : self { function foo(A $a) { $a->foo()-> } - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -465,7 +465,7 @@ class C {} function bar(A $a, C $c) { $a->foo($c->) } - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -496,7 +496,7 @@ class C {} function bar(A $a, C $c) { $a->foo($c)-> } - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -521,7 +521,7 @@ class A {} function bar(A $a) { $a -> - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -548,7 +548,7 @@ function baz(A $a) { $a -> } - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -578,7 +578,7 @@ public function foo() : self { function bar(A $a) { $a->foo() -> } - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -609,7 +609,7 @@ function baz(A $a) { $a->foo() -> } - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -638,7 +638,7 @@ public function map(callable $mapper) : self { function bar(Collection $a) { $a->map(function ($foo) {})-> - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -667,7 +667,7 @@ public function map(callable $mapper) : self { function baz(Collection $a) { $a->map(function ($foo) {return $foo;})-> - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -694,7 +694,7 @@ public function bar(string $a) { } public function baz() {} - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -725,7 +725,7 @@ public function testCompletionOnNewExceptionWithoutNamespace(): void 'file_provider->openFile('somefile.php'); @@ -748,7 +748,7 @@ public function testCompletionOnNewExceptionWithNamespaceNoUse(): void function foo() : void { throw new Ex - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -763,7 +763,7 @@ function foo() : void { 'symbol', 110, ], - $completion_data + $completion_data, ); $completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php'); @@ -800,7 +800,7 @@ class Antelope {} function foo() : void { new ArrayO - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -815,7 +815,7 @@ function foo() : void { 'symbol', 220, ], - $completion_data + $completion_data, ); $completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php'); @@ -846,7 +846,7 @@ class B { public function foo() : void { \Ex } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -861,7 +861,7 @@ public function foo() : void { 'symbol', 150, ], - $completion_data + $completion_data, ); $completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php'); @@ -889,7 +889,7 @@ class B { public function foo() : void { Ex } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -904,7 +904,7 @@ public function foo() : void { 'symbol', 149, ], - $completion_data + $completion_data, ); $completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php'); @@ -938,7 +938,7 @@ function my_function_in_bar() : void { } - my_function_in' + my_function_in', ); $codebase->file_provider->openFile('somefile.php'); @@ -969,7 +969,7 @@ function strlen() : void { } - strlen' + strlen', ); $codebase->file_provider->openFile('somefile.php'); @@ -995,7 +995,7 @@ public function testCompletionForFunctionNamesRespectUsedNamespaces(): void 'file_provider->openFile('somefile.php'); @@ -1022,7 +1022,7 @@ public function testCompletionForFunctionNamesRespectCase(): void 'file_provider->openFile('somefile.php'); @@ -1048,7 +1048,7 @@ public function testGetMatchingFunctionNames(): void 'file_provider->openFile('somefile.php'); @@ -1070,7 +1070,7 @@ public function testGetMatchingFunctionNamesFromPredefinedFunctions(): void $this->addFile( 'somefile.php', - 'file_provider->openFile('somefile.php'); @@ -1093,7 +1093,7 @@ public function testGetMatchingFunctionNamesFromUsedFunction(): void namespace Foo; use function phpunit\framework\atleastonce; - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -1116,7 +1116,7 @@ public function testGetMatchingFunctionNamesFromUsedNamespace(): void namespace Foo; use phpunit\framework; - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -1139,7 +1139,7 @@ public function testGetMatchingFunctionNamesFromUsedNamespaceRespectFirstCharCas namespace Foo; use phpunit\framework; - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -1161,7 +1161,7 @@ public function testGetMatchingFunctionNamesWithNamespace(): void 'file_provider->openFile('somefile.php'); @@ -1194,7 +1194,7 @@ class Anteater {} function foo($a) : void { if ($a instanceof Ant) {} - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -1209,7 +1209,7 @@ function foo($a) : void { 'symbol', 267, ], - $completion_data + $completion_data, ); $completion_items = $codebase->getCompletionItemsForPartialSymbol($completion_data[0], $completion_data[2], 'somefile.php'); @@ -1234,7 +1234,7 @@ class Alpha { static function add() : void { } } - Alpha::' + Alpha::', ); $codebase->file_provider->openFile('somefile.php'); @@ -1269,7 +1269,7 @@ public function add() : void {} $alpha-> - $a = 5;' + $a = 5;', ); $codebase->file_provider->openFile('somefile.php'); @@ -1303,7 +1303,7 @@ static function add() : void {} Alpha:: - $a = 5;' + $a = 5;', ); $codebase->file_provider->openFile('somefile.php'); @@ -1327,7 +1327,7 @@ public function testNoCrashOnLoopId(): void $this->addFile( 'somefile.php', 'file_provider->openFile('somefile.php'); @@ -1347,7 +1347,7 @@ public function testCompletionOnArrayKey(): void ' 1, "bar" => 2]; $my_array[] - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -1361,7 +1361,7 @@ public function testCompletionOnArrayKey(): void '[', 86, ], - $completion_data + $completion_data, ); $completion_items = $codebase->getCompletionItemsForArrayKeys($completion_data[0]); @@ -1383,7 +1383,7 @@ public function testTypeContextForFunctionArgument(): void function my_func(string $arg_a, bool $arg_b) : string { } - my_func()' + my_func()', ); $codebase->file_provider->openFile('somefile.php'); @@ -1407,7 +1407,7 @@ public function testTypeContextForFunctionArgumentWithWhiteSpace(): void function my_func(string $arg_a, bool $arg_b) : string { } - my_func( "yes", )' + my_func( "yes", )', ); $codebase->file_provider->openFile('somefile.php'); @@ -1436,7 +1436,7 @@ public function testFoo() { public static function bar() : void {} public function baz() : void {} - }' + }', ); $codebase = $this->project_analyzer->getCodebase(); diff --git a/tests/LanguageServer/FileMapTest.php b/tests/LanguageServer/FileMapTest.php index 1e3bc9f63b6..3eff330fd10 100644 --- a/tests/LanguageServer/FileMapTest.php +++ b/tests/LanguageServer/FileMapTest.php @@ -30,12 +30,12 @@ public function setUp(): void null, null, new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); $this->project_analyzer->getCodebase()->store_node_types = true; @@ -54,7 +54,7 @@ class A { function __construct( string $var ) { } } - $a = new A( "foo" );' + $a = new A( "foo" );', ); $codebase->file_provider->openFile('somefile.php'); @@ -84,7 +84,7 @@ class A { function __construct( string $var ) { } } - $a = new A( "foo" );' + $a = new A( "foo" );', ); $codebase->file_provider->openFile('somefile.php'); @@ -103,7 +103,7 @@ function __construct( string $var ) { '146-147:A', ], ], - $type_map + $type_map, ); } @@ -128,7 +128,7 @@ public function first(\DateTimeImmutable $d) : void { public function second(\DateTimeImmutable $d) : void { echo $d->format("Y"); } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -152,7 +152,7 @@ public function first(\DateTimeImmutable $d) : void { public function second(\DateTimeImmutable $d) : void { echo $d->format("Y"); } - }' + }', ); $codebase->reloadFiles($this->project_analyzer, ['somefile.php']); $codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false); @@ -183,7 +183,7 @@ public function second_method(\DateTimeImmutable $d) : void { new \DateTimeImmutable("2010-01-01"); echo $d->format("Y"); } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -202,7 +202,7 @@ public function second_method(\DateTimeImmutable $d) : void { new \DateTimeImmutable("2010-01-01"); echo $d->format("Y"); } - }' + }', ); $codebase->reloadFiles($this->project_analyzer, ['somefile.php']); $codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false); @@ -230,7 +230,7 @@ public function first(\DateTimeImmutable $d) : void { public function second(\DateTimeImmutable $d) : void { echo $d->format("Y"); } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -248,7 +248,7 @@ class A { public function second(\DateTimeImmutable $d) : void { echo $d->format("Y"); } - }' + }', ); $codebase->reloadFiles($this->project_analyzer, ['somefile.php']); $codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false); @@ -276,7 +276,7 @@ public function first(\DateTimeImmutable $d) : void { public function second(\DateTimeImmutable $d) : void { echo $d->format("Y"); } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -303,7 +303,7 @@ public function third(\DateTimeImmutable $d) : void { public function second(\DateTimeImmutable $d) : void { echo $d->format("Y"); } - }' + }', ); $codebase->reloadFiles($this->project_analyzer, ['somefile.php']); $codebase->analyzer->analyzeFiles($this->project_analyzer, 1, false); diff --git a/tests/LanguageServer/SymbolLookupTest.php b/tests/LanguageServer/SymbolLookupTest.php index be928a96dc2..4223885110f 100644 --- a/tests/LanguageServer/SymbolLookupTest.php +++ b/tests/LanguageServer/SymbolLookupTest.php @@ -30,12 +30,12 @@ public function setUp(): void null, null, new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); @@ -78,7 +78,7 @@ function qux(int $a, int $b) : int { return $a + $b; } - $_SESSION;' + $_SESSION;', ); new FileAnalyzer($this->project_analyzer, 'somefile.php', 'somefile.php'); @@ -126,7 +126,7 @@ public function testSimpleSymbolLookupGlobalConst(): void 'somefile.php', 'project_analyzer, 'somefile.php', 'somefile.php'); @@ -164,7 +164,7 @@ public function foo() : void { function bar() : int { return 5; - }' + }', ); new FileAnalyzer($this->project_analyzer, 'somefile.php', 'somefile.php'); @@ -231,7 +231,7 @@ public function bar() : void { $a = 2; echo $a; } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -259,7 +259,7 @@ public function bar() : void { $a = 2; echo $a; } - }' + }', ); $codebase->reloadFiles($this->project_analyzer, ['somefile.php']); @@ -304,7 +304,7 @@ public function foo(int $i) : string { public function bar() : void { $this->foo(); } - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -332,7 +332,7 @@ public function testGetSymbolPositionGlobalVariable(): void function foo() : void { global $my_global; echo $my_global; - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -361,7 +361,7 @@ public function testGetSymbolPositionNullableArg(): void class AClass { } function B( ?AClass $class ) { - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -391,7 +391,7 @@ class AClass { protected function get_command() : AClass { } } - ' + ', ); $codebase->file_provider->openFile('somefile.php'); @@ -415,7 +415,7 @@ public function testGetSymbolPositionUseStatement(): void 'file_provider->openFile('somefile.php'); @@ -442,7 +442,7 @@ public function testGetSymbolPositionRange(): void function foo() : string { } - $active_symbol = foo();' + $active_symbol = foo();', ); $codebase->file_provider->openFile('somefile.php'); @@ -472,7 +472,7 @@ public function testGetTypeInDocblock(): void class A { /** @var \Exception|null */ public $prop; - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -556,7 +556,7 @@ public function __construct() {} } function foo(string $a) { - }' + }', ); $codebase->file_provider->openFile('somefile.php'); @@ -600,7 +600,7 @@ public function testGetSignatureHelpIncludesParamDescription(): void */ function foo(string $a) { } - foo();' + foo();', ); $codebase->file_provider->openFile('somefile.php'); diff --git a/tests/Loop/DoTest.php b/tests/Loop/DoTest.php index d3a436c031f..f77ea2005da 100644 --- a/tests/Loop/DoTest.php +++ b/tests/Loop/DoTest.php @@ -331,8 +331,8 @@ function nextEvent(bool $c): void { } } while (!$b);', 'assertions' => [ - '$b' => 'true' - ] + '$b' => 'true', + ], ], 'doConditionInWhileAndIfWithTwoVars' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 0; $i--) {} - }' + }', ], 'noCrashOnLongThing' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $value) { echo $key . " " . $value; - }' + }', ], 'loopClosure' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'setFoo(); } elseif ($a->foo !== null) {} } - }' + }', ], 'propertyTypeUpdatedInBranchWithBreak' => [ 'code' => 'foo !== null) {} - }' + }', ], 'whileTrueDontHaveExitPathForReturn' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'setString(5); $c = $child->getBool("hello"); $d = $child->getArray(); - $e = $child->getCallable();' + $e = $child->getCallable();', ); $this->analyzeFile('somefile.php', new Context()); @@ -67,7 +67,7 @@ class Obj {} /** * @method Obj|null find() */ - class C extends B {}' + class C extends B {}', ); $this->analyzeFile('somefile.php', new Context()); @@ -89,7 +89,7 @@ class Child {} $child = new Child(); - $child->getString();' + $child->getString();', ); $context = new Context(); @@ -115,7 +115,7 @@ public static function getMe() : self { */ class Child extends ParentClass {} - $child = Child::getMe();' + $child = Child::getMe();', ); $context = new Context(); @@ -139,7 +139,7 @@ class MyException extends Exception {} function foo(MyException $e): int { return $e->getCode(); - }' + }', ); $context = new Context(); @@ -568,7 +568,7 @@ public function __call(string $name, array $args) {} $child = new Child(); $child->boolean(5); - $child->integer(5);' + $child->integer(5);', ], 'overrideWithSelfBeforeMethodName' => [ 'code' => ' [ 'code' => ' [ 'code' => 'foo();' + $child->foo();', ], 'allowFinalOverrider' => [ 'code' => ' [ 'code' => 'items = $foos; } - }' + }', ], 'parseFloatInDefault' => [ 'code' => 'randomInt(); - }' + }', ], 'negativeInDefault' => [ 'code' => 'foo();' + (new G)->foo();', ], 'namespacedNegativeInDefault' => [ 'code' => 'foo(); - }' + }', ], 'namespacedUnion' => [ 'code' => 'bar(new \DateTime(), new Cache());' + (new Cache)->bar(new \DateTime(), new Cache());', ], 'magicMethodInheritance' => [ 'code' => 'foo()); - consumeInt($b->bar());' + consumeInt($b->bar());', ], 'magicMethodInheritanceOnInterface' => [ 'code' => 'foo());' + consumeString($i->foo());', ], 'magicStaticMethodInheritance' => [ 'code' => ' [ 'code' => ' [ 'code' => 'create([])); $d = new BlahModel(); - consumeBlah($d->create([]));' + consumeBlah($d->create([]));', ], 'returnThisShouldKeepGenerics' => [ 'code' => ' [ '$b' => 'A&static', '$c' => 'I&static', - ] + ], ], 'genericsOfInheritedMethodsShouldBeResolved' => [ 'code' => ' 'B', '$c' => 'B', '$e' => 'B', - ] + ], ], ]; } @@ -1136,7 +1136,7 @@ public function baz(): Foo } }', 'error_message' => 'UndefinedVariable', - ] + ], ]; } @@ -1155,7 +1155,7 @@ class B extends A {} $b = new B(); $b->foo(); - ' + ', ); $error_message = 'UndefinedMagicMethod'; @@ -1180,7 +1180,7 @@ class B extends A {} $b = new B(); $b->foo(); - ' + ', ); $this->analyzeFile('somefile.php', new Context()); @@ -1203,7 +1203,7 @@ public function foo(): void {} $b = new B(); $b->foo(); - ' + ', ); $this->analyzeFile('somefile.php', new Context()); @@ -1225,7 +1225,7 @@ class B extends A {} $b = new B(); $b->foo(); - ' + ', ); $this->analyzeFile('somefile.php', new Context()); @@ -1246,7 +1246,7 @@ class B extends A {} $b = new B(); $b->foo(); - ' + ', ); $this->analyzeFile('somefile.php', new Context()); @@ -1269,7 +1269,7 @@ public function otherMethod(): void {} /** @var A & B $b */ $b = new B(); $b->otherMethod(); - ' + ', ); $this->analyzeFile('somefile.php', new Context()); @@ -1292,7 +1292,7 @@ public function otherMethod(): void {} /** @var A & B $b */ $b = new B(); $b->nonExistantMethod(); - ' + ', ); $error_message = 'UndefinedMagicMethod'; diff --git a/tests/MagicPropertyTest.php b/tests/MagicPropertyTest.php index 72aeda98350..34e04f80974 100644 --- a/tests/MagicPropertyTest.php +++ b/tests/MagicPropertyTest.php @@ -29,7 +29,7 @@ class Child {} $child = new Child(); - $a = $child->hello;' + $a = $child->hello;', ); $this->analyzeFile('somefile.php', new Context()); @@ -622,7 +622,7 @@ public function main() : void { echo $this->a[0]; } } - }' + }', ], 'magicPropertyDefinedOnTrait' => [ 'code' => 'email; $record->password; - $record->last_login_at = new DateTimeImmutable("now");' + $record->last_login_at = new DateTimeImmutable("now");', ], 'reconcileMagicProperties' => [ 'code' => ' [ 'code' => 'errors; return $errors; } - }' - ] + }', + ], ]; } @@ -1185,7 +1185,7 @@ class A { /** @property string[] */ public array $arr; }', - 'error_message' => 'InvalidDocblock' + 'error_message' => 'InvalidDocblock', ], ]; } @@ -1205,7 +1205,7 @@ class B extends A {} $b = new B(); $result = $b->foo; - ' + ', ); $error_message = 'UndefinedMagicPropertyFetch'; diff --git a/tests/MatchTest.php b/tests/MatchTest.php index 943d3c296e8..0d00e62df55 100644 --- a/tests/MatchTest.php +++ b/tests/MatchTest.php @@ -29,7 +29,7 @@ function f(A $obj): string { }', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'defaultAboveCase' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'allMatchedNoRedundantCondition' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'getClassWithMethod' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'MatchWithCount' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], ]; } @@ -114,7 +114,7 @@ class B {} };', 'error_message' => 'UndefinedMethod', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'getClassMissingClass' => [ 'code' => ' 'UndefinedClass', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'allMatchedDefaultImpossible' => [ 'code' => ' 'TypeDoesNotContainType', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'allMatchedAnotherImpossible' => [ 'code' => ' 'TypeDoesNotContainType', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'notAllEnumsMet' => [ 'code' => 'addFile( 'somefile.php', 'analyzeFile('somefile.php', new Context()); @@ -51,7 +51,7 @@ public function bat() : void {} if ($a->getFoo()->getBar()) { $a->getFoo()->getBar()->bat(); } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -83,7 +83,7 @@ function doSomething(Foo $foo): string { } return "hello"; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -118,7 +118,7 @@ function doSomething(Foo $foo): string { } return "hello"; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -151,7 +151,7 @@ function printInt(int $int): void { if ($obj->getInt()) { printInt($obj->getInt()); - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -187,7 +187,7 @@ function printInt(int $int): void { if ($obj->getInt()) { printInt($obj->getInt()); - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -278,7 +278,7 @@ public function __call(string $method_name, array $args) : string { $s = $a->bar();', 'assertions' => [ '$s' => 'string', - ] + ], ], 'canBeCalledOnMagic' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'domElement' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'PDOMethod' => [ 'code' => 'bar(); } - }' + }', ], 'callMethodAfterCheckingExistenceInClosure' => [ 'code' => ' [ 'code' => 'foo(); $object->bar(); - }' + }', ], 'callManyMethodsAfterCheckingExistenceChained' => [ 'code' => 'foo(); $object->bar(); } - }' + }', ], 'callManyMethodsOnKnownObjectAfterCheckingExistenceChained' => [ 'code' => 'foo(); $object->bar(); } - }' + }', ], 'preserveMethodExistsType' => [ 'code' => ' [ 'code' => ' [ 'code' => 'prepare("SELECT 1"); $sth->execute(); return $sth->fetch(PDO::FETCH_ASSOC); - }' + }', ], 'pdoStatementFetchBoth' => [ 'code' => 'prepare("SELECT 1"); $sth->execute(); return $sth->fetch(PDO::FETCH_BOTH); - }' + }', ], 'pdoStatementFetchBound' => [ 'code' => 'prepare("SELECT 1"); $sth->execute(); return $sth->fetch(PDO::FETCH_BOUND); - }' + }', ], 'pdoStatementFetchClass' => [ 'code' => 'prepare("SELECT 1"); $sth->execute(); return $sth->fetch(PDO::FETCH_CLASS); - }' + }', ], 'pdoStatementFetchLazy' => [ 'code' => 'prepare("SELECT 1"); $sth->execute(); return $sth->fetch(PDO::FETCH_LAZY); - }' + }', ], 'pdoStatementFetchNamed' => [ 'code' => 'prepare("SELECT 1"); $sth->execute(); return $sth->fetch(PDO::FETCH_NAMED); - }' + }', ], 'pdoStatementFetchNum' => [ 'code' => 'prepare("SELECT 1"); $sth->execute(); return $sth->fetch(PDO::FETCH_NUM); - }' + }', ], 'pdoStatementFetchObj' => [ 'code' => 'prepare("SELECT 1"); $sth->execute(); return $sth->fetch(PDO::FETCH_OBJ); - }' + }', ], 'dateTimeSecondArg' => [ 'code' => 'format("Y-m-d H:i:sP") . "\n";' + echo $date->format("Y-m-d H:i:sP") . "\n";', ], 'noCrashOnGetClassMethodCallWithNull' => [ 'code' => ' [ 'code' => 'getA()) { echo strlen($a->getA()); - }' + }', ], 'ignorePossiblyNull' => [ 'code' => 'type; } - }' + }', ], 'abstractMethodExistsOnChild' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'pdoQueryTwoArgs' => [ 'code' => 'query("SELECT * FROM projects", PDO::FETCH_NAMED);' + $pdo->query("SELECT * FROM projects", PDO::FETCH_NAMED);', ], 'unchainedInferredMutationFreeMethodCallMemoize' => [ 'code' => 'getProperty() !== null && $main->getProperty()->test()) {}' + if ($main->getProperty() !== null && $main->getProperty()->test()) {}', ], 'getterTypeInferring' => [ 'code' => ' [ '$a' => 'SplObjectStorage', - ] + ], ], 'allowIteratorToBeNull' => [ 'code' => 'current() === null) {}' + if ($it->current() === null) {}', ], 'resolveFinalInParentCall' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => ['MixedReturnStatement', 'MixedInferredReturnType'], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'nullsafeShortCircuit' => [ 'code' => 'getBar()->doBaz();', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'parentMagicMethodCall' => [ 'code' => 'create([]);', 'assertions' => [ '$n' => 'BlahModel', - ] + ], ], ]; } @@ -1334,12 +1334,12 @@ public function foo(): void {} $p = new A(); $p->foo()->bar();', - 'error_message' => 'NullReference' + 'error_message' => 'NullReference', ], 'dateTimeNullFirstArg' => [ 'code' => ' 'NullArgument' + 'error_message' => 'NullArgument', ], 'noCrashOnGetClassMethodCall' => [ 'code' => ' 'PossiblyNullArgument' + 'error_message' => 'PossiblyNullArgument', ], 'getterAutomagicOverriddenWithAssertion' => [ 'code' => ' 'PossiblyNullArgument' + 'error_message' => 'PossiblyNullArgument', ], 'checkVariableInUnknownClassConstructor' => [ 'code' => 'doBaz();', 'error_message' => 'PossiblyNullReference', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'undefinedMethodOnParentCallWithMethodExistsOnSelf' => [ 'code' => 'user_viewdata); } - }' + }', ); new FileAnalyzer($this->project_analyzer, 'somefile.php', 'somefile.php'); @@ -96,7 +96,7 @@ public function barBar(): Response { new MethodIdentifier('FooController', 'barbar'), $method_context, 'somefile.php', - 'somefile.php' + 'somefile.php', ); $this->assertSame('UserViewData', (string)$method_context->vars_in_scope['$this->user_viewdata']); @@ -129,7 +129,7 @@ public function barBar(): void { $this->doThingWithUser(); } - }' + }', ); new FileAnalyzer($this->project_analyzer, 'somefile.php', 'somefile.php'); @@ -140,7 +140,7 @@ public function barBar(): void { new MethodIdentifier('FooController', 'barbar'), $method_context, 'somefile.php', - 'somefile.php' + 'somefile.php', ); $this->assertSame('User|null', (string)$method_context->vars_in_scope['$this->user']); @@ -166,7 +166,7 @@ class FooController extends Controller { public function __construct() { parent::__construct(); } - }' + }', ); new FileAnalyzer($this->project_analyzer, 'somefile.php', 'somefile.php'); @@ -177,7 +177,7 @@ public function __construct() { new MethodIdentifier('FooController', '__construct'), $method_context, 'somefile.php', - 'somefile.php' + 'somefile.php', ); $this->assertSame('Foo', (string)$method_context->vars_in_scope['$this->foo']); @@ -205,7 +205,7 @@ class FooController { public function __construct() { $this->setFoo(); } - }' + }', ); new FileAnalyzer($this->project_analyzer, 'somefile.php', 'somefile.php'); @@ -216,7 +216,7 @@ public function __construct() { new MethodIdentifier('FooController', '__construct'), $method_context, 'somefile.php', - 'somefile.php' + 'somefile.php', ); $this->assertSame('Foo', (string)$method_context->vars_in_scope['$this->foo']); diff --git a/tests/MethodSignatureTest.php b/tests/MethodSignatureTest.php index 1a67e863598..b37761b1553 100644 --- a/tests/MethodSignatureTest.php +++ b/tests/MethodSignatureTest.php @@ -38,7 +38,7 @@ public function __soapCall( ) { return $_GET["foo"]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -60,7 +60,7 @@ public function __soapCall( ) { return $_GET["foo"]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -82,7 +82,7 @@ public function __soapCall( ) { return $_GET["foo"]; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -109,7 +109,7 @@ function foo(): D { } } class C {} - class D extends C {}' + class D extends C {}', ); $this->analyzeFile('somefile.php', new Context()); @@ -133,7 +133,7 @@ function foo(): D { } } class C {} - class D extends C {}' + class D extends C {}', ); $this->analyzeFile('somefile.php', new Context()); @@ -158,7 +158,7 @@ class B extends A { function foo(): self { return new B(); } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -180,7 +180,7 @@ class B extends A { function foo(): self { return new B(); } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -204,7 +204,7 @@ public function foo(C $c): void {} } class C {} - class D extends C {}' + class D extends C {}', ); $this->analyzeFile('somefile.php', new Context()); @@ -225,7 +225,7 @@ public function foo(C $c): void {} } class C {} - class D extends C {}' + class D extends C {}', ); $this->analyzeFile('somefile.php', new Context()); @@ -258,7 +258,7 @@ public function __soapCall( ) { } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -283,7 +283,7 @@ public function __soapCall( ) { } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -695,7 +695,7 @@ class SomeClass { public function a(self $b): self { return $this; } - }' + }', ], 'allowMatchIn74' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'allowOverridingThrowable' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.1' + 'php_version' => '7.1', ], 'consistentConstructor' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'suppressDocblockFinal' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'extendStaticReturnTypeInFinal' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'notExtendedStaticReturntypeInFinal' => [ 'code' => ' [ 'code' => ' [ 'code' => ' 'MethodSignatureMismatch', 'ignored_issues' => [], - 'php_version' => '7.3' + 'php_version' => '7.3', ], 'inconsistentConstructorExplicitParentConstructorArgCount' => [ 'code' => ' 'MethodSignatureMismatch', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'noTypehintInNativeDescendant' => [ 'code' => ' 'MethodSignatureMustProvideReturnType', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], ]; } diff --git a/tests/MixinAnnotationTest.php b/tests/MixinAnnotationTest.php index a1651c63686..1769546aab2 100644 --- a/tests/MixinAnnotationTest.php +++ b/tests/MixinAnnotationTest.php @@ -78,7 +78,7 @@ public function c(int $s) : void {} } $a = new A(); - $a->b();' + $a->b();', ], 'allowConstructor' => [ 'code' => ' [ 'code' => 'next(); } - }' + }', ], 'wrapCustomIterator' => [ 'code' => 'index(0);', 'assertions' => [ '$b' => 'bool', - ] + ], ], 'templatedMixin' => [ 'code' => 'hi();', 'assertions' => [ '$b' => 'string', - ] + ], ], 'templatedMixinSelf' => [ 'code' => 'get(); - }' + }', ], 'inheritPropertyAnnotations' => [ 'code' => 'foo; - }' + }', ], 'inheritTemplatedMixinWithStatic' => [ 'code' => 'type(); - }' + }', ], 'inheritTemplatedMixinWithStaticAndFinalClass' => [ 'code' => 'getMixin(); - }' + }', ], 'mixinParseWithTextAfter' => [ 'code' => ' [ 'code' => ' $b */ function foo(Builder $b) : Model { return $b->active(); - }' + }', ], 'multipleMixins' => [ 'code' => 'other(); - }' + }', ], 'multipleMixinsWithSameMethod' => [ 'code' => 'foo();' + $bar->foo();', ], 'templatedMixinBindStatic' => [ 'code' => 'getInner();', 'assertions' => [ '$g' => 'list', - ] + ], ], ]; } @@ -604,7 +604,7 @@ public function providerInvalidCodeParse(): iterable 'code' => ' 'UndefinedDocblockClass' + 'error_message' => 'UndefinedDocblockClass', ], 'undefinedMixinClassWithPropertyFetch' => [ 'code' => 'foo;', - 'error_message' => 'UndefinedPropertyFetch' + 'error_message' => 'UndefinedPropertyFetch', ], 'undefinedMixinClassWithPropertyAssignment' => [ 'code' => 'foo = "bar";', - 'error_message' => 'UndefinedPropertyAssignment' + 'error_message' => 'UndefinedPropertyAssignment', ], 'undefinedMixinClassWithMethodCall' => [ 'code' => 'foo();', - 'error_message' => 'UndefinedMethod' + 'error_message' => 'UndefinedMethod', ], 'inheritTemplatedMixinWithSelf' => [ 'code' => 'type(); }', - 'error_message' => 'LessSpecificReturnStatement' + 'error_message' => 'LessSpecificReturnStatement', ], 'mixinStaticCallShouldNotPolluteContext' => [ 'code' => ' 'UndefinedVariable' + 'error_message' => 'UndefinedVariable', ], ]; } diff --git a/tests/NativeIntersectionsTest.php b/tests/NativeIntersectionsTest.php index 2bea8a9f40f..5d7c2a0367c 100644 --- a/tests/NativeIntersectionsTest.php +++ b/tests/NativeIntersectionsTest.php @@ -29,7 +29,7 @@ public function self(): A&B }', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'nativeTypeIntersectionAsArgument' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], ]; } @@ -75,7 +75,7 @@ function test(A&B $in): void { ', 'error_message' => 'InvalidArgument', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'mismatchDocblockNativeIntersectionArgument' => [ 'code' => ' 'MismatchingDocblockParamType', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'intersectionsNotAllowedWithUnions' => [ 'code' => ' 'ParseError', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'intersectionsNotAllowedWithNonClasses' => [ 'code' => ' 'ParseError', 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'intersectionsNotAllowedInPHP80' => [ 'code' => ' 'ParseError', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], ]; } diff --git a/tests/NativeUnionsTest.php b/tests/NativeUnionsTest.php index d28a9cbb5f6..3c066181812 100644 --- a/tests/NativeUnionsTest.php +++ b/tests/NativeUnionsTest.php @@ -29,7 +29,7 @@ public function self(): A|B }', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'nativeTypeUnionAsArgument' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'unionAndNullableEquivalent' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], ]; } @@ -77,7 +77,7 @@ function test(string|null $in): string|null { ', 'error_message' => 'InvalidScalarArgument', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'mismatchDocblockNativeUnionArgument' => [ 'code' => ' 'MismatchingDocblockParamType', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'unionsNotAllowedInPHP74' => [ 'code' => ' 'ParseError', 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], ]; } diff --git a/tests/ProjectCheckerTest.php b/tests/ProjectCheckerTest.php index 6920e14b4f2..612baedea05 100644 --- a/tests/ProjectCheckerTest.php +++ b/tests/ProjectCheckerTest.php @@ -75,9 +75,9 @@ private function getProjectAnalyzerWithConfig(Config $config): ProjectAnalyzer new FileStorageInstanceCacheProvider(), new ClassLikeStorageInstanceCacheProvider(), new FakeFileReferenceCacheProvider(), - new ProjectCacheProvider() + new ProjectCacheProvider(), ), - new ReportOptions() + new ReportOptions(), ); } @@ -91,8 +91,8 @@ public function testCheck(): void - ' - ) + ', + ), ); $this->project_analyzer->setPhpVersion('8.1', 'tests'); @@ -113,8 +113,8 @@ public function testCheck(): void $this->assertSame( 'Psalm was able to infer types for 100% of the codebase', $codebase->analyzer->getTypeInferenceSummary( - $codebase - ) + $codebase, + ), ); } @@ -141,8 +141,8 @@ public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event - ' - ) + ', + ), ); $hook_class = get_class($hook); @@ -166,8 +166,8 @@ public function testCheckAfterNoChange(): void - ' - ) + ', + ), ); $this->assertNotNull($this->project_analyzer->stdout_report_options); @@ -182,8 +182,8 @@ public function testCheckAfterNoChange(): void $this->assertSame( 'Psalm was able to infer types for 100% of the codebase', $this->project_analyzer->getCodebase()->analyzer->getTypeInferenceSummary( - $this->project_analyzer->getCodebase() - ) + $this->project_analyzer->getCodebase(), + ), ); $this->project_analyzer->getCodebase()->reloadFiles($this->project_analyzer, []); @@ -195,8 +195,8 @@ public function testCheckAfterNoChange(): void $this->assertSame( 'Psalm was able to infer types for 100% of the codebase', $this->project_analyzer->getCodebase()->analyzer->getTypeInferenceSummary( - $this->project_analyzer->getCodebase() - ) + $this->project_analyzer->getCodebase(), + ), ); } @@ -210,8 +210,8 @@ public function testCheckAfterFileChange(): void - ' - ) + ', + ), ); $this->assertNotNull($this->project_analyzer->stdout_report_options); @@ -226,8 +226,8 @@ public function testCheckAfterFileChange(): void $this->assertSame( 'Psalm was able to infer types for 100% of the codebase', $this->project_analyzer->getCodebase()->analyzer->getTypeInferenceSummary( - $this->project_analyzer->getCodebase() - ) + $this->project_analyzer->getCodebase(), + ), ); $bat_file_path = getcwd() @@ -260,8 +260,8 @@ public function __construct() $this->assertSame( 'Psalm was able to infer types for 100% of the codebase', $this->project_analyzer->getCodebase()->analyzer->getTypeInferenceSummary( - $this->project_analyzer->getCodebase() - ) + $this->project_analyzer->getCodebase(), + ), ); } @@ -275,8 +275,8 @@ public function testCheckDir(): void - ' - ) + ', + ), ); $this->project_analyzer->setPhpVersion('8.1', 'tests'); @@ -294,8 +294,8 @@ public function testCheckDir(): void $this->assertSame( 'Psalm was able to infer types for 100% of the codebase', $this->project_analyzer->getCodebase()->analyzer->getTypeInferenceSummary( - $this->project_analyzer->getCodebase() - ) + $this->project_analyzer->getCodebase(), + ), ); } @@ -309,8 +309,8 @@ public function testCheckPaths(): void - ' - ) + ', + ), ); $this->project_analyzer->setPhpVersion('8.1', 'tests'); @@ -333,8 +333,8 @@ public function testCheckPaths(): void $this->assertSame( 'Psalm was able to infer types for 100% of the codebase', $this->project_analyzer->getCodebase()->analyzer->getTypeInferenceSummary( - $this->project_analyzer->getCodebase() - ) + $this->project_analyzer->getCodebase(), + ), ); } @@ -348,8 +348,8 @@ public function testCheckFile(): void - ' - ) + ', + ), ); $this->project_analyzer->setPhpVersion('8.1', 'tests'); @@ -372,8 +372,8 @@ public function testCheckFile(): void $this->assertSame( 'Psalm was able to infer types for 100% of the codebase', $this->project_analyzer->getCodebase()->analyzer->getTypeInferenceSummary( - $this->project_analyzer->getCodebase() - ) + $this->project_analyzer->getCodebase(), + ), ); } } diff --git a/tests/PropertiesOfTest.php b/tests/PropertiesOfTest.php index 0f36623ab01..73562916830 100644 --- a/tests/PropertiesOfTest.php +++ b/tests/PropertiesOfTest.php @@ -49,7 +49,7 @@ function test3() {} '$result1===' => 'array{a: int, ...}', '$result2===' => 'array{a: int, ...}', '$result3===' => 'array{a: int, ...}', - ] + ], ], 'publicPropertiesOf' => [ 'code' => ' true]; } ', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'publicPropertiesOfPicksNoPrivate' => [ 'code' => ' true]; } ', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'publicPropertiesOfPicksNoProtected' => [ 'code' => ' true]; } ', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'protectedPropertiesOfPicksNoPublic' => [ 'code' => ' true]; } ', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'protectedPropertiesOfPicksNoPrivate' => [ 'code' => ' true]; } ', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'privatePropertiesOfPicksNoPublic' => [ 'code' => ' true]; } ', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'privatePropertiesOfPicksNoProtected' => [ 'code' => ' true]; } ', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'finalPropertiesOfInexact' => [ 'code' => ' true]; } ', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], ]; } diff --git a/tests/PropertyTypeTest.php b/tests/PropertyTypeTest.php index 1a29a4d7e28..ab8a6325add 100644 --- a/tests/PropertyTypeTest.php +++ b/tests/PropertyTypeTest.php @@ -46,7 +46,7 @@ public function getX(): int { return $this->x; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -78,7 +78,7 @@ public function getX(): int { return $this->x; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -114,7 +114,7 @@ function testX(X $x): void { } if ($x->x === null) {} - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -146,7 +146,7 @@ public function baz(): void private function foo() : void { $this->bar = 5; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -187,7 +187,7 @@ function testX(X $x): void { XCollector::modify(); if ($x->getX() === null) {} } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -225,7 +225,7 @@ function testX(X $x): void { XCollector::modify(); if ($x->getX() === null) {} } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -259,7 +259,7 @@ function testX(X $x): void { XCollector::modify(); if ($x->x === null) {} } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -284,7 +284,7 @@ public function validate(): void { maybeMutates(); } } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -326,7 +326,7 @@ public function alter() : void { array_pop($this->c); } } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -363,7 +363,7 @@ public function alter() : void { array_pop($this->b); } } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -405,7 +405,7 @@ public function alter() : void { array_pop($this->c); } } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -447,7 +447,7 @@ public function alter() : void { array_pop($this->c); } } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -489,7 +489,7 @@ public function alter() : void { array_pop($this->c); } } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -508,7 +508,7 @@ public function testUniversalObjectCrates(): void // sets are fine $f->buzz = false; - ' + ', ); $this->analyzeFile('somefile.php', new Context()); @@ -544,7 +544,7 @@ public function getX(bool $b): int { return $this->x; } - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -729,7 +729,7 @@ function foo(DOMElement $e) : void { 'code' => 'attributes->item(0); - }' + }', ], 'goodArrayProperties' => [ 'code' => ' */ private $t2 = []; - }' + }', ], 'propagateIgnoreNullableOnPropertyFetch' => [ 'code' => 'foo = true; } } - }' + }', ], 'testRemoveClauseAfterReassignment' => [ 'code' => 'a = "bar"; } - }' + }', ], 'allowGoodArrayPushOnArrayValue' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo; } - }' + }', ], 'aliasedFinalMethod' => [ 'code' => 'setPropFinal(1); } - }' + }', ], 'aliasedAsFinalMethod' => [ 'code' => 'setPropFinal(1); } - }' + }', ], 'staticPropertyAssertion' => [ 'code' => ' [ 'code' => 'i); } - }' + }', ], 'unionPropertyType' => [ 'code' => ' [ 'code' => 'foo;' + echo (new A)->foo;', ], 'promotedPublicPropertyWitoutDefault' => [ 'code' => 'foo;' + echo (new A(5))->foo;', ], 'promotedProtectedProperty' => [ 'code' => 'foo; } - }' + }', ], 'skipConstructor' => [ 'code' => 's; } - }' + }', ], 'getPropertyThatMayNotBeSet' => [ 'code' => 'b = "c"; echo strlen($this->b); } - }' + }', ], 'noErrorForSplatArgs' => [ 'code' => ' [ 'code' => 'foo; - }' + }', ], 'noRedundantCastWhenCheckingProperties' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'dynamicPropertyFetch' => [ 'code' => '{$b} ?? null; - }' + }', ], 'nullCoalesceWithNullablePropertyAccess' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'possiblyNullOnFunctionCallCoalesced' => [ 'code' => 'a = new A(); } } - }' + }', ], 'allowDefaultForTemplatedProperty' => [ 'code' => ' [ 'code' => ' [ 'code' => 'isAutoCommitEnabled() === false); $mode->enableAutoCommit(); - assert($mode->isAutoCommitEnabled() === true);' + assert($mode->isAutoCommitEnabled() === true);', ], 'promotedInheritedPropertyWithDocblock' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'impossibleIntersection' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], ]; } @@ -3455,7 +3455,7 @@ public function __construct() { } }', 'error_message' => 'UninitializedProperty', - 'ignored_issues' => ['MixedArgument', 'MissingPropertyType'] + 'ignored_issues' => ['MixedArgument', 'MissingPropertyType'], ], 'unitializedObjectProperty' => [ 'code' => ' 1]; }', - 'error_message' => 'InvalidPropertyAssignmentValue' + 'error_message' => 'InvalidPropertyAssignmentValue', ], 'addNullToMixedAfterNullablePropertyFetch' => [ 'code' => 'map[$class] = 5; } }', - 'error_message' => 'InvalidPropertyAssignmentValue' + 'error_message' => 'InvalidPropertyAssignmentValue', ], 'preventArrayPushOnArrayValue' => [ 'code' => 'prop, "bad"); } }', - 'error_message' => 'InvalidPropertyAssignmentValue' + 'error_message' => 'InvalidPropertyAssignmentValue', ], 'overriddenConstructorCalledMethod' => [ 'code' => ' 'PropertyNotSetInConstructor' + 'error_message' => 'PropertyNotSetInConstructor', ], 'propertyWithSameNameUndefined' => [ 'code' => 'prop = 42; ', 'error_message' => 'UndefinedPropertyAssignment', - ] + ], ]; } } diff --git a/tests/PsalmPluginTest.php b/tests/PsalmPluginTest.php index 4ba57ad3ecc..b6b2515d711 100644 --- a/tests/PsalmPluginTest.php +++ b/tests/PsalmPluginTest.php @@ -49,7 +49,7 @@ public function setUp(): void ]); $this->app->getDefinition()->addOption( - new InputOption('config', 'c', InputOption::VALUE_REQUIRED, 'Path to Psalm config file') + new InputOption('config', 'c', InputOption::VALUE_REQUIRED, 'Path to Psalm config file'), ); $this->app->setDefaultCommand('show'); diff --git a/tests/PureAnnotationTest.php b/tests/PureAnnotationTest.php index c5cdd484f92..11f3a99422c 100644 --- a/tests/PureAnnotationTest.php +++ b/tests/PureAnnotationTest.php @@ -44,7 +44,7 @@ function highlight(string $needle, string $output) : string { $output = preg_replace("#({$needles})#im", "$1", $output); return $output; - }' + }', ], 'implicitAnnotations' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'getMessage(); } - echo getMessage(new Exception("test"));' + echo getMessage(new Exception("test"));', ], 'exceptionGetCode' => [ 'code' => 'getCode(); } - echo getCode(new Exception("test"));' + echo getCode(new Exception("test"));', ], 'exceptionGetFile' => [ 'code' => 'getFile(); } - echo getFile(new Exception("test"));' + echo getFile(new Exception("test"));', ], 'exceptionGetLine' => [ 'code' => 'getLine(); } - echo getLine(new Exception("test"));' + echo getLine(new Exception("test"));', ], 'exceptionGetTrace' => [ 'code' => 'getTrace(); } - echo count(getTrace(new Exception("test")));' + echo count(getTrace(new Exception("test")));', ], 'exceptionGetPrevious' => [ 'code' => 'getPrevious(); } - echo gettype(getPrevious(new Exception("test")));' + echo gettype(getPrevious(new Exception("test")));', ], 'exceptionGetTraceAsString' => [ 'code' => 'getTraceAsString(); } - echo getTraceAsString(new Exception("test"));' + echo getTraceAsString(new Exception("test"));', ], 'callingMethodInThrowStillPure' => [ 'code' => ' [ 'code' => 'checkNotNullNested(); $this->other->foo(); } - }' + }', ], 'allowPropertyAccessOnImmutableClass' => [ 'code' => '= 1 && $portNumber <= 1000; } - }' + }', ], 'pureThroughCallStatic' => [ 'code' => ' 'ImpureByReferenceAssignment' + 'error_message' => 'ImpureByReferenceAssignment', ], 'staticPropertyFetch' => [ 'code' => ' 'ImpureMethodCall' + 'error_message' => 'ImpureMethodCall', ], 'preventImpureToStringViaConcatenation' => [ 'code' => ' 'ImpureMethodCall' + 'error_message' => 'ImpureMethodCall', ], 'countCanBeImpure' => [ 'code' => 'bar;' + echo (new A)->bar;', ], 'readonlyPropertySetInConstructor' => [ 'code' => 'bar;', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.1' + 'php_version' => '8.1', ], 'docblockReadonlyWithPrivateMutationsAllowedPropertySetInAnotherMethod' => [ 'code' => 'bar;' + echo (new A)->bar;', ], 'readonlyPublicPropertySetInAnotherMethod' => [ 'code' => 'bar;' + echo (new A)->bar;', ], 'docblockReadonlyWithPrivateMutationsAllowedConstructorPropertySetInAnotherMethod' => [ 'code' => 'bar;' + echo (new A)->bar;', ], 'readonlyPublicConstructorPropertySetInAnotherMethod' => [ 'code' => 'bar;' + echo (new A)->bar;', ], 'readonlyPropertySetChildClass' => [ 'code' => 'bar;' + echo (new B)->bar;', ], ]; } @@ -263,7 +263,7 @@ public function __construct(int $prop) { $test = new Test(5); $test->prop += 1;', - 'error_message' => 'InaccessibleProperty' + 'error_message' => 'InaccessibleProperty', ], 'readonlyPropertyWithDefault' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'file_provider, - new FakeParserCacheProvider() + new FakeParserCacheProvider(), ), new ReportOptions(), - $json_report_options + $json_report_options, ); } @@ -88,7 +88,7 @@ function addPrefixToInput($prefix, $input): string { $this->addFile( 'taintflow-test/vulnerable.php', - $vulnerable_file_contents + $vulnerable_file_contents, ); $this->analyzeFile('taintflow-test/vulnerable.php', new Context(), true, true); @@ -113,11 +113,11 @@ public function testSarifReport(): void 'id' => '246', 'name' => 'TaintedShell', 'shortDescription' => [ - 'text' => 'TaintedShell' + 'text' => 'TaintedShell', ], 'properties' => [ 'tags' => [ - 'security' + 'security', ], ], 'helpUri' => 'https://psalm.dev/246', @@ -130,11 +130,11 @@ public function testSarifReport(): void 'id' => '245', 'name' => 'TaintedHtml', 'shortDescription' => [ - 'text' => 'TaintedHtml' + 'text' => 'TaintedHtml', ], 'properties' => [ 'tags' => [ - 'security' + 'security', ], ], 'helpUri' => 'https://psalm.dev/245', @@ -147,11 +147,11 @@ public function testSarifReport(): void 'id' => '274', 'name' => 'TaintedTextWithQuotes', 'shortDescription' => [ - 'text' => 'TaintedTextWithQuotes' + 'text' => 'TaintedTextWithQuotes', ], 'properties' => [ 'tags' => [ - 'security' + 'security', ], ], 'helpUri' => 'https://psalm.dev/274', @@ -160,35 +160,35 @@ public function testSarifReport(): void 'text' => file_get_contents(__DIR__ . '/../docs/running_psalm/issues/TaintedTextWithQuotes.md'), ], ], - ] - ] + ], + ], ], 'results' => [ [ 'ruleId' => '246', 'message' => [ - 'text' => 'Detected tainted shell code' + 'text' => 'Detected tainted shell code', ], 'level' => 'error', 'locations' => [ [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 9, 'endLine' => 9, 'startColumn' => 12, - 'endColumn' => 25 - ] - ] - ] + 'endColumn' => 25, + ], + ], + ], ], 'codeFlows' => [ [ 'message' => [ - 'text' => 'Tracing the path from user input to insecure usage' + 'text' => 'Tracing the path from user input to insecure usage', ], 'threadFlows' => [ [ @@ -197,153 +197,153 @@ public function testSarifReport(): void 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 46, - 'endColumn' => 52 - ] - ] - ] + 'endColumn' => 52, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 46, - 'endColumn' => 59 - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 36, - 'endColumn' => 42 - ] - ] - ] + 'endColumn' => 42, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 36, - 'endColumn' => 42 - ] - ] - ] + 'endColumn' => 42, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 4, 'endLine' => 4, 'startColumn' => 12, - 'endColumn' => 28 - ] - ] - ] + 'endColumn' => 28, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 45, - 'endColumn' => 51 - ] - ] - ] + 'endColumn' => 51, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 1, - 'endColumn' => 14 - ] - ] - ] + 'endColumn' => 14, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 9, 'endLine' => 9, 'startColumn' => 12, - 'endColumn' => 25 - ] - ] - ] - ] - ] - ] - ] - ] - ] + 'endColumn' => 25, + ], + ], + ], + ], + ], + ], + ], + ], + ], ], [ 'ruleId' => '245', 'message' => [ - 'text' => 'Detected tainted HTML' + 'text' => 'Detected tainted HTML', ], 'level' => 'error', 'locations' => [ [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 11, 'endLine' => 11, 'startColumn' => 6, - 'endColumn' => 59 - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], ], 'codeFlows' => [ [ 'message' => [ - 'text' => 'Tracing the path from user input to insecure usage' + 'text' => 'Tracing the path from user input to insecure usage', ], 'threadFlows' => [ [ @@ -352,168 +352,168 @@ public function testSarifReport(): void 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 46, - 'endColumn' => 52 - ] - ] - ] + 'endColumn' => 52, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 46, - 'endColumn' => 59 - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 36, - 'endColumn' => 42 - ] - ] - ] + 'endColumn' => 42, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 36, - 'endColumn' => 42 - ] - ] - ] + 'endColumn' => 42, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 4, 'endLine' => 4, 'startColumn' => 12, - 'endColumn' => 28 - ] - ] - ] + 'endColumn' => 28, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 45, - 'endColumn' => 51 - ] - ] - ] + 'endColumn' => 51, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 1, - 'endColumn' => 14 - ] - ] - ] + 'endColumn' => 14, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 11, 'endLine' => 11, 'startColumn' => 6, - 'endColumn' => 59 - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 11, 'endLine' => 11, 'startColumn' => 6, - 'endColumn' => 59 - ] - ] - ] - ] - ] - ] - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], + ], + ], + ], + ], + ], + ], ], [ 'ruleId' => '274', 'message' => [ - 'text' => 'Detected tainted text with possible quotes' + 'text' => 'Detected tainted text with possible quotes', ], 'level' => 'error', 'locations' => [ [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 11, 'endLine' => 11, 'startColumn' => 6, - 'endColumn' => 59 - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], ], 'codeFlows' => [ [ 'message' => [ - 'text' => 'Tracing the path from user input to insecure usage' + 'text' => 'Tracing the path from user input to insecure usage', ], 'threadFlows' => [ [ @@ -522,153 +522,153 @@ public function testSarifReport(): void 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 46, - 'endColumn' => 52 - ] - ] - ] + 'endColumn' => 52, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 46, - 'endColumn' => 59 - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 36, - 'endColumn' => 42 - ] - ] - ] + 'endColumn' => 42, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 36, - 'endColumn' => 42 - ] - ] - ] + 'endColumn' => 42, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 4, 'endLine' => 4, 'startColumn' => 12, - 'endColumn' => 28 - ] - ] - ] + 'endColumn' => 28, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 3, 'endLine' => 3, 'startColumn' => 45, - 'endColumn' => 51 - ] - ] - ] + 'endColumn' => 51, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 7, 'endLine' => 7, 'startColumn' => 1, - 'endColumn' => 14 - ] - ] - ] + 'endColumn' => 14, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 11, 'endLine' => 11, 'startColumn' => 6, - 'endColumn' => 59 - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], ], [ 'location' => [ 'physicalLocation' => [ 'artifactLocation' => [ - 'uri' => 'taintflow-test/vulnerable.php' + 'uri' => 'taintflow-test/vulnerable.php', ], 'region' => [ 'startLine' => 11, 'endLine' => 11, 'startColumn' => 6, - 'endColumn' => 59 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] + 'endColumn' => 59, + ], + ], + ], + ], + ], + ], + ], + ], + ], + ], + ], + ], + ], ]; $sarif_report_options = ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.sarif'])[0]; $this->assertSame( $issue_data, - json_decode(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $sarif_report_options), true, 512, JSON_THROW_ON_ERROR) + json_decode(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $sarif_report_options), true, 512, JSON_THROW_ON_ERROR), ); } @@ -694,7 +694,7 @@ function psalmCanVerify(int $your_code): ?string { $this->addFile( 'somefile.php', - $file_contents + $file_contents, ); $this->analyzeFile('somefile.php', new Context()); @@ -821,7 +821,7 @@ public function testJsonReport(): void $this->assertSame( $issue_data, - json_decode(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $json_report_options), true, 512, JSON_THROW_ON_ERROR) + json_decode(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $json_report_options), true, 512, JSON_THROW_ON_ERROR), ); } @@ -843,7 +843,7 @@ public function testFilteredJsonReportIsStillArray(): void 196, 203, 6, - 8 + 8, ), ]; @@ -853,7 +853,7 @@ public function testFilteredJsonReportIsStillArray(): void $report = new JsonReport( $issues_data, $fixable_issue_counts, - $report_options + $report_options, ); $this->assertIsArray(json_decode($report->create(), null, 512, JSON_THROW_ON_ERROR)); } @@ -952,7 +952,7 @@ public function testSonarqubeReport(): void $this->assertSame( $issue_data, - json_decode(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $sonarqube_report_options), true, 512, JSON_THROW_ON_ERROR) + json_decode(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $sonarqube_report_options), true, 512, JSON_THROW_ON_ERROR), ); } @@ -969,7 +969,7 @@ public function testEmacsReport(): void somefile.php:8:6:error - Const CHANGE_ME is not defined somefile.php:17:6:warning - Possibly undefined global variable $a, first seen on line 11 ', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $emacs_report_options) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $emacs_report_options), ); } @@ -986,7 +986,7 @@ public function testPylintReport(): void somefile.php:8: [E0001] UndefinedConstant: Const CHANGE_ME is not defined (column 6) somefile.php:17: [W0001] PossiblyUndefinedGlobalVariable: Possibly undefined global variable $a, first seen on line 11 (column 6) ', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $pylint_report_options) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $pylint_report_options), ); } @@ -1014,7 +1014,7 @@ function psalmCanVerify(int $your_code): ?string { echo $a ', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $console_report_options) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $console_report_options), ); } @@ -1040,7 +1040,7 @@ function psalmCanVerify(int $your_code): ?string { echo CHANGE_ME; ', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $console_report_options) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $console_report_options), ); } @@ -1069,7 +1069,7 @@ public function testConsoleReportNoSnippet(): void ', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $console_report_options) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $console_report_options), ); } @@ -1086,7 +1086,7 @@ public function testConsoleReportWithLinks(): void $this->assertStringContainsString( "\033]8;;file://somefile.php#L3\033\\\033[1;31msomefile.php:3:10\033[0m\033]8;;\033\\", - $output + $output, ); } @@ -1103,7 +1103,7 @@ public function testConsoleReportLinksAreDisabledInCI(): void $this->assertStringNotContainsString( "\033]8;;file://somefile.php#L3\033\\", - $output + $output, ); } @@ -1127,7 +1127,7 @@ public function testCompactReport(): void '| ERROR | 8 | UndefinedConstant | Const CHANGE_ME is not defined |' . "\n" . '| INFO | 17 | PossiblyUndefinedGlobalVariable | Possibly undefined global variable $a, first seen on line 11 |' . "\n" . '+----------+------+---------------------------------+---------------------------------------------------------------+' . "\n", - $this->toUnixLineEndings(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $compact_report_options)) + $this->toUnixLineEndings(IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $compact_report_options)), ); } @@ -1157,7 +1157,7 @@ public function testCheckstyleReport(): void
', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $checkstyle_report_options) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $checkstyle_report_options), ); // FIXME: The XML parser only return strings, all int value are casted, so the assertSame failed @@ -1232,7 +1232,7 @@ public function testJunitReport(): void ', - $xml + $xml, ); // Validate against junit xsd @@ -1267,7 +1267,7 @@ public function testGithubActionsOutput(): void EOF; $this->assertSame( $expected_output, - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $github_report_options) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $github_report_options), ); } @@ -1287,7 +1287,7 @@ public function testCountOutput(): void EOF; $this->assertSame( $expected_output, - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $report_options) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), $report_options), ); } @@ -1295,18 +1295,18 @@ public function testEmptyReportIfNotError(): void { $this->addFile( 'somefile.php', - '' + '', ); $this->analyzeFile('somefile.php', new Context()); $this->assertSame( '[] ', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.json'])[0]) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.json'])[0]), ); $this->assertSame( '', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.emacs'])[0]) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.emacs'])[0]), ); $this->assertSame( ' @@ -1314,7 +1314,7 @@ public function testEmptyReportIfNotError(): void ', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.xml'])[0]) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.xml'])[0]), ); $this->assertSame( @@ -1322,7 +1322,7 @@ public function testEmptyReportIfNotError(): void ', - IssueBuffer::getOutput(IssueBuffer::getIssuesData(), ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.checkstyle.xml'])[0]) + IssueBuffer::getOutput(IssueBuffer::getIssuesData(), ProjectAnalyzer::getFileReportOptions([__DIR__ . '/test-report.checkstyle.xml'])[0]), ); ob_start(); diff --git a/tests/ReturnTypeProvider/GetObjectVarsTest.php b/tests/ReturnTypeProvider/GetObjectVarsTest.php index b7eeb178bce..ced035514bf 100644 --- a/tests/ReturnTypeProvider/GetObjectVarsTest.php +++ b/tests/ReturnTypeProvider/GetObjectVarsTest.php @@ -121,8 +121,8 @@ public function __construct(public mixed $t) {} $a = get_object_vars(new a("test"));', 'assertions' => [ - '$a===' => "array{t: 'test'}" - ] + '$a===' => "array{t: 'test'}", + ], ]; yield 'SKIPPED-dynamicProperties' => [ @@ -135,8 +135,8 @@ public function __construct(public string $t) {} $a->b = "test"; $test = get_object_vars($a);', 'assertions' => [ - '$test===' => "array{t: 'test'}" - ] + '$test===' => "array{t: 'test'}", + ], ]; yield 'SKIPPED-dynamicProperties82' => [ @@ -150,9 +150,9 @@ public function __construct(public string $t) {} $a->b = "test"; $test = get_object_vars($a);', 'assertions' => [ - '$test===' => "array{t: 'test'}" + '$test===' => "array{t: 'test'}", ], - 'php_version' => '8.2' + 'php_version' => '8.2', ]; yield 'SKIPPED-noDynamicProperties82' => [ @@ -164,9 +164,9 @@ public function __construct(public string $t) {} $a = new a("test"); $test = get_object_vars($a);', 'assertions' => [ - '$test===' => "array{t: 'test'}" + '$test===' => "array{t: 'test'}", ], - 'php_version' => '8.2' + 'php_version' => '8.2', ]; } } diff --git a/tests/ReturnTypeTest.php b/tests/ReturnTypeTest.php index 65d6796e79e..e34770750f2 100644 --- a/tests/ReturnTypeTest.php +++ b/tests/ReturnTypeTest.php @@ -766,7 +766,7 @@ function reflexive(Closure $op): Closure { '$res' => 'Closure(int):bool', ], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'infersClosureReturnTypesWithPartialTypehinting' => [ 'code' => ' $_) { echo "$k\n"; - }' + }', ], 'allowImplicitNever' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'returnsNullSometimes' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'value = 123; } - }' + }', ], 'returnTypeOfAbstractMethodFromTemplatedTraitAndImplementationFromNonTemplatedTrait' => [ 'code' => 'value = 123; } - }' + }', ], 'nestedArrayMapReturnTypeDoesntCrash' => [ 'code' => ' 'InvalidClass', - ] + ], ]; } } diff --git a/tests/StubTest.php b/tests/StubTest.php index 68c89282be8..a670bd8c571 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -54,8 +54,8 @@ private function getProjectAnalyzerWithConfig(Config $config): ProjectAnalyzer $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $project_analyzer->setPhpVersion('7.4', 'tests'); @@ -83,8 +83,8 @@ public function testNonexistentStubFile(): void - ' - ) + ', + ), ); } @@ -104,8 +104,8 @@ public function testStubFileClass(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -118,7 +118,7 @@ public function testStubFileClass(): void $a = new \SystemClass(); $b = $a->foo(5, "hello"); $c = \SystemClass::bar(5, "hello"); - echo \SystemClass::HELLO;' + echo \SystemClass::HELLO;', ); $this->analyzeFile($file_path, new Context()); @@ -144,8 +144,8 @@ public function testLoadStubFileWithRelativePath(): void - ' - ) + ', + ), ); $path = $this->getOperatingSystemStyledPath('tests/fixtures/stubs/systemclass.phpstub'); @@ -166,8 +166,8 @@ public function testLoadStubFileWithAbsolutePath(): void - ' - ) + ', + ), ); $path = $this->getOperatingSystemStyledPath('tests/fixtures/stubs/systemclass.phpstub'); @@ -191,8 +191,8 @@ public function testStubFileConstant(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -205,7 +205,7 @@ public function testStubFileConstant(): void $d = ROOT_CONST_CONSTANT; $e = \ROOT_CONST_CONSTANT; $f = ROOT_DEFINE_CONSTANT; - $g = \ROOT_DEFINE_CONSTANT;' + $g = \ROOT_DEFINE_CONSTANT;', ); $this->analyzeFile($file_path, new Context()); @@ -229,8 +229,8 @@ public function testStubFileParentClass(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -247,7 +247,7 @@ public function foo(string $a, string $b): string return $a . $b; } } - ' + ', ); $this->analyzeFile($file_path, new Context()); @@ -271,8 +271,8 @@ public function testStubFileCircularReference(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -281,7 +281,7 @@ public function testStubFileCircularReference(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -303,8 +303,8 @@ public function testPhpStormMetaParsingFile(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -367,7 +367,7 @@ function bar(array $a) {} $d1 = \foO(5); $d2 = \baR(["hello"]); - }' + }', ); $context = new Context(); @@ -390,8 +390,8 @@ public function testNamespacedStubClass(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -405,7 +405,7 @@ public function testNamespacedStubClass(): void $b = $a->foo(5, "hello"); $c = Foo\SystemClass::bar(5, "hello"); - echo Foo\BAR;' + echo Foo\BAR;', ); $this->analyzeFile($file_path, new Context()); @@ -427,8 +427,8 @@ public function testStubRegularFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -436,7 +436,7 @@ public function testStubRegularFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -458,8 +458,8 @@ public function testStubVariadicFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -467,7 +467,7 @@ public function testStubVariadicFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -491,8 +491,8 @@ public function testStubVariadicFunctionWrongArgType(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -500,7 +500,7 @@ public function testStubVariadicFunctionWrongArgType(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -520,8 +520,8 @@ public function testUserVariadicWithFalseVariadic(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -533,7 +533,7 @@ public function testUserVariadicWithFalseVariadic(): void * @param string ...$bar */ function variadic() : void {} - variadic("hello");' + variadic("hello");', ); $this->analyzeFile($file_path, new Context()); @@ -555,8 +555,8 @@ public function testPolyfilledFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -565,7 +565,7 @@ public function testPolyfilledFunction(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -587,8 +587,8 @@ public function testConditionalConstantDefined(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -597,7 +597,7 @@ public function testConditionalConstantDefined(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -619,8 +619,8 @@ public function testClassAlias(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -658,7 +658,7 @@ function getAliased(): B { D::bat(); $d::bat(); - class E implements IAlias {}' + class E implements IAlias {}', ); $this->analyzeFile($file_path, new Context()); @@ -680,8 +680,8 @@ public function testStubFunctionWithFunctionExists(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -690,7 +690,7 @@ public function testStubFunctionWithFunctionExists(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -712,8 +712,8 @@ public function testNamespacedStubFunctionWithFunctionExists(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -723,7 +723,7 @@ public function testNamespacedStubFunctionWithFunctionExists(): void 'analyzeFile($file_path, new Context()); @@ -743,8 +743,8 @@ public function testNoStubFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -752,7 +752,7 @@ public function testNoStubFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -774,8 +774,8 @@ public function testNamespacedStubFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -783,7 +783,7 @@ public function testNamespacedStubFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -805,8 +805,8 @@ public function testConditionalNamespacedStubFunction(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -814,7 +814,7 @@ public function testConditionalNamespacedStubFunction(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -836,8 +836,8 @@ public function testConditionallyExtendingInterface(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -861,7 +861,7 @@ function bat(I7 $d) : void { function baz(I8 $d) : void { $d->getMessage(); - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -883,8 +883,8 @@ public function testStubFileWithExistingClassDefinition(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -892,7 +892,7 @@ public function testStubFileWithExistingClassDefinition(): void $this->addFile( $file_path, 'analyzeFile($file_path, new Context()); @@ -905,13 +905,13 @@ public function versionDependentStubsProvider(): iterable '7.0', 'something("zzz");' + $a->something("zzz");', ]; yield '8.0' => [ '8.0', 'something();' + $a->something();', ]; } @@ -932,8 +932,8 @@ public function testVersionDependentStubs(string $php_version, string $code): vo - ' - ) + ', + ), ); $this->project_analyzer->setPhpVersion($php_version, 'tests'); @@ -960,8 +960,8 @@ public function testStubFileWithPartialClassDefinitionWithMoreMethods(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -986,7 +986,7 @@ public function bar(int $i) : void {} class A {} (new PartiallyStubbedClass())->foo(A::class); - (new PartiallyStubbedClass())->bar(5);' + (new PartiallyStubbedClass())->bar(5);', ); $this->analyzeFile($file_path, new Context()); @@ -1008,8 +1008,8 @@ public function testExtendOnlyStubbedClass(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1021,7 +1021,7 @@ public function testExtendOnlyStubbedClass(): void class A extends PartiallyStubbedClass {} - (new A)->foo(A::class);' + (new A)->foo(A::class);', ); $this->analyzeFile($file_path, new Context()); @@ -1043,8 +1043,8 @@ public function testStubFileWithExtendedStubbedClass(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1056,7 +1056,7 @@ public function testStubFileWithExtendedStubbedClass(): void class Bar extends PartiallyStubbedClass {} - new Bar();' + new Bar();', ); $this->analyzeFile($file_path, new Context()); @@ -1080,8 +1080,8 @@ public function testStubFileWithPartialClassDefinitionWithCoercion(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1101,7 +1101,7 @@ public function foo(string $a) { } } - (new PartiallyStubbedClass())->foo("dasda");' + (new PartiallyStubbedClass())->foo("dasda");', ); $this->analyzeFile($file_path, new Context()); @@ -1125,8 +1125,8 @@ public function testStubFileWithPartialClassDefinitionGeneralReturnType(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1144,7 +1144,7 @@ class PartiallyStubbedClass { public function foo(string $a) { return new \stdClass; } - }' + }', ); $this->analyzeFile($file_path, new Context()); @@ -1166,8 +1166,8 @@ public function testStubFileWithTemplatedClassDefinitionAndMagicMethodOverride() - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1195,7 +1195,7 @@ class Obj {} /** * @method ?Obj find(int $id, $lockMode = null, $lockVersion = null) */ - class C extends B {}' + class C extends B {}', ); $this->analyzeFile($file_path, new Context()); @@ -1213,8 +1213,8 @@ public function testInheritedMethodUsedInStub(): void - ' - ) + ', + ), ); $this->project_analyzer->getCodebase()->reportUnusedCode(); @@ -1232,7 +1232,7 @@ abstract public function foo() : void; public static function vendorFunction(VendorClass $v) : void { $v->foo(); } - }' + }', ); $file_path = getcwd() . '/src/somefile.php'; @@ -1244,7 +1244,7 @@ class MyClass extends \SomeVendor\VendorClass { public function foo() : void {} } - \SomeVendor\VendorClass::vendorFunction(new MyClass);' + \SomeVendor\VendorClass::vendorFunction(new MyClass);', ); $this->analyzeFile($file_path, new Context(), false); @@ -1265,8 +1265,8 @@ public function testStubOverridingMissingClass(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1275,7 +1275,7 @@ public function testStubOverridingMissingClass(): void $file_path, 'expectException(InvalidClasslikeOverrideException::class); @@ -1296,8 +1296,8 @@ public function testStubOverridingMissingMethod(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -1306,7 +1306,7 @@ public function testStubOverridingMissingMethod(): void $file_path, 'expectException(InvalidMethodOverrideException::class); @@ -1327,8 +1327,8 @@ public function testStubReplacingInterfaceDocblock(): void - ' - ) + ', + ), ); $this->addFile( @@ -1358,7 +1358,7 @@ public function getReference($entityName, $id) { */ return new \stdClass; } - }' + }', ); $file_path = getcwd() . '/src/somefile.php'; @@ -1372,7 +1372,7 @@ class A {} function em(EntityManager $em) : void { echo $em->getReference(A::class, 1); - }' + }', ); $this->expectException(CodeException::class); diff --git a/tests/SuperGlobalsTest.php b/tests/SuperGlobalsTest.php index 84d4018d846..5a9852f3e6f 100644 --- a/tests/SuperGlobalsTest.php +++ b/tests/SuperGlobalsTest.php @@ -17,7 +17,7 @@ function returnsList(): array { return $http_response_header; } ', - 'assertions' => [] + 'assertions' => [], ]; yield 'ENV has scalar entries only' => [ @@ -26,7 +26,7 @@ function returnsList(): array { function f(): array { return $_ENV; } - ' + ', ]; } } diff --git a/tests/SwitchTypeTest.php b/tests/SwitchTypeTest.php index 75aa02319c2..c8bd80ed940 100644 --- a/tests/SwitchTypeTest.php +++ b/tests/SwitchTypeTest.php @@ -555,7 +555,7 @@ function getGlobalConstType( } return null; - }' + }', ], 'evenLongerSwitch' => [ 'code' => ' [ 'code' => 'format("Y") === "2020": $a->format("d-m-Y"); - }' + }', ], 'evenWorseSwitch' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'ParadoxicalCondition' + 'error_message' => 'ParadoxicalCondition', ], 'loopWithSwitchDoesntReturnFirstCase' => [ 'code' => ' 'InvalidReturnType' + 'error_message' => 'InvalidReturnType', ], 'clearDependentTypeWhenAssigning' => [ 'code' => 'bar(); } }', - 'error_message' => 'UndefinedMethod' + 'error_message' => 'UndefinedMethod', ], ]; } diff --git a/tests/TaintTest.php b/tests/TaintTest.php index fd461807e81..0c5e6a7d721 100644 --- a/tests/TaintTest.php +++ b/tests/TaintTest.php @@ -30,7 +30,7 @@ public function testValidCode(string $code): void $this->addFile( $file_path, - $code + $code, ); $this->project_analyzer->trackTaintedInputs(); @@ -56,7 +56,7 @@ public function testInvalidCode(string $code, string $error_message): void $this->addFile( $file_path, - $code + $code, ); $this->project_analyzer->trackTaintedInputs(); @@ -78,7 +78,7 @@ public function providerValidCodeParse(): array $data = ["name" => $name, "id" => $id]; echo "

" . htmlentities($data["name"], \ENT_QUOTES) . "

"; - echo "

" . $data["id"] . "

";' + echo "

" . $data["id"] . "

";', ], 'taintedInputInAssignedArrayNotEchoed' => [ 'code' => '" . htmlentities($data["name"], \ENT_QUOTES) . ""; - echo "

" . $data["id"] . "

";' + echo "

" . $data["id"] . "

";', ], 'taintedInputDirectlySuppressed' => [ 'code' => 'exec("delete from users where user_id = " . $userId); } - }' + }', ], 'taintedInputDirectlySuppressedWithOtherUse' => [ 'code' => ' [ 'code' => 'exec("delete from users where user_id = " . $userId2); } - }' + }', ], 'ValidatedInputFromParam' => [ 'code' => 'exec("delete from users where user_id = " . $userId); } - }' + }', ], 'untaintedInputAfterIntCast' => [ 'code' => 'getAppendedUserId(); $pdo->exec("delete from users where user_id = " . $userId); } - }' + }', ], 'specializedCoreFunctionCall' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 's); } - }' + }', ], 'taintOnPregReplaceCallRemovedInFunction' => [ 'code' => 's); } - }' + }', ], 'taintOnStrReplaceCallRemovedInline' => [ 'code' => 's); echo $a; } - }' + }', ], 'NoTaintsOnSimilarPureCall' => [ 'code' => 't)); } - }' + }', ], 'taintPropertyPassingObjectWithDifferentValue' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'x;' + echo $a->x;', ], 'dontTaintSpecializedCallsForAnonymousInstance' => [ 'code' => 'render($_GET["untrusted"]); - echo (new StringRenderer())->render("a");' + echo (new StringRenderer())->render("a");', ], 'dontTaintSpecializedCallsForStubMadeInstance' => [ 'code' => 'render($_GET["untrusted"]); - echo stub()->render("a");' + echo stub()->render("a");', ], 'suppressTaintedInput' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'getTaint();' + echo $b->getTaint();', ], 'immutableClassTrackInputThroughMethod' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $_GET["bad"]]);' + takesArray(["good" => $_GET["bad"]]);', ], 'resultOfComparisonIsNotTainted' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'TaintedHtml' + 'error_message' => 'TaintedHtml', ], 'potentialTaintThroughChildClassSettingProperty' => [ 'code' => ' ' 'TaintedShell' - ] + 'error_message' => 'TaintedShell', + ], ]; } @@ -2413,7 +2413,7 @@ public function multipleTaintIssuesAreDetected(string $code, array $expectedIssu $actualIssueTypes = array_map( fn(IssueData $issue): string => $issue->type . '{ ' . trim($issue->snippet) . ' }', - IssueBuffer::getIssuesDataForFile($filePath) + IssueBuffer::getIssuesDataForFile($filePath), ); self::assertSame($expectedIssuesTypes, $actualIssueTypes); } diff --git a/tests/Template/ClassStringMapTest.php b/tests/Template/ClassStringMapTest.php index 2bf4aca174e..cf2564af288 100644 --- a/tests/Template/ClassStringMapTest.php +++ b/tests/Template/ClassStringMapTest.php @@ -81,7 +81,7 @@ function takesVariadic(...$args): void { /** @param class-string-map $arr */ function foo(array $arr) : void { takesVariadic(...$arr); - }' + }', ], ]; } @@ -105,7 +105,7 @@ public function get(string $class) : void { self::$map[$class] = 5; } }', - 'error_message' => 'InvalidPropertyAssignmentValue' + 'error_message' => 'InvalidPropertyAssignmentValue', ], 'assignInvalidClassDifferentTemplateName' => [ 'code' => ' 'InvalidPropertyAssignmentValue' + 'error_message' => 'InvalidPropertyAssignmentValue', ], ]; } diff --git a/tests/Template/ClassTemplateCovarianceTest.php b/tests/Template/ClassTemplateCovarianceTest.php index 8c3110681e9..aac3581493d 100644 --- a/tests/Template/ClassTemplateCovarianceTest.php +++ b/tests/Template/ClassTemplateCovarianceTest.php @@ -51,7 +51,7 @@ class Bar { public function __construct() { $this->arrayOfFoo = new Foo(function(): array { return ["foo" => "bar"]; }); } - }' + }', ], 'allowPassingToCovariantCollectionWithoutExtends' => [ 'code' => 'view(); } - getView(new Cat());' + getView(new Cat());', ], 'allowExtendingInterfaceWithExtraParam' => [ 'code' => ' $col */ - function usesElementInterfaceCollection(CollectionInterface $col) :void {}' + function usesElementInterfaceCollection(CollectionInterface $col) :void {}', ], 'extendsCovariantCoreClassWithSameParamCount' => [ 'code' => ' $a */ function takesMyArrayOfException(MyArray $a) : void { takesIteratorAggregate($a); - }' + }', ], 'extendsCovariantCoreClassWithSubstitutedParam' => [ 'code' => ' $a */ function takesMyArrayOfException(MyArray $a) : void { takesIteratorAggregate($a); - }' + }', ], 'allowImmutableCovariance' => [ 'code' => 'reference; } - }' + }', ], 'allowCovariantReturnOnArrays' => [ 'code' => 'reference; } }', - 'error_message' => 'InvalidTemplateParam' + 'error_message' => 'InvalidTemplateParam', ], 'preventExtendingCoreWithCovariantParam' => [ 'code' => 'm = new Impl(); } - }' + }', ], 'constructorCheckInChildClassArrayType' => [ 'code' => ' */ - class Test extends C {}' + class Test extends C {}', ], 'eitherType' => [ 'code' => ' [ 'code' => 'extract(); - }' + }', ], 'extendIterable' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ - '$dogs' => 'CollectionChild' - ] + '$dogs' => 'CollectionChild', + ], ], 'inheritTemplateParamViaConstructorDifferentName' => [ 'code' => ' [ - '$dogs' => 'CollectionChild' - ] + '$dogs' => 'CollectionChild', + ], ], 'extendsClassWithClassStringProperty' => [ 'code' => 'c = $c; } - }' + }', ], 'implementsParameterisedIterator' => [ 'code' => ' [ 'code' => ' */ public function slice(int $start, int $length): ICollection; - }' + }', ], 'concreteDefinesNoSignatureTypes' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'container->get(1)->foo = 2; } - }' + }', ], 'templateYieldFrom' => [ 'code' => 'decorated; } - }' + }', ], 'extendsTemplatedInterface' => [ 'code' => ' [ 'code' => ' [ 'code' => 'c->filter($p); } - }' + }', ], 'implementsTemplatedTwice' => [ 'code' => 'get();', 'assertions' => [ '$foo' => 'string', - ] + ], ], 'extendsWithJustParentConstructor' => [ 'code' => 'subject = $subject; } - }' + }', ], 'annotationDefinedInInheritedInterface' => [ 'code' => 'boo("boo"); - }' + }', ], 'allowPropertyCoercionExtendedParam' => [ 'code' => ' [ 'code' => ' [ 'code' => 'execute($query); - }' + }', ], 'respectExtendsAnnotationWhenVerifyingFinalChildReturnType' => [ 'code' => ' [ 'code' => 'collection; } - }' + }', ], 'setInheritedTemplatedPropertyOutsideClass' => [ 'code' => 'value = 10;' + $watcher->value = 10;', ], 'setRetemplatedPropertyOutsideClass' => [ 'code' => ' $watcher */ $watcher = new Watcher2(0); - $watcher->value = 10;' + $watcher->value = 10;', ], 'argInSameLocationShouldHaveConvertedParams' => [ 'code' => ' [ 'code' => ' [ 'code' => ' 'StringKeyedPair', '$a' => 'int', '$b' => 'string', - ] + ], ], 'templateInheritedPropertySameName' => [ 'code' => ' 'StringKeyedPair', '$a' => 'int', '$b' => 'string', - ] + ], ], 'templateInheritedPropertySameNameFlipped' => [ 'code' => ' 'StringKeyedPair', '$a' => 'int', '$b' => 'string', - ] + ], ], 'implementExtendedInterfaceWithMethodOwnTemplateParams' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'implementInterfaceWithMethodOwnTemplateParams' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'staticShouldBeBoundInCall' => [ 'code' => ' [ 'code' => ' [ 'code' => 'getTypes(); - }' + }', ], 'unwrapExtendedTypeWhileInferring' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 't; } - }' + }', ], 'classStringTemplatedExtends' => [ 'code' => 'handle(StringRequest::class); } - }' + }', ], 'extendTemplateTypeInParamAsType' => [ 'code' => '): void */ public function i(): Closure; - }' + }', ], 'extendsWithArraySameObject' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'extendsWithArrayDifferentObject' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'allowNestedInterfaceDefinitions' => [ 'code' => ' [ 'code' => ' $param */ abstract public function foo($param): void; - }' + }', ], 'extendAndImplementedTemplatedProperty' => [ 'code' => ' [ 'code' => 'obj->foo(); } - }' + }', ], 'extendAndImplementedTemplatedIntersectionReceives' => [ 'code' => ' */ class BTestCase extends ATestCase {} - new BTestCase(new BMock());' + new BTestCase(new BMock());', ], 'yieldTemplated' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 1, ]; } - }' + }', ], 'inheritCorrectParams' => [ 'code' => ' [ 'code' => 'map($function); - }' + }', ], 'extendStubbedInterfaceTwice' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'inheritInterfacesManyTimes' => [ 'code' => ' */ function getIterator(): Traversable; - }' + }', ], 'extendsWithAlias' => [ 'code' => ' [ 'code' => 'closure; } - }' + }', ], 'inferPropertyTypeOnThisInstanceofExtended' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'extendTemplatedClassString' => [ 'code' => 'c; } - }' + }', ], 'templateExtendsFewerTemplateParameters' => [ 'code' => ' 'InvalidDocblock' + 'error_message' => 'InvalidDocblock', ], 'invalidReturnParamType' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'preventExtendingWithTemplatedClassWithExplicitTypeGiven' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'noCrashForTooManyTemplateParams' => [ 'code' => ' 'TooManyTemplateParams' + 'error_message' => 'TooManyTemplateParams', ], 'concreteDefinesSignatureTypesDifferent' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'preventExplicitMethodClassTemplateReturn' => [ 'code' => ' 'LessSpecificReturnStatement' + 'error_message' => 'LessSpecificReturnStatement', ], 'preventImplicitMethodClassTemplateReturn' => [ 'code' => ' 'LessSpecificReturnStatement' + 'error_message' => 'LessSpecificReturnStatement', ], 'preventBadOverrideWhenVerifyingNonFinalChildReturnType' => [ 'code' => ' 'LessSpecificImplementedReturnType' + 'error_message' => 'LessSpecificImplementedReturnType', ], 'preventBadLocallyDefinedDocblockWhenVerifyingChildReturnType' => [ 'code' => ' 'LessSpecificReturnStatement' + 'error_message' => 'LessSpecificReturnStatement', ], 'detectIssueInDoublyInheritedMethod' => [ 'code' => 'test($f); }', - 'error_message' => 'ArgumentTypeCoercion' + 'error_message' => 'ArgumentTypeCoercion', ], 'templateExtendsSameNameWithStaticCallUnsafeTemplatedExtended' => [ 'code' => ' */ class ObjectContainer extends Container {}', - 'error_message' => 'InvalidTemplateParam' + 'error_message' => 'InvalidTemplateParam', ], 'templateExtendsSameNameWithStaticCallUnsafeMissingExtendedParam' => [ 'code' => ' */ class ObjectContainer extends Container {}', - 'error_message' => 'MissingTemplateParam' + 'error_message' => 'MissingTemplateParam', ], 'templateExtendsSameNameWithStaticCallNoExtendsParams' => [ 'code' => ' 'MissingTemplateParam' + 'error_message' => 'MissingTemplateParam', ], 'templateExtendsSameNameWithStaticCallUnsafeTooManyTemplatedExtended' => [ 'code' => ' */ class ObjectContainer extends Container {}', - 'error_message' => 'TooManyTemplateParams' + 'error_message' => 'TooManyTemplateParams', ], 'templateExtendsSameNameWithStaticCallUnsafeInstantiationParameterised' => [ 'code' => 't; } }', - 'error_message' => 'UnsafeGenericInstantiation' + 'error_message' => 'UnsafeGenericInstantiation', ], 'templateExtendsSameNameWithStaticCallUnsafeInstantiationNoParameters' => [ 'code' => 't; } }', - 'error_message' => 'UnsafeGenericInstantiation' + 'error_message' => 'UnsafeGenericInstantiation', ], ]; } diff --git a/tests/Template/ClassTemplateTest.php b/tests/Template/ClassTemplateTest.php index f447f8d8c00..1acee39179e 100644 --- a/tests/Template/ClassTemplateTest.php +++ b/tests/Template/ClassTemplateTest.php @@ -1953,7 +1953,7 @@ public function set($val) : void { public function get() { return $this->value; } - }' + }', ], 'templatedInvoke' => [ 'code' => 'get(); - }' + }', ], 'templatedLiteralStringReplacement' => [ 'code' => ' $value */ function client($value): void {} - client(value("awdawd"));' + client(value("awdawd"));', ], 'yieldFromGenericObjectNotExtendingIterator' => [ 'code' => ' [], - 'ignored_issues' => ['TooManyTemplateParams'] + 'ignored_issues' => ['TooManyTemplateParams'], ], 'coerceEmptyArrayToGeneral' => [ 'code' => ' [ 'code' => ' [ 'code' => 'parent === null; // So TP does contain null } - }' + }', ], 'useMethodWithExistingGenericParam' => [ 'code' => 'getFoo() === "foo"; } ); - }' + }', ], 'unboundVariableIsEmptyInInstanceMethod' => [ 'code' => 'collectInstance("a");' + echo (new A)->collectInstance("a");', ], 'unboundVariableIsEmptyInStaticMethod' => [ 'code' => ' [ 'code' => ' */ - class LazyArrayCollection extends ArrayCollection {}' + class LazyArrayCollection extends ArrayCollection {}', ], 'weakReferenceIsTyped' => [ 'code' => ' [ 'code' => 't; return $t::factory(); } - }' + }', ], 'uasortCallableInMethod' => [ 'code' => ' [ 'code' => ' [ 'code' => 'type = $type; } - }' + }', ], 'createEmptyArrayCollection' => [ 'code' => ' [ - '$a' => 'ArrayCollection' - ] + '$a' => 'ArrayCollection', + ], ], 'newGenericBecomesPropertyTypeValidArg' => [ 'code' => 'elements[$key] = $t; } - }' + }', ], 'allowPropertyCoercion' => [ 'code' => ' [ 'code' => ' [ - '$packages' => 'Collection' - ] + '$packages' => 'Collection', + ], ], 'assertSameOnTemplatedProperty' => [ 'code' => ' [ 'code' => ' */ $a = new A(); - if (null !== $a->filter) {}' + if (null !== $a->filter) {}', ], 'setTemplatedPropertyOutsideClass' => [ 'code' => ' $watcher */ $watcher = new Watcher(0); - $watcher->value = 0;' + $watcher->value = 0;', ], 'callableAsClassStringArray' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [], - 'ignored_issues' => ['MissingClosureParamType'] + 'ignored_issues' => ['MissingClosureParamType'], ], 'templatedPropertyAllowsNull' => [ 'code' => 'key = $key; } - }' + }', ], 'templatePropertyWithoutParams' => [ 'code' => 'onEach; $fn($o); - }' + }', ], 'changePropertyTypeOfTemplate' => [ 'code' => 'x = 1; - }' + }', ], 'multipleMatchingObjectsInUnion' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'templateWithLateResolvedType' => [ 'code' => ' $foo */ - $foo = new Foo();' + $foo = new Foo();', ], 'SKIPPED-extendedPropertyTypeParameterised' => [ 'code' => ' */ abstract protected function createMap(): Map; - }' + }', ], 'looseEquality' => [ 'code' => ' [ 'code' => 'entity = $qux; } } - }' + }', ], 'flippedParamsMethodInside' => [ 'code' => 'getTraversable(); } - }' + }', ], 'flippedParamsMethodOutside' => [ 'code' => ' */ public abstract function getTraversable() : Traversable; - }' + }', ], 'flippedParamsPropertyInside' => [ 'code' => 'traversable; } - }' + }', ], 'flippedParamsPropertyOutside' => [ 'code' => ' */ public $traversable; - }' + }', ], 'simpleTemplate' => [ 'code' => ' [ 'code' => 'elements); return self::createFrom($new_elements); } - }' + }', ], 'arrayCollectionMapExternal' => [ 'code' => ' [ 'code' => ' [ 'code' => 'foo($e); } - }' + }', ], 'templatedStaticUnion' => [ 'code' => 'v); } } - }' + }', ], 'templatedTypeWithLimitGoesIntoTemplatedType' => [ 'code' => 'value; } - }' + }', ], 'newWithoutInferredTemplate' => [ 'code' => ' [ - '$f' => 'Foo' - ] + '$f' => 'Foo', + ], ], 'PHP80-weakmapIsGeneric' => [ 'code' => 'getOrElse([2, 4])[0];', 'assertions' => [ - '$b===' => '1|2' - ] + '$b===' => '1|2', + ], ], 'generaliseTemplatedString' => [ 'code' => 'data === "David") {}' + if ($me->data === "David") {}', ], 'generaliseTemplatedArray' => [ 'code' => 'data["name"] === "David") {}' + if ($me->data["name"] === "David") {}', ], 'allowCovariantBoundsMismatchSameContainers' => [ 'code' => ' [ 'code' => 'set(new A()); foo($container->get()); - ' + ', ], 'templateOnDocblockMethodOnInterface' => [ 'code' => ' $container */ $container->set(new A()); foo($container->get()); - ' + ', ], 'refineTemplateTypeOfUnion' => [ 'code' => 'get();', 'assertions' => [ '$a===' => 'FutureB<123>', - '$r===' => 'ArrayObject' - ] + '$r===' => 'ArrayObject', + ], ], 'return TemplatedClass' => [ 'code' => ' $foo */ function takesFooDerived($foo): void {}', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'possiblySpecialiseTypeBeforeReturning' => [ 'code' => ' $foo */ function takesFooDerived($foo): void {}', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'preventUseWithMoreSpecificParamInt' => [ 'code' => 'add(456); }', - 'error_message' => 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'preventUseWithMoreSpecificParamEmptyArray' => [ 'code' => 'add([]); }', - 'error_message' => 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'preventTemplatedCorrectionBeingWrittenTo' => [ 'code' => ' 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'noClassTemplatesInStaticMethods' => [ 'code' => ' 'UndefinedDocblockClass' + 'error_message' => 'UndefinedDocblockClass', ], 'newGenericBecomesPropertyTypeInvalidArg' => [ 'code' => 'elements[$key] = $t; } }', - 'error_message' => 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'preventIteratorAggregateToIterableWithDifferentTypes' => [ 'code' => ' 'InvalidArgument', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'bindClosureParamAccurately' => [ 'code' => ' [ '$a' => 'string', '$b' => 'array', - '$c' => 'array|string' - ] + '$c' => 'array|string', + ], ], 'nestedConditionalOnIntReturnType' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'float|int', '$float2' => 'float', '$float3' => 'float|int', - ] + ], ], 'possiblyNullArgumentStillMatchesType' => [ 'code' => ' [ '$int' => 'int', - ] + ], ], 'nestedClassConstantConditionalComparison' => [ 'code' => ' 'string', '$int2' => 'int', '$bool2' => 'bool', - ] + ], ], 'variableConditionalSyntax' => [ 'code' => ' [ 'code' => ' [ 'code' => 'test1(); - app()->test2();' + app()->test2();', ], 'refineTypeInConditionalWithString' => [ 'code' => ' [ '$a' => 'string', '$b' => 'string', - ] + ], ], 'refineTypeInConditionalWithClassName' => [ 'code' => ' [ '$a' => 'AChild', '$b' => 'A', - ] + ], ], 'isTemplateArrayCheck' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$c1' => 'Promise', '$c2' => 'Promise', - ] + ], ], 'conditionalReturnShouldMatchInherited' => [ 'code' => ' [ 'code' => ' 'false', '$b' => 'string', '$c' => 'string', - ] + ], ], 'namespaceFuncNumArgs' => [ 'code' => ' [ 'code' => ' $c */ function getNullableDateTime(C $c) : ?DateTime { return $c->get("t", null); - }' + }', ], 'literalStringIsNotAClassString' => [ 'code' => 'deserialize($data, \'array\'); - }' + }', ], 'inheritConditional' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'object', '$expect_a_object' => 'A', '$expect_mixed_from_literal' => 'mixed', - ] + ], ], 'isArryCheckOnTemplate' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'getParams()["a"]; /** @psalm-suppress MixedArgument */ - echo (new Request)->getParams(Request::SOURCE_GET)["a"];' + echo (new Request)->getParams(Request::SOURCE_GET)["a"];', ], 'conditionalArrayValues' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$something' => 'int', - '$somethingElse' => 'string' + '$somethingElse' => 'string', ], 'ignored_issues' => [], - 'php_version' => '7.2' - ] + 'php_version' => '7.2', + ], ]; } } diff --git a/tests/Template/FunctionClassStringTemplateTest.php b/tests/Template/FunctionClassStringTemplateTest.php index d6c4312c93f..d3dfbabda97 100644 --- a/tests/Template/FunctionClassStringTemplateTest.php +++ b/tests/Template/FunctionClassStringTemplateTest.php @@ -663,7 +663,7 @@ function test(string $a1, string $a2) { $b_or_c = test(B::class, C::class);', 'assertions' => [ '$b_or_c' => 'B|C', - ] + ], ], 'allowComparisonWithoutCrash' => [ 'code' => ' [ 'code' => ' 'Closure(object):void' + 'error_message' => 'Closure(object):void', ], 'preventClassStringInPlaceOfTemplatedClassString' => [ 'code' => 'create(MusicFile::class); }', - 'error_message' => 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], ]; } diff --git a/tests/Template/FunctionTemplateAssertTest.php b/tests/Template/FunctionTemplateAssertTest.php index 19cf9b9b4b1..e8f9c855d8f 100644 --- a/tests/Template/FunctionTemplateAssertTest.php +++ b/tests/Template/FunctionTemplateAssertTest.php @@ -550,7 +550,7 @@ function consume2($value) nullOrImplementsInterface($value, A::class); return $value; - }' + }', ], 'assertTemplatedTemplateSimple' => [ 'code' => 'is($x); return $x; - }' + }', ], 'assertTemplatedTemplateIfTrue' => [ 'code' => 'is($x) ? $x : false; - }' + }', ], 'assertOnClass' => [ 'code' => 'matches($value)); return $value; } - }' + }', ], 'noCrashWhenAsserting' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $l) { assertSame($i, $l); } - }' + }', ], 'assertSameOnMemoizedMethodCall' => [ 'code' => ' [ 'code' => 'is($mixed)) { acceptsIntList($mixed); - }' + }', ], 'assertListFromGeneric' => [ 'code' => 'assert($mixed); - acceptsIntList($mixed);' + acceptsIntList($mixed);', ], 'assertArrayFromGeneric' => [ 'code' => 'assert($mixed); - acceptsArray($mixed);' + acceptsArray($mixed);', ], ]; } diff --git a/tests/Template/FunctionTemplateTest.php b/tests/Template/FunctionTemplateTest.php index a6edfaac9e4..1a99b80e0cf 100644 --- a/tests/Template/FunctionTemplateTest.php +++ b/tests/Template/FunctionTemplateTest.php @@ -744,7 +744,7 @@ function bar($foo): void { if (!is_object($foo)) {} if (is_callable($foo)) {} if (!is_callable($foo)) {} - }' + }', ], 'interpretFunctionCallableReturnValue' => [ 'code' => ' [ 'code' => 'newInstance(); - }' + }', ], 'unboundVariableIsEmpty' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ - '$a' => 'iterable' - ] + '$a' => 'iterable', + ], ], 'testClosureCallableInference' => [ 'code' => ' [ - '$a' => 'iterable' - ] + '$a' => 'iterable', + ], ], 'possiblyNullMatchesTemplateType' => [ 'code' => ' [ '$a' => 'A', - ] + ], ], 'possiblyNullMatchesAnotherTemplateType' => [ 'code' => ' [ 'code' => ' [ 'code' => 'bar();' + createProxy(A::class, function(object $o):void {})->bar();', ], 'bottomTypeInNamespacedCallableShouldMatch' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'mixedDoesntSwallowNull' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'templateChildClass' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' "a"; } - map(iter(), "mapper");' + map(iter(), "mapper");', ], 'dontScreamForArithmeticsOnIntTemplates' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' - ] + 'php_version' => '8.0', + ], ]; } @@ -2089,13 +2089,13 @@ public function __invoke(A $a) : void { } apply(new Printer(), new B());', - 'error_message' => 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'invalidTemplateDocblock' => [ 'code' => ' 'MissingDocblockType' + 'error_message' => 'MissingDocblockType', ], 'returnNamedObjectWhereTemplateIsExpected' => [ 'code' => 'bar();', - 'error_message' => 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'bottomTypeInNamespacedCallableShouldClash' => [ 'code' => 'bar();', - 'error_message' => 'InvalidArgument' + 'error_message' => 'InvalidArgument', ], 'preventBadArraySubtyping' => [ 'code' => ' 123]; return $b; }', - 'error_message' => 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'modifyTemplatedShape' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'preventArrayOverwriting' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'catchIssueInTemplatedFunctionInsideClass' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'keyOfTemplateNotIncludesInt' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'keyOfUnresolvedTemplateParamIsStillChecked' => [ 'code' => ' 'MismatchingDocblockReturnType' + 'error_message' => 'MismatchingDocblockReturnType', ], ]; } diff --git a/tests/Template/NestedTemplateTest.php b/tests/Template/NestedTemplateTest.php index dd1bca2081b..7db4c52778f 100644 --- a/tests/Template/NestedTemplateTest.php +++ b/tests/Template/NestedTemplateTest.php @@ -44,7 +44,7 @@ class TeacherModel extends BaseModel {} class StudentRepository extends BaseRepository {} /** @extends BaseRepository */ - class TeacherRepository extends BaseRepository {}' + class TeacherRepository extends BaseRepository {}', ], 'unwrapIndirectGenericTemplated' => [ 'code' => 'unwrap(); - }' + }', ], 'unwrapFromTemplatedClassString' => [ 'code' => 'unwrap(); } - $result = load(StringWrapper::class);' + $result = load(StringWrapper::class);', ], 'unwrapNestedTemplateWithReset' => [ 'code' => ' */ class StudentRepository extends BaseRepository {}', - 'error_message' => 'InvalidTemplateParam' + 'error_message' => 'InvalidTemplateParam', ], ]; } diff --git a/tests/Template/PropertiesOfTemplateTest.php b/tests/Template/PropertiesOfTemplateTest.php index cdcb95c5865..a5724751107 100644 --- a/tests/Template/PropertiesOfTemplateTest.php +++ b/tests/Template/PropertiesOfTemplateTest.php @@ -76,8 +76,8 @@ public function __construct(public $a) {} $objAsArray = asArray($obj); ', 'assertions' => [ - '$objAsArray===' => 'array{a: 42, b: bool, c: string, ...}' - ] + '$objAsArray===' => 'array{a: 42, b: bool, c: string, ...}', + ], ], 'privatePropertiesPicksPrivate' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'privatePropertiesPicksNoPublic' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'privatePropertiesPicksNoProtected' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'protectedPropertiesPicksNoPublic' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'protectedPropertiesPicksNoPrivate' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'publicPropertiesPicksNoPrivate' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'publicPropertiesPicksNoProtected' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], 'propertiesOfNestedTemplatesPickPublic' => [ 'code' => ' 'InvalidArrayOffset' + 'error_message' => 'InvalidArrayOffset', ], ]; } diff --git a/tests/Template/TraitTemplateTest.php b/tests/Template/TraitTemplateTest.php index f7651b3f5de..8fd8d9317ee 100644 --- a/tests/Template/TraitTemplateTest.php +++ b/tests/Template/TraitTemplateTest.php @@ -331,7 +331,7 @@ protected function doNormalize($v): string { return trim($v); } - }' + }', ], 'useTraitReturnTypeForInheritedClass' => [ 'code' => ' [ 'code' => ' */ use A; - }' + }', ], 'inheritTraitPropertyArray' => [ 'code' => ' */ use A; - }' + }', ], 'applyTemplatedValueInTraitProperty' => [ 'code' => 'value = $value; } - }' + }', ], 'traitSelfAsParam' => [ 'code' => ' [ 'code' => 'value; } - }' + }', ], ]; } @@ -672,7 +672,7 @@ public function foo($offset) : void { $this->offsetGet($offset)->bar(); } }', - 'error_message' => 'PossiblyNullReference' + 'error_message' => 'PossiblyNullReference', ], 'possiblyNullReferenceOnTraitDefinedMethodExtended' => [ 'code' => 'offsetGet($offset)->bar(); } }', - 'error_message' => 'MixedMethodCall' + 'error_message' => 'MixedMethodCall', ], ]; } diff --git a/tests/Template/ValueOfTemplateTest.php b/tests/Template/ValueOfTemplateTest.php index 0f66feb9814..011181e7beb 100644 --- a/tests/Template/ValueOfTemplateTest.php +++ b/tests/Template/ValueOfTemplateTest.php @@ -26,7 +26,7 @@ public function providerValidCodeParse(): iterable function getValues($array) { return array_values($array); } - ' + ', ], 'SKIPPED-acceptsIfInArrayFn' => [ 'code' => ' [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'valueOfTemplateNotIncludesInt' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'valueOfUnresolvedTemplateParamIsStillChecked' => [ 'code' => ' 'MismatchingDocblockReturnType' + 'error_message' => 'MismatchingDocblockReturnType', ], ]; } diff --git a/tests/TestCase.php b/tests/TestCase.php index d617b14aee3..00739cbccb0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -71,12 +71,12 @@ public function setUp(): void $providers = new Providers( $this->file_provider, - new FakeParserCacheProvider() + new FakeParserCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $this->testConfig, - $providers + $providers, ); $this->project_analyzer->setPhpVersion('7.4', 'tests'); @@ -123,7 +123,7 @@ public function analyzeFile(string $file_path, Context $context, bool $track_unu $file_analyzer = new FileAnalyzer( $this->project_analyzer, $file_path, - $codebase->config->shortenFileName($file_path) + $codebase->config->shortenFileName($file_path), ); $file_analyzer->analyze($context); diff --git a/tests/TestConfig.php b/tests/TestConfig.php index 518fa0f987c..dc72087410f 100644 --- a/tests/TestConfig.php +++ b/tests/TestConfig.php @@ -34,7 +34,7 @@ public function __construct() self::$cached_project_files = ProjectFileFilter::loadFromXMLElement( new SimpleXMLElement($this->getContents()), $this->base_dir, - true + true, ); } diff --git a/tests/ThisOutTest.php b/tests/ThisOutTest.php index b0d4b4f6436..a537996aeae 100644 --- a/tests/ThisOutTest.php +++ b/tests/ThisOutTest.php @@ -31,7 +31,7 @@ public function baz() { $bar = new Bar(); $bar->baz(); $bar->far(); - ' + ', ], 'changeTemplateArguments' => [ 'code' => 'data; } '$data1===' => 'list<1>', '$data2===' => 'list<2>', '$data3===' => 'list<2|3>', - ] - ] + ], + ], ]; } } diff --git a/tests/ThrowsAnnotationTest.php b/tests/ThrowsAnnotationTest.php index da8b5f44b28..4caea968cff 100644 --- a/tests/ThrowsAnnotationTest.php +++ b/tests/ThrowsAnnotationTest.php @@ -19,7 +19,7 @@ public function testUndefinedClassAsThrows(): void /** * @throws Foo */ - function bar() : void {}' + function bar() : void {}', ); $context = new Context(); @@ -40,7 +40,7 @@ class Foo {} /** * @throws Foo */ - function bar() : void {}' + function bar() : void {}', ); $context = new Context(); @@ -60,7 +60,7 @@ class Foo { * @throws MyException|Throwable */ public function bar() : void {} - }' + }', ); $context = new Context(); @@ -87,7 +87,7 @@ function foo(int $x, int $y) : int { } return intdiv($x, $y); - }' + }', ); $context = new Context(); @@ -116,7 +116,7 @@ function foo(int $x, int $y) : int { } return intdiv($x, $y); - }' + }', ); $context = new Context(); @@ -144,7 +144,7 @@ function foo(int $x, int $y) : int { } return intdiv($x, $y); - }' + }', ); $context = new Context(); @@ -168,7 +168,7 @@ function foo(int $x, int $y) : int { } return intdiv($x, $y); - }' + }', ); $context = new Context(); @@ -203,7 +203,7 @@ function foo(int $x, int $y) : int { function bar(int $x, int $y) : void { foo($x, $y); - }' + }', ); $context = new Context(); @@ -240,7 +240,7 @@ function foo(int $x, int $y) : int { */ function bar(int $x, int $y) : void { foo($x, $y); - }' + }', ); $context = new Context(); @@ -277,7 +277,7 @@ public function test(): string return ""; } } - }' + }', ); $context = new Context(); @@ -314,7 +314,7 @@ function bar(int $x, int $y) : void { } catch (RangeException $e) { } catch (InvalidArgumentException $e) {} - }' + }', ); $context = new Context(); @@ -353,7 +353,7 @@ function bar(int $x, int $y) : void { } catch (\RangeException $e) { } - }' + }', ); $context = new Context(); @@ -373,7 +373,7 @@ public function testEmptyThrows(): void /** * @throws */ - function foo(int $x, int $y) : int {}' + function foo(int $x, int $y) : int {}', ); $context = new Context(); @@ -408,7 +408,7 @@ function bar(int $x, int $y) : void { try { foo($x, $y); } catch (Exception $e) {} - }' + }', ); $context = new Context(); @@ -441,7 +441,7 @@ public function test(): void throw new \InvalidArgumentException(); } } - ' + ', ); $context = new Context(); @@ -471,7 +471,7 @@ public function test(): void throw new \InvalidArgumentException(); } } - ' + ', ); $context = new Context(); @@ -505,7 +505,7 @@ public function test(): void throw new \OutOfBoundsException(); } } - ' + ', ); $context = new Context(); @@ -539,7 +539,7 @@ public function test(): void throw new \InvalidArgumentException(); } } - ' + ', ); $context = new Context(); @@ -574,7 +574,7 @@ public function test(): void throw new \InvalidArgumentException(); } } - ' + ', ); $context = new Context(); @@ -600,7 +600,7 @@ function foo() : void { } catch (Exception $e) { throw new RuntimeException("bar"); } - }' + }', ); $context = new Context(); @@ -627,7 +627,7 @@ function method(): void } catch (\Exception $e) { throw new \RuntimeException(); } - }' + }', ); $context = new Context(); diff --git a/tests/ThrowsInGlobalScopeTest.php b/tests/ThrowsInGlobalScopeTest.php index ea8cd2c4e8f..afdc9029d3f 100644 --- a/tests/ThrowsInGlobalScopeTest.php +++ b/tests/ThrowsInGlobalScopeTest.php @@ -33,7 +33,7 @@ function foo(int $x, int $y) : int { return intdiv($x, $y); } - foo(0, 0);' + foo(0, 0);', ); $context = new Context(); @@ -67,7 +67,7 @@ function foo(int $x, int $y) : int { try { foo(0, 0); - } catch (Exception $e) {}' + } catch (Exception $e) {}', ); $context = new Context(); @@ -94,7 +94,7 @@ function foo(int $x, int $y) : int { return intdiv($x, $y); } - foo(0, 0);' + foo(0, 0);', ); $context = new Context(); @@ -128,7 +128,7 @@ function foo(int $x, int $y) : int { return intdiv($x, $y); } - foo(0, 0);' + foo(0, 0);', ); $context = new Context(); @@ -146,7 +146,7 @@ public function testUncaughtThrow(): void $this->addFile( 'somefile.php', ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'implicitStringable' => [ 'code' => ' [ 'code' => ' 'InvalidToString', 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'implicitCastWithStrictTypes' => [ 'code' => ' 'ImplicitToStringCast' + 'error_message' => 'ImplicitToStringCast', ], 'implicitCastInList' => [ 'code' => ' 'ImplicitToStringCast' + 'error_message' => 'ImplicitToStringCast', ], 'implicitCastInTuple' => [ 'code' => ' 'ImplicitToStringCast' + 'error_message' => 'ImplicitToStringCast', ], 'implicitCastInShape' => [ 'code' => ' 'ImplicitToStringCast' + 'error_message' => 'ImplicitToStringCast', ], 'implicitCastInIterable' => [ 'code' => ' 'ImplicitToStringCast' + 'error_message' => 'ImplicitToStringCast', ], 'implicitCastInToString' => [ 'code' => ' 'ImplicitToStringCast' + 'error_message' => 'ImplicitToStringCast', ], 'toStringTypecastNonString' => [ 'code' => ' [ 'MixedAssignment', ], - ] + ], ]; } } diff --git a/tests/TraitTest.php b/tests/TraitTest.php index f6d75d7903e..20e5c8cae3f 100644 --- a/tests/TraitTest.php +++ b/tests/TraitTest.php @@ -885,7 +885,7 @@ class C { public function bar() { return $this; } - }' + }', ], 'classAliasedTrait' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'getMessage();' + echo $lastException->getMessage();', ], 'varSetInOnlyCatchWithNull' => [ 'code' => 'getMessage();' + echo $lastException->getMessage();', ], 'allowDoubleNestedLoop' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'issetInCatch' => [ 'code' => ' [ 'code' => ' 'NullableReturnStatement' + 'error_message' => 'NullableReturnStatement', ], 'isAlwaysDefinedInFinally' => [ 'code' => ' 'RedundantCondition' + 'error_message' => 'RedundantCondition', ], ]; } diff --git a/tests/TypeAnnotationTest.php b/tests/TypeAnnotationTest.php index ec23ccd462c..a4dc169d510 100644 --- a/tests/TypeAnnotationTest.php +++ b/tests/TypeAnnotationTest.php @@ -198,7 +198,7 @@ function toArray(): array { (new Phone)->toArray() ); } - }' + }', ], 'classTypeAliasImportWithAlias' => [ 'code' => 'toArray()); } - }' + }', ], 'classTypeAliasDirectUsage' => [ 'code' => 'toArray()); } - }' + }', ], 'classTypeAliasFromExternalNamespace' => [ 'code' => 'toArray(); } } - }' + }', ], 'importTypeForParam' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' */ class C implements A {} - ' + ', ], 'importedTypeAliasAsTypeParameterForExtendedClass' => [ 'code' => ' [ '$output' => 'string', - ] + ], ], 'importedTypeUsedInOtherType' => [ 'code' => ' [ '$output===' => 'list<1|2>', - ] - ] + ], + ], ]; } diff --git a/tests/TypeCombinationTest.php b/tests/TypeCombinationTest.php index b2219e92007..071b4b8d617 100644 --- a/tests/TypeCombinationTest.php +++ b/tests/TypeCombinationTest.php @@ -28,7 +28,7 @@ public function testValidTypeCombination(string $expected, array $types): void $this->assertSame( $expected, - TypeCombiner::combine($converted_types)->getId() + TypeCombiner::combine($converted_types)->getId(), ); } @@ -544,7 +544,7 @@ public function providerTestValidTypeCombination(): array 'callable', [ 'callable-string', - 'callable' + 'callable', ], ], 'combineCallableAndCallableObject' => [ @@ -558,7 +558,7 @@ public function providerTestValidTypeCombination(): array 'callable', [ 'callable-object', - 'callable' + 'callable', ], ], 'combineCallableAndCallableArray' => [ @@ -572,7 +572,7 @@ public function providerTestValidTypeCombination(): array 'callable', [ 'callable-array', - 'callable' + 'callable', ], ], 'combineCallableArrayAndArray' => [ @@ -621,7 +621,7 @@ public function providerTestValidTypeCombination(): array 'list{null|string, ..., string>}', [ 'non-empty-list', - 'array{null}' + 'array{null}', ], ], 'combineZeroAndPositiveInt' => [ @@ -696,112 +696,112 @@ public function providerTestValidTypeCombination(): array [ 'non-empty-array', 'array{0?:int}', - ] + ], ], 'combineNonEmptyStringAndLiteral' => [ 'non-empty-string', [ 'non-empty-string', '"foo"', - ] + ], ], 'combineLiteralAndNonEmptyString' => [ 'non-empty-string', [ '"foo"', - 'non-empty-string' - ] + 'non-empty-string', + ], ], 'combineTruthyStringAndNonEmptyString' => [ 'non-empty-string', [ 'truthy-string', - 'non-empty-string' - ] + 'non-empty-string', + ], ], 'combineNonFalsyNonEmptyString' => [ 'non-empty-string', [ 'non-falsy-string', - 'non-empty-string' - ] + 'non-empty-string', + ], ], 'combineNonEmptyNonFalsyString' => [ 'non-empty-string', [ 'non-empty-string', - 'non-falsy-string' - ] + 'non-falsy-string', + ], ], 'combineNonEmptyStringAndNumericString' => [ 'non-empty-string', [ 'non-empty-string', - 'numeric-string' - ] + 'numeric-string', + ], ], 'combineNumericStringAndNonEmptyString' => [ 'non-empty-string', [ 'numeric-string', - 'non-empty-string' - ] + 'non-empty-string', + ], ], 'combineNonEmptyLowercaseAndNonFalsyString' => [ 'non-empty-string', [ 'non-falsy-string', 'non-empty-lowercase-string', - ] + ], ], 'combineNonEmptyAndEmptyScalar' => [ 'scalar', [ 'non-empty-scalar', 'empty-scalar', - ] + ], ], 'combineLiteralStringAndNonspecificLiteral' => [ 'literal-string', [ 'literal-string', '"foo"', - ] + ], ], 'combineNonspecificLiteralAndLiteralString' => [ 'literal-string', [ '"foo"', 'literal-string', - ] + ], ], 'combineLiteralIntAndNonspecificLiteral' => [ 'literal-int', [ 'literal-int', '5', - ] + ], ], 'combineNonspecificLiteralAndLiteralInt' => [ 'literal-int', [ '5', 'literal-int', - ] + ], ], 'combineNonspecificLiteralAndPositiveInt' => [ 'int', [ 'positive-int', 'literal-int', - ] + ], ], 'combinePositiveAndLiteralInt' => [ 'int', [ 'literal-int', 'positive-int', - ] + ], ], 'combineNonEmptyStringAndNonEmptyNonSpecificLiteralString' => [ 'non-empty-string', diff --git a/tests/TypeComparatorTest.php b/tests/TypeComparatorTest.php index 3b2f4c6fdce..a648a74aace 100644 --- a/tests/TypeComparatorTest.php +++ b/tests/TypeComparatorTest.php @@ -27,12 +27,12 @@ public function setUp(): void $providers = new Providers( $this->file_provider, - new FakeParserCacheProvider() + new FakeParserCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); } @@ -48,8 +48,8 @@ public function testTypeAcceptsItself(string $type_string): void UnionTypeComparator::isContainedBy( $this->project_analyzer->getCodebase(), $type_1, - $type_2 - ) + $type_2, + ), ); } @@ -82,14 +82,14 @@ public function getAllBasicTypes(): array [ 'array' => true, // Requires a shape 'list' => true, // Requires a shape - ] + ], ); $basic_types['array{test: 123}'] = true; $basic_types['list{123}'] = true; return array_map( fn($type) => [$type], - array_keys($basic_types) + array_keys($basic_types), ); } @@ -105,8 +105,8 @@ public function testTypeAcceptsType(string $parent_type_string, string $child_ty UnionTypeComparator::isContainedBy( $this->project_analyzer->getCodebase(), $child_type, - $parent_type - ) + $parent_type, + ), ); } diff --git a/tests/TypeParseTest.php b/tests/TypeParseTest.php index 194f93c3b03..07f7c68ce06 100644 --- a/tests/TypeParseTest.php +++ b/tests/TypeParseTest.php @@ -35,12 +35,12 @@ public function setUp(): void $providers = new Providers( $this->file_provider, - new FakeParserCacheProvider() + new FakeParserCacheProvider(), ); $this->project_analyzer = new ProjectAnalyzer( $config, - $providers + $providers, ); } @@ -166,7 +166,7 @@ public function testTraversableAndIteratorOrNull(): void { $this->assertSame( 'Traversable&Iterator|null', - (string) Type::parseString('Traversable&Iterator|null') + (string) Type::parseString('Traversable&Iterator|null'), ); } @@ -174,7 +174,7 @@ public function testIteratorAndTraversableOrNull(): void { $this->assertSame( 'Iterator&Traversable|null', - (string) Type::parseString('Iterator&Traversable|null') + (string) Type::parseString('Iterator&Traversable|null'), ); } @@ -279,7 +279,7 @@ public function testPhpDocTKeyedArray(): void { $this->assertSame( 'array', - (string) Type::parseString('array{b: bool, d: string}[]') + (string) Type::parseString('array{b: bool, d: string}[]'), ); } @@ -378,7 +378,7 @@ public function testTKeyedArrayWithUnionArgs(): void { $this->assertSame( 'array{a: int|string, b: string}', - (string) Type::parseString('array{a: int|string, b: string}') + (string) Type::parseString('array{a: int|string, b: string}'), ); } @@ -386,7 +386,7 @@ public function testTKeyedArrayWithGenericArgs(): void { $this->assertSame( 'array{a: array, b: string}', - (string) Type::parseString('array{a: array, b: string}') + (string) Type::parseString('array{a: array, b: string}'), ); } @@ -394,7 +394,7 @@ public function testTKeyedArrayWithIntKeysAndUnionArgs(): void { $this->assertSame( 'list{null|stdClass}', - (string)Type::parseString('list{stdClass|null}') + (string)Type::parseString('list{stdClass|null}'), ); } @@ -402,12 +402,12 @@ public function testTKeyedArrayWithIntKeysAndGenericArgs(): void { $this->assertSame( 'list{array}', - (string)Type::parseString('array{array}') + (string)Type::parseString('array{array}'), ); $this->assertSame( 'list{array}', - (string)Type::parseString('array{array}') + (string)Type::parseString('array{array}'), ); } @@ -415,7 +415,7 @@ public function testTKeyedArrayOptional(): void { $this->assertSame( 'array{a: int, b?: int}', - (string)Type::parseString('array{a: int, b?: int}') + (string)Type::parseString('array{a: int, b?: int}'), ); } @@ -423,7 +423,7 @@ public function testTKeyedArrayNotSealed(): void { $this->assertSame( 'array{a: int, ...}', - (string)Type::parseString('array{a: int, ...}') + (string)Type::parseString('array{a: int, ...}'), ); } @@ -431,7 +431,7 @@ public function testTKeyedList(): void { $this->assertSame( 'list{int, int, string}', - (string)Type::parseString('list{int, int, string}') + (string)Type::parseString('list{int, int, string}'), ); } @@ -439,7 +439,7 @@ public function testTKeyedListOptional(): void { $this->assertSame( 'list{0: int, 1?: int, 2?: string}', - (string)Type::parseString('list{0: int, 1?: int, 2?: string}') + (string)Type::parseString('list{0: int, 1?: int, 2?: string}'), ); } @@ -448,7 +448,7 @@ public function testTKeyedArrayList(): void { $this->assertSame( 'list{int, int, string}', - (string)Type::parseString('array{int, int, string}') + (string)Type::parseString('array{int, int, string}'), ); } @@ -457,7 +457,7 @@ public function testTKeyedArrayNonList(): void { $this->assertSame( 'array{0: int, 1: int, 2: string}', - (string)Type::parseString('array{0: int, 1: int, 2: string}') + (string)Type::parseString('array{0: int, 1: int, 2: string}'), ); } @@ -466,7 +466,7 @@ public function testTKeyedCallableArrayNonList(): void { $this->assertSame( 'callable-array{0: class-string, 1: string}', - (string)Type::parseString('callable-array{0: class-string, 1: string}') + (string)Type::parseString('callable-array{0: class-string, 1: string}'), ); } @@ -525,7 +525,7 @@ public function testSimpleCallable(): void { $this->assertSame( 'callable(int, string):void', - (string)Type::parseString('callable(int, string) : void') + (string)Type::parseString('callable(int, string) : void'), ); } @@ -539,7 +539,7 @@ public function testCallableWithParamNames(): void { $this->assertSame( 'callable(int, string):void', - (string)Type::parseString('callable(int $foo, string $bar) : void') + (string)Type::parseString('callable(int $foo, string $bar) : void'), ); } @@ -547,7 +547,7 @@ public function testCallableReturningIntersection(): void { $this->assertSame( 'callable(int, string):I1&I2', - (string)Type::parseString('callable(int, string) : (I1&I2)') + (string)Type::parseString('callable(int, string) : (I1&I2)'), ); } @@ -555,7 +555,7 @@ public function testEmptyCallable(): void { $this->assertSame( 'callable():void', - (string)Type::parseString('callable() : void') + (string)Type::parseString('callable() : void'), ); } @@ -563,7 +563,7 @@ public function testCallableWithUnionLastType(): void { $this->assertSame( 'callable(int, int|string):void', - (string)Type::parseString('callable(int, int|string) : void') + (string)Type::parseString('callable(int, int|string) : void'), ); } @@ -571,7 +571,7 @@ public function testCallableWithVariadic(): void { $this->assertSame( 'callable(int, string...):void', - (string)Type::parseString('callable(int, string...) : void') + (string)Type::parseString('callable(int, string...) : void'), ); } @@ -579,7 +579,7 @@ public function testCallableThatReturnsACallable(): void { $this->assertSame( 'callable():callable():string', - (string)Type::parseString('callable() : callable() : string') + (string)Type::parseString('callable() : callable() : string'), ); } @@ -587,7 +587,7 @@ public function testCallableThatReturnsACallableThatReturnsACallable(): void { $this->assertSame( 'callable():callable():callable():string', - (string)Type::parseString('callable() : callable() : callable() : string') + (string)Type::parseString('callable() : callable() : callable() : string'), ); } @@ -595,7 +595,7 @@ public function testCallableOrInt(): void { $this->assertSame( 'callable(string):void|int', - (string)Type::parseString('callable(string):void|int') + (string)Type::parseString('callable(string):void|int'), ); } @@ -609,7 +609,7 @@ public function testCallableWithSpreadBefore(): void { $this->assertSame( 'callable(int, string...):void', - (string)Type::parseString('callable(int, ...string):void') + (string)Type::parseString('callable(int, ...string):void'), ); } @@ -617,7 +617,7 @@ public function testConditionalTypeWithSpaces(): void { $this->assertSame( '(T is string ? string : int)', - (string) Type::parseString('(T is string ? string : int)', null, ['T' => ['' => Type::getArray()]]) + (string) Type::parseString('(T is string ? string : int)', null, ['T' => ['' => Type::getArray()]]), ); } @@ -625,7 +625,7 @@ public function testConditionalTypeWithUnion(): void { $this->assertSame( '(T is string|true ? int|string : int)', - Type::parseString('(T is "hello"|true ? string|int : int)', null, ['T' => ['' => Type::getArray()]])->getId(false) + Type::parseString('(T is "hello"|true ? string|int : int)', null, ['T' => ['' => Type::getArray()]])->getId(false), ); } @@ -633,7 +633,7 @@ public function testConditionalTypeWithTKeyedArray(): void { $this->assertSame( '(T is array{a: string} ? string : int)', - (string) Type::parseString('(T is array{a: string} ? string : int)', null, ['T' => ['' => Type::getArray()]]) + (string) Type::parseString('(T is array{a: string} ? string : int)', null, ['T' => ['' => Type::getArray()]]), ); } @@ -641,7 +641,7 @@ public function testConditionalTypeWithGenericIs(): void { $this->assertSame( '(T is array ? string : int)', - (string) Type::parseString('(T is array ? string : int)', null, ['T' => ['' => Type::getArray()]]) + (string) Type::parseString('(T is array ? string : int)', null, ['T' => ['' => Type::getArray()]]), ); } @@ -649,7 +649,7 @@ public function testConditionalTypeWithIntersection(): void { $this->assertSame( '(T is A&B ? string : int)', - (string) Type::parseString('(T is A&B ? string : int)', null, ['T' => ['' => Type::getArray()]]) + (string) Type::parseString('(T is A&B ? string : int)', null, ['T' => ['' => Type::getArray()]]), ); } @@ -657,7 +657,7 @@ public function testConditionalTypeWithoutSpaces(): void { $this->assertSame( '(T is string ? string : int)', - (string) Type::parseString('(T is string?string:int)', null, ['T' => ['' => Type::getArray()]]) + (string) Type::parseString('(T is string?string:int)', null, ['T' => ['' => Type::getArray()]]), ); } @@ -671,7 +671,7 @@ public function testConditionalTypeWithCallableReturningBoolElseBool(): void { $this->assertSame( '(T is string ? callable():bool : bool)', - (string) Type::parseString('(T is string ? (callable() : bool) : bool)', null, ['T' => ['' => Type::getArray()]]) + (string) Type::parseString('(T is string ? (callable() : bool) : bool)', null, ['T' => ['' => Type::getArray()]]), ); } @@ -682,8 +682,8 @@ public function testConditionalTypeWithGenerics(): void (string) Type::parseString( '(T is string ? string : array)', null, - ['T' => ['' => Type::getArray()]] - ) + ['T' => ['' => Type::getArray()]], + ), ); } @@ -694,8 +694,8 @@ public function testConditionalTypeWithCallableBracketed(): void (string) Type::parseString( '(T is string ? (callable(string, string):string) : (callable(mixed...):mixed))', null, - ['T' => ['' => Type::getArray()]] - ) + ['T' => ['' => Type::getArray()]], + ), ); } @@ -706,8 +706,8 @@ public function testConditionalTypeWithCallableNotBracketed(): void (string) Type::parseString( '(T is string ? callable(string, string):string : callable(mixed...):mixed)', null, - ['T' => ['' => Type::getArray()]] - ) + ['T' => ['' => Type::getArray()]], + ), ); } @@ -727,7 +727,7 @@ public function testCallableWithMissingVariadicType(): void { $this->assertSame( 'callable(mixed...):void', - (string) Type::parseString('callable(...): void') + (string) Type::parseString('callable(...): void'), ); } @@ -819,7 +819,7 @@ public function testCallableWithDefault(): void { $this->assertSame( 'callable(int, string=):void', - (string)Type::parseString('callable(int, string=) : void') + (string)Type::parseString('callable(int, string=) : void'), ); } @@ -827,7 +827,7 @@ public function testNestedCallable(): void { $this->assertSame( 'callable(callable(A):B):C', - (string)Type::parseString('callable(callable(A):B):C') + (string)Type::parseString('callable(callable(A):B):C'), ); } @@ -835,7 +835,7 @@ public function testCallableWithoutReturn(): void { $this->assertSame( 'callable(int, string)', - (string)Type::parseString('callable(int, string)') + (string)Type::parseString('callable(int, string)'), ); } @@ -843,7 +843,7 @@ public function testCombineLiteralStringWithClassString(): void { $this->assertSame( "'array'|class-string", - Type::parseString('"array"|class-string')->getId() + Type::parseString('"array"|class-string')->getId(), ); } @@ -851,7 +851,7 @@ public function testCombineLiteralClassStringWithClassString(): void { $this->assertSame( 'class-string', - Type::parseString('A::class|class-string')->getId() + Type::parseString('A::class|class-string')->getId(), ); } @@ -859,7 +859,7 @@ public function testKeyOfClassConstant(): void { $this->assertSame( 'key-of', - (string)Type::parseString('key-of') + (string)Type::parseString('key-of'), ); } @@ -867,7 +867,7 @@ public function testKeyOfTemplate(): void { $this->assertSame( 'key-of', - Type::parseString('key-of', null, ['T' => ['' => Type::getArray()]])->getId(false) + Type::parseString('key-of', null, ['T' => ['' => Type::getArray()]])->getId(false), ); } @@ -875,7 +875,7 @@ public function testValueOfTemplate(): void { $this->assertSame( 'value-of', - (string)Type::parseString('value-of', null, ['T' => ['' => Type::getArray()]]) + (string)Type::parseString('value-of', null, ['T' => ['' => Type::getArray()]]), ); } @@ -889,10 +889,10 @@ public function testIndexedAccess(): void [ 'T' => ['' => Type::getArray()], 'K' => ['' => new Union([ - new TTemplateKeyOf('T', 'fn-foo', Type::getMixed()) + new TTemplateKeyOf('T', 'fn-foo', Type::getMixed()), ])], - ] - ) + ], + ), ); } @@ -900,7 +900,7 @@ public function testValueOfClassConstant(): void { $this->assertSame( 'value-of', - (string)Type::parseString('value-of') + (string)Type::parseString('value-of'), ); } @@ -908,7 +908,7 @@ public function testClassStringMap(): void { $this->assertSame( 'class-string-map', - Type::parseString('class-string-map')->getId(false) + Type::parseString('class-string-map')->getId(false), ); } @@ -918,7 +918,7 @@ public function testVeryLargeType(): void $this->assertSame( $very_large_type, - (string) Type::parseString($very_large_type) + (string) Type::parseString($very_large_type), ); } @@ -1006,7 +1006,7 @@ public function testSingleLiteralString(): void { $this->assertSame( "'var'", - Type::parseString('"var"')->getId() + Type::parseString('"var"')->getId(), ); } @@ -1014,7 +1014,7 @@ public function testEmptyArrayShape(): void { $this->assertSame( 'array', - (string)Type::parseString('array{}') + (string)Type::parseString('array{}'), ); } @@ -1022,7 +1022,7 @@ public function testSingleLiteralInt(): void { $this->assertSame( '6', - Type::parseString('6')->getId() + Type::parseString('6')->getId(), ); } @@ -1030,7 +1030,7 @@ public function testSingleLiteralFloat(): void { $this->assertSame( 'float(6.315)', - Type::parseString('6.315')->getId() + Type::parseString('6.315')->getId(), ); } @@ -1118,22 +1118,22 @@ function someFunction(string $param, array $param2, ?int $param3 = null): string $this->assertSame( 'string', - (string) Codebase::getPsalmTypeFromReflection($reflectionParams[0]->getType()) + (string) Codebase::getPsalmTypeFromReflection($reflectionParams[0]->getType()), ); $this->assertSame( 'array', - (string) Codebase::getPsalmTypeFromReflection($reflectionParams[1]->getType()) + (string) Codebase::getPsalmTypeFromReflection($reflectionParams[1]->getType()), ); $this->assertSame( 'int|null', - (string) Codebase::getPsalmTypeFromReflection($reflectionParams[2]->getType()) + (string) Codebase::getPsalmTypeFromReflection($reflectionParams[2]->getType()), ); $this->assertSame( 'string', - (string) Codebase::getPsalmTypeFromReflection($reflectionFunc->getReturnType()) + (string) Codebase::getPsalmTypeFromReflection($reflectionFunc->getReturnType()), ); } diff --git a/tests/TypeReconciliation/ArrayKeyExistsTest.php b/tests/TypeReconciliation/ArrayKeyExistsTest.php index a8e7aeaea50..3ee780251c1 100644 --- a/tests/TypeReconciliation/ArrayKeyExistsTest.php +++ b/tests/TypeReconciliation/ArrayKeyExistsTest.php @@ -28,7 +28,7 @@ function foo(array $a) { } throw new \Exception("bad"); - }' + }', ], 'arrayKeyExistsThrice' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'arrayKeyExistsComplex' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'status, $bar)) { echo $bar[$foo->status]; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); @@ -581,7 +581,7 @@ class Foo { if (array_key_exists(Foo::$status, $bar)) { echo $bar[Foo::$status]; - }' + }', ); $this->analyzeFile('somefile.php', new Context()); diff --git a/tests/TypeReconciliation/AssignmentInConditionalTest.php b/tests/TypeReconciliation/AssignmentInConditionalTest.php index 6a8e3f7aab7..70a476ae8fe 100644 --- a/tests/TypeReconciliation/AssignmentInConditionalTest.php +++ b/tests/TypeReconciliation/AssignmentInConditionalTest.php @@ -25,7 +25,7 @@ function test(): string { ($foo !== null) || ($foo = ""); return $foo; - }' + }', ], 'andWithAssignment' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo();', 'assertions' => [ '$a' => 'bool', - ] + ], ], 'assertVarRedefinedInOpWithOr' => [ 'code' => 'foo();', 'assertions' => [ '$a' => 'bool', - ] + ], ], 'assertVarInOrAfterAnd' => [ 'code' => ' [ 'code' => ' [ 'code' => 'foo(); } - }' + }', ], 'definedInConditionalAndCheckedInSubbranch' => [ 'code' => 'foo(); } } - }' + }', ], 'definedInRhsOfConditionalInNegation' => [ 'code' => 'foo(); } - }' + }', ], 'definedInOrRHS' => [ 'code' => 'foo(); - }' + }', ], 'possiblyDefinedVarInAssertion' => [ 'code' => ' [ 'code' => ' [ 'code' => 'foo(); } - }' + }', ], 'allowBasicOrAssignment' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'assignmentForComparison' => [ 'code' => ' 1) {} if ($a) {} - }' + }', ], ]; } diff --git a/tests/TypeReconciliation/ConditionalTest.php b/tests/TypeReconciliation/ConditionalTest.php index a8d9a2378b0..ae3163cf287 100644 --- a/tests/TypeReconciliation/ConditionalTest.php +++ b/tests/TypeReconciliation/ConditionalTest.php @@ -823,8 +823,8 @@ function bar(float $f) : void { if (is_bool($s)) {} if (!is_bool($s)) {}', 'assertions' => [ - '$s' => 'scalar' - ] + '$s' => 'scalar', + ], ], 'scalarToString' => [ 'code' => ' [ - '$s' => 'scalar' - ] + '$s' => 'scalar', + ], ], 'scalarToInt' => [ 'code' => ' [ - '$s' => 'scalar' - ] + '$s' => 'scalar', + ], ], 'scalarToFloat' => [ 'code' => ' [ - '$s' => 'scalar' - ] + '$s' => 'scalar', + ], ], 'removeFromArray' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 1]; - }' + }', ], 'setArrayConstantOffset' => [ 'code' => 'id] = new B(); } $arr[$a->id]->foo(); - }' + }', ], 'assertAfterNotEmptyArrayCheck' => [ 'code' => 'c[$s]) && empty($this->c[$t])) {} } - }' + }', ], 'assertNotEmptyTwiceOnStaticPropertyArray' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'arr[0] = new stdClass; return $this->arr[0]; } - }' + }', ], 'assertPropertiesOfElseStatement' => [ 'code' => 'b === "baz") {} if ($obj->b === "baz") {} - }' + }', ], 'assertPropertiesOfElseifStatement' => [ 'code' => 'b === "baz") {} if ($obj->b === "baz") {} - }' + }', ], 'assertArrayWithOffset' => [ 'code' => ' [ 'code' => ' [ 'code' => 'b && !$b->b; echo $a->b ? 1 : 0; - }' + }', ], 'literalStringComparisonInIf' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 5) {} } - }' + }', ], 'arrayUnionTypeSwitching' => [ 'code' => ' [ 'code' => 'old) && is_int($diff_elem->new)) ) { } - }' + }', ], 'manyNestedAsserts' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo() : "bar"; } - }' + }', ], 'reconcileEmptinessBetter' => [ 'code' => ' [ 'code' => ' [ 'code' => 'assessment->root); - }' + }', ], 'castIsType' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'nullsafeMethodCall' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'onlySingleErrorForEarlyExit' => [ 'code' => 'bar($arr)) { return; } - }' + }', ], 'nonRedundantConditionAfterThing' => [ 'code' => 'takes($b)) || $b === null ) {} - }' + }', ], 'usedAssertedVarButNotWithStrongerTypeGuarantee' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$_a===' => "'N'|'Y'", - ] + ], ], 'assertionsWorksBothWays' => [ 'code' => ' [ '$a===' => '2', '$b===' => '2', - ] + ], ], 'nullErasureWithSmallerAndGreater' => [ 'code' => ' [ 'code' => ' [ - '$int' => 'int<48, 57>|int<256, 1000>' - ] + '$int' => 'int<48, 57>|int<256, 1000>', + ], ], 'ctypeLowerMakesStringLowercase' => [ 'code' => ' [ - '$int' => 'int<97, 122>' - ] + '$int' => 'int<97, 122>', + ], ], ]; } @@ -3238,7 +3238,7 @@ function firstChar(string $s) : string { return $s; } function foo(?string $s) : string { return ((string) $s) ?? "bar"; }', - 'error_message' => 'RedundantCondition' + 'error_message' => 'RedundantCondition', ], 'allowEmptyScalarAndNonEmptyScalarAssertions1' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ // #8163 'code' => ' 'MixedReturnTypeCoercion' + 'error_message' => 'MixedReturnTypeCoercion', ], 'preventEmptyEquivalentCreatingArray' => [ 'code' => ' 'MixedReturnTypeCoercion' + 'error_message' => 'MixedReturnTypeCoercion', ], ]; } diff --git a/tests/TypeReconciliation/InArrayTest.php b/tests/TypeReconciliation/InArrayTest.php index 13bf529d3fc..77e182cc00e 100644 --- a/tests/TypeReconciliation/InArrayTest.php +++ b/tests/TypeReconciliation/InArrayTest.php @@ -169,7 +169,7 @@ function assertInArray(string|bool $x, $y) { }', 'assertions' => [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'in_arrayNullOrString' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'in_array-mixed-twice' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'in_array-string-twice' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'in_array-keyed-array-string-twice' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], ]; } diff --git a/tests/TypeReconciliation/IssetTest.php b/tests/TypeReconciliation/IssetTest.php index 63f6980e654..4eda90451d7 100644 --- a/tests/TypeReconciliation/IssetTest.php +++ b/tests/TypeReconciliation/IssetTest.php @@ -617,7 +617,7 @@ function level3($array) { throw new \LogicException(); } return $array; - }' + }', ], 'issetOnStringArrayShouldInformArrayness' => [ 'code' => ' [ @@ -646,7 +646,7 @@ function foo(array $options): void { } if ($options["b"] === 2) {} - }' + }', ], 'listDestructuringErrorSuppress' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo() ?? ""); - }' + }', ], 'issetOnMethodCallInsideMethodCall' => [ 'code' => 'foo->bar(); } - }' + }', ], 'issetOnArrayOfArraysReturningStringInElse' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'assertComplex' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'UndefinedVariable' + 'error_message' => 'UndefinedVariable', ], 'issetNullVar' => [ 'code' => ' 'TypeDoesNotContainNull' + 'error_message' => 'TypeDoesNotContainNull', ], 'issetOnArrayOfArraysReturningString' => [ 'code' => 'file_analyzer->context = new Context(); $this->statements_analyzer = new StatementsAnalyzer( $this->file_analyzer, - new NodeDataProvider() + new NodeDataProvider(), ); $this->addFile('newfile.php', ' @@ -74,12 +74,12 @@ public function testReconcilation(string $expected_type, Assertion $assertion, s null, $this->statements_analyzer, false, - [] + [], ); $this->assertSame( $expected_type, - $reconciled->getId() + $reconciled->getId(), ); $this->assertContainsOnlyInstancesOf('Psalm\Type\Atomic', $reconciled->getAtomicTypes()); @@ -94,8 +94,8 @@ public function testTypeIsContainedBy(string $input, string $container): void UnionTypeComparator::isContainedBy( $this->project_analyzer->getCodebase(), Type::parseString($input), - Type::parseString($container) - ) + Type::parseString($container), + ), ); } @@ -228,7 +228,7 @@ class Foo const PREFIX_BAZ = \'baz\'; const PREFIX_QOO = Foo::PREFIX_BAR; } - ' + ', ); $this->project_analyzer->getCodebase()->scanFiles(); @@ -240,12 +240,12 @@ class Foo null, $this->statements_analyzer, false, - [] + [], ); $this->assertSame( $expected_type, - $reconciled->getId() + $reconciled->getId(), ); } diff --git a/tests/TypeReconciliation/RedundantConditionTest.php b/tests/TypeReconciliation/RedundantConditionTest.php index 330eba4cd3a..7b105c7ac3a 100644 --- a/tests/TypeReconciliation/RedundantConditionTest.php +++ b/tests/TypeReconciliation/RedundantConditionTest.php @@ -696,7 +696,7 @@ function b($impl) : void { } else { if ($impl instanceof One) {} } - }' + }', ], 'invalidateAfterPostIncrement' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ '$fp' => 'closed-resource', - ] + ], ], 'allowCheckOnReturnTypeUnion' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'RedundantCondition' + 'error_message' => 'RedundantCondition', ], 'secondFalsyTwiceWithoutChangeWithElse' => [ 'code' => ' 'RedundantCondition' + 'error_message' => 'RedundantCondition', ], ]; } diff --git a/tests/TypeReconciliation/TypeAlgebraTest.php b/tests/TypeReconciliation/TypeAlgebraTest.php index 6e5b6c5b690..ac14bb665fb 100644 --- a/tests/TypeReconciliation/TypeAlgebraTest.php +++ b/tests/TypeReconciliation/TypeAlgebraTest.php @@ -904,7 +904,7 @@ function foo(X $x) : void { if ($x->c) {} if ($a) {} - }' + }', ], 'twoVarChangeInElseOnly' => [ 'code' => 'foo(); $to->foo(); - }' + }', ], 'twoVarChangeInElseif' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo(); } - }' + }', ], 'assignSameName' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'dontReport(RuntimeException::class); $h->shouldReport(new Exception()); - $h->shouldReport(new RuntimeException());' + $h->shouldReport(new RuntimeException());', ], 'ThrowableInstanceOfThrowableMayBeTrue' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], 'php_version' => '8.0', - ] + ], ]; } diff --git a/tests/TypeReconciliation/TypeTest.php b/tests/TypeReconciliation/TypeTest.php index 8e1edbe77f0..2573bc7549f 100644 --- a/tests/TypeReconciliation/TypeTest.php +++ b/tests/TypeReconciliation/TypeTest.php @@ -25,8 +25,8 @@ public function providerValidCodeParse(): iterable assert(count($a) === 1); ', 'assertions' => [ - '$a===' => 'array{a: mixed}' - ] + '$a===' => 'array{a: mixed}', + ], ], 'sealedArrayCount' => [ 'code' => ' [ '$a===' => 'list{0?: 0, 1?: 1}', - '$b===' => 'list{0, 1}|null' - ] + '$b===' => 'list{0, 1}|null', + ], ], 'sealedArrayMagic' => [ 'code' => ' 'list', '$urls===' => 'list{0?: non-falsy-string}', '$mainUrlSet===' => 'bool', - ] + ], ], 'validSealedArrayAssertions' => [ 'code' => ' [ '$a===' => 'array{a: string, b: string, c: string}', - ] + ], ], 'instanceOfInterface' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'nullableMethodWithTernaryGuard' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 0; } if (count($a) > 1) { }', - 'error_message' => 'RedundantConditionGivenDocblockType' + 'error_message' => 'RedundantConditionGivenDocblockType', ], 'invalidSealedArrayAssertion2' => [ 'code' => ' 0; } if (count($a) > 3) { }', - 'error_message' => 'DocblockTypeContradiction' + 'error_message' => 'DocblockTypeContradiction', ], 'invalidSealedArrayAssertion3' => [ 'code' => ' 0; } if (count($a) > 4) { }', - 'error_message' => 'DocblockTypeContradiction' + 'error_message' => 'DocblockTypeContradiction', ], 'invalidSealedArrayAssertion4' => [ 'code' => ' 0; } if (count($a) < 1) { }', - 'error_message' => 'DocblockTypeContradiction' + 'error_message' => 'DocblockTypeContradiction', ], 'invalidSealedArrayAssertion5' => [ 'code' => ' 0; } if (count($a) < 2) { }', - 'error_message' => 'DocblockTypeContradiction' + 'error_message' => 'DocblockTypeContradiction', ], 'invalidSealedArrayAssertion6' => [ 'code' => ' 0; } if (count($a) < 4) { }', - 'error_message' => 'RedundantConditionGivenDocblockType' + 'error_message' => 'RedundantConditionGivenDocblockType', ], 'intersectionTypeClassCheckAfterInstanceof' => [ 'code' => 'file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $this->project_analyzer->setPhpVersion('7.3', 'tests'); @@ -610,7 +610,7 @@ class A { * @psalm-var "easy" */ private $type = "easy"; - }' + }', ], 'supportMultipleValues' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 0) {}' + if ($f > 0) {}', ], 'assignOpThenCheck' => [ 'code' => ' 0) {}' + if ($data["e"] > 0) {}', ], 'compareToNullImplicitly' => [ 'code' => ' [ 'code' => ' [ 'code' => ' ' 1)){} - }' + }', ], 'returnFromUnionLiteral' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'returnFromUnionLiteralNegated' => [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '8.0' + 'php_version' => '8.0', ], 'inArrayInsideLoop' => [ 'code' => ' [ 'code' => ' [], 'ignored_issues' => [], - 'php_version' => '7.4' + 'php_version' => '7.4', ], 'zeroIsNonEmptyString' => [ 'code' => ' 'ArgumentTypeCoercion' + 'error_message' => 'ArgumentTypeCoercion', ], 'stringCoercedToNonEmptyString' => [ 'code' => ' [ 'code' => 'file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $this->project_analyzer->getCodebase()->reportUnusedCode(); @@ -55,7 +55,7 @@ public function testValidCode(string $code, array $ignored_issues = []): void $this->addFile( $file_path, - $code + $code, ); $this->project_analyzer->setPhpVersion('8.0', 'tests'); @@ -92,7 +92,7 @@ public function testInvalidCode(string $code, string $error_message, array $igno $this->addFile( $file_path, - $code + $code, ); $this->analyzeFile($file_path, new Context(), false); @@ -123,7 +123,7 @@ function bar(): void{ echo "foo"; } } - ' + ', ); $this->analyzeFile($file_path, new Context(), false); $this->project_analyzer->consolidateAnalyzedData(); @@ -155,7 +155,7 @@ function bar(): void{ echo "foo"; } } - ' + ', ); $this->analyzeFile($file_path, new Context(), false); $this->project_analyzer->consolidateAnalyzedData(); @@ -577,7 +577,7 @@ class A { public function foo() : void {} } - new A();' + new A();', ], 'usedFunctionInCall' => [ 'code' => 'foo("COUNT{$s}"); - }' + }', ], 'usedFunctioninMethodCallName' => [ 'code' => 'bar("request");' + (new Foo)->bar("request");', ], 'usedMethodCallForExternalMutationFreeClass' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'baz();' + createFoo(Foo::class)->baz();', ], 'usedMethodReferencedByString' => [ 'code' => ' [ 'code' => 'bar(["a" => "b"]);' + (new References)->bar(["a" => "b"]);', ], 'promotedPropertyIsUsed' => [ 'code' => 'id; - echo $test->name;' + echo $test->name;', ], 'unusedNoReturnFunctionCall' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'getPrevious() ?? $exception);' + throw ($exception->getPrevious() ?? $exception);', ], 'publicPropertyReadInFile' => [ 'code' => 'foo(); - ' + ', ], 'staticMethodReturnValueUsedInThrow' => [ 'code' => ' [ 'code' => 'file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $this->project_analyzer->getCodebase()->reportUnusedVariables(); @@ -54,7 +54,7 @@ public function testValidCode(string $code, array $ignored_issues = [], string $ $this->addFile( $file_path, - $code + $code, ); foreach ($ignored_issues as $error_level) { @@ -87,7 +87,7 @@ public function testInvalidCode(string $code, string $error_message, array $igno $this->addFile( $file_path, - $code + $code, ); $this->analyzeFile($file_path, new Context()); @@ -763,7 +763,7 @@ function far(array $arr): void { foreach ($rules as $rule) { $report["runs"][] = $rule; } - echo(count($report));' + echo(count($report));', ], 'arrayAssignmentInFunctionCoerced' => [ 'code' => 'b = (int) $b; } } - ' + ', ], 'varCheckAfterNestedAssignmentAndBreak' => [ 'code' => ' [ 'code' => ' [ 'code' => 'setValue([get_class($mock) => "hello"]); - }' + }', ], 'defineBeforeAssignmentInConditional' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $_testValue) { echo $key; } - }' + }', ], 'usedAfterMixedVariableAssignment' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'value; $update = $value; } - }' + }', ], 'createdAndUsedInCondition' => [ 'code' => 'foo()) {}' + if (!($a = getA()) || $a->foo()) {}', ], 'usedInUndefinedFunction' => [ 'code' => ' [ 'code' => ' $value) { ${$name} = $value; - }' + }', ], 'usedLoopVariable' => [ 'code' => ' [ 'code' => ' [ 'code' => ' 0; $i--) { echo $i . "\n"; } - }' + }', ], 'usedForVariablePlusString' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $p */ function takes_ref(array &$p): void { echo implode(",", $p); - }' + }', ], 'doWhileWithBreak' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'b) {} - }' + }', ], 'loopOverUnknown' => [ 'code' => ' [ 'code' => ' [ 'code' => ' $_) { echo $key; } - }' + }', ], 'continuingEducation' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => 'foo($hue); - }' + }', ], 'usedAsArrayKey' => [ 'code' => ' $lightness]; return $arr; - }' + }', ], 'assignToGlobalVar' => [ 'code' => ' $value) { $_GET[$key] = $value; } - }' + }', ], 'assignToArrayTwice' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' $e->getMessage(); - }' + }', ], 'useImmutableGetIteratorInForeach' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => '$k; return $sortA; - }' + }', ], 'varDocblockVariableIsUsedByRef' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'UnusedForeachValue' + 'error_message' => 'UnusedForeachValue', ], 'defineInBothBranchesOfConditional' => [ 'code' => ' 'PossiblyNullArgument' + 'error_message' => 'PossiblyNullArgument', ], 'useArrayAssignmentNeverUsed' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:42 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:47' + 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:42 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:47', ], 'warnAboutOriginalBadFunctionCall' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44' + 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44', ], 'warnAboutOriginalBadStaticCall' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:62' + 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:62', ], 'warnAboutOriginalBadInstanceCall' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:55' + 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:38 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:55', ], 'warnAboutDocblockReturnType' => [ 'code' => ' 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:47 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:33' + 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:47 - Unable to determine the type that $a is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:33', ], 'warnAboutMixedArgument' => [ 'code' => ' 'MixedArgument - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:30 - Argument 1 of echo cannot be mixed, expecting string. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44' + 'error_message' => 'MixedArgument - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:30 - Argument 1 of echo cannot be mixed, expecting string. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44', ], 'warnAboutMixedMethodCall' => [ 'code' => 'foo(); }', - 'error_message' => 'MixedMethodCall - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:29 - Cannot determine the type of $a when calling method foo. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44' + 'error_message' => 'MixedMethodCall - src' . DIRECTORY_SEPARATOR . 'somefile.php:10:29 - Cannot determine the type of $a when calling method foo. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44', ], 'warnAboutMixedReturnStatement' => [ 'code' => ' 'MixedReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:11:36 - Could not infer a return type. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44' + 'error_message' => 'MixedReturnStatement - src' . DIRECTORY_SEPARATOR . 'somefile.php:11:36 - Could not infer a return type. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:44', ], 'warnAboutIterableKeySource' => [ 'code' => ' $_) {} }', - 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:42 - Unable to determine the type that $key is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:43' + 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:42 - Unable to determine the type that $key is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:43', ], 'warnAboutMixedKeySource' => [ 'code' => ' $_) {} }', - 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:4:42 - Unable to determine the type that $key is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:34' + 'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:4:42 - Unable to determine the type that $key is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:34', ], 'warnAboutMixedArgumentTypeCoercionSource' => [ 'code' => ' 'MixedArgumentTypeCoercion - src' . DIRECTORY_SEPARATOR . 'somefile.php:12:44 - Argument 1 of takesArrayOfString expects array, but parent type list{mixed} provided. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:10:41' + 'error_message' => 'MixedArgumentTypeCoercion - src' . DIRECTORY_SEPARATOR . 'somefile.php:12:44 - Argument 1 of takesArrayOfString expects array, but parent type list{mixed} provided. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:10:41', ], 'warnAboutUnusedVariableInTryReassignedInCatch' => [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'noIntForValueOfStringArrayLiteral' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'noStringForValueOfIntList' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'noOtherStringAllowedForValueOfKeyedArray' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'noOtherIntAllowedInValueOfUnionLiteralInts' => [ 'code' => ' 'InvalidReturnStatement' + 'error_message' => 'InvalidReturnStatement', ], 'valueOfUnitEnum' => [ 'code' => 'analyzeFile('somefile.php', new Context()); @@ -54,8 +54,8 @@ public function testVariadicFunctionFromAutoloadFile(): void - ' - ) + ', + ), ); $file_path = getcwd() . '/src/somefile.php'; @@ -64,7 +64,7 @@ public function testVariadicFunctionFromAutoloadFile(): void $file_path, 'analyzeFile($file_path, new Context()); @@ -139,8 +139,8 @@ private function getProjectAnalyzerWithConfig(Config $config): ProjectAnalyzer $config, new Providers( $this->file_provider, - new FakeParserCacheProvider() - ) + new FakeParserCacheProvider(), + ), ); $project_analyzer->setPhpVersion('7.3', 'tests');