From 39402c233d4856447615dfccf1d3431eca6ca6c9 Mon Sep 17 00:00:00 2001 From: rarila Date: Sun, 5 Dec 2021 18:51:26 +0100 Subject: [PATCH] Return type hints (#7065) Co-authored-by: ralila <> --- phpcs.xml | 26 +++++++++ src/Psalm/CodeLocation.php | 2 +- src/Psalm/Codebase.php | 16 +++--- src/Psalm/Config.php | 2 +- src/Psalm/Config/Creator.php | 10 ++-- src/Psalm/Config/FileFilter.php | 4 +- src/Psalm/Context.php | 2 +- src/Psalm/DocComment.php | 2 +- src/Psalm/ErrorBaseline.php | 4 +- src/Psalm/FileManipulation.php | 4 +- .../Internal/Analyzer/AttributeAnalyzer.php | 4 +- src/Psalm/Internal/Analyzer/ClassAnalyzer.php | 14 ++--- .../Internal/Analyzer/ClassLikeAnalyzer.php | 4 +- .../Internal/Analyzer/ClosureAnalyzer.php | 4 +- .../Internal/Analyzer/CommentAnalyzer.php | 6 +-- src/Psalm/Internal/Analyzer/FileAnalyzer.php | 16 +++--- .../Internal/Analyzer/FunctionAnalyzer.php | 2 +- .../FunctionLike/ReturnTypeAnalyzer.php | 2 +- .../FunctionLike/ReturnTypeCollector.php | 2 +- .../Analyzer/FunctionLikeAnalyzer.php | 10 ++-- .../Internal/Analyzer/MethodComparator.php | 14 ++--- .../Internal/Analyzer/NamespaceAnalyzer.php | 2 +- .../Internal/Analyzer/ProjectAnalyzer.php | 14 ++--- .../Internal/Analyzer/SourceAnalyzer.php | 8 +-- .../Analyzer/Statements/Block/DoAnalyzer.php | 2 +- .../Statements/Block/ForeachAnalyzer.php | 4 +- .../Statements/Block/IfElse/IfAnalyzer.php | 8 +-- .../Statements/Block/SwitchCaseAnalyzer.php | 4 +- .../Statements/Block/WhileAnalyzer.php | 2 +- .../Analyzer/Statements/BreakAnalyzer.php | 2 +- .../Analyzer/Statements/EchoAnalyzer.php | 2 +- .../Statements/Expression/ArrayAnalyzer.php | 6 +-- .../Statements/Expression/AssertionFinder.php | 2 +- .../Assignment/ArrayAssignmentAnalyzer.php | 4 +- .../InstancePropertyAssignmentAnalyzer.php | 4 +- .../Expression/AssignmentAnalyzer.php | 6 +-- .../Expression/BinaryOp/AndAnalyzer.php | 2 +- .../BinaryOp/ArithmeticOpAnalyzer.php | 2 +- .../Expression/BinaryOp/CoalesceAnalyzer.php | 2 +- .../BinaryOp/NonComparisonOpAnalyzer.php | 2 +- .../Expression/BinaryOp/OrAnalyzer.php | 2 +- .../Expression/BinaryOpAnalyzer.php | 6 +-- .../Expression/BooleanNotAnalyzer.php | 2 +- .../Expression/Call/ArgumentAnalyzer.php | 6 +-- .../Expression/Call/ArgumentsAnalyzer.php | 4 +- .../Call/ClassTemplateParamCollector.php | 2 +- .../Expression/Call/FunctionCallAnalyzer.php | 15 +++--- .../Call/FunctionCallReturnTypeFetcher.php | 8 +-- .../Call/Method/AtomicMethodCallAnalyzer.php | 8 +-- .../ExistingAtomicMethodCallAnalyzer.php | 10 ++-- .../Call/Method/MethodCallPurityAnalyzer.php | 2 +- .../Method/MethodCallReturnTypeFetcher.php | 6 +-- .../Call/Method/MissingMethodCallHandler.php | 4 +- .../Expression/Call/MethodCallAnalyzer.php | 4 +- .../Call/NamedFunctionCallHandler.php | 6 +-- .../Expression/Call/NewAnalyzer.php | 2 +- .../Expression/Call/StaticCallAnalyzer.php | 4 +- .../StaticMethod/AtomicStaticCallAnalyzer.php | 6 +-- .../ExistingAtomicStaticCallAnalyzer.php | 6 +-- .../Statements/Expression/CallAnalyzer.php | 6 +-- .../Statements/Expression/CastAnalyzer.php | 4 +- .../Statements/Expression/CloneAnalyzer.php | 2 +- .../Statements/Expression/EmptyAnalyzer.php | 2 +- .../Expression/EncapsulatedStringAnalyzer.php | 2 +- .../Statements/Expression/EvalAnalyzer.php | 2 +- .../Statements/Expression/ExitAnalyzer.php | 2 +- .../Expression/Fetch/ArrayFetchAnalyzer.php | 8 +-- .../Fetch/AtomicPropertyFetchAnalyzer.php | 8 +-- .../Fetch/ClassConstFetchAnalyzer.php | 2 +- .../Expression/Fetch/ConstFetchAnalyzer.php | 2 +- .../Fetch/InstancePropertyFetchAnalyzer.php | 2 +- .../Fetch/StaticPropertyFetchAnalyzer.php | 4 +- .../Fetch/VariableFetchAnalyzer.php | 10 ++-- .../Expression/IncDecExpressionAnalyzer.php | 2 +- .../Statements/Expression/IncludeAnalyzer.php | 4 +- .../Expression/InstanceofAnalyzer.php | 2 +- .../Statements/Expression/IssetAnalyzer.php | 2 +- .../Expression/MagicConstAnalyzer.php | 2 +- .../Statements/Expression/MatchAnalyzer.php | 4 +- .../Expression/NullsafeAnalyzer.php | 2 +- .../Statements/Expression/PrintAnalyzer.php | 2 +- .../Statements/Expression/TernaryAnalyzer.php | 2 +- .../Expression/UnaryPlusMinusAnalyzer.php | 2 +- .../Statements/Expression/YieldAnalyzer.php | 2 +- .../Expression/YieldFromAnalyzer.php | 4 +- .../Statements/ExpressionAnalyzer.php | 4 +- .../Analyzer/Statements/GlobalAnalyzer.php | 2 +- .../Analyzer/Statements/ReturnAnalyzer.php | 2 +- .../Analyzer/Statements/ThrowAnalyzer.php | 2 +- .../Internal/Analyzer/StatementsAnalyzer.php | 22 ++++---- src/Psalm/Internal/Analyzer/TypeAnalyzer.php | 4 +- src/Psalm/Internal/Clause.php | 8 +-- src/Psalm/Internal/Cli/Psalter.php | 4 +- src/Psalm/Internal/Codebase/Analyzer.php | 12 ++--- src/Psalm/Internal/Codebase/ClassLikes.php | 16 +++--- .../Codebase/ConstantTypeResolver.php | 4 +- src/Psalm/Internal/Codebase/DataFlowGraph.php | 8 +-- src/Psalm/Internal/Codebase/Functions.php | 8 +-- .../Codebase/InternalCallMapHandler.php | 2 +- src/Psalm/Internal/Codebase/Methods.php | 12 ++--- src/Psalm/Internal/Codebase/Populator.php | 2 +- .../Codebase/ReferenceMapGenerator.php | 2 +- src/Psalm/Internal/Codebase/Reflection.php | 4 +- src/Psalm/Internal/Codebase/Scanner.php | 6 +-- .../Internal/Codebase/TaintFlowGraph.php | 20 +++---- .../Internal/Codebase/VariableUseGraph.php | 12 ++--- src/Psalm/Internal/Diff/AstDiffer.php | 6 +-- src/Psalm/Internal/Diff/FileDiffer.php | 4 +- src/Psalm/Internal/ErrorHandler.php | 2 +- .../BuildInfoCollector.php | 12 ++--- .../ExecutionEnvironment/GitInfoCollector.php | 6 +-- .../SystemCommandExecutor.php | 2 +- .../ClassDocblockManipulator.php | 4 +- .../FileManipulationBuffer.php | 4 +- .../FunctionDocblockManipulator.php | 4 +- .../PropertyDocblockManipulator.php | 4 +- .../LanguageServer/EmitterInterface.php | 6 +-- .../Internal/LanguageServer/EmitterTrait.php | 4 +- .../LanguageServer/LanguageServer.php | 2 +- .../LanguageServer/ProtocolStreamReader.php | 4 +- .../Internal/PhpTraverser/CustomTraverser.php | 4 +- .../PhpVisitor/PartialParserVisitor.php | 4 +- .../Reflector/AttributeResolver.php | 2 +- .../Reflector/ClassLikeDocblockParser.php | 2 +- .../Reflector/ClassLikeNodeScanner.php | 10 ++-- .../Reflector/ExpressionResolver.php | 6 +-- .../Reflector/ExpressionScanner.php | 2 +- .../Reflector/FunctionLikeDocblockScanner.php | 10 ++-- .../Reflector/FunctionLikeNodeScanner.php | 4 +- .../PhpVisitor/Reflector/TypeHintResolver.php | 2 +- .../Internal/PhpVisitor/ReflectorVisitor.php | 9 ++-- src/Psalm/Internal/PhpVisitor/TraitFinder.php | 2 +- .../PhpVisitor/TypeMappingVisitor.php | 3 ++ .../Provider/FileReferenceCacheProvider.php | 2 +- .../Provider/FileReferenceProvider.php | 30 +++++------ .../Provider/FunctionExistenceProvider.php | 10 ++-- .../Provider/FunctionParamsProvider.php | 10 ++-- .../Provider/FunctionReturnTypeProvider.php | 8 +-- .../Provider/MethodExistenceProvider.php | 10 ++-- .../Provider/MethodParamsProvider.php | 10 ++-- .../Provider/MethodReturnTypeProvider.php | 10 ++-- .../Provider/MethodVisibilityProvider.php | 10 ++-- .../Internal/Provider/NodeDataProvider.php | 20 +++---- .../Provider/ProjectCacheProvider.php | 6 +-- .../Provider/PropertyExistenceProvider.php | 10 ++-- .../Provider/PropertyTypeProvider.php | 10 ++-- .../Provider/PropertyVisibilityProvider.php | 6 +-- .../ArrayColumnReturnTypeProvider.php | 4 +- .../ArrayFillReturnTypeProvider.php | 4 +- .../ArrayFilterReturnTypeProvider.php | 4 +- .../ArrayMapReturnTypeProvider.php | 8 +-- .../ArrayMergeReturnTypeProvider.php | 4 +- ...rayPointerAdjustmentReturnTypeProvider.php | 4 +- .../ArrayPopReturnTypeProvider.php | 4 +- .../ArrayRandReturnTypeProvider.php | 4 +- .../ArrayReduceReturnTypeProvider.php | 4 +- .../ArrayReverseReturnTypeProvider.php | 4 +- .../ArraySliceReturnTypeProvider.php | 4 +- .../ArraySpliceReturnTypeProvider.php | 4 +- .../ArrayUniqueReturnTypeProvider.php | 4 +- .../ArrayValuesReturnTypeProvider.php | 4 +- .../ClosureFromCallableReturnTypeProvider.php | 2 +- .../ReturnTypeProvider/DomNodeAppendChild.php | 2 +- .../ExplodeReturnTypeProvider.php | 4 +- .../FilterVarReturnTypeProvider.php | 4 +- .../FirstArgStringReturnTypeProvider.php | 2 +- .../GetClassMethodsReturnTypeProvider.php | 2 +- .../GetObjectVarsReturnTypeProvider.php | 2 +- .../HexdecReturnTypeProvider.php | 4 +- .../ImagickPixelColorReturnTypeProvider.php | 2 +- .../IteratorToArrayReturnTypeProvider.php | 4 +- .../MktimeReturnTypeProvider.php | 4 +- .../ParseUrlReturnTypeProvider.php | 4 +- .../PdoStatementReturnTypeProvider.php | 2 +- .../PdoStatementSetFetchMode.php | 2 +- .../SimpleXmlElementAsXml.php | 2 +- .../StrReplaceReturnTypeProvider.php | 4 +- .../StrTrReturnTypeProvider.php | 4 +- .../VersionCompareReturnTypeProvider.php | 4 +- .../Internal/Provider/StatementsProvider.php | 6 +-- src/Psalm/Internal/Scanner/DocblockParser.php | 4 +- src/Psalm/Internal/Scanner/ParsedDocblock.php | 2 +- .../Internal/Scanner/PhpStormMetaScanner.php | 6 +-- .../Generator/ClassLikeStubGenerator.php | 4 +- .../Stubs/Generator/StubsGenerator.php | 2 +- src/Psalm/Internal/Type/ArrayType.php | 3 -- .../Internal/Type/AssertionReconciler.php | 10 ++-- .../Type/Comparator/ArrayTypeComparator.php | 2 +- .../Type/Comparator/AtomicTypeComparator.php | 4 +- .../Comparator/CallableTypeComparator.php | 4 +- .../Comparator/ClassLikeStringComparator.php | 2 +- .../Type/Comparator/GenericTypeComparator.php | 2 +- .../Comparator/IntegerRangeComparator.php | 4 +- .../Type/Comparator/KeyedArrayComparator.php | 4 +- .../Type/Comparator/ScalarTypeComparator.php | 2 +- .../Type/Comparator/UnionTypeComparator.php | 2 +- src/Psalm/Internal/Type/ParseTree.php | 2 +- src/Psalm/Internal/Type/ParseTreeCreator.php | 28 +++++----- .../Type/SimpleAssertionReconciler.php | 54 +++++++++---------- .../Type/SimpleNegatedAssertionReconciler.php | 32 ++++++----- .../Type/TemplateInferredTypeReplacer.php | 2 +- .../Type/TemplateStandinTypeReplacer.php | 14 ++--- src/Psalm/Internal/Type/TypeCombiner.php | 6 +-- src/Psalm/Internal/Type/TypeExpander.php | 4 +- src/Psalm/Internal/Type/TypeParser.php | 9 ++-- src/Psalm/Internal/Type/TypeTokenizer.php | 4 +- .../TypeVisitor/ContainsClassLikeVisitor.php | 4 +- .../TypeVisitor/ContainsLiteralVisitor.php | 4 +- .../TypeVisitor/FromDocblockSetter.php | 2 +- .../TypeVisitor/TemplateTypeCollector.php | 4 +- .../Internal/TypeVisitor/TypeChecker.php | 14 ++--- .../Internal/TypeVisitor/TypeScanner.php | 2 +- src/Psalm/Issue/MixedIssue.php | 4 +- src/Psalm/Issue/MixedIssueTrait.php | 4 +- src/Psalm/Issue/TaintedInput.php | 4 +- src/Psalm/IssueBuffer.php | 22 ++++---- src/Psalm/NodeTypeProvider.php | 4 +- .../AfterClassLikeAnalysisInterface.php | 1 + .../AfterClassLikeVisitInterface.php | 1 + .../AfterCodebasePopulatedInterface.php | 1 + .../FunctionExistenceProviderInterface.php | 2 +- .../FunctionParamsProviderInterface.php | 2 +- .../FunctionReturnTypeProviderInterface.php | 2 +- .../MethodExistenceProviderInterface.php | 2 +- .../MethodParamsProviderInterface.php | 2 +- .../MethodReturnTypeProviderInterface.php | 2 +- .../MethodVisibilityProviderInterface.php | 2 +- .../PropertyExistenceProviderInterface.php | 2 +- .../PropertyTypeProviderInterface.php | 2 +- .../PropertyVisibilityProviderInterface.php | 2 +- .../Hook/AfterClassLikeAnalysisInterface.php | 1 + .../Hook/AfterClassLikeVisitInterface.php | 1 + .../Hook/AfterCodebasePopulatedInterface.php | 1 + .../FunctionExistenceProviderInterface.php | 2 +- .../Hook/FunctionParamsProviderInterface.php | 2 +- .../FunctionReturnTypeProviderInterface.php | 2 +- .../Hook/MethodExistenceProviderInterface.php | 2 +- .../Hook/MethodParamsProviderInterface.php | 2 +- .../MethodReturnTypeProviderInterface.php | 2 +- .../MethodVisibilityProviderInterface.php | 2 +- .../PropertyExistenceProviderInterface.php | 2 +- .../Hook/PropertyTypeProviderInterface.php | 2 +- .../PropertyVisibilityProviderInterface.php | 2 +- .../Hook/StringInterpreterInterface.php | 2 +- src/Psalm/Plugin/Shepherd.php | 4 +- src/Psalm/Progress/DebugProgress.php | 2 +- src/Psalm/Progress/DefaultProgress.php | 2 +- src/Psalm/Progress/LongProgress.php | 4 +- src/Psalm/Progress/Progress.php | 2 +- src/Psalm/Report.php | 2 +- src/Psalm/Report/CodeClimateReport.php | 1 - src/Psalm/Report/ConsoleReport.php | 2 +- src/Psalm/Report/PhpStormReport.php | 2 +- src/Psalm/SourceControl/Git/CommitInfo.php | 16 +++--- src/Psalm/SourceControl/Git/GitInfo.php | 8 +-- src/Psalm/SourceControl/Git/RemoteInfo.php | 2 +- src/Psalm/SourceControl/SourceControlInfo.php | 2 +- src/Psalm/StatementsSource.php | 4 +- src/Psalm/Storage/Assertion.php | 4 +- src/Psalm/Storage/FunctionLikeParameter.php | 2 +- src/Psalm/Storage/FunctionLikeStorage.php | 2 +- src/Psalm/Storage/PropertyStorage.php | 2 +- src/Psalm/Type.php | 6 +-- src/Psalm/Type/Atomic.php | 16 +++--- src/Psalm/Type/Atomic/CallableTrait.php | 6 +-- src/Psalm/Type/Atomic/DependentType.php | 4 +- src/Psalm/Type/Atomic/GenericTrait.php | 6 +-- .../Type/Atomic/HasIntersectionTrait.php | 8 +-- src/Psalm/Type/Atomic/TClassString.php | 4 +- src/Psalm/Type/Atomic/TClassStringMap.php | 8 +-- src/Psalm/Type/Atomic/TConditional.php | 4 +- src/Psalm/Type/Atomic/TDependentGetClass.php | 4 +- .../Type/Atomic/TDependentGetDebugType.php | 4 +- src/Psalm/Type/Atomic/TDependentListKey.php | 4 +- src/Psalm/Type/Atomic/TGenericObject.php | 2 +- src/Psalm/Type/Atomic/TIterable.php | 2 +- src/Psalm/Type/Atomic/TKeyedArray.php | 8 +-- src/Psalm/Type/Atomic/TList.php | 6 +-- src/Psalm/Type/Atomic/TLiteralString.php | 2 +- src/Psalm/Type/Atomic/TNamedObject.php | 4 +- .../Type/Atomic/TObjectWithProperties.php | 6 +-- src/Psalm/Type/Atomic/TString.php | 2 +- src/Psalm/Type/Atomic/TTemplateParam.php | 4 +- src/Psalm/Type/NodeVisitor.php | 6 +-- src/Psalm/Type/Reconciler.php | 6 +-- src/Psalm/Type/TypeNode.php | 2 +- src/Psalm/Type/Union.php | 32 +++++------ src/command_functions.php | 4 +- src/spl_object_id.php | 6 +-- tests/AlgebraTest.php | 2 +- tests/AnnotationTest.php | 2 +- tests/ArrayAccessTest.php | 4 +- tests/BadFormatTest.php | 2 +- tests/CodebaseTest.php | 9 ++-- tests/Config/ConfigFileTest.php | 4 +- tests/Config/ConfigTest.php | 6 +-- tests/Config/CreatorTest.php | 4 +- .../Config/Plugin/Hook/FooMethodProvider.php | 2 +- .../Plugin/Hook/FooPropertyProvider.php | 2 +- .../Plugin/Hook/MagicFunctionProvider.php | 2 +- .../Config/Plugin/Hook/SqlStringProvider.php | 2 +- .../Hook/StringProvider/TSqlSelectString.php | 2 +- tests/Config/PluginListTest.php | 2 +- tests/Config/PluginTest.php | 17 ++++-- tests/DocumentationTest.php | 2 +- tests/ErrorBaselineTest.php | 2 +- .../ClassConstantMoveTest.php | 2 +- tests/FileManipulation/ClassMoveTest.php | 2 +- .../FileManipulationTestCase.php | 2 +- tests/FileManipulation/MethodMoveTest.php | 2 +- tests/FileManipulation/NamespaceMoveTest.php | 2 +- tests/FileManipulation/PropertyMoveTest.php | 2 +- tests/FileReferenceTest.php | 2 +- tests/FileUpdates/AnalyzedMethodTest.php | 2 +- tests/FileUpdates/CachedStorageTest.php | 2 +- tests/FileUpdates/ErrorAfterUpdateTest.php | 2 +- tests/FileUpdates/ErrorFixTest.php | 2 +- tests/FileUpdates/TemporaryUpdateTest.php | 2 +- .../Provider/ProjectCacheProvider.php | 4 +- tests/JsonOutputTest.php | 2 +- tests/LanguageServer/CompletionTest.php | 2 +- tests/LanguageServer/FileMapTest.php | 2 +- tests/LanguageServer/SymbolLookupTest.php | 2 +- tests/Loop/WhileTest.php | 8 +-- tests/MagicMethodAnnotationTest.php | 2 +- tests/MatchTest.php | 4 +- tests/MethodSignatureTest.php | 2 +- tests/ProjectCheckerTest.php | 9 ++-- tests/PropertyTypeTest.php | 10 ++-- tests/PsalmPluginTest.php | 2 +- tests/ReportOutputTest.php | 6 +-- tests/ReturnTypeTest.php | 2 +- tests/StubTest.php | 6 +-- tests/SwitchTypeTest.php | 6 +-- tests/TestCase.php | 8 +-- tests/TestConfig.php | 2 +- tests/ThrowsAnnotationTest.php | 6 +-- tests/TypeComparatorTest.php | 2 +- tests/TypeParseTest.php | 18 +++---- tests/TypeReconciliation/ConditionalTest.php | 8 +-- tests/TypeReconciliation/ReconcilerTest.php | 2 +- tests/TypeReconciliation/ScopeTest.php | 2 +- tests/TypeReconciliation/TypeTest.php | 4 +- tests/TypeReconciliation/ValueTest.php | 2 +- tests/UnusedCodeTest.php | 2 +- tests/UnusedVariableTest.php | 2 +- 346 files changed, 889 insertions(+), 854 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 0bb7f80fd2b..3e7e43b964d 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -10,6 +10,7 @@ * Configuration * ************************************************************************************************************** --> + @@ -126,4 +127,29 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Psalm/CodeLocation.php b/src/Psalm/CodeLocation.php index 90e83a5e9dc..83d08c3474b 100644 --- a/src/Psalm/CodeLocation.php +++ b/src/Psalm/CodeLocation.php @@ -384,7 +384,7 @@ public function getHash(): string return $this->file_name . ' ' . $this->raw_file_start . $this->raw_file_end; } - public function getShortSummary() : string + public function getShortSummary(): string { return $this->file_name . ':' . $this->getLineNumber() . ':' . $this->getColumn(); } diff --git a/src/Psalm/Codebase.php b/src/Psalm/Codebase.php index f01d2c86c05..800d7b5a7ae 100644 --- a/src/Psalm/Codebase.php +++ b/src/Psalm/Codebase.php @@ -560,7 +560,7 @@ public function exhumeClassLikeStorage(string $fq_classlike_name, string $file_p } } - public static function getPsalmTypeFromReflection(?ReflectionType $type) : Type\Union + public static function getPsalmTypeFromReflection(?ReflectionType $type): Type\Union { return Reflection::getPsalmTypeFromReflectionType($type); } @@ -823,8 +823,6 @@ public function getFunctionLikeStorage( * * @param string|MethodIdentifier $method_id * @param string|MethodIdentifier|null $calling_method_id - * - @return bool */ public function methodExists( $method_id, @@ -1513,7 +1511,7 @@ public function getTypeContextAtPosition(string $file_path, Position $position): /** * @return list */ - public function getCompletionItemsForClassishThing(string $type_string, string $gap) : array + public function getCompletionItemsForClassishThing(string $type_string, string $gap): array { $completion_items = []; @@ -1595,7 +1593,7 @@ public function getCompletionItemsForPartialSymbol( string $type_string, int $offset, string $file_path - ) : array { + ): array { $fq_suggestion = false; if (($type_string[1] ?? '') === '\\') { @@ -1818,7 +1816,7 @@ public function getCompletionItemsForType(Type\Union $type): array */ public function getCompletionItemsForArrayKeys( string $type_string - ) : array { + ): array { $completion_items = []; $type = Type::parseString($type_string); foreach ($type->getAtomicTypes() as $atomic_type) { @@ -1839,7 +1837,7 @@ public function getCompletionItemsForArrayKeys( return $completion_items; } - private static function getPositionFromOffset(int $offset, string $file_contents) : Position + private static function getPositionFromOffset(int $offset, string $file_contents): Position { $file_contents = substr($file_contents, 0, $offset); @@ -1957,7 +1955,7 @@ public function addTaintSource( string $taint_id, array $taints = TaintKindGroup::ALL_INPUT, ?CodeLocation $code_location = null - ) : void { + ): void { if (!$this->taint_flow_graph) { return; } @@ -1986,7 +1984,7 @@ public function addTaintSink( string $taint_id, array $taints = TaintKindGroup::ALL_INPUT, ?CodeLocation $code_location = null - ) : void { + ): void { if (!$this->taint_flow_graph) { return; } diff --git a/src/Psalm/Config.php b/src/Psalm/Config.php index 0902fdebc34..aa98e01872d 100644 --- a/src/Psalm/Config.php +++ b/src/Psalm/Config.php @@ -2100,7 +2100,7 @@ function () use ($vendor_autoload_files_path) { $codebase->classlikes->forgetMissingClassLikes(); $this->include_collector->runAndCollect( - function () { + function (): void { // do this in a separate method so scope does not leak /** @psalm-suppress UnresolvableInclude */ require $this->autoloader; diff --git a/src/Psalm/Config/Creator.php b/src/Psalm/Config/Creator.php index 8c988583682..aa7ac61709a 100644 --- a/src/Psalm/Config/Creator.php +++ b/src/Psalm/Config/Creator.php @@ -56,7 +56,7 @@ public static function getContents( ?string $suggested_dir, int $level, string $vendor_dir - ) : string { + ): string { $paths = self::getPaths($current_dir, $suggested_dir); $template = str_replace( @@ -90,7 +90,7 @@ public static function createBareConfig( string $current_dir, ?string $suggested_dir, string $vendor_dir - ) : Config { + ): Config { $config_contents = self::getContents($current_dir, $suggested_dir, 1, $vendor_dir); return Config::loadFromXML($current_dir, $config_contents); @@ -99,7 +99,7 @@ public static function createBareConfig( /** * @param array $issues */ - public static function getLevel(array $issues, int $counted_types) : int + public static function getLevel(array $issues, int $counted_types): int { if ($counted_types === 0) { $counted_types = 1; @@ -210,7 +210,7 @@ public static function getPaths(string $current_dir, ?string $suggested_dir): ar * @psalm-suppress MixedArgument * @psalm-suppress PossiblyUndefinedArrayOffset */ - private static function getPsr4Or0Paths(string $current_dir, array $composer_json) : array + private static function getPsr4Or0Paths(string $current_dir, array $composer_json): array { $psr_paths = array_merge( $composer_json['autoload']['psr-4'] ?? [], @@ -256,7 +256,7 @@ private static function getPsr4Or0Paths(string $current_dir, array $composer_jso /** * @return list */ - private static function guessPhpFileDirs(string $current_dir) : array + private static function guessPhpFileDirs(string $current_dir): array { $nodes = []; diff --git a/src/Psalm/Config/FileFilter.php b/src/Psalm/Config/FileFilter.php index 5b5a064f2d1..71f04699853 100644 --- a/src/Psalm/Config/FileFilter.php +++ b/src/Psalm/Config/FileFilter.php @@ -412,10 +412,10 @@ public static function loadFromXMLElement( return self::loadFromArray($config, $base_dir, $inclusive); } - private static function isRegularExpression(string $string) : bool + private static function isRegularExpression(string $string): bool { set_error_handler( - function () : bool { + function (): bool { return false; }, E_WARNING diff --git a/src/Psalm/Context.php b/src/Psalm/Context.php index 4b61dadac28..bcb9cc7619d 100644 --- a/src/Psalm/Context.php +++ b/src/Psalm/Context.php @@ -760,7 +760,7 @@ public function hasVariable(string $var_name): bool return isset($this->vars_in_scope[$var_name]); } - public function getScopeSummary() : string + public function getScopeSummary(): string { $summary = []; foreach ($this->vars_possibly_in_scope as $k => $_) { diff --git a/src/Psalm/DocComment.php b/src/Psalm/DocComment.php index f334e39d6b3..1060f1ee8a2 100644 --- a/src/Psalm/DocComment.php +++ b/src/Psalm/DocComment.php @@ -181,7 +181,7 @@ public static function parse(string $docblock, ?int $line_number = null, bool $p /** * Parse a docblock comment into its parts. */ - public static function parsePreservingLength(Doc $docblock) : ParsedDocblock + public static function parsePreservingLength(Doc $docblock): ParsedDocblock { $parsed_docblock = DocblockParser::parse( $docblock->getText(), diff --git a/src/Psalm/ErrorBaseline.php b/src/Psalm/ErrorBaseline.php index e61ef9eb525..f889c7f63b2 100644 --- a/src/Psalm/ErrorBaseline.php +++ b/src/Psalm/ErrorBaseline.php @@ -258,7 +258,7 @@ private static function writeToFile( ('php:' . PHP_VERSION), ], array_map( - function (string $extension) : string { + function (string $extension): string { return $extension . ':' . phpversion($extension); }, $extensions @@ -302,7 +302,7 @@ function (string $extension) : string { /** * @param string[] $matches */ - function (array $matches) : string { + function (array $matches): string { return 'remove_trailing_newline = $remove_trailing_newline; } - public function getKey() : string + public function getKey(): string { return $this->start === $this->end ? ($this->start . ':' . sha1($this->insertion_text)) : ($this->start . ':' . $this->end); } - public function transform(string $existing_contents) : string + public function transform(string $existing_contents): string { if ($this->preserve_indentation) { $newline_pos = strrpos($existing_contents, "\n", $this->start - strlen($existing_contents)); diff --git a/src/Psalm/Internal/Analyzer/AttributeAnalyzer.php b/src/Psalm/Internal/Analyzer/AttributeAnalyzer.php index 4dee8b9f2fd..ecdfee9a6d5 100644 --- a/src/Psalm/Internal/Analyzer/AttributeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/AttributeAnalyzer.php @@ -32,7 +32,7 @@ public static function analyze( array $suppressed_issues, int $target, ?ClassLikeStorage $classlike_storage = null - ) : void { + ): void { if (ClassLikeAnalyzer::checkFullyQualifiedClassLikeName( $source, $attribute->fq_class_name, @@ -186,7 +186,7 @@ private static function checkAttributeTargets( SourceAnalyzer $source, AttributeStorage $attribute, int $target - ) : void { + ): void { $codebase = $source->getCodebase(); $attribute_class_storage = $codebase->classlike_storage_provider->get($attribute->fq_class_name); diff --git a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php index 4d9e3da8608..4aada953394 100644 --- a/src/Psalm/Internal/Analyzer/ClassAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassAnalyzer.php @@ -666,7 +666,7 @@ public static function addContextProperties( string $fq_class_name, ?string $parent_fq_class_name, array $stmts = [] - ) : void { + ): void { $codebase = $statements_source->getCodebase(); foreach ($storage->appearing_property_ids as $property_name => $appearing_property_id) { @@ -1113,7 +1113,7 @@ private function checkPropertyInitialization( $constructor_storage = $constructor_class_storage->methods['__construct']; $fake_constructor_params = array_map( - function (FunctionLikeParameter $param) : PhpParser\Node\Param { + function (FunctionLikeParameter $param): PhpParser\Node\Param { $fake_param = (new PhpParser\Builder\Param($param->name)); if ($param->signature_type) { $fake_param->setType((string)$param->signature_type); @@ -1137,7 +1137,7 @@ function (FunctionLikeParameter $param) : PhpParser\Node\Param { ); $fake_constructor_stmt_args = array_map( - function (FunctionLikeParameter $param) : PhpParser\Node\Arg { + function (FunctionLikeParameter $param): PhpParser\Node\Arg { $attributes = $param->location ? [ 'startFilePos' => $param->location->raw_file_start, @@ -1591,7 +1591,7 @@ private static function addOrUpdatePropertyType( Type\Union $inferred_type, StatementsSource $source, bool $docblock_only = false - ) : void { + ): void { $manipulator = PropertyDocblockManipulator::getForProperty( $project_analyzer, $source->getFilePath(), @@ -1849,7 +1849,7 @@ public static function analyzeClassMethodReturnType( MethodIdentifier $analyzed_method_id, MethodIdentifier $actual_method_id, bool $did_explicitly_return - ) : void { + ): void { $secondary_return_type_location = null; $actual_method_storage = $codebase->methods->getStorage($actual_method_id); @@ -2149,7 +2149,7 @@ private function checkImplementedInterfaces( Codebase $codebase, string $fq_class_name, ClassLikeStorage $storage - ) : bool { + ): bool { $classlike_storage_provider = $codebase->classlike_storage_provider; foreach ($class->implements as $interface_name) { @@ -2425,7 +2425,7 @@ private function checkParentClass( ClassLikeStorage $storage, Codebase $codebase, ?Context $class_context - ) : void { + ): void { $classlike_storage_provider = $codebase->classlike_storage_provider; if (!$parent_fq_class_name) { diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php index dbcbac2367a..d7728d32114 100644 --- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php @@ -184,7 +184,7 @@ public function getMethodMutations( } } - public function getFunctionLikeAnalyzer(string $method_name) : ?MethodAnalyzer + public function getFunctionLikeAnalyzer(string $method_name): ?MethodAnalyzer { foreach ($this->class->stmts as $stmt) { if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod && @@ -639,7 +639,7 @@ public static function getClassesForFile(Codebase $codebase, string $file_path): } } - public function getFileAnalyzer() : FileAnalyzer + public function getFileAnalyzer(): FileAnalyzer { return $this->file_analyzer; } diff --git a/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php b/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php index 0cb2ade5a98..bf4cfc4052b 100644 --- a/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClosureAnalyzer.php @@ -68,7 +68,7 @@ public static function analyzeExpression( StatementsAnalyzer $statements_analyzer, PhpParser\Node\FunctionLike $stmt, Context $context - ) : bool { + ): bool { $closure_analyzer = new ClosureAnalyzer($stmt, $statements_analyzer); if ($stmt instanceof PhpParser\Node\Expr\Closure @@ -230,7 +230,7 @@ public static function analyzeClosureUses( Context $context ): ?bool { $param_names = array_map( - function (PhpParser\Node\Param $p) : string { + function (PhpParser\Node\Param $p): string { if (!$p->var instanceof PhpParser\Node\Expr\Variable || !is_string($p->var->name) ) { diff --git a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php index 02bf3bb0a8b..72179a45194 100644 --- a/src/Psalm/Internal/Analyzer/CommentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/CommentAnalyzer.php @@ -77,7 +77,7 @@ public static function arrayToDocblocks( Aliases $aliases, ?array $template_type_map = null, ?array $type_aliases = null - ) : array { + ): array { $var_id = null; $var_type_tokens = null; @@ -211,7 +211,7 @@ public static function arrayToDocblocks( private static function decorateVarDocblockComment( VarDocblockComment $var_comment, ParsedDocblock $parsed_docblock - ) : void { + ): void { $var_comment->deprecated = isset($parsed_docblock->tags['deprecated']); $var_comment->internal = isset($parsed_docblock->tags['internal']); $var_comment->readonly = isset($parsed_docblock->tags['readonly']) @@ -252,7 +252,7 @@ private static function decorateVarDocblockComment( /** * @psalm-pure */ - public static function sanitizeDocblockType(string $docblock_type) : string + public static function sanitizeDocblockType(string $docblock_type): string { $docblock_type = preg_replace('@^[ \t]*\*@m', '', $docblock_type); $docblock_type = preg_replace('/,\n\s+\}/', '}', $docblock_type); diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php index 8223811b707..0d26436d40a 100644 --- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php @@ -445,7 +445,7 @@ public function getMethodMutations( } } - public function getFunctionLikeAnalyzer(MethodIdentifier $method_id) : ?MethodAnalyzer + public function getFunctionLikeAnalyzer(MethodIdentifier $method_id): ?MethodAnalyzer { $fq_class_name = $method_id->fq_class_name; $method_name = $method_id->method_name; @@ -634,7 +634,7 @@ public function isStatic(): bool /** * @psalm-mutation-free */ - public function getFileAnalyzer() : FileAnalyzer + public function getFileAnalyzer(): FileAnalyzer { return $this; } @@ -642,22 +642,22 @@ public function getFileAnalyzer() : FileAnalyzer /** * @psalm-mutation-free */ - public function getProjectAnalyzer() : ProjectAnalyzer + public function getProjectAnalyzer(): ProjectAnalyzer { return $this->project_analyzer; } - public function getCodebase() : Codebase + public function getCodebase(): Codebase { return $this->codebase; } - public function getFirstStatementOffset() : int + public function getFirstStatementOffset(): int { return $this->first_statement_offset; } - public function getNodeTypeProvider() : NodeTypeProvider + public function getNodeTypeProvider(): NodeTypeProvider { if (!$this->node_data) { throw new UnexpectedValueException('There should be a node type provider'); @@ -666,12 +666,12 @@ public function getNodeTypeProvider() : NodeTypeProvider return $this->node_data; } - public function getReturnType() : ?Type\Union + public function getReturnType(): ?Type\Union { return $this->return_type; } - public function clearSourceBeforeDestruction() : void + public function clearSourceBeforeDestruction(): void { unset($this->source); } diff --git a/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php index f2eb2127eed..a03542503d5 100644 --- a/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionAnalyzer.php @@ -54,7 +54,7 @@ public static function analyzeStatement( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Stmt\Function_ $stmt, Context $context - ) : void { + ): void { foreach ($stmt->stmts as $function_stmt) { if ($function_stmt instanceof PhpParser\Node\Stmt\Global_) { foreach ($function_stmt->vars as $var) { diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php index 661739595e7..cc6ca0d0976 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeAnalyzer.php @@ -238,7 +238,7 @@ public static function verifyReturnType( if ($number_of_types > 1) { $inferred_return_type_parts = array_filter( $inferred_return_type_parts, - static function (Union $union_type) : bool { + static function (Union $union_type): bool { return !($union_type->isNever() || $union_type->isEmpty()); } ); diff --git a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php index 3bf0e613c5e..cd1b239d313 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php +++ b/src/Psalm/Internal/Analyzer/FunctionLike/ReturnTypeCollector.php @@ -243,7 +243,7 @@ private static function processYieldTypes( Codebase $codebase, array $return_types, array $yield_types - ) : array { + ): array { $key_type = null; $value_type = null; diff --git a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php index 5946b953fe6..fe99cb29fa8 100644 --- a/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php @@ -812,7 +812,7 @@ private function checkParamReferences( FunctionLikeStorage $storage, ?ClassLikeStorage $class_storage, Context $context - ) : void { + ): void { $codebase = $statements_analyzer->getCodebase(); $unused_params = []; @@ -956,7 +956,7 @@ private function processParams( array $params, Context $context, bool $has_template_types - ) : bool { + ): bool { $check_stmts = true; $codebase = $statements_analyzer->getCodebase(); $project_analyzer = $statements_analyzer->getProjectAnalyzer(); @@ -1262,7 +1262,7 @@ private function alterParams( FunctionLikeStorage $storage, array $params, Context $context - ) : void { + ): void { foreach ($this->function->params as $param) { $param_name_node = null; @@ -1589,7 +1589,7 @@ public function getFunctionLikeStorage(?StatementsAnalyzer $statements_analyzer } /** @return non-empty-string */ - public function getId() : string + public function getId(): string { if ($this instanceof MethodAnalyzer) { return (string) $this->getMethodId(); @@ -1654,7 +1654,7 @@ public function isStatic(): bool return $this->is_static; } - public function getCodebase() : Codebase + public function getCodebase(): Codebase { return $this->codebase; } diff --git a/src/Psalm/Internal/Analyzer/MethodComparator.php b/src/Psalm/Internal/Analyzer/MethodComparator.php index f2fa1e89ffb..01d302204e3 100644 --- a/src/Psalm/Internal/Analyzer/MethodComparator.php +++ b/src/Psalm/Internal/Analyzer/MethodComparator.php @@ -225,7 +225,7 @@ private static function checkForObviousMethodMismatches( bool $trait_mismatches_are_fatal, CodeLocation $code_location, array $suppressed_issues - ) : void { + ): void { if ($implementer_visibility > $guide_visibility) { if ($trait_mismatches_are_fatal || $guide_classlike_storage->is_trait === $implementer_classlike_storage->is_trait @@ -322,7 +322,7 @@ private static function compareMethodParams( bool $prevent_method_signature_mismatch, CodeLocation $code_location, array $suppressed_issues - ) : void { + ): void { if ($prevent_method_signature_mismatch) { if (!$guide_classlike_storage->user_defined && $guide_param->type @@ -530,7 +530,7 @@ private static function compareMethodSignatureParams( string $cased_implementer_method_id, CodeLocation $code_location, array $suppressed_issues - ) : void { + ): void { $guide_param_signature_type = $guide_param->signature_type ? TypeExpander::expandUnion( $codebase, @@ -652,7 +652,7 @@ private static function compareMethodDocblockParams( Type\Union $implementer_param_type, CodeLocation $code_location, array $suppressed_issues - ) : void { + ): void { $implementer_method_storage_param_type = TypeExpander::expandUnion( $codebase, $implementer_param_type, @@ -817,7 +817,7 @@ private static function compareMethodSignatureReturnTypes( string $cased_implementer_method_id, CodeLocation $code_location, array $suppressed_issues - ) : void { + ): void { $guide_signature_return_type = TypeExpander::expandUnion( $codebase, $guide_signature_return_type, @@ -906,7 +906,7 @@ private static function compareMethodDocblockReturnTypes( ?MethodIdentifier $implementer_declaring_method_id, CodeLocation $code_location, array $suppressed_issues - ) : void { + ): void { $implementer_method_storage_return_type = TypeExpander::expandUnion( $codebase, $implementer_return_type, @@ -1031,7 +1031,7 @@ private static function transformTemplates( string $base_class_name, Type\Union $templated_type, Codebase $codebase - ) : void { + ): void { if (isset($template_extended_params[$base_class_name])) { $map = $template_extended_params[$base_class_name]; diff --git a/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php b/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php index 62d8e2cbd86..aa86c4d6d15 100644 --- a/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/NamespaceAnalyzer.php @@ -144,7 +144,7 @@ public static function getConstantsForNamespace(string $namespace_name, int $vis throw new InvalidArgumentException('Given $visibility not supported'); } - public function getFileAnalyzer() : FileAnalyzer + public function getFileAnalyzer(): FileAnalyzer { return $this->source; } diff --git a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php index f0e0f567470..5844cedb9ae 100644 --- a/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php @@ -334,7 +334,7 @@ public function __construct( self::$instance = $this; } - private function clearCacheDirectoryIfConfigOrComposerLockfileChanged() : void + private function clearCacheDirectoryIfConfigOrComposerLockfileChanged(): void { if ($this->project_cache_provider && $this->project_cache_provider->hasLockfileChanged() @@ -414,7 +414,7 @@ public static function getFileReportOptions(array $report_file_paths, bool $show return $report_options; } - private function visitAutoloadFiles() : void + private function visitAutoloadFiles(): void { $start_time = microtime(true); @@ -718,7 +718,7 @@ public function trackUnusedSuppressions(): void $this->codebase->track_unused_suppressions = true; } - public function interpretRefactors() : void + public function interpretRefactors(): void { if (!$this->codebase->alter_code) { throw new UnexpectedValueException('Should not be checking references'); @@ -919,7 +919,7 @@ public function interpretRefactors() : void } } - public function prepareMigration() : void + public function prepareMigration(): void { if (!$this->codebase->alter_code) { throw new UnexpectedValueException('Should not be checking references'); @@ -940,7 +940,7 @@ public function prepareMigration() : void ); } - public function migrateCode() : void + public function migrateCode(): void { if (!$this->codebase->alter_code) { throw new UnexpectedValueException('Should not be checking references'); @@ -1095,7 +1095,7 @@ public function addProjectFile(string $file_path): void $this->project_files[$file_path] = $file_path; } - public function addExtraFile(string $file_path) : void + public function addExtraFile(string $file_path): void { $this->extra_files[$file_path] = $file_path; } @@ -1445,7 +1445,7 @@ public function getMethodMutations( public function getFunctionLikeAnalyzer( MethodIdentifier $method_id, string $file_path - ) : ?FunctionLikeAnalyzer { + ): ?FunctionLikeAnalyzer { $file_analyzer = new FileAnalyzer( $this, $file_path, diff --git a/src/Psalm/Internal/Analyzer/SourceAnalyzer.php b/src/Psalm/Internal/Analyzer/SourceAnalyzer.php index 604633ae30c..f2c05f5003b 100644 --- a/src/Psalm/Internal/Analyzer/SourceAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/SourceAnalyzer.php @@ -145,7 +145,7 @@ public function isStatic(): bool /** * @psalm-mutation-free */ - public function getCodebase() : Codebase + public function getCodebase(): Codebase { return $this->source->getCodebase(); } @@ -153,7 +153,7 @@ public function getCodebase() : Codebase /** * @psalm-mutation-free */ - public function getProjectAnalyzer() : ProjectAnalyzer + public function getProjectAnalyzer(): ProjectAnalyzer { return $this->source->getProjectAnalyzer(); } @@ -161,7 +161,7 @@ public function getProjectAnalyzer() : ProjectAnalyzer /** * @psalm-mutation-free */ - public function getFileAnalyzer() : FileAnalyzer + public function getFileAnalyzer(): FileAnalyzer { return $this->source->getFileAnalyzer(); } @@ -174,7 +174,7 @@ public function getTemplateTypeMap(): ?array return $this->source->getTemplateTypeMap(); } - public function getNodeTypeProvider() : NodeTypeProvider + public function getNodeTypeProvider(): NodeTypeProvider { return $this->source->getNodeTypeProvider(); } diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/DoAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/DoAnalyzer.php index 03aa1c92757..e707bdabd28 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/DoAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/DoAnalyzer.php @@ -176,7 +176,7 @@ private static function analyzeDoNaively( PhpParser\Node\Stmt\Do_ $stmt, Context $context, LoopScope $loop_scope - ) : void { + ): void { $do_context = clone $context; $suppressed_issues = $statements_analyzer->getSuppressedIssues(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php index 47a7fd68dbf..3bca62e6f85 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/ForeachAnalyzer.php @@ -979,7 +979,7 @@ public static function getKeyValueParamsForTraversableObject( : array_values( array_map( /** @param array $arr */ - function (array $arr) use ($iterator_atomic_type) : Type\Union { + function (array $arr) use ($iterator_atomic_type): Type\Union { return $arr[$iterator_atomic_type->value] ?? Type::getMixed(); }, $generic_storage->template_types @@ -1016,7 +1016,7 @@ private static function getFakeMethodCallType( PhpParser\Node\Expr $foreach_expr, Context $context, string $method_name - ) : ?Type\Union { + ): ?Type\Union { $old_data_provider = $statements_analyzer->node_data; $statements_analyzer->node_data = clone $statements_analyzer->node_data; diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php index 7910f9d5e54..d964ef5b0e3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/IfElse/IfAnalyzer.php @@ -263,7 +263,7 @@ private static function handleMicDrop( IfScope $if_scope, Context $post_if_context, array $new_assigned_var_ids - ) : bool { + ): bool { if (!$if_scope->negated_types) { return false; } @@ -352,7 +352,7 @@ public static function addConditionallyAssignedVarsToContext( Context $post_leaving_if_context, Context $post_if_context, array $assigned_in_conditional_var_ids - ) : void { + ): void { // this filters out coercions to expected types in ArgumentAnalyzer $assigned_in_conditional_var_ids = array_filter($assigned_in_conditional_var_ids); @@ -432,7 +432,7 @@ private static function getDefinitelyEvaluatedOredExpressions(PhpParser\Node\Exp return [$stmt]; } - private static function negateExpr(PhpParser\Node\Expr $expr) : PhpParser\Node\Expr + private static function negateExpr(PhpParser\Node\Expr $expr): PhpParser\Node\Expr { if ($expr instanceof PhpParser\Node\Expr\BooleanNot) { return $expr->expr; @@ -455,7 +455,7 @@ public static function updateIfScope( array $possibly_assigned_var_ids, array $newly_reconciled_var_ids, bool $update_new_vars = true - ) : void { + ): void { $redefined_vars = $if_context->getRedefinedVars($outer_context->vars_in_scope); if ($if_scope->new_vars === null) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php index c86965e7e3b..4cd3d80e0b3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php @@ -675,7 +675,7 @@ private static function handleNonReturningCase( private static function simplifyCaseEqualityExpression( PhpParser\Node\Expr $case_equality_expr, PhpParser\Node\Expr\Variable $var - ) : ?PhpParser\Node\Expr\FuncCall { + ): ?PhpParser\Node\Expr\FuncCall { if ($case_equality_expr instanceof PhpParser\Node\Expr\BinaryOp\BooleanOr) { $nested_or_options = self::getOptionsFromNestedOr($case_equality_expr, $var); @@ -719,7 +719,7 @@ private static function getOptionsFromNestedOr( PhpParser\Node\Expr $case_equality_expr, PhpParser\Node\Expr\Variable $var, array $in_array_values = [] - ) : ?array { + ): ?array { if ($case_equality_expr instanceof PhpParser\Node\Expr\BinaryOp\Identical && $case_equality_expr->left instanceof PhpParser\Node\Expr\Variable && $case_equality_expr->left->name === $var->name diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/WhileAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/WhileAnalyzer.php index 3625168ebf1..307f9079d0f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/WhileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/WhileAnalyzer.php @@ -125,7 +125,7 @@ public static function analyze( */ public static function getAndExpressions( PhpParser\Node\Expr $expr - ) : array { + ): array { if ($expr instanceof PhpParser\Node\Expr\BinaryOp\BooleanAnd) { return array_merge( self::getAndExpressions($expr->left), diff --git a/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php index a0a1932b8be..aa74929b7e3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/BreakAnalyzer.php @@ -15,7 +15,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Stmt\Break_ $stmt, Context $context - ) : void { + ): void { $loop_scope = $context->loop_scope; $leaving_switch = true; diff --git a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php index 62c550eb170..36e1bd2b380 100644 --- a/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/EchoAnalyzer.php @@ -23,7 +23,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Stmt\Echo_ $stmt, Context $context - ) : bool { + ): bool { $echo_param = new FunctionLikeParameter( 'var', false diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php index f417b6defbb..f77ca5f8d31 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ArrayAnalyzer.php @@ -37,7 +37,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Array_ $stmt, Context $context - ) : bool { + ): bool { // if the array is empty, this special type allows us to match any other array type against it if (empty($stmt->items)) { $statements_analyzer->node_data->setType($stmt, Type::getEmptyArray()); @@ -233,7 +233,7 @@ private static function analyzeArrayItem( ArrayCreationInfo $array_creation_info, PhpParser\Node\Expr\ArrayItem $item, Codebase $codebase - ) : void { + ): void { if ($item->unpack) { if (ExpressionAnalyzer::analyze($statements_analyzer, $item->value, $context) === false) { return; @@ -485,7 +485,7 @@ private static function handleUnpackedArray( PhpParser\Node\Expr\ArrayItem $item, Type\Union $unpacked_array_type, Codebase $codebase - ) : void { + ): void { foreach ($unpacked_array_type->getAtomicTypes() as $unpacked_atomic_type) { if ($unpacked_atomic_type instanceof Type\Atomic\TKeyedArray) { foreach ($unpacked_atomic_type->properties as $key => $property_value) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php index cdb37a02941..1ed859dd3e4 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php @@ -813,7 +813,7 @@ private static function processIrreconcilableFunctionCall( StatementsAnalyzer $source, Codebase $codebase, bool $negate - ) : void { + ): void { if ($first_var_type->hasMixed()) { return; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php index ab625accf3b..884931b32ad 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php @@ -283,7 +283,7 @@ private static function updateTypeWithKeyValues( Type\Union $child_stmt_type, Type\Union $current_type, array $key_values - ) : Type\Union { + ): Type\Union { $has_matching_objectlike_property = false; $has_matching_string = false; @@ -394,7 +394,7 @@ private static function taintArrayAssignment( Type\Union $child_stmt_type, ?string $var_var_id, array $key_values - ) : void { + ): void { if ($statements_analyzer->data_flow_graph && ($statements_analyzer->data_flow_graph instanceof VariableUseGraph || !in_array('TaintedInput', $statements_analyzer->getSuppressedIssues())) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php index 0190b4f9a15..0c4e331242e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/InstancePropertyAssignmentAnalyzer.php @@ -448,7 +448,7 @@ private static function taintProperty( ClassLikeStorage $class_storage, Type\Union $assignment_value_type, Context $context - ) : void { + ): void { if (!$statements_analyzer->data_flow_graph) { return; } @@ -1412,7 +1412,7 @@ public static function getExpandedPropertyType( string $fq_class_name, string $property_name, ClassLikeStorage $storage - ) : ?Type\Union { + ): ?Type\Union { $property_class_name = $codebase->properties->getDeclaringClassForProperty( $fq_class_name . '::$' . $property_name, true diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php index 194aa2aea94..6a714681295 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssignmentAnalyzer.php @@ -616,7 +616,7 @@ public static function assignTypeFromVarDocblock( ?Type\Union &$comment_type = null, ?CodeLocation\DocblockTypeLocation &$comment_type_location = null, array $not_ignored_docblock_var_ids = [] - ) : void { + ): void { if (!$var_comment->type) { return; } @@ -726,7 +726,7 @@ private static function taintAssignment( CodeLocation $var_location, array $removed_taints, array $added_taints - ) : void { + ): void { $parent_nodes = $type->parent_nodes; $unspecialized_parent_nodes = array_filter( @@ -842,7 +842,7 @@ public static function analyzeAssignmentRef( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\AssignRef $stmt, Context $context - ) : bool { + ): bool { $assignment_type = self::analyze( $statements_analyzer, $stmt->var, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php index 695c446143c..c15606ee2b8 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php @@ -33,7 +33,7 @@ public static function analyze( PhpParser\Node\Expr\BinaryOp $stmt, Context $context, bool $from_stmt = false - ) : bool { + ): bool { if ($from_stmt) { $fake_if_stmt = new VirtualIf( $stmt->left, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php index 9b50880574c..e95c17b3368 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php @@ -62,7 +62,7 @@ public static function analyze( PhpParser\Node $parent, ?Type\Union &$result_type = null, ?Context $context = null - ) : void { + ): void { $codebase = $statements_source ? $statements_source->getCodebase() : null; $left_type = $nodes->getType($left); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php index c6523224c5d..ed1501b3804 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/CoalesceAnalyzer.php @@ -21,7 +21,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\BinaryOp\Coalesce $stmt, Context $context - ) : bool { + ): bool { $left_expr = $stmt->left; $root_expr = $left_expr; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php index cbd606cd901..9f7d678015f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/NonComparisonOpAnalyzer.php @@ -16,7 +16,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\BinaryOp $stmt, Context $context - ) : void { + ): void { $stmt_left_type = $statements_analyzer->node_data->getType($stmt->left); $stmt_right_type = $statements_analyzer->node_data->getType($stmt->right); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php index d76f07de626..a71bd2e0aa9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/OrAnalyzer.php @@ -41,7 +41,7 @@ public static function analyze( PhpParser\Node\Expr\BinaryOp $stmt, Context $context, bool $from_stmt = false - ) : bool { + ): bool { if ($from_stmt) { $fake_if_stmt = new VirtualIf( new VirtualBooleanNot($stmt->left, $stmt->left->getAttributes()), diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php index a49d8ba0090..7831a768d23 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOpAnalyzer.php @@ -37,7 +37,7 @@ public static function analyze( Context $context, int $nesting = 0, bool $from_stmt = false - ) : bool { + ): bool { if ($stmt instanceof PhpParser\Node\Expr\BinaryOp\Concat && $nesting > 100) { $statements_analyzer->node_data->setType($stmt, Type::getString()); @@ -365,7 +365,7 @@ public static function addDataFlow( PhpParser\Node\Expr $left, PhpParser\Node\Expr $right, string $type = 'binaryop' - ) : void { + ): void { if ($stmt->getLine() === -1) { throw new UnexpectedValueException('bad'); } @@ -446,7 +446,7 @@ private static function checkForImpureEqualityComparison( PhpParser\Node\Expr\BinaryOp\Equal $stmt, Type\Union $stmt_left_type, Type\Union $stmt_right_type - ) : void { + ): void { $codebase = $statements_analyzer->getCodebase(); if ($stmt_left_type->hasString() && $stmt_right_type->hasObjectType()) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php index 773b20032ad..65ef31f3ca9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BooleanNotAnalyzer.php @@ -13,7 +13,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\BooleanNot $stmt, Context $context - ) : bool { + ): bool { $inside_negation = $context->inside_negation; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index dc1574c1088..469215a775b 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -1150,7 +1150,7 @@ private static function verifyExplicitParam( CodeLocation $arg_location, PhpParser\Node\Expr $input_expr, Context $context - ) : void { + ): void { $codebase = $statements_analyzer->getCodebase(); foreach ($param_type->getAtomicTypes() as $param_type_part) { @@ -1333,7 +1333,7 @@ private static function coerceValueAfterGatekeeperArgument( Context $context, bool $unpack, ?Type\Atomic $unpacked_atomic_array - ) : void { + ): void { if ($param_type->hasMixed()) { return; } @@ -1458,7 +1458,7 @@ private static function processTaintedness( PhpParser\Node\Expr $expr, Context $context, bool $specialize_taint - ) : Type\Union { + ): Type\Union { $codebase = $statements_analyzer->getCodebase(); if (!$statements_analyzer->data_flow_graph diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php index 985cadd5934..ac083fb1bfa 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php @@ -238,7 +238,7 @@ private static function handleArrayMapFilterArrayArg( PhpParser\Node\Arg $arg, Context $context, ?TemplateResult &$template_result - ) : void { + ): void { $codebase = $statements_analyzer->getCodebase(); $generic_param_type = new Type\Union([ @@ -295,7 +295,7 @@ private static function handleClosureArg( int $argument_offset, PhpParser\Node\Arg $arg, FunctionLikeParameter $param - ) : void { + ): void { if (!$param->type) { return; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php index 562340610c9..0c5bd1475f9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ClassTemplateParamCollector.php @@ -233,7 +233,7 @@ private static function expandType( array $e, string $static_fq_class_name, ?array $static_template_types - ) : array { + ): array { $output_type_extends = []; foreach ($input_type_extends->getAtomicTypes() as $type_extends_atomic) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php index a907c0d8a23..f108cff5589 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php @@ -74,7 +74,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\FuncCall $stmt, Context $context - ) : bool { + ): bool { $function_name = $stmt->name; $codebase = $statements_analyzer->getCodebase(); @@ -300,7 +300,7 @@ public static function analyze( $statements_analyzer->node_data->setIfTrueAssertions( $stmt, array_map( - function (Assertion $assertion) use ($inferred_lower_bounds, $codebase) : Assertion { + function (Assertion $assertion) use ($inferred_lower_bounds, $codebase): Assertion { return $assertion->getUntemplatedCopy($inferred_lower_bounds ?: [], null, $codebase); }, $function_call_info->function_storage->if_true_assertions @@ -312,7 +312,7 @@ function (Assertion $assertion) use ($inferred_lower_bounds, $codebase) : Assert $statements_analyzer->node_data->setIfFalseAssertions( $stmt, array_map( - function (Assertion $assertion) use ($inferred_lower_bounds, $codebase) : Assertion { + function (Assertion $assertion) use ($inferred_lower_bounds, $codebase): Assertion { return $assertion->getUntemplatedCopy($inferred_lower_bounds ?: [], null, $codebase); }, $function_call_info->function_storage->if_false_assertions @@ -358,9 +358,6 @@ function (Assertion $assertion) use ($inferred_lower_bounds, $codebase) : Assert return true; } - /** - * @return FunctionCallInfo - */ private static function handleNamedFunction( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\FuncCall $stmt, @@ -784,7 +781,7 @@ private static function analyzeInvokeCall( PhpParser\Node\Expr $function_name, Context $context, Type\Atomic $atomic_type - ) : void { + ): void { $old_data_provider = $statements_analyzer->node_data; $statements_analyzer->node_data = clone $statements_analyzer->node_data; @@ -840,7 +837,7 @@ private static function processAssertFunctionEffects( PhpParser\Node\Expr\FuncCall $stmt, PhpParser\Node\Arg $first_arg, Context $context - ) : void { + ): void { $first_arg_value_id = spl_object_id($first_arg->value); $assert_clauses = FormulaGenerator::getFormula( @@ -932,7 +929,7 @@ private static function checkFunctionCallPurity( PhpParser\Node $function_name, FunctionCallInfo $function_call_info, Context $context - ) : void { + ): void { $config = $codebase->config; if (!$context->collect_initializations diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php index 8ef3fe3e235..eeb8e8db6c8 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallReturnTypeFetcher.php @@ -54,7 +54,7 @@ public static function fetch( ?TCallable $callmap_callable, TemplateResult $template_result, Context $context - ) : Type\Union { + ): Type\Union { $stmt_type = null; $config = $codebase->config; @@ -539,7 +539,7 @@ private static function taintReturnType( Type\Union $stmt_type, TemplateResult $template_result, Context $context - ) : ?DataFlowNode { + ): ?DataFlowNode { if (!$statements_analyzer->data_flow_graph) { return null; } @@ -703,7 +703,7 @@ public static function taintUsingFlows( DataFlowNode $function_call_node, array $removed_taints, array $added_taints = [] - ) : void { + ): void { foreach ($function_storage->return_source_params as $i => $path_type) { if (!isset($args[$i])) { continue; @@ -749,7 +749,7 @@ public static function taintUsingFlows( /** * @psalm-pure */ - private static function simpleExclusion(string $pattern, string $escape_char) : bool + private static function simpleExclusion(string $pattern, string $escape_char): bool { $str_length = strlen($pattern); 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 40494474436..f464f99065b 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php @@ -63,7 +63,7 @@ public static function analyze( bool $is_intersection, ?string $lhs_var_id, AtomicMethodCallAnalysisResult $result - ) : void { + ): void { if ($lhs_type_part instanceof TTemplateParam && !$lhs_type_part->as->isMixed() ) { @@ -471,7 +471,7 @@ private static function getIntersectionReturnType( ?string $lhs_var_id, AtomicMethodCallAnalysisResult $result, array $intersection_types - ) : array { + ): array { $all_intersection_return_type = null; $all_intersection_existent_method_ids = []; @@ -528,7 +528,7 @@ private static function updateResultReturnType( Type\Union $return_type_candidate, ?Type\Union $all_intersection_return_type, Codebase $codebase - ) : void { + ): void { if ($all_intersection_return_type) { $return_type_candidate = Type::intersectUnionTypes( $all_intersection_return_type, @@ -550,7 +550,7 @@ private static function handleInvalidClass( Context $context, bool $is_intersection, AtomicMethodCallAnalysisResult $result - ) : void { + ): void { switch (get_class($lhs_type_part)) { case Type\Atomic\TNull::class: case Type\Atomic\TFalse::class: 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 9083f3c573c..ecae3b31a61 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/ExistingAtomicMethodCallAnalyzer.php @@ -58,7 +58,7 @@ public static function analyze( ?string $lhs_var_id, MethodIdentifier $method_id, AtomicMethodCallAnalysisResult $result - ) : Type\Union { + ): Type\Union { $config = $codebase->config; $fq_class_name = $lhs_type_part->value; @@ -300,7 +300,7 @@ public static function analyze( $context->vars_in_scope[$lhs_var_id] = $self_out_candidate; } - + if (!$context->collect_mutations && !$context->collect_initializations) { MethodCallPurityAnalyzer::analyze( $statements_analyzer, @@ -370,7 +370,7 @@ function (Assertion $assertion) use ( $class_template_params, $lhs_var_id, $codebase - ) : Assertion { + ): Assertion { return $assertion->getUntemplatedCopy( $class_template_params ?: [], $lhs_var_id, @@ -390,7 +390,7 @@ function (Assertion $assertion) use ( $class_template_params, $lhs_var_id, $codebase - ) : Assertion { + ): Assertion { return $assertion->getUntemplatedCopy( $class_template_params ?: [], $lhs_var_id, @@ -468,7 +468,7 @@ private static function getMagicGetterOrSetterProperty( PhpParser\Node\Identifier $stmt_name, Context $context, string $fq_class_name - ) : ?Type\Union { + ): ?Type\Union { $method_name = strtolower($stmt_name->name); if (!in_array($method_name, ['__get', '__set'], true)) { return null; 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 1166430ee64..30ae25cf5e9 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallPurityAnalyzer.php @@ -32,7 +32,7 @@ public static function analyze( Context $context, Config $config, AtomicMethodCallAnalysisResult $result - ) : void { + ): void { $method_pure_compatible = $method_storage->external_mutation_free && $statements_analyzer->node_data->isPureCompatible($stmt->var); 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 0fbd9b3713f..54ee8053b91 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php @@ -48,7 +48,7 @@ public static function fetch( array $args, AtomicMethodCallAnalysisResult $result, TemplateResult $template_result - ) : Type\Union { + ): Type\Union { $call_map_id = $declaring_method_id ?? $method_id; $fq_class_name = $method_id->fq_class_name; @@ -246,7 +246,7 @@ public static function taintMethodCallResult( ?MethodIdentifier $declaring_method_id, string $cased_method_id, Context $context - ) : void { + ): void { if (!$statements_analyzer->data_flow_graph || !$declaring_method_id ) { @@ -526,7 +526,7 @@ public static function replaceTemplateTypes( MethodIdentifier $method_id, int $arg_count, Codebase $codebase - ) : Type\Union { + ): Type\Union { if ($template_result->template_types) { $bindable_template_types = $return_type_candidate->getTemplateTypes(); 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 fa6a4cfd1cd..9f01a786c17 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php @@ -33,7 +33,7 @@ public static function handleMagicMethod( Config $config, ?Type\Union $all_intersection_return_type, AtomicMethodCallAnalysisResult $result - ) : ?AtomicCallContext { + ): ?AtomicCallContext { $fq_class_name = $method_id->fq_class_name; $method_name_lc = $method_id->method_name; @@ -204,7 +204,7 @@ public static function handleMissingOrMagicMethod( ?string $intersection_method_id, string $cased_method_id, AtomicMethodCallAnalysisResult $result - ) : void { + ): void { $fq_class_name = $method_id->fq_class_name; $method_name_lc = $method_id->method_name; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php index 0a54d7eb11f..6e33e4dcc12 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php @@ -42,7 +42,7 @@ public static function analyze( PhpParser\Node\Expr\MethodCall $stmt, Context $context, bool $real_method_call = true - ) : bool { + ): bool { $was_inside_call = $context->inside_call; $context->inside_call = true; @@ -440,7 +440,7 @@ function (?Type\Union $type_1, Type\Union $type_2) use ($codebase): Type\Union { return true; } - public static function hasNullsafe(PhpParser\Node\Expr $expr) : bool + public static function hasNullsafe(PhpParser\Node\Expr $expr): bool { if ($expr instanceof PhpParser\Node\Expr\MethodCall || $expr instanceof PhpParser\Node\Expr\PropertyFetch diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php index 05d56ac1274..bb3fa53c14d 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NamedFunctionCallHandler.php @@ -53,7 +53,7 @@ public static function handle( PhpParser\Node\Name $function_name, ?string $function_id, Context $context - ) : void { + ): void { if ($function_id === 'get_class' || $function_id === 'gettype' || $function_id === 'get_debug_type' @@ -347,7 +347,7 @@ public static function handle( foreach ($anded_assertions as $assertions) { $referenced_var_ids = array_map( - function (array $_) : bool { + function (array $_): bool { return true; }, $assertions @@ -461,7 +461,7 @@ private static function handleDependentTypeFunction( PhpParser\Node\Expr\FuncCall $real_stmt, string $function_id, Context $context - ) : void { + ): void { $first_arg = $stmt->getArgs()[0] ?? null; if ($first_arg) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php index 1136fb219a1..b274be2ed2e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/NewAnalyzer.php @@ -54,7 +54,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\New_ $stmt, Context $context - ) : bool { + ): bool { $fq_class_name = null; $codebase = $statements_analyzer->getCodebase(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php index 4abb30b236d..da80dbed86c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticCallAnalyzer.php @@ -39,7 +39,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\StaticCall $stmt, Context $context - ) : bool { + ): bool { $method_id = null; $lhs_type = null; @@ -251,7 +251,7 @@ public static function taintReturnType( ?MethodStorage $method_storage, ?TemplateResult $template_result, ?Context $context = null - ) : void { + ): void { if (!$statements_analyzer->data_flow_graph) { return; } 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 ecd94e410d7..1fc99732243 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php @@ -57,7 +57,7 @@ public static function analyze( bool &$moved_call, bool &$has_mock, bool &$has_existing_method - ) : void { + ): void { $intersection_types = []; if ($lhs_type_part instanceof TNamedObject) { @@ -253,7 +253,7 @@ private static function handleNamedCall( string $fq_class_name, bool &$moved_call, bool &$has_existing_method - ) : bool { + ): bool { $codebase = $statements_analyzer->getCodebase(); $method_name_lc = strtolower($stmt_name->name); @@ -901,7 +901,7 @@ public static function handleNonObjectCall( Context $context, Type\Atomic $lhs_type_part, bool $ignore_nullable_issues - ) : void { + ): void { $codebase = $statements_analyzer->getCodebase(); $config = $codebase->config; 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 241720a86a3..d55263db206 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php @@ -54,7 +54,7 @@ public static function analyze( string $cased_method_id, ClassLikeStorage $class_storage, bool &$moved_call - ) : void { + ): void { $fq_class_name = $method_id->fq_class_name; $method_name_lc = $method_id->method_name; @@ -321,7 +321,7 @@ public static function analyze( $statements_analyzer->node_data->setIfTrueAssertions( $stmt, array_map( - function (Assertion $assertion) use ($generic_params, $codebase) : Assertion { + function (Assertion $assertion) use ($generic_params, $codebase): Assertion { return $assertion->getUntemplatedCopy($generic_params, null, $codebase); }, $method_storage->if_true_assertions @@ -333,7 +333,7 @@ function (Assertion $assertion) use ($generic_params, $codebase) : Assertion { $statements_analyzer->node_data->setIfFalseAssertions( $stmt, array_map( - function (Assertion $assertion) use ($generic_params, $codebase) : Assertion { + function (Assertion $assertion) use ($generic_params, $codebase): Assertion { return $assertion->getUntemplatedCopy($generic_params, null, $codebase); }, $method_storage->if_false_assertions diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php index 73d79060360..ac6a2c5f21f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php @@ -268,7 +268,7 @@ public static function checkMethodArgs( Context $context, CodeLocation $code_location, StatementsAnalyzer $statements_analyzer - ) : bool { + ): bool { $codebase = $statements_analyzer->getCodebase(); if (!$method_id) { @@ -383,7 +383,7 @@ public static function getTemplateTypesForCall( ?ClassLikeStorage $calling_class_storage, array $existing_template_types = [], array $class_template_params = [] - ) : array { + ): array { $template_types = $existing_template_types; if ($declaring_class_storage) { @@ -1006,7 +1006,7 @@ public static function checkTemplateResult( TemplateResult $template_result, CodeLocation $code_location, ?string $function_id - ) : void { + ): void { if ($template_result->lower_bounds && $template_result->upper_bounds) { foreach ($template_result->upper_bounds as $template_name => $defining_map) { foreach ($defining_map as $defining_id => $upper_bound) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php index d109bdc2f85..c9aafbb533d 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CastAnalyzer.php @@ -43,7 +43,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Cast $stmt, Context $context - ) : bool { + ): bool { if ($stmt instanceof PhpParser\Node\Expr\Cast\Int_) { if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) { return false; @@ -274,7 +274,7 @@ public static function castStringAttempt( Type\Union $stmt_type, PhpParser\Node\Expr $stmt, bool $explicit_cast = false - ) : Type\Union { + ): Type\Union { $codebase = $statements_analyzer->getCodebase(); $invalid_casts = []; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php index 325b8ad0936..a1cb1a24327 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CloneAnalyzer.php @@ -27,7 +27,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Clone_ $stmt, Context $context - ) : bool { + ): bool { $codebase = $statements_analyzer->getCodebase(); $codebase_methods = $codebase->methods; if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php index 3505211c088..e93460bb5d7 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EmptyAnalyzer.php @@ -16,7 +16,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Empty_ $stmt, Context $context - ) : void { + ): void { IssetAnalyzer::analyzeIssetVar($statements_analyzer, $stmt->expr, $context); $codebase = $statements_analyzer->getCodebase(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php index e06eb90999d..fbb4acb5020 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EncapsulatedStringAnalyzer.php @@ -18,7 +18,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Scalar\Encapsed $stmt, Context $context - ) : bool { + ): bool { $stmt_type = Type::getString(); $non_empty = false; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php index 8046e967ed8..dddcf65f171 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/EvalAnalyzer.php @@ -24,7 +24,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Eval_ $stmt, Context $context - ) : void { + ): void { ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context); $codebase = $statements_analyzer->getCodebase(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php index 5dd1eb4632a..c3fd6592c3c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/ExitAnalyzer.php @@ -24,7 +24,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, Exit_ $stmt, Context $context - ) : bool { + ): bool { $expr_type = null; $config = $statements_analyzer->getProjectAnalyzer()->getConfig(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php index c6d2f8108f4..1f6441cd91b 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ArrayFetchAnalyzer.php @@ -89,7 +89,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\ArrayDimFetch $stmt, Context $context - ) : bool { + ): bool { $array_var_id = ExpressionIdentifier::getArrayVarId( $stmt->var, $statements_analyzer->getFQCLN(), @@ -345,7 +345,7 @@ public static function taintArrayFetch( Type\Union $stmt_type, Type\Union $offset_type, ?Context $context = null - ) : void { + ): void { if ($statements_analyzer->data_flow_graph && ($stmt_var_type = $statements_analyzer->node_data->getType($var)) && $stmt_var_type->parent_nodes @@ -848,7 +848,7 @@ private static function checkLiteralIntArrayOffset( PhpParser\Node\Expr\ArrayDimFetch $stmt, Context $context, StatementsAnalyzer $statements_analyzer - ) : void { + ): void { if ($context->inside_isset || $context->inside_unset) { return; } @@ -901,7 +901,7 @@ private static function checkLiteralStringArrayOffset( PhpParser\Node\Expr\ArrayDimFetch $stmt, Context $context, StatementsAnalyzer $statements_analyzer - ) : void { + ): void { if ($context->inside_isset || $context->inside_unset) { return; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php index 09476e7c53f..a3547a51d08 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzer.php @@ -79,7 +79,7 @@ public static function analyze( bool &$has_valid_fetch_type, array &$invalid_fetch_types, bool $is_static_access = false - ) : void { + ): void { if ($lhs_type_part instanceof TNull) { return; } @@ -538,7 +538,7 @@ private static function propertyFetchCanBeAnalyzed( ClassLikeStorage $class_storage, MethodIdentifier $get_method_id, bool $in_assignment - ) : bool { + ): bool { if ((!$naive_property_exists || ($stmt_var_id !== '$this' && $fq_class_name !== $context->self @@ -698,7 +698,7 @@ public static function localizePropertyType( TGenericObject $lhs_type_part, ClassLikeStorage $property_class_storage, ClassLikeStorage $property_declaring_class_storage - ) : Type\Union { + ): Type\Union { $template_types = CallAnalyzer::getTemplateTypesForCall( $codebase, $property_declaring_class_storage, @@ -771,7 +771,7 @@ public static function processTaints( ClassLikeStorage $class_storage, bool $in_assignment, ?Context $context = null - ) : void { + ): void { if (!$statements_analyzer->data_flow_graph) { return; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ClassConstFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ClassConstFetchAnalyzer.php index faedcb412e4..96c1db298fa 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ClassConstFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ClassConstFetchAnalyzer.php @@ -46,7 +46,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\ClassConstFetch $stmt, Context $context - ) : bool { + ): bool { $codebase = $statements_analyzer->getCodebase(); $statements_analyzer->node_data->setType($stmt, Type::getMixed()); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php index 24727b9712e..093eb86cd19 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/ConstFetchAnalyzer.php @@ -268,7 +268,7 @@ public static function getConstName( NodeDataProvider $type_provider, Codebase $codebase, Aliases $aliases - ) : ?string { + ): ?string { $const_name = null; if ($first_arg_value instanceof PhpParser\Node\Scalar\String_) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php index 3db51dd4017..e36586dceda 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/InstancePropertyFetchAnalyzer.php @@ -38,7 +38,7 @@ public static function analyze( Context $context, bool $in_assignment = false, bool $is_static_access = false - ) : bool { + ): bool { $was_inside_general_use = $context->inside_general_use; $context->inside_general_use = true; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php index 8e90ece4263..4d5e3add800 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/StaticPropertyFetchAnalyzer.php @@ -39,7 +39,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\StaticPropertyFetch $stmt, Context $context - ) : bool { + ): bool { if (!$stmt->class instanceof PhpParser\Node\Name) { self::analyzeVariableStaticPropertyFetch($statements_analyzer, $stmt->class, $stmt, $context); return true; @@ -397,7 +397,7 @@ private static function analyzeVariableStaticPropertyFetch( PhpParser\Node\Expr $stmt_class, PhpParser\Node\Expr\StaticPropertyFetch $stmt, Context $context - ) : void { + ): void { $was_inside_general_use = $context->inside_general_use; $context->inside_general_use = true; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php index 8e4d087f180..77fae50dff3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/VariableFetchAnalyzer.php @@ -53,7 +53,7 @@ public static function analyze( ?Type\Union $by_ref_type = null, bool $array_assignment = false, bool $from_global = false - ) : bool { + ): bool { $project_analyzer = $statements_analyzer->getFileAnalyzer()->project_analyzer; $codebase = $statements_analyzer->getCodebase(); @@ -403,7 +403,7 @@ private static function addDataFlowToVariable( string $var_name, Type\Union $stmt_type, Context $context - ) : void { + ): void { $codebase = $statements_analyzer->getCodebase(); if ($statements_analyzer->data_flow_graph @@ -477,7 +477,7 @@ private static function taintVariable( string $var_name, Type\Union $type, PhpParser\Node\Expr\Variable $stmt - ) : void { + ): void { if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph && !in_array('TaintedInput', $statements_analyzer->getSuppressedIssues()) ) { @@ -508,7 +508,7 @@ private static function taintVariable( /** * @psalm-pure */ - public static function isSuperGlobal(string $var_id) : bool + public static function isSuperGlobal(string $var_id): bool { return in_array( $var_id, @@ -517,7 +517,7 @@ public static function isSuperGlobal(string $var_id) : bool ); } - public static function getGlobalType(string $var_id) : Type\Union + public static function getGlobalType(string $var_id): Type\Union { $config = Config::getInstance(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php index e7de67fc00f..9689da0a732 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IncDecExpressionAnalyzer.php @@ -24,7 +24,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr $stmt, Context $context - ) : bool { + ): bool { $was_inside_assignment = $context->inside_assignment; $context->inside_assignment = true; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php index 571cad72021..0b158831ad6 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IncludeAnalyzer.php @@ -51,7 +51,7 @@ public static function analyze( PhpParser\Node\Expr\Include_ $stmt, Context $context, ?Context $global_context = null - ) : bool { + ): bool { $codebase = $statements_analyzer->getCodebase(); $config = $codebase->config; @@ -398,7 +398,7 @@ public static function resolveIncludePath(string $file_name, string $current_dir /** * @psalm-pure */ - public static function normalizeFilePath(string $path_to_file) : string + public static function normalizeFilePath(string $path_to_file): string { // replace all \ with / for normalization $path_to_file = str_replace('\\', '/', $path_to_file); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php index 2fb5221fd0d..f23d2b26180 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/InstanceofAnalyzer.php @@ -19,7 +19,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Instanceof_ $stmt, Context $context - ) : bool { + ): bool { $was_inside_general_use = $context->inside_general_use; $context->inside_general_use = true; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/IssetAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/IssetAnalyzer.php index 02bb800ad87..0f115f9d36f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/IssetAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/IssetAnalyzer.php @@ -38,7 +38,7 @@ public static function analyzeIssetVar( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr $stmt, Context $context - ) : void { + ): void { $context->inside_isset = true; ExpressionAnalyzer::analyze($statements_analyzer, $stmt, $context); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php index 516e418168c..176bb75650a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/MagicConstAnalyzer.php @@ -18,7 +18,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Scalar\MagicConst $stmt, Context $context - ) : void { + ): void { if ($stmt instanceof PhpParser\Node\Scalar\MagicConst\Line) { $statements_analyzer->node_data->setType($stmt, Type::getInt()); } elseif ($stmt instanceof PhpParser\Node\Scalar\MagicConst\Class_) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php index b9ea5007244..83d391ea223 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/MatchAnalyzer.php @@ -41,7 +41,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Match_ $stmt, Context $context - ) : bool { + ): bool { $was_inside_call = $context->inside_call; $context->inside_call = true; @@ -296,7 +296,7 @@ private static function convertCondsToConditional( array $conds, PhpParser\Node\Expr $match_condition, array $attributes - ) : PhpParser\Node\Expr { + ): PhpParser\Node\Expr { if (count($conds) === 1) { return new VirtualIdentical( $match_condition, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php index fb6b6d1a789..1fe390dfa2f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/NullsafeAnalyzer.php @@ -26,7 +26,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr $stmt, Context $context - ) : bool { + ): bool { if (!$stmt->var instanceof PhpParser\Node\Expr\Variable) { $was_inside_general_use = $context->inside_general_use; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php index baeb254d58b..62e0bf526e3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/PrintAnalyzer.php @@ -21,7 +21,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Print_ $stmt, Context $context - ) : bool { + ): bool { $codebase = $statements_analyzer->getCodebase(); if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) { diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php index 67e56307f43..b53065f2dc2 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/TernaryAnalyzer.php @@ -39,7 +39,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Ternary $stmt, Context $context - ) : bool { + ): bool { $codebase = $statements_analyzer->getCodebase(); $if_scope = new IfScope(); diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php index fca1ecea1bc..ba922d94ead 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/UnaryPlusMinusAnalyzer.php @@ -24,7 +24,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr $stmt, Context $context - ) : bool { + ): bool { if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) { return false; } diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php index 6dc6552923e..ce8ff774bdc 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldAnalyzer.php @@ -24,7 +24,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\Yield_ $stmt, Context $context - ) : bool { + ): bool { $doc_comment = $stmt->getDocComment(); $var_comments = []; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php index fbe19b0eec4..72270a50013 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/YieldFromAnalyzer.php @@ -16,7 +16,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Expr\YieldFrom $stmt, Context $context - ) : bool { + ): bool { $was_inside_call = $context->inside_call; $context->inside_call = true; @@ -45,7 +45,7 @@ public static function analyze( ) { return false; } - + $yield_from_type = null; foreach ($stmt_expr_type->getAtomicTypes() as $atomic_type) { diff --git a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php index 9755e3f9c7b..46350fb848c 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php @@ -40,7 +40,7 @@ public static function analyze( bool $array_assignment = false, ?Context $global_context = null, bool $from_stmt = false - ) : bool { + ): bool { $codebase = $statements_analyzer->getCodebase(); if (self::handleExpression( @@ -114,7 +114,7 @@ private static function handleExpression( bool $array_assignment, ?Context $global_context, bool $from_stmt - ) : bool { + ): bool { if ($stmt instanceof PhpParser\Node\Expr\Variable) { return Expression\Fetch\VariableFetchAnalyzer::analyze( $statements_analyzer, diff --git a/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php index 17a55a04f95..e0b2dd30b9a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/GlobalAnalyzer.php @@ -21,7 +21,7 @@ public static function analyze( PhpParser\Node\Stmt\Global_ $stmt, Context $context, ?Context $global_context - ) : void { + ): void { if (!$context->collect_initializations && !$global_context) { IssueBuffer::maybeAdd( new InvalidGlobal( diff --git a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php index 1249c9256f1..d8bd232a5e5 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ReturnAnalyzer.php @@ -534,7 +534,7 @@ private static function handleTaints( string $cased_method_id, Type\Union $inferred_type, FunctionLikeStorage $storage - ) : void { + ): void { if (!$statements_analyzer->data_flow_graph instanceof TaintFlowGraph || !$stmt->expr || !$storage->location diff --git a/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php index 629c7b23864..9eb5bc3dc5d 100644 --- a/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/ThrowAnalyzer.php @@ -24,7 +24,7 @@ public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node $stmt, Context $context - ) : bool { + ): bool { $context->inside_throw = true; if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->expr, $context) === false) { return false; diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php index 91bffa4450c..63f91056c86 100644 --- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php @@ -234,7 +234,7 @@ public function analyze( /** * @param array $stmts */ - private function hoistFunctions(array $stmts, Context $context) : void + private function hoistFunctions(array $stmts, Context $context): void { foreach ($stmts as $stmt) { if ($stmt instanceof PhpParser\Node\Stmt\Function_) { @@ -285,7 +285,7 @@ private static function hoistConstants( StatementsAnalyzer $statements_analyzer, array $stmts, Context $context - ) : void { + ): void { $codebase = $statements_analyzer->getCodebase(); foreach ($stmts as $stmt) { @@ -667,7 +667,7 @@ private function parseStatementDocblock( PhpParser\Comment\Doc $docblock, PhpParser\Node\Stmt $stmt, Context $context - ) : void { + ): void { $codebase = $this->getCodebase(); try { @@ -863,7 +863,7 @@ public function getUnusedVarLocations(): array public function registerPossiblyUndefinedVariable( string $undefined_var_id, PhpParser\Node\Expr\Variable $stmt - ) : void { + ): void { if (!$this->data_flow_graph) { return; } @@ -889,7 +889,7 @@ public function registerPossiblyUndefinedVariable( /** * @return array */ - public function getParentNodesForPossiblyUndefinedVariable(string $undefined_var_id) : array + public function getParentNodesForPossiblyUndefinedVariable(string $undefined_var_id): array { if (!$this->data_flow_graph) { return []; @@ -925,12 +925,12 @@ public function addVariableInitialization(string $var_id, int $branch_point): vo $this->vars_to_initialize[$var_id] = $branch_point; } - public function getFileAnalyzer() : FileAnalyzer + public function getFileAnalyzer(): FileAnalyzer { return $this->file_analyzer; } - public function getCodebase() : Codebase + public function getCodebase(): Codebase { return $this->codebase; } @@ -1004,12 +1004,12 @@ public function getUncaughtThrows(Context $context): array return $uncaught_throws; } - public function getFunctionAnalyzer(string $function_id) : ?FunctionAnalyzer + public function getFunctionAnalyzer(string $function_id): ?FunctionAnalyzer { return $this->function_analyzers[$function_id] ?? null; } - public function getParsedDocblock() : ?ParsedDocblock + public function getParsedDocblock(): ?ParsedDocblock { return $this->parsed_docblock; } @@ -1023,7 +1023,7 @@ public function getFQCLN(): ?string return parent::getFQCLN(); } - public function setFQCLN(string $fake_this_class) : void + public function setFQCLN(string $fake_this_class): void { $this->fake_this_class = $fake_this_class; } @@ -1031,7 +1031,7 @@ public function setFQCLN(string $fake_this_class) : void /** * @return NodeDataProvider */ - public function getNodeTypeProvider() : NodeTypeProvider + public function getNodeTypeProvider(): NodeTypeProvider { return $this->node_data; } diff --git a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php index e384724bfad..1ee4c3ce8e6 100644 --- a/src/Psalm/Internal/Analyzer/TypeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/TypeAnalyzer.php @@ -30,7 +30,7 @@ public static function isContainedBy( bool $ignore_false = false, ?TypeComparisonResult $union_comparison_result = null, bool $allow_interface_equality = false - ) : bool { + ): bool { return UnionTypeComparator::isContainedBy( $codebase, $input_type, @@ -55,7 +55,7 @@ public static function isAtomicContainedBy( bool $allow_interface_equality = false, bool $allow_float_int_equality = true, ?TypeComparisonResult $atomic_comparison_result = null - ) : bool { + ): bool { return AtomicTypeComparator::isContainedBy( $codebase, $input_type_part, diff --git a/src/Psalm/Internal/Clause.php b/src/Psalm/Internal/Clause.php index f8019d5978e..4eb32980923 100644 --- a/src/Psalm/Internal/Clause.php +++ b/src/Psalm/Internal/Clause.php @@ -189,7 +189,7 @@ function (string $value) use ($var_id): string { return reset($clause_strings); } - public function makeUnique() : self + public function makeUnique(): self { $possibilities = $this->possibilities; @@ -208,7 +208,7 @@ public function makeUnique() : self ); } - public function removePossibilities(string $var_id) : ?self + public function removePossibilities(string $var_id): ?self { $possibilities = $this->possibilities; unset($possibilities[$var_id]); @@ -231,7 +231,7 @@ public function removePossibilities(string $var_id) : ?self /** * @param non-empty-list $clause_var_possibilities */ - public function addPossibilities(string $var_id, array $clause_var_possibilities) : self + public function addPossibilities(string $var_id, array $clause_var_possibilities): self { $possibilities = $this->possibilities; $possibilities[$var_id] = $clause_var_possibilities; @@ -247,7 +247,7 @@ public function addPossibilities(string $var_id, array $clause_var_possibilities ); } - public function calculateNegation() : self + public function calculateNegation(): self { if ($this->impossibilities !== null) { return $this; diff --git a/src/Psalm/Internal/Cli/Psalter.php b/src/Psalm/Internal/Cli/Psalter.php index 8f8451ac18c..b04190e66a6 100644 --- a/src/Psalm/Internal/Cli/Psalter.php +++ b/src/Psalm/Internal/Cli/Psalter.php @@ -494,7 +494,7 @@ private static function loadCodeowners(Providers $providers): array $codeowners_file = file_get_contents($codeowners_file_path); $codeowner_lines = array_map( - function (string $line) : array { + function (string $line): array { $line_parts = preg_split('/\s+/', $line); $file_selector = substr(array_shift($line_parts), 1); @@ -502,7 +502,7 @@ function (string $line) : array { }, array_filter( explode("\n", $codeowners_file), - function (string $line) : bool { + function (string $line): bool { $line = trim($line); // currently we don’t match wildcard files or files that could appear anywhere diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php index dd8c482000f..6ad8333bca3 100644 --- a/src/Psalm/Internal/Codebase/Analyzer.php +++ b/src/Psalm/Internal/Codebase/Analyzer.php @@ -282,7 +282,7 @@ public function analyzeFiles( $this->files_to_analyze = array_filter( $this->files_to_analyze, - function (string $file_path) : bool { + function (string $file_path): bool { return $this->file_provider->fileExists($file_path); } ); @@ -339,7 +339,7 @@ function (string $file_path) : bool { } } - private function doAnalysis(ProjectAnalyzer $project_analyzer, int $pool_size) : void + private function doAnalysis(ProjectAnalyzer $project_analyzer, int $pool_size): void { $this->progress->start(count($this->files_to_analyze)); @@ -1147,7 +1147,7 @@ public function shiftFileOffsets(array $diff_map, array $deletion_ranges): void /** * @return array> */ - public function getMixedMemberNames() : array + public function getMixedMemberNames(): array { return $this->mixed_member_names; } @@ -1157,7 +1157,7 @@ public function addMixedMemberName(string $member_id, string $reference): void $this->mixed_member_names[$member_id][$reference] = true; } - public function hasMixedMemberName(string $member_id) : bool + public function hasMixedMemberName(string $member_id): bool { return isset($this->mixed_member_names[$member_id]); } @@ -1266,7 +1266,7 @@ public function getFunctionTimings(): array return $this->function_timings; } - public function addFunctionTiming(string $function_id, float $time_per_node) : void + public function addFunctionTiming(string $function_id, float $time_per_node): void { $this->function_timings[$function_id] = $time_per_node; } @@ -1620,7 +1620,7 @@ public function getPossibleMethodParamTypes(): array return $this->possible_method_param_types; } - public function addMutableClass(string $fqcln) : void + public function addMutableClass(string $fqcln): void { $this->mutable_classes[strtolower($fqcln)] = true; } diff --git a/src/Psalm/Internal/Codebase/ClassLikes.php b/src/Psalm/Internal/Codebase/ClassLikes.php index a393e0cce4a..4d4e86050c6 100644 --- a/src/Psalm/Internal/Codebase/ClassLikes.php +++ b/src/Psalm/Internal/Codebase/ClassLikes.php @@ -285,7 +285,7 @@ public function addFullyQualifiedClassLikeName(string $fq_class_name_lc, ?string /** * @return list */ - public function getMatchingClassLikeNames(string $stub) : array + public function getMatchingClassLikeNames(string $stub): array { $matching_classes = []; @@ -932,7 +932,7 @@ public static function makeImmutable( PhpParser\Node\Stmt\Class_ $class_stmt, ProjectAnalyzer $project_analyzer, string $file_path - ) : void { + ): void { $manipulator = ClassDocblockManipulator::getForClass( $project_analyzer, $file_path, @@ -1208,7 +1208,7 @@ public function handleClassLikeReferenceInMigration( ?string $calling_method_id, bool $force_change = false, bool $was_self = false - ) : bool { + ): bool { if ($class_name_node instanceof VirtualNode) { return false; } @@ -1391,7 +1391,7 @@ public function handleDocblockTypeInMigration( Type\Union $type, CodeLocation $type_location, ?string $calling_method_id - ) : void { + ): void { $calling_fq_class_name = $source->getFQCLN(); $fq_class_name_lc = strtolower($calling_fq_class_name ?? ''); @@ -1519,7 +1519,7 @@ public function airliftClassLikeReference( int $source_end, bool $add_class_constant = false, bool $allow_self = false - ) : void { + ): void { $project_analyzer = ProjectAnalyzer::getInstance(); $codebase = $project_analyzer->getCodebase(); @@ -1555,7 +1555,7 @@ public function airliftClassDefinedDocblockType( string $source_file_path, int $source_start, int $source_end - ) : void { + ): void { $project_analyzer = ProjectAnalyzer::getInstance(); $codebase = $project_analyzer->getCodebase(); @@ -1635,7 +1635,7 @@ public function getClassConstantType( int $visibility, ?StatementsAnalyzer $statements_analyzer = null, array $visited_constant_ids = [] - ) : ?Type\Union { + ): ?Type\Union { $class_name = strtolower($class_name); if (!$this->classlike_storage_provider->has($class_name)) { @@ -2224,7 +2224,7 @@ public function doesClassLikeExist(string $fq_classlike_name_lc): bool && $this->existing_classlikes_lc[$fq_classlike_name_lc]; } - public function forgetMissingClassLikes() : void + public function forgetMissingClassLikes(): void { $this->existing_classlikes_lc = array_filter($this->existing_classlikes_lc); } diff --git a/src/Psalm/Internal/Codebase/ConstantTypeResolver.php b/src/Psalm/Internal/Codebase/ConstantTypeResolver.php index a19cb3d5dc0..07294fc34fe 100644 --- a/src/Psalm/Internal/Codebase/ConstantTypeResolver.php +++ b/src/Psalm/Internal/Codebase/ConstantTypeResolver.php @@ -26,7 +26,7 @@ public static function resolve( UnresolvedConstantComponent $c, StatementsAnalyzer $statements_analyzer = null, array $visited_constant_ids = [] - ) : Type\Atomic { + ): Type\Atomic { $c_id = spl_object_id($c); if (isset($visited_constant_ids[$c_id])) { @@ -305,7 +305,7 @@ public static function resolve( /** * @param string|int|float|bool|null $value */ - private static function getLiteralTypeFromScalarValue($value) : Type\Atomic + private static function getLiteralTypeFromScalarValue($value): Type\Atomic { if (is_string($value)) { return new Type\Atomic\TLiteralString($value); diff --git a/src/Psalm/Internal/Codebase/DataFlowGraph.php b/src/Psalm/Internal/Codebase/DataFlowGraph.php index 615c3fbbd79..988a814062f 100644 --- a/src/Psalm/Internal/Codebase/DataFlowGraph.php +++ b/src/Psalm/Internal/Codebase/DataFlowGraph.php @@ -20,7 +20,7 @@ abstract class DataFlowGraph /** @var array> */ protected $forward_edges = []; - abstract public function addNode(DataFlowNode $node) : void; + abstract public function addNode(DataFlowNode $node): void; /** * @param array $added_taints @@ -32,7 +32,7 @@ public function addPath( string $path_type, ?array $added_taints = null, ?array $removed_taints = null - ) : void { + ): void { $from_id = $from->id; $to_id = $to->id; @@ -63,7 +63,7 @@ protected static function shouldIgnoreFetch( string $path_type, string $expression_type, array $previous_path_types - ) : bool { + ): bool { $el = strlen($expression_type); // arraykey-fetch requires a matching arraykey-assignment at the same level @@ -107,7 +107,7 @@ protected static function shouldIgnoreFetch( /** * @return array{int, int, int, float} */ - public function getEdgeStats() : array + public function getEdgeStats(): array { $lengths = 0; diff --git a/src/Psalm/Internal/Codebase/Functions.php b/src/Psalm/Internal/Codebase/Functions.php index 2588dc8ae68..63845cbcad5 100644 --- a/src/Psalm/Internal/Codebase/Functions.php +++ b/src/Psalm/Internal/Codebase/Functions.php @@ -78,7 +78,7 @@ public function getStorage( string $function_id, ?string $root_file_path = null, ?string $checked_file_path = null - ) : FunctionStorage { + ): FunctionStorage { if ($function_id[0] === '\\') { $function_id = substr($function_id, 1); } @@ -271,7 +271,7 @@ public function getMatchingFunctionNames( int $offset, string $file_path, Codebase $codebase - ) : array { + ): array { if ($stub[0] === '*') { $stub = substr($stub, 1); } @@ -396,7 +396,7 @@ public function isCallMapFunctionPure( string $function_id, ?array $args, bool &$must_use = true - ) : bool { + ): bool { $impure_functions = [ // file io 'chdir', 'chgrp', 'chmod', 'chown', 'chroot', 'copy', 'file_get_contents', 'file_put_contents', @@ -591,7 +591,7 @@ public function isCallMapFunctionPure( return true; } - public static function clearCache() : void + public static function clearCache(): void { self::$stubbed_functions = []; } diff --git a/src/Psalm/Internal/Codebase/InternalCallMapHandler.php b/src/Psalm/Internal/Codebase/InternalCallMapHandler.php index af68ce288a0..37ab3c466a3 100644 --- a/src/Psalm/Internal/Codebase/InternalCallMapHandler.php +++ b/src/Psalm/Internal/Codebase/InternalCallMapHandler.php @@ -429,7 +429,7 @@ public static function inCallMap(string $key): bool return isset(self::getCallMap()[strtolower($key)]); } - public static function clearCache() : void + public static function clearCache(): void { self::$call_map_callables = []; } diff --git a/src/Psalm/Internal/Codebase/Methods.php b/src/Psalm/Internal/Codebase/Methods.php index 8b1febf6583..94afca13281 100644 --- a/src/Psalm/Internal/Codebase/Methods.php +++ b/src/Psalm/Internal/Codebase/Methods.php @@ -105,7 +105,7 @@ public function methodExists( ?string $source_file_path = null, bool $use_method_existence_provider = true, bool $is_used = false - ) : bool { + ): bool { $fq_class_name = $method_id->fq_class_name; $method_name = $method_id->method_name; @@ -353,7 +353,7 @@ public function getMethodParams( ?StatementsSource $source = null, ?array $args = null, ?Context $context = null - ) : array { + ): array { $fq_class_name = $method_id->fq_class_name; $method_name = $method_id->method_name; @@ -501,7 +501,7 @@ public static function localizeType( Type\Union $type, string $appearing_fq_class_name, string $base_fq_class_name - ) : Type\Union { + ): Type\Union { $class_storage = $codebase->classlike_storage_provider->get($appearing_fq_class_name); $extends = $class_storage->template_extended_params; @@ -619,7 +619,7 @@ public static function localizeType( public static function getExtendedTemplatedTypes( Type\Atomic\TTemplateParam $atomic_type, array $extends - ) : array { + ): array { $extra_added_types = []; if (isset($extends[$atomic_type->defining_class][$atomic_type->param_name])) { @@ -1083,7 +1083,7 @@ public function setAppearingMethodId( public function getDeclaringMethodId( MethodIdentifier $method_id - ) : ?MethodIdentifier { + ): ?MethodIdentifier { $fq_class_name = $this->classlikes->getUnAliasedName($method_id->fq_class_name); $class_storage = $this->classlike_storage_provider->get($fq_class_name); @@ -1106,7 +1106,7 @@ public function getDeclaringMethodId( */ public function getAppearingMethodId( MethodIdentifier $method_id - ) : ?MethodIdentifier { + ): ?MethodIdentifier { $fq_class_name = $this->classlikes->getUnAliasedName($method_id->fq_class_name); $class_storage = $this->classlike_storage_provider->get($fq_class_name); diff --git a/src/Psalm/Internal/Codebase/Populator.php b/src/Psalm/Internal/Codebase/Populator.php index a3251835f32..3117e627700 100644 --- a/src/Psalm/Internal/Codebase/Populator.php +++ b/src/Psalm/Internal/Codebase/Populator.php @@ -447,7 +447,7 @@ private function populateDataFromTraits( private static function extendType( Type\Union $type, ClassLikeStorage $storage - ) : Type\Union { + ): Type\Union { $extended_types = []; foreach ($type->getAtomicTypes() as $atomic_type) { diff --git a/src/Psalm/Internal/Codebase/ReferenceMapGenerator.php b/src/Psalm/Internal/Codebase/ReferenceMapGenerator.php index bd41dca774d..c343dcead6b 100644 --- a/src/Psalm/Internal/Codebase/ReferenceMapGenerator.php +++ b/src/Psalm/Internal/Codebase/ReferenceMapGenerator.php @@ -11,7 +11,7 @@ class ReferenceMapGenerator public static function getReferenceMap( ClassLikeStorageProvider $classlike_storage_provider, array $expected_references - ) : array { + ): array { $reference_dictionary = []; foreach ($classlike_storage_provider->getAll() as $storage) { diff --git a/src/Psalm/Internal/Codebase/Reflection.php b/src/Psalm/Internal/Codebase/Reflection.php index 4194397d16d..18162dad873 100644 --- a/src/Psalm/Internal/Codebase/Reflection.php +++ b/src/Psalm/Internal/Codebase/Reflection.php @@ -416,7 +416,7 @@ public function registerFunction(string $function_id): ?bool return null; } - public static function getPsalmTypeFromReflectionType(?ReflectionType $reflection_type = null) : Type\Union + public static function getPsalmTypeFromReflectionType(?ReflectionType $reflection_type = null): Type\Union { if (!$reflection_type) { return Type::getMixed(); @@ -542,7 +542,7 @@ public function getFunctions(): array return self::$builtin_functions; } - public static function clearCache() : void + public static function clearCache(): void { self::$builtin_functions = []; } diff --git a/src/Psalm/Internal/Codebase/Scanner.php b/src/Psalm/Internal/Codebase/Scanner.php index d0fdfca90e9..f9c72f48e3d 100644 --- a/src/Psalm/Internal/Codebase/Scanner.php +++ b/src/Psalm/Internal/Codebase/Scanner.php @@ -310,12 +310,12 @@ public function scanFiles(ClassLikes $classlikes, int $pool_size = 1): bool return $has_changes; } - private function scanFilePaths(int $pool_size) : bool + private function scanFilePaths(int $pool_size): bool { $filetype_scanners = $this->config->getFiletypeScanners(); $files_to_scan = array_filter( $this->files_to_scan, - function (string $file_path) : bool { + function (string $file_path): bool { return $this->file_provider->fileExists($file_path) && (!isset($this->scanned_files[$file_path]) || (isset($this->files_to_deep_scan[$file_path]) && !$this->scanned_files[$file_path])); @@ -361,7 +361,7 @@ function (int $_, string $file_path) use ($filetype_scanners, $files_to_deep_sca // files up among a given number of child processes. $pool = new Pool( $process_file_paths, - function () { + function (): void { $this->progress->debug('Initialising forked process for scanning' . PHP_EOL); $project_analyzer = ProjectAnalyzer::getInstance(); diff --git a/src/Psalm/Internal/Codebase/TaintFlowGraph.php b/src/Psalm/Internal/Codebase/TaintFlowGraph.php index 6ef336852b9..2812bb6a1fd 100644 --- a/src/Psalm/Internal/Codebase/TaintFlowGraph.php +++ b/src/Psalm/Internal/Codebase/TaintFlowGraph.php @@ -58,7 +58,7 @@ class TaintFlowGraph extends DataFlowGraph /** @var array> */ private $specializations = []; - public function addNode(DataFlowNode $node) : void + public function addNode(DataFlowNode $node): void { $this->nodes[$node->id] = $node; @@ -68,19 +68,19 @@ public function addNode(DataFlowNode $node) : void } } - public function addSource(TaintSource $node) : void + public function addSource(TaintSource $node): void { $this->sources[$node->id] = $node; } - public function addSink(TaintSink $node) : void + public function addSink(TaintSink $node): void { $this->sinks[$node->id] = $node; // in the rare case the sink is the _next_ node, this is necessary $this->nodes[$node->id] = $node; } - public function addGraph(self $taint) : void + public function addGraph(self $taint): void { $this->sources += $taint->sources; $this->sinks += $taint->sinks; @@ -104,7 +104,7 @@ public function addGraph(self $taint) : void } } - public function getPredecessorPath(DataFlowNode $source) : string + public function getPredecessorPath(DataFlowNode $source): string { $location_summary = ''; @@ -135,7 +135,7 @@ public function getPredecessorPath(DataFlowNode $source) : string return $source_descriptor; } - public function getSuccessorPath(DataFlowNode $sink) : string + public function getSuccessorPath(DataFlowNode $sink): string { $location_summary = ''; @@ -169,7 +169,7 @@ public function getSuccessorPath(DataFlowNode $sink) : string /** * @return list */ - public function getIssueTrace(DataFlowNode $source) : array + public function getIssueTrace(DataFlowNode $source): array { $previous_source = $source->previous; @@ -190,7 +190,7 @@ public function getIssueTrace(DataFlowNode $source) : array return [$node]; } - public function connectSinksAndSources() : void + public function connectSinksAndSources(): void { $visited_source_ids = []; @@ -241,7 +241,7 @@ private function getChildNodes( array $source_taints, array $sinks, array $visited_source_ids - ) : array { + ): array { $new_sources = []; $config = Config::getInstance(); @@ -474,7 +474,7 @@ private function getChildNodes( } /** @return array */ - private function getSpecializedSources(DataFlowNode $source) : array + private function getSpecializedSources(DataFlowNode $source): array { $generated_sources = []; diff --git a/src/Psalm/Internal/Codebase/VariableUseGraph.php b/src/Psalm/Internal/Codebase/VariableUseGraph.php index 3531680a754..4698f3e2dbc 100644 --- a/src/Psalm/Internal/Codebase/VariableUseGraph.php +++ b/src/Psalm/Internal/Codebase/VariableUseGraph.php @@ -18,7 +18,7 @@ class VariableUseGraph extends DataFlowGraph /** @var array */ private $nodes = []; - public function addNode(DataFlowNode $node) : void + public function addNode(DataFlowNode $node): void { $this->nodes[$node->id] = $node; } @@ -33,7 +33,7 @@ public function addPath( string $path_type, ?array $added_taints = null, ?array $removed_taints = null - ) : void { + ): void { $from_id = $from->id; $to_id = $to->id; @@ -56,7 +56,7 @@ public function addPath( $this->forward_edges[$from_id][$to_id] = new Path($path_type, $length); } - public function isVariableUsed(DataFlowNode $assignment_node) : bool + public function isVariableUsed(DataFlowNode $assignment_node): bool { $visited_source_ids = []; @@ -92,7 +92,7 @@ public function isVariableUsed(DataFlowNode $assignment_node) : bool /** * @return list */ - public function getOriginLocations(DataFlowNode $assignment_node) : array + public function getOriginLocations(DataFlowNode $assignment_node): array { $visited_child_ids = []; @@ -138,7 +138,7 @@ public function getOriginLocations(DataFlowNode $assignment_node) : array private function getChildNodes( DataFlowNode $generated_source, array $visited_source_ids - ) : ?array { + ): ?array { $new_child_nodes = []; if (!isset($this->forward_edges[$generated_source->id])) { @@ -193,7 +193,7 @@ private function getChildNodes( private function getParentNodes( DataFlowNode $destination, array $visited_source_ids - ) : array { + ): array { $new_parent_nodes = []; if (!isset($this->backward_edges[$destination->id])) { diff --git a/src/Psalm/Internal/Diff/AstDiffer.php b/src/Psalm/Internal/Diff/AstDiffer.php index ae7d34f5a51..8f96624d0a2 100644 --- a/src/Psalm/Internal/Diff/AstDiffer.php +++ b/src/Psalm/Internal/Diff/AstDiffer.php @@ -22,7 +22,7 @@ class AstDiffer { /** - * @param Closure(Stmt, Stmt, string, string, bool=) : bool $is_equal + * @param Closure(Stmt, Stmt, string, string, bool=): bool $is_equal * @param array $a * @param array $b * @@ -34,7 +34,7 @@ protected static function calculateTrace( array $b, string $a_code, string $b_code - ) : array { + ): array { $n = count($a); $m = count($b); $max = $n + $m; @@ -81,7 +81,7 @@ protected static function calculateTrace( * * @psalm-pure */ - protected static function extractDiff(array $trace, int $x, int $y, array $a, array $b, array $bc) : array + protected static function extractDiff(array $trace, int $x, int $y, array $a, array $b, array $bc): array { $result = []; for ($d = count($trace) - 1; $d >= 0; --$d) { diff --git a/src/Psalm/Internal/Diff/FileDiffer.php b/src/Psalm/Internal/Diff/FileDiffer.php index 22c05780ba8..bad0f7c8aa6 100644 --- a/src/Psalm/Internal/Diff/FileDiffer.php +++ b/src/Psalm/Internal/Diff/FileDiffer.php @@ -34,7 +34,7 @@ class FileDiffer private static function calculateTrace( array $a, array $b - ) : array { + ): array { $n = count($a); $m = count($b); $max = $n + $m; @@ -74,7 +74,7 @@ private static function calculateTrace( * * @psalm-pure */ - private static function extractDiff(array $trace, int $x, int $y, array $a, array $b) : array + private static function extractDiff(array $trace, int $x, int $y, array $a, array $b): array { $result = []; for ($d = count($trace) - 1; $d >= 0; --$d) { diff --git a/src/Psalm/Internal/ErrorHandler.php b/src/Psalm/Internal/ErrorHandler.php index 7a12b3b6000..802f4727dbc 100644 --- a/src/Psalm/Internal/ErrorHandler.php +++ b/src/Psalm/Internal/ErrorHandler.php @@ -80,7 +80,7 @@ private static function installExceptionHandler(): void * then print more of the backtrace than is done by default to stderr, * then exit with a non-zero exit code to indicate failure. */ - set_exception_handler(static function (Throwable $throwable) : void { + set_exception_handler(static function (Throwable $throwable): void { fwrite(STDERR, "Uncaught $throwable\n"); $version = defined('PSALM_VERSION') ? PSALM_VERSION : '(unknown version)'; fwrite(STDERR, "(Psalm $version crashed due to an uncaught Throwable)\n"); diff --git a/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php b/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php index 7e476f9ab40..eba0b71f9c8 100644 --- a/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php +++ b/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php @@ -44,7 +44,7 @@ public function __construct(array $env) /** * Collect environment variables. */ - public function collect() : array + public function collect(): array { $this->readEnv = []; @@ -70,7 +70,7 @@ public function collect() : array * * @psalm-suppress PossiblyUndefinedStringArrayOffset */ - protected function fillTravisCi() : self + protected function fillTravisCi(): self { if (isset($this->env['TRAVIS']) && $this->env['TRAVIS'] && isset($this->env['TRAVIS_JOB_ID'])) { $this->readEnv['CI_JOB_ID'] = $this->env['TRAVIS_JOB_ID']; @@ -113,7 +113,7 @@ protected function fillTravisCi() : self * * @return $this */ - protected function fillCircleCi() : self + protected function fillCircleCi(): self { if (isset($this->env['CIRCLECI']) && $this->env['CIRCLECI'] && isset($this->env['CIRCLE_BUILD_NUM'])) { $this->env['CI_BUILD_NUMBER'] = $this->env['CIRCLE_BUILD_NUM']; @@ -147,7 +147,7 @@ protected function fillCircleCi() : self * * @return $this */ - protected function fillAppVeyor() : self + protected function fillAppVeyor(): self { if (isset($this->env['APPVEYOR']) && $this->env['APPVEYOR'] && isset($this->env['APPVEYOR_BUILD_NUMBER'])) { $this->readEnv['CI_BUILD_NUMBER'] = $this->env['APPVEYOR_BUILD_NUMBER']; @@ -195,7 +195,7 @@ protected function fillAppVeyor() : self * * @return $this */ - protected function fillJenkins() : self + protected function fillJenkins(): self { if (isset($this->env['JENKINS_URL']) && isset($this->env['BUILD_NUMBER'])) { $this->readEnv['CI_BUILD_NUMBER'] = $this->env['BUILD_NUMBER']; @@ -220,7 +220,7 @@ protected function fillJenkins() : self * * @return $this */ - protected function fillScrutinizer() : self + protected function fillScrutinizer(): self { if (isset($this->env['SCRUTINIZER']) && $this->env['SCRUTINIZER']) { $this->readEnv['CI_JOB_ID'] = $this->env['SCRUTINIZER_INSPECTION_UUID']; diff --git a/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php b/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php index 66ba7d7e166..ade9ef749eb 100644 --- a/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php +++ b/src/Psalm/Internal/ExecutionEnvironment/GitInfoCollector.php @@ -41,7 +41,7 @@ public function __construct() /** * Collect git repository info. */ - public function collect() : GitInfo + public function collect(): GitInfo { $branch = $this->collectBranch(); $commit = $this->collectCommit(); @@ -55,7 +55,7 @@ public function collect() : GitInfo * * @throws RuntimeException */ - protected function collectBranch() : string + protected function collectBranch(): string { $branchesResult = $this->executor->execute('git branch'); @@ -75,7 +75,7 @@ protected function collectBranch() : string * * @throws RuntimeException */ - protected function collectCommit() : CommitInfo + protected function collectCommit(): CommitInfo { $commitResult = $this->executor->execute('git log -1 --pretty=format:%H%n%aN%n%ae%n%cN%n%ce%n%s%n%at'); diff --git a/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php b/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php index 7df45d57f35..ea6541dace2 100644 --- a/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php +++ b/src/Psalm/Internal/ExecutionEnvironment/SystemCommandExecutor.php @@ -23,7 +23,7 @@ final class SystemCommandExecutor * * @return string[] */ - public function execute(string $command) : array + public function execute(string $command): array { if (!function_exists('exec')) { throw new RuntimeException(sprintf('exec does not exist, failed to execute command: %s', $command)); diff --git a/src/Psalm/Internal/FileManipulation/ClassDocblockManipulator.php b/src/Psalm/Internal/FileManipulation/ClassDocblockManipulator.php index 643a9f80219..daf6aeec08d 100644 --- a/src/Psalm/Internal/FileManipulation/ClassDocblockManipulator.php +++ b/src/Psalm/Internal/FileManipulation/ClassDocblockManipulator.php @@ -42,7 +42,7 @@ public static function getForClass( ProjectAnalyzer $project_analyzer, string $file_path, Class_ $stmt - ) : self { + ): self { if (isset(self::$manipulators[$file_path][$stmt->getLine()])) { return self::$manipulators[$file_path][$stmt->getLine()]; } @@ -75,7 +75,7 @@ private function __construct( $this->indentation = str_replace(ltrim($first_line), '', $first_line); } - public function makeImmutable() : void + public function makeImmutable(): void { $this->immutable = true; } diff --git a/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php b/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php index 99058167003..5c7ac7179c7 100644 --- a/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php +++ b/src/Psalm/Internal/FileManipulation/FileManipulationBuffer.php @@ -41,7 +41,7 @@ public static function add(string $file_path, array $file_manipulations): void } /** @param CodeMigration[] $code_migrations */ - public static function addCodeMigrations(array $code_migrations) : void + public static function addCodeMigrations(array $code_migrations): void { self::$code_migrations = array_merge(self::$code_migrations, $code_migrations); } @@ -53,7 +53,7 @@ private static function getCodeOffsets( string $source_file_path, int $source_start, int $source_end - ) : array { + ): array { if (!isset(self::$file_manipulations[$source_file_path])) { return [0, 0]; } diff --git a/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php b/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php index 68a5af1a389..dfad6e08179 100644 --- a/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php +++ b/src/Psalm/Internal/FileManipulation/FunctionDocblockManipulator.php @@ -522,7 +522,7 @@ public static function getManipulationsForFile(string $file_path): array return $file_manipulations; } - public function makePure() : void + public function makePure(): void { $this->is_pure = true; } @@ -535,7 +535,7 @@ public static function clearCache(): void /** * @param array> $manipulators */ - public static function addManipulators(array $manipulators) : void + public static function addManipulators(array $manipulators): void { self::$manipulators = array_merge($manipulators, self::$manipulators); } diff --git a/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php b/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php index e0e008d5cae..3f1e1fc1733 100644 --- a/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php +++ b/src/Psalm/Internal/FileManipulation/PropertyDocblockManipulator.php @@ -71,7 +71,7 @@ public static function getForProperty( ProjectAnalyzer $project_analyzer, string $file_path, Property $stmt - ) : self { + ): self { if (isset(self::$manipulators[$file_path][$stmt->getLine()])) { return self::$manipulators[$file_path][$stmt->getLine()]; } @@ -152,7 +152,7 @@ public function setType( string $phpdoc_type, bool $is_php_compatible, ?string $description = null - ) : void { + ): void { $new_type = str_replace(['', '', ''], '', $new_type); $this->new_php_type = $php_type; diff --git a/src/Psalm/Internal/LanguageServer/EmitterInterface.php b/src/Psalm/Internal/LanguageServer/EmitterInterface.php index 6fd1e4f5d5d..860528b930a 100644 --- a/src/Psalm/Internal/LanguageServer/EmitterInterface.php +++ b/src/Psalm/Internal/LanguageServer/EmitterInterface.php @@ -46,7 +46,7 @@ public function emit( string $eventName, array $arguments = [], ?callable $continueCallBack = null - ) : void; + ): void; /** * Returns the list of listeners for an event. @@ -56,7 +56,7 @@ public function emit( * * @return callable[] */ - public function listeners(string $eventName) : array; + public function listeners(string $eventName): array; /** * Removes a specific listener from an event. @@ -65,5 +65,5 @@ public function listeners(string $eventName) : array; * was removed it will return true. * @psalm-suppress PossiblyUnusedReturnValue */ - public function removeListener(string $eventName, callable $listener) : bool; + public function removeListener(string $eventName, callable $listener): bool; } diff --git a/src/Psalm/Internal/LanguageServer/EmitterTrait.php b/src/Psalm/Internal/LanguageServer/EmitterTrait.php index 5111b728eb4..fad2b4b8136 100644 --- a/src/Psalm/Internal/LanguageServer/EmitterTrait.php +++ b/src/Psalm/Internal/LanguageServer/EmitterTrait.php @@ -113,7 +113,7 @@ public function emit( * * @return callable[] */ - public function listeners(string $eventName) : array + public function listeners(string $eventName): array { if (!isset($this->listeners[$eventName])) { return []; @@ -137,7 +137,7 @@ public function listeners(string $eventName) : array * If the listener could not be found, this method will return false. If it * was removed it will return true. */ - public function removeListener(string $eventName, callable $listener) : bool + public function removeListener(string $eventName, callable $listener): bool { if (!isset($this->listeners[$eventName])) { return false; diff --git a/src/Psalm/Internal/LanguageServer/LanguageServer.php b/src/Psalm/Internal/LanguageServer/LanguageServer.php index bb17d756502..c5608aeabc4 100644 --- a/src/Psalm/Internal/LanguageServer/LanguageServer.php +++ b/src/Psalm/Internal/LanguageServer/LanguageServer.php @@ -359,7 +359,7 @@ public function emitIssues(array $uris): void foreach ($uris as $file_path => $uri) { $diagnostics = array_map( - function (IssueData $issue_data) : Diagnostic { + function (IssueData $issue_data): Diagnostic { //$check_name = $issue->check_name; $description = $issue_data->message; $severity = $issue_data->severity; diff --git a/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php b/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php index d457e1395c4..f034e891a4a 100644 --- a/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php +++ b/src/Psalm/Internal/LanguageServer/ProtocolStreamReader.php @@ -55,7 +55,7 @@ public function __construct($input) * @psalm-suppress MixedArgument in old Amp versions * @psalm-suppress MixedAssignment in old Amp versions */ - function () use ($input) : Generator { + function () use ($input): Generator { while ($this->is_accepting_new_requests) { $read_promise = $input->read(); @@ -82,7 +82,7 @@ static function () use ($input): void { ); } - private function readMessages(string $buffer) : int + private function readMessages(string $buffer): int { $emitted_messages = 0; $i = 0; diff --git a/src/Psalm/Internal/PhpTraverser/CustomTraverser.php b/src/Psalm/Internal/PhpTraverser/CustomTraverser.php index bb6250955f9..4ed1b1ff818 100644 --- a/src/Psalm/Internal/PhpTraverser/CustomTraverser.php +++ b/src/Psalm/Internal/PhpTraverser/CustomTraverser.php @@ -28,7 +28,7 @@ public function __construct() * * @return Node Result of traversal (may be original node or new one) */ - protected function traverseNode(Node $node) : Node + protected function traverseNode(Node $node): Node { foreach ($node->getSubNodeNames() as $name) { $subNode = &$node->$name; @@ -98,7 +98,7 @@ protected function traverseNode(Node $node) : Node * * @return array Result of traversal (may be original array or changed one) */ - protected function traverseArray(array $nodes) : array + protected function traverseArray(array $nodes): array { $doNodes = []; diff --git a/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php b/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php index 3eaf9156e3e..5ec3051be94 100644 --- a/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/PartialParserVisitor.php @@ -377,7 +377,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true) return null; } - public function mustRescan() : bool + public function mustRescan(): bool { return $this->must_rescan || $this->non_method_changes; } @@ -385,7 +385,7 @@ public function mustRescan() : bool /** * @psalm-pure */ - private static function balanceBrackets(string $fake_class) : string + private static function balanceBrackets(string $fake_class): string { $tokens = token_get_all($fake_class); diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php index 51ce9710f74..a36455e2bcf 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/AttributeResolver.php @@ -25,7 +25,7 @@ public static function resolve( Aliases $aliases, PhpParser\Node\Attribute $stmt, ?string $fq_classlike_name - ) : AttributeStorage { + ): AttributeStorage { if ($stmt->name instanceof PhpParser\Node\Name\FullyQualified) { $fq_type_string = (string)$stmt->name; } else { diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php index d1f362edc8b..b7e978af0b2 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeDocblockParser.php @@ -493,7 +493,7 @@ protected static function addMagicPropertyToInfo( ClassLikeDocblockComment $info, array $specials, string $property_tag - ) : void { + ): void { $magic_property_comments = $specials[$property_tag] ?? []; foreach ($magic_property_comments as $offset => $property) { diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php index a31e1b12e2c..ebf77070abc 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ClassLikeNodeScanner.php @@ -415,7 +415,7 @@ public function start(PhpParser\Node\Stmt\ClassLike $node): ?bool usort( $docblock_info->templates, - function (array $l, array $r) : int { + function (array $l, array $r): int { return $l[4] > $r[4] ? 1 : -1; } ); @@ -743,7 +743,7 @@ function (array $l, array $r) : int { return null; } - public function finish(PhpParser\Node\Stmt\ClassLike $node) : ClassLikeStorage + public function finish(PhpParser\Node\Stmt\ClassLike $node): ClassLikeStorage { if (!$this->storage) { throw new UnexpectedValueException( @@ -812,7 +812,7 @@ function (TypeAlias\InlineTypeAlias $t): ?TypeAlias\ClassTypeAlias { return $classlike_storage; } - public function handleTraitUse(PhpParser\Node\Stmt\TraitUse $node) : void + public function handleTraitUse(PhpParser\Node\Stmt\TraitUse $node): void { $storage = $this->storage; @@ -1152,7 +1152,7 @@ private function useTemplatedType( } } - private static function registerEmptyConstructor(ClassLikeStorage $class_storage) : void + private static function registerEmptyConstructor(ClassLikeStorage $class_storage): void { $method_name_lc = '__construct'; @@ -1596,7 +1596,7 @@ private function visitPropertyDeclaration( * * @return array */ - private function getImportedTypeAliases(ClassLikeDocblockComment $comment, string $fq_classlike_name) : array + private function getImportedTypeAliases(ClassLikeDocblockComment $comment, string $fq_classlike_name): array { /** @var array $results */ $results = []; diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php index c2a48537c9b..aaf75b75bff 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionResolver.php @@ -28,7 +28,7 @@ public static function getUnresolvedClassConstExpr( Aliases $aliases, ?string $fq_classlike_name, ?string $parent_fq_class_name = null - ) : ?UnresolvedConstantComponent { + ): ?UnresolvedConstantComponent { if ($stmt instanceof PhpParser\Node\Expr\BinaryOp) { $left = self::getUnresolvedClassConstExpr( $stmt->left, @@ -285,7 +285,7 @@ public static function enterConditional( Codebase $codebase, string $file_path, PhpParser\Node\Expr $expr - ) : ?bool { + ): ?bool { if ($expr instanceof PhpParser\Node\Expr\BooleanNot) { $enter_negated = self::enterConditional($codebase, $file_path, $expr->expr); @@ -350,7 +350,7 @@ private static function functionEvaluatesToTrue( Codebase $codebase, string $file_path, PhpParser\Node\Expr\FuncCall $function - ) : ?bool { + ): ?bool { if (!$function->name instanceof PhpParser\Node\Name) { return null; } diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php index 6a21a3ba048..f38865008bb 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/ExpressionScanner.php @@ -41,7 +41,7 @@ public static function scan( PhpParser\Node\Expr $node, ?FunctionLikeStorage $functionlike_storage, ?int $skip_if_descendants - ) : void { + ): void { if ($node instanceof PhpParser\Node\Expr\Include_ && !$skip_if_descendants) { self::visitInclude( $codebase, diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php index 966a14ffac6..c3a741b20e7 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php @@ -63,7 +63,7 @@ public static function addDocblockInfo( bool $is_functionlike_override, bool $fake_method, string $cased_function_id - ) : void { + ): void { self::handleUnexpectedTags($docblock_info, $storage, $stmt, $file_scanner, $cased_function_id); $config = Config::getInstance(); @@ -416,7 +416,7 @@ private static function getConditionalSanitizedTypeTokens( ?ClassLikeStorage $classlike_storage, string $cased_function_id, array $function_template_types - ) : array { + ): array { $fixed_type_tokens = TypeTokenizer::getFullyQualifiedTokens( $docblock_return_type, $aliases, @@ -537,7 +537,7 @@ private static function getAssertionParts( array $function_template_types, array $type_aliases, ?string $self_fqcln - ) : ?array { + ): ?array { $prefix = ''; if ($assertion_type[0] === '!') { @@ -852,7 +852,7 @@ private static function improveParamsFromDocblock( $params_without_docblock_type = array_filter( $storage->params, - function (FunctionLikeParameter $p) : bool { + function (FunctionLikeParameter $p): bool { return !$p->has_docblock_type && (!$p->type || $p->type->hasArray()); } ); @@ -882,7 +882,7 @@ private static function handleReturn( ?ClassLikeStorage $classlike_storage, string $cased_function_id, FileStorage $file_storage - ) : void { + ): void { if (!$fake_method && $docblock_info->return_type_line_number && $docblock_info->return_type_start diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index c4338ed9960..a60d37eeb52 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -737,7 +737,7 @@ private function inferPropertyTypeFromConstructor( PhpParser\Node\Stmt\ClassMethod $stmt, MethodStorage $storage, ClassLikeStorage $classlike_storage - ) : void { + ): void { if (!$stmt->stmts) { return; } @@ -803,7 +803,7 @@ private function getTranslatedFunctionParam( PhpParser\Node\FunctionLike $stmt, bool $fake_method, ?string $fq_classlike_name - ) : FunctionLikeParameter { + ): FunctionLikeParameter { $param_type = null; $is_nullable = $param->default !== null && diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php b/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php index 3b0032b304f..4ae2f7bef55 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/TypeHintResolver.php @@ -27,7 +27,7 @@ public static function resolve( Aliases $aliases, int $php_major_version, int $php_minor_version - ) : Type\Union { + ): Type\Union { if ($hint instanceof PhpParser\Node\UnionType) { $type = null; diff --git a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php index 966ec1be3de..0a17be159ed 100644 --- a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php @@ -403,7 +403,7 @@ public function enterNode(PhpParser\Node $node): ?int return null; } - private function handleNamespace(PhpParser\Node\Stmt\Namespace_ $node) : void + private function handleNamespace(PhpParser\Node\Stmt\Namespace_ $node): void { $this->file_storage->aliases = $this->aliases; @@ -426,7 +426,7 @@ private function handleNamespace(PhpParser\Node\Stmt\Namespace_ $node) : void } } - private function handleUse(PhpParser\Node\Stmt\Use_ $node) : void + private function handleUse(PhpParser\Node\Stmt\Use_ $node): void { foreach ($node->uses as $use) { $use_path = implode('\\', $use->name->parts); @@ -458,7 +458,7 @@ private function handleUse(PhpParser\Node\Stmt\Use_ $node) : void $this->aliases->uses_end = (int) $node->getAttribute('endFilePos') + 1; } - private function handleGroupUse(PhpParser\Node\Stmt\GroupUse $node) : void + private function handleGroupUse(PhpParser\Node\Stmt\GroupUse $node): void { $use_prefix = implode('\\', $node->prefix->parts); @@ -633,6 +633,9 @@ public function getAliases(): Aliases return $this->aliases; } + /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint + */ public function afterTraverse(array $nodes) { $this->file_storage->type_aliases = $this->type_aliases; diff --git a/src/Psalm/Internal/PhpVisitor/TraitFinder.php b/src/Psalm/Internal/PhpVisitor/TraitFinder.php index d60afec585f..089d8e51b51 100644 --- a/src/Psalm/Internal/PhpVisitor/TraitFinder.php +++ b/src/Psalm/Internal/PhpVisitor/TraitFinder.php @@ -56,7 +56,7 @@ public function enterNode(PhpParser\Node $node, bool &$traverseChildren = true): return null; } - public function getNode() : ?PhpParser\Node\Stmt\Trait_ + public function getNode(): ?PhpParser\Node\Stmt\Trait_ { if (!count($this->matching_trait_nodes)) { return null; diff --git a/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php b/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php index 8261d080924..ebbfab9e73b 100644 --- a/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php @@ -19,6 +19,9 @@ public function __construct( $this->real_type_provider = $real_type_provider; } + /** + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint + */ public function enterNode(Node $node) { $origNode = $node; diff --git a/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php b/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php index 3248c48d705..af84e9b8d64 100644 --- a/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php +++ b/src/Psalm/Internal/Provider/FileReferenceCacheProvider.php @@ -55,7 +55,7 @@ public function __construct(Config $config) $this->config = $config; } - public function hasConfigChanged() : bool + public function hasConfigChanged(): bool { $new_hash = $this->config->computeHash(); $has_changed = $new_hash !== $this->getConfigHashCache(); diff --git a/src/Psalm/Internal/Provider/FileReferenceProvider.php b/src/Psalm/Internal/Provider/FileReferenceProvider.php index d6a7a0d38fc..0930b7d3b34 100644 --- a/src/Psalm/Internal/Provider/FileReferenceProvider.php +++ b/src/Psalm/Internal/Provider/FileReferenceProvider.php @@ -229,7 +229,7 @@ public function addNonMethodReferencesToClasses(array $references): void /** * @param array $map */ - public function addClassLikeFiles(array $map) : void + public function addClassLikeFiles(array $map): void { self::$classlike_files += $map; } @@ -238,7 +238,7 @@ public function addFileReferenceToClassMember( string $source_file, string $referenced_member_id, bool $inside_return - ) : void { + ): void { self::$file_references_to_class_members[$referenced_member_id][$source_file] = true; if ($inside_return) { @@ -827,31 +827,31 @@ public function addCallingLocationForClass(CodeLocation $code_location, string $ } } - public function isClassMethodReferenced(string $method_id) : bool + public function isClassMethodReferenced(string $method_id): bool { return !empty(self::$file_references_to_class_members[$method_id]) || !empty(self::$method_references_to_class_members[$method_id]); } - public function isClassPropertyReferenced(string $property_id) : bool + public function isClassPropertyReferenced(string $property_id): bool { return !empty(self::$file_references_to_class_properties[$property_id]) || !empty(self::$method_references_to_class_properties[$property_id]); } - public function isMethodReturnReferenced(string $method_id) : bool + public function isMethodReturnReferenced(string $method_id): bool { return !empty(self::$file_references_to_method_returns[$method_id]) || !empty(self::$method_references_to_method_returns[$method_id]); } - public function isClassReferenced(string $fq_class_name_lc) : bool + public function isClassReferenced(string $fq_class_name_lc): bool { return isset(self::$method_references_to_classes[$fq_class_name_lc]) || isset(self::$nonmethod_references_to_classes[$fq_class_name_lc]); } - public function isMethodParamUsed(string $method_id, int $offset) : bool + public function isMethodParamUsed(string $method_id, int $offset): bool { return !empty(self::$method_param_uses[$method_id][$offset]); } @@ -868,7 +868,7 @@ public function setNonMethodReferencesToClasses(array $references): void /** * @return array> */ - public function getAllClassMethodLocations() : array + public function getAllClassMethodLocations(): array { return self::$class_method_locations; } @@ -876,7 +876,7 @@ public function getAllClassMethodLocations() : array /** * @return array> */ - public function getAllClassPropertyLocations() : array + public function getAllClassPropertyLocations(): array { return self::$class_property_locations; } @@ -884,7 +884,7 @@ public function getAllClassPropertyLocations() : array /** * @return array> */ - public function getAllClassLocations() : array + public function getAllClassLocations(): array { return self::$class_locations; } @@ -892,7 +892,7 @@ public function getAllClassLocations() : array /** * @return array */ - public function getClassMethodLocations(string $method_id) : array + public function getClassMethodLocations(string $method_id): array { return self::$class_method_locations[$method_id] ?? []; } @@ -900,7 +900,7 @@ public function getClassMethodLocations(string $method_id) : array /** * @return array */ - public function getClassPropertyLocations(string $property_id) : array + public function getClassPropertyLocations(string $property_id): array { return self::$class_property_locations[$property_id] ?? []; } @@ -908,7 +908,7 @@ public function getClassPropertyLocations(string $property_id) : array /** * @return array */ - public function getClassLocations(string $fq_class_name_lc) : array + public function getClassLocations(string $fq_class_name_lc): array { return self::$class_locations[$fq_class_name_lc] ?? []; } @@ -1210,7 +1210,7 @@ public function addClassLocations(array $references): void /** * @return array> */ - public function getExistingIssues() : array + public function getExistingIssues(): array { return self::$issues; } @@ -1251,7 +1251,7 @@ public function setAnalyzedMethods(array $analyzed_methods): void /** * @param array $file_maps */ - public function setFileMaps(array $file_maps) : void + public function setFileMaps(array $file_maps): void { self::$file_maps = $file_maps; } diff --git a/src/Psalm/Internal/Provider/FunctionExistenceProvider.php b/src/Psalm/Internal/Provider/FunctionExistenceProvider.php index 1cf57231df8..f21c70c956f 100644 --- a/src/Psalm/Internal/Provider/FunctionExistenceProvider.php +++ b/src/Psalm/Internal/Provider/FunctionExistenceProvider.php @@ -15,7 +15,7 @@ class FunctionExistenceProvider /** * @var array< * lowercase-string, - * array + * array * > */ private static $handlers = []; @@ -26,7 +26,7 @@ class FunctionExistenceProvider * array + * ): ?bool> * > */ private static $legacy_handlers = []; @@ -59,7 +59,7 @@ public function registerClass(string $class): void /** * @param lowercase-string $function_id - * @param Closure(FunctionExistenceProviderEvent) : ?bool $c + * @param Closure(FunctionExistenceProviderEvent): ?bool $c */ public function registerClosure(string $function_id, Closure $c): void { @@ -71,14 +71,14 @@ public function registerClosure(string $function_id, Closure $c): void * @param Closure( * StatementsSource, * string - * ) : ?bool $c + * ): ?bool $c */ public function registerLegacyClosure(string $function_id, Closure $c): void { self::$legacy_handlers[$function_id][] = $c; } - public function has(string $function_id) : bool + public function has(string $function_id): bool { return isset(self::$handlers[strtolower($function_id)]) || isset(self::$legacy_handlers[strtolower($function_id)]); diff --git a/src/Psalm/Internal/Provider/FunctionParamsProvider.php b/src/Psalm/Internal/Provider/FunctionParamsProvider.php index 7455d2dbf9c..9939902b581 100644 --- a/src/Psalm/Internal/Provider/FunctionParamsProvider.php +++ b/src/Psalm/Internal/Provider/FunctionParamsProvider.php @@ -19,7 +19,7 @@ class FunctionParamsProvider /** * @var array< * lowercase-string, - * array> + * array> * > */ private static $handlers = []; @@ -33,7 +33,7 @@ class FunctionParamsProvider * list, * ?Context=, * ?CodeLocation= - * ) : ?array> + * ): ?array> * > */ private static $legacy_handlers = []; @@ -65,7 +65,7 @@ public function registerClass(string $class): void } /** - * @param Closure(FunctionParamsProviderEvent) : ?array $c + * @param Closure(FunctionParamsProviderEvent): ?array $c */ public function registerClosure(string $fq_classlike_name, Closure $c): void { @@ -79,14 +79,14 @@ public function registerClosure(string $fq_classlike_name, Closure $c): void * list, * ?Context=, * ?CodeLocation= - * ) : ?array $c + * ): ?array $c */ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): void { self::$legacy_handlers[strtolower($fq_classlike_name)][] = $c; } - public function has(string $fq_classlike_name) : bool + public function has(string $fq_classlike_name): bool { return isset(self::$handlers[strtolower($fq_classlike_name)]) || isset(self::$legacy_handlers[strtolower($fq_classlike_name)]); diff --git a/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php b/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php index 5d2c97293b5..fc19fc9e623 100644 --- a/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/FunctionReturnTypeProvider.php @@ -20,7 +20,7 @@ class FunctionReturnTypeProvider /** * @var array< * lowercase-string, - * array + * array * > */ private static $handlers = []; @@ -34,7 +34,7 @@ class FunctionReturnTypeProvider * list, * Context, * CodeLocation - * ) : ?Type\Union> + * ): ?Type\Union> * > */ private static $legacy_handlers = []; @@ -114,14 +114,14 @@ public function registerClosure(string $function_id, Closure $c): void * list, * Context, * CodeLocation - * ) : ?Type\Union $c + * ): ?Type\Union $c */ public function registerLegacyClosure(string $function_id, Closure $c): void { self::$legacy_handlers[$function_id][] = $c; } - public function has(string $function_id) : bool + public function has(string $function_id): bool { return isset(self::$handlers[strtolower($function_id)]) || isset(self::$legacy_handlers[strtolower($function_id)]); diff --git a/src/Psalm/Internal/Provider/MethodExistenceProvider.php b/src/Psalm/Internal/Provider/MethodExistenceProvider.php index 7332720379c..95318dba6dd 100644 --- a/src/Psalm/Internal/Provider/MethodExistenceProvider.php +++ b/src/Psalm/Internal/Provider/MethodExistenceProvider.php @@ -16,7 +16,7 @@ class MethodExistenceProvider /** * @var array< * lowercase-string, - * array + * array * > */ private static $handlers = []; @@ -29,7 +29,7 @@ class MethodExistenceProvider * string, * ?StatementsSource=, * ?CodeLocation - * ) : ?bool> + * ): ?bool> * > */ private static $legacy_handlers = []; @@ -61,7 +61,7 @@ public function registerClass(string $class): void } /** - * @param Closure(MethodExistenceProviderEvent) : ?bool $c + * @param Closure(MethodExistenceProviderEvent): ?bool $c */ public function registerClosure(string $fq_classlike_name, Closure $c): void { @@ -74,14 +74,14 @@ public function registerClosure(string $fq_classlike_name, Closure $c): void * string, * ?StatementsSource=, * ?CodeLocation - * ) : ?bool $c + * ): ?bool $c */ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): void { self::$legacy_handlers[strtolower($fq_classlike_name)][] = $c; } - public function has(string $fq_classlike_name) : bool + public function has(string $fq_classlike_name): bool { return isset(self::$handlers[strtolower($fq_classlike_name)]) || isset(self::$legacy_handlers[strtolower($fq_classlike_name)]); diff --git a/src/Psalm/Internal/Provider/MethodParamsProvider.php b/src/Psalm/Internal/Provider/MethodParamsProvider.php index 492d6f9c063..bd69baf7453 100644 --- a/src/Psalm/Internal/Provider/MethodParamsProvider.php +++ b/src/Psalm/Internal/Provider/MethodParamsProvider.php @@ -19,7 +19,7 @@ class MethodParamsProvider /** * @var array< * lowercase-string, - * array> + * array> * > */ private static $handlers = []; @@ -34,7 +34,7 @@ class MethodParamsProvider * ?StatementsSource=, * ?Context=, * ?CodeLocation= - * ) : ?array> + * ): ?array> * > */ private static $legacy_handlers = []; @@ -68,7 +68,7 @@ public function registerClass(string $class): void } /** - * @param Closure(MethodParamsProviderEvent) : ?array $c + * @param Closure(MethodParamsProviderEvent): ?array $c */ public function registerClosure(string $fq_classlike_name, Closure $c): void { @@ -83,14 +83,14 @@ public function registerClosure(string $fq_classlike_name, Closure $c): void * ?StatementsSource=, * ?Context=, * ?CodeLocation= - * ) : ?array $c + * ): ?array $c */ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): void { self::$legacy_handlers[strtolower($fq_classlike_name)][] = $c; } - public function has(string $fq_classlike_name) : bool + public function has(string $fq_classlike_name): bool { return isset(self::$handlers[strtolower($fq_classlike_name)]) || isset(self::$legacy_handlers[strtolower($fq_classlike_name)]); diff --git a/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php b/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php index ef8c94f1859..8d91ffffca4 100644 --- a/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php @@ -19,7 +19,7 @@ class MethodReturnTypeProvider /** * @var array< * lowercase-string, - * array + * array * > */ private static $handlers = []; @@ -37,7 +37,7 @@ class MethodReturnTypeProvider * ?array=, * ?string=, * ?lowercase-string= - * ) : ?Type\Union> + * ): ?Type\Union> * > */ private static $legacy_handlers = []; @@ -75,7 +75,7 @@ public function registerClass(string $class): void } /** - * @param Closure(MethodReturnTypeProviderEvent) : ?Type\Union $c + * @param Closure(MethodReturnTypeProviderEvent): ?Type\Union $c */ public function registerClosure(string $fq_classlike_name, Closure $c): void { @@ -93,7 +93,7 @@ public function registerClosure(string $fq_classlike_name, Closure $c): void * ?array=, * ?string=, * ?lowercase-string= - * ) : ?Type\Union $c + * ): ?Type\Union $c * */ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): void @@ -101,7 +101,7 @@ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): vo self::$legacy_handlers[strtolower($fq_classlike_name)][] = $c; } - public function has(string $fq_classlike_name) : bool + public function has(string $fq_classlike_name): bool { return isset(self::$handlers[strtolower($fq_classlike_name)]) || isset(self::$legacy_handlers[strtolower($fq_classlike_name)]); diff --git a/src/Psalm/Internal/Provider/MethodVisibilityProvider.php b/src/Psalm/Internal/Provider/MethodVisibilityProvider.php index 6385b6dbd00..96b5e2e8211 100644 --- a/src/Psalm/Internal/Provider/MethodVisibilityProvider.php +++ b/src/Psalm/Internal/Provider/MethodVisibilityProvider.php @@ -17,7 +17,7 @@ class MethodVisibilityProvider /** * @var array< * lowercase-string, - * array + * array * > */ private static $handlers = []; @@ -31,7 +31,7 @@ class MethodVisibilityProvider * string, * Context, * ?CodeLocation - * ) : ?bool> + * ): ?bool> * > */ private static $legacy_handlers = []; @@ -64,7 +64,7 @@ public function registerClass(string $class): void } /** - * @param Closure(MethodVisibilityProviderEvent) : ?bool $c + * @param Closure(MethodVisibilityProviderEvent): ?bool $c */ public function registerClosure(string $fq_classlike_name, Closure $c): void { @@ -78,14 +78,14 @@ public function registerClosure(string $fq_classlike_name, Closure $c): void * string, * Context, * ?CodeLocation - * ) : ?bool $c + * ): ?bool $c */ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): void { self::$legacy_handlers[strtolower($fq_classlike_name)][] = $c; } - public function has(string $fq_classlike_name) : bool + public function has(string $fq_classlike_name): bool { return isset(self::$handlers[strtolower($fq_classlike_name)]) || isset(self::$legacy_handlers[strtolower($fq_classlike_name)]); diff --git a/src/Psalm/Internal/Provider/NodeDataProvider.php b/src/Psalm/Internal/Provider/NodeDataProvider.php index 6175a45ac1c..3987a231ffd 100644 --- a/src/Psalm/Internal/Provider/NodeDataProvider.php +++ b/src/Psalm/Internal/Provider/NodeDataProvider.php @@ -46,7 +46,7 @@ public function __construct() /** * @param Expr|Name|Return_ $node */ - public function setType(NodeAbstract $node, Union $type) : void + public function setType(NodeAbstract $node, Union $type): void { $this->node_types[$node] = $type; } @@ -54,7 +54,7 @@ public function setType(NodeAbstract $node, Union $type) : void /** * @param Expr|Name|Return_ $node */ - public function getType(NodeAbstract $node) : ?Union + public function getType(NodeAbstract $node): ?Union { return $this->node_types[$node] ?? null; } @@ -62,7 +62,7 @@ public function getType(NodeAbstract $node) : ?Union /** * @param list>>>|null $assertions */ - public function setAssertions(Expr $node, ?array $assertions) : void + public function setAssertions(Expr $node, ?array $assertions): void { if (!$this->cache_assertions) { return; @@ -74,7 +74,7 @@ public function setAssertions(Expr $node, ?array $assertions) : void /** * @return list>>>|null */ - public function getAssertions(Expr $node) : ?array + public function getAssertions(Expr $node): ?array { if (!$this->cache_assertions) { return null; @@ -87,7 +87,7 @@ public function getAssertions(Expr $node) : ?array * @param FuncCall|MethodCall|StaticCall|New_ $node * @param array $assertions */ - public function setIfTrueAssertions(Expr $node, array $assertions) : void + public function setIfTrueAssertions(Expr $node, array $assertions): void { $this->node_if_true_assertions[$node] = $assertions; } @@ -96,7 +96,7 @@ public function setIfTrueAssertions(Expr $node, array $assertions) : void * @param Expr\FuncCall|MethodCall|StaticCall|New_ $node * @return array|null */ - public function getIfTrueAssertions(Expr $node) : ?array + public function getIfTrueAssertions(Expr $node): ?array { return $this->node_if_true_assertions[$node] ?? null; } @@ -105,7 +105,7 @@ public function getIfTrueAssertions(Expr $node) : ?array * @param FuncCall|MethodCall|StaticCall|New_ $node * @param array $assertions */ - public function setIfFalseAssertions(Expr $node, array $assertions) : void + public function setIfFalseAssertions(Expr $node, array $assertions): void { $this->node_if_false_assertions[$node] = $assertions; } @@ -114,19 +114,19 @@ public function setIfFalseAssertions(Expr $node, array $assertions) : void * @param FuncCall|MethodCall|StaticCall|New_ $node * @return array|null */ - public function getIfFalseAssertions(Expr $node) : ?array + public function getIfFalseAssertions(Expr $node): ?array { return $this->node_if_false_assertions[$node] ?? null; } - public function isPureCompatible(Expr $node) : bool + public function isPureCompatible(Expr $node): bool { $node_type = $this->getType($node); return ($node_type && $node_type->reference_free) || $node->getAttribute('pure', false); } - public function clearNodeOfTypeAndAssertions(Expr $node) : void + public function clearNodeOfTypeAndAssertions(Expr $node): void { unset($this->node_types[$node], $this->node_assertions[$node]); } diff --git a/src/Psalm/Internal/Provider/ProjectCacheProvider.php b/src/Psalm/Internal/Provider/ProjectCacheProvider.php index c3754c36ddf..4c7983f3e93 100644 --- a/src/Psalm/Internal/Provider/ProjectCacheProvider.php +++ b/src/Psalm/Internal/Provider/ProjectCacheProvider.php @@ -78,7 +78,7 @@ public function getLastRun(string $psalm_version): int return $this->last_run; } - public function hasLockfileChanged() : bool + public function hasLockfileChanged(): bool { if (!file_exists($this->composer_lock_location)) { return true; @@ -99,7 +99,7 @@ public function hasLockfileChanged() : bool return $changed; } - public function updateComposerLockHash() : void + public function updateComposerLockHash(): void { $cache_directory = Config::getInstance()->getCacheDirectory(); @@ -116,7 +116,7 @@ public function updateComposerLockHash() : void file_put_contents($lock_hash_location, $this->composer_lock_hash); } - protected function getComposerLockHash() : string + protected function getComposerLockHash(): string { if ($this->composer_lock_hash === null) { $cache_directory = Config::getInstance()->getCacheDirectory(); diff --git a/src/Psalm/Internal/Provider/PropertyExistenceProvider.php b/src/Psalm/Internal/Provider/PropertyExistenceProvider.php index be52dc06bd8..eef9af3b095 100644 --- a/src/Psalm/Internal/Provider/PropertyExistenceProvider.php +++ b/src/Psalm/Internal/Provider/PropertyExistenceProvider.php @@ -17,7 +17,7 @@ class PropertyExistenceProvider /** * @var array< * lowercase-string, - * array + * array * > */ private static $handlers = []; @@ -32,7 +32,7 @@ class PropertyExistenceProvider * ?StatementsSource=, * ?Context=, * ?CodeLocation= - * ) : ?bool> + * ): ?bool> * > */ private static $legacy_handlers = []; @@ -65,7 +65,7 @@ public function registerClass(string $class): void } /** - * @param Closure(PropertyExistenceProviderEvent) : ?bool $c + * @param Closure(PropertyExistenceProviderEvent): ?bool $c */ public function registerClosure(string $fq_classlike_name, Closure $c): void { @@ -80,14 +80,14 @@ public function registerClosure(string $fq_classlike_name, Closure $c): void * ?StatementsSource=, * ?Context=, * ?CodeLocation= - * ) : ?bool $c + * ): ?bool $c */ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): void { self::$legacy_handlers[strtolower($fq_classlike_name)][] = $c; } - public function has(string $fq_classlike_name) : bool + public function has(string $fq_classlike_name): bool { return isset(self::$handlers[strtolower($fq_classlike_name)]) || isset(self::$legacy_handlers[strtolower($fq_classlike_name)]); diff --git a/src/Psalm/Internal/Provider/PropertyTypeProvider.php b/src/Psalm/Internal/Provider/PropertyTypeProvider.php index b7562ae33e1..cf59a5f64cf 100644 --- a/src/Psalm/Internal/Provider/PropertyTypeProvider.php +++ b/src/Psalm/Internal/Provider/PropertyTypeProvider.php @@ -18,7 +18,7 @@ class PropertyTypeProvider /** * @var array< * lowercase-string, - * array + * array * > */ private static $handlers = []; @@ -32,7 +32,7 @@ class PropertyTypeProvider * bool, * ?StatementsSource=, * ?Context= - * ) : ?Type\Union> + * ): ?Type\Union> * > */ private static $legacy_handlers = []; @@ -66,7 +66,7 @@ public function registerClass(string $class): void } /** - * @param Closure(PropertyTypeProviderEvent) : ?Type\Union $c + * @param Closure(PropertyTypeProviderEvent): ?Type\Union $c */ public function registerClosure(string $fq_classlike_name, Closure $c): void { @@ -80,14 +80,14 @@ public function registerClosure(string $fq_classlike_name, Closure $c): void * bool, * ?StatementsSource=, * ?Context= - * ) : ?Type\Union $c + * ): ?Type\Union $c */ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): void { self::$legacy_handlers[strtolower($fq_classlike_name)][] = $c; } - public function has(string $fq_classlike_name) : bool + public function has(string $fq_classlike_name): bool { return isset(self::$handlers[strtolower($fq_classlike_name)]) || isset(self::$legacy_handlers[strtolower($fq_classlike_name)]); diff --git a/src/Psalm/Internal/Provider/PropertyVisibilityProvider.php b/src/Psalm/Internal/Provider/PropertyVisibilityProvider.php index f85792825e7..b70d730cb94 100644 --- a/src/Psalm/Internal/Provider/PropertyVisibilityProvider.php +++ b/src/Psalm/Internal/Provider/PropertyVisibilityProvider.php @@ -17,7 +17,7 @@ class PropertyVisibilityProvider /** * @var array< * lowercase-string, - * array + * array * > */ private static $handlers = []; @@ -32,7 +32,7 @@ class PropertyVisibilityProvider * bool, * Context, * CodeLocation - * ) : ?bool> + * ): ?bool> * > */ private static $legacy_handlers = []; @@ -87,7 +87,7 @@ public function registerLegacyClosure(string $fq_classlike_name, Closure $c): vo self::$legacy_handlers[strtolower($fq_classlike_name)][] = $c; } - public function has(string $fq_classlike_name) : bool + public function has(string $fq_classlike_name): bool { return isset(self::$handlers[strtolower($fq_classlike_name)]) || isset(self::$legacy_handlers[strtolower($fq_classlike_name)]); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php index da035ac33d4..9db375bb311 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayColumnReturnTypeProvider.php @@ -14,12 +14,12 @@ class ArrayColumnReturnTypeProvider implements FunctionReturnTypeProviderInterfa /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_column']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php index a0391c2aced..1ade25103b0 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFillReturnTypeProvider.php @@ -11,12 +11,12 @@ class ArrayFillReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_fill']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php index f0c28d1f250..bea34669a54 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayFilterReturnTypeProvider.php @@ -30,12 +30,12 @@ class ArrayFilterReturnTypeProvider implements FunctionReturnTypeProviderInterfa /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_filter']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php index 5fb7d50f3f2..57b8d3cb6c2 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMapReturnTypeProvider.php @@ -38,12 +38,12 @@ class ArrayMapReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_map']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); @@ -256,7 +256,7 @@ private static function executeFakeCall( PhpParser\Node\Expr $fake_call, Context $context, ?array &$assertions = null - ) : ?Type\Union { + ): ?Type\Union { $old_data_provider = $statements_analyzer->node_data; $statements_analyzer->node_data = clone $statements_analyzer->node_data; @@ -339,7 +339,7 @@ public static function getReturnTypeFromMappingIds( PhpParser\Node\Arg $function_call_arg, array $array_args, ?array &$assertions = null - ) : Type\Union { + ): Type\Union { $mapping_return_type = null; $codebase = $statements_source->getCodebase(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php index e60ec1ae769..12674e9d921 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php @@ -18,12 +18,12 @@ class ArrayMergeReturnTypeProvider implements FunctionReturnTypeProviderInterfac /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_merge', 'array_replace']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php index 7784de19e18..a1d0da9e6ca 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPointerAdjustmentReturnTypeProvider.php @@ -16,12 +16,12 @@ class ArrayPointerAdjustmentReturnTypeProvider implements FunctionReturnTypeProv /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['current', 'next', 'prev', 'reset', 'end']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPopReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPopReturnTypeProvider.php index 51f717ae567..99c7984b96b 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPopReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayPopReturnTypeProvider.php @@ -11,12 +11,12 @@ class ArrayPopReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_pop', 'array_shift']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayRandReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayRandReturnTypeProvider.php index 2481abe3564..e94f7637389 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayRandReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayRandReturnTypeProvider.php @@ -12,12 +12,12 @@ class ArrayRandReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_rand']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php index a29172c1f18..3e267ee4357 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php @@ -27,12 +27,12 @@ class ArrayReduceReturnTypeProvider implements FunctionReturnTypeProviderInterfa /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_reduce']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php index 81b92c927c9..59768aadb18 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php @@ -11,12 +11,12 @@ class ArrayReverseReturnTypeProvider implements FunctionReturnTypeProviderInterf /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_reverse']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySliceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySliceReturnTypeProvider.php index bfe09f30769..35f9896fc53 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySliceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySliceReturnTypeProvider.php @@ -15,12 +15,12 @@ class ArraySliceReturnTypeProvider implements FunctionReturnTypeProviderInterfac /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_slice']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySpliceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySpliceReturnTypeProvider.php index 979b91d659c..3d6835f34a7 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySpliceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArraySpliceReturnTypeProvider.php @@ -11,12 +11,12 @@ class ArraySpliceReturnTypeProvider implements FunctionReturnTypeProviderInterfa /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_splice']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayUniqueReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayUniqueReturnTypeProvider.php index 9fd2670462d..80ca137d6cf 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayUniqueReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayUniqueReturnTypeProvider.php @@ -11,12 +11,12 @@ class ArrayUniqueReturnTypeProvider implements FunctionReturnTypeProviderInterfa /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_unique']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayValuesReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayValuesReturnTypeProvider.php index 204768fe85b..8ba6ae03b2a 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayValuesReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayValuesReturnTypeProvider.php @@ -15,12 +15,12 @@ class ArrayValuesReturnTypeProvider implements FunctionReturnTypeProviderInterfa /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['array_values']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php index 3ed27557c1a..bdf5ed8a4b5 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ClosureFromCallableReturnTypeProvider.php @@ -10,7 +10,7 @@ class ClosureFromCallableReturnTypeProvider implements MethodReturnTypeProviderInterface { - public static function getClassLikeNames() : array + public static function getClassLikeNames(): array { return ['Closure']; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/DomNodeAppendChild.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/DomNodeAppendChild.php index f94246115ec..7eaabcf853d 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/DomNodeAppendChild.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/DomNodeAppendChild.php @@ -8,7 +8,7 @@ class DomNodeAppendChild implements MethodReturnTypeProviderInterface { - public static function getClassLikeNames() : array + public static function getClassLikeNames(): array { return ['DomNode']; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php index 9c23e9abbd4..271854c7b3a 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php @@ -14,12 +14,12 @@ class ExplodeReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['explode']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php index d8d35051d3e..6c99c67118f 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/FilterVarReturnTypeProvider.php @@ -26,12 +26,12 @@ class FilterVarReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['filter_var']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php index bc92da8c5c7..95e521c9980 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/FirstArgStringReturnTypeProvider.php @@ -11,7 +11,7 @@ class FirstArgStringReturnTypeProvider implements FunctionReturnTypeProviderInte /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return [ 'crypt', diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetClassMethodsReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetClassMethodsReturnTypeProvider.php index f9ac699a06e..9e0a729d8b7 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetClassMethodsReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetClassMethodsReturnTypeProvider.php @@ -11,7 +11,7 @@ class GetClassMethodsReturnTypeProvider implements FunctionReturnTypeProviderInt /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return [ 'get_class_methods', diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php index 2eae7930b83..b3b92a76e4a 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/GetObjectVarsReturnTypeProvider.php @@ -19,7 +19,7 @@ class GetObjectVarsReturnTypeProvider implements FunctionReturnTypeProviderInter /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return [ 'get_object_vars', diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/HexdecReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/HexdecReturnTypeProvider.php index 452779f5975..7897527f74e 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/HexdecReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/HexdecReturnTypeProvider.php @@ -11,12 +11,12 @@ class HexdecReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['hexdec']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); if (!$statements_source instanceof StatementsAnalyzer) { diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php index a73a67f69e7..7617743a192 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ImagickPixelColorReturnTypeProvider.php @@ -15,7 +15,7 @@ class ImagickPixelColorReturnTypeProvider implements MethodReturnTypeProviderInterface { - public static function getClassLikeNames() : array + public static function getClassLikeNames(): array { return ['imagickpixel']; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php index 44961f05567..994de0c1611 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/IteratorToArrayReturnTypeProvider.php @@ -18,14 +18,14 @@ class IteratorToArrayReturnTypeProvider implements FunctionReturnTypeProviderInt /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return [ 'iterator_to_array', ]; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php index a786b72deb5..0be42df41dd 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/MktimeReturnTypeProvider.php @@ -11,14 +11,14 @@ class MktimeReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return [ 'mktime', ]; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php index c84871e266c..6d98842a26c 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ParseUrlReturnTypeProvider.php @@ -23,12 +23,12 @@ class ParseUrlReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['parse_url']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php index 3b60535cd5f..1f29ec1b534 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementReturnTypeProvider.php @@ -10,7 +10,7 @@ class PdoStatementReturnTypeProvider implements MethodReturnTypeProviderInterface { - public static function getClassLikeNames() : array + public static function getClassLikeNames(): array { return ['PDOStatement']; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementSetFetchMode.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementSetFetchMode.php index cbc1a876484..e059911f8c3 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementSetFetchMode.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/PdoStatementSetFetchMode.php @@ -11,7 +11,7 @@ class PdoStatementSetFetchMode implements MethodParamsProviderInterface { - public static function getClassLikeNames() : array + public static function getClassLikeNames(): array { return ['PDOStatement']; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/SimpleXmlElementAsXml.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/SimpleXmlElementAsXml.php index 14fce674a30..f1d43eee7d9 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/SimpleXmlElementAsXml.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/SimpleXmlElementAsXml.php @@ -9,7 +9,7 @@ class SimpleXmlElementAsXml implements MethodReturnTypeProviderInterface { - public static function getClassLikeNames() : array + public static function getClassLikeNames(): array { return ['SimpleXMLElement']; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php index ad6e524f2a1..a89c2ede23f 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrReplaceReturnTypeProvider.php @@ -14,7 +14,7 @@ class StrReplaceReturnTypeProvider implements FunctionReturnTypeProviderInterfac /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return [ 'str_replace', @@ -25,7 +25,7 @@ public static function getFunctionIds() : array ]; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php index 77281cb0ed6..8cd95a26d8c 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/StrTrReturnTypeProvider.php @@ -15,14 +15,14 @@ class StrTrReturnTypeProvider implements FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return [ 'strtr', ]; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php index 98b163b7e4c..78f63533c5f 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/VersionCompareReturnTypeProvider.php @@ -14,12 +14,12 @@ class VersionCompareReturnTypeProvider implements FunctionReturnTypeProviderInte /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['version_compare']; } - public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union + public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event): Type\Union { $statements_source = $event->getStatementsSource(); $call_args = $event->getCallArgs(); diff --git a/src/Psalm/Internal/Provider/StatementsProvider.php b/src/Psalm/Internal/Provider/StatementsProvider.php index a8cf151d036..8c49a77d496 100644 --- a/src/Psalm/Internal/Provider/StatementsProvider.php +++ b/src/Psalm/Internal/Provider/StatementsProvider.php @@ -229,7 +229,7 @@ function (int $_): bool { $file_path_hash = md5($file_path); $changed_members = array_map( - function (string $key) use ($file_path_hash) : string { + function (string $key) use ($file_path_hash): string { if (strpos($key, 'use:') === 0) { return $key . ':' . $file_path_hash; } @@ -341,7 +341,7 @@ public function addUnchangedSignatureMembers(array $more_unchanged_members): voi /** * @return array */ - public function getErrors() : array + public function getErrors(): array { return $this->errors; } @@ -513,7 +513,7 @@ public static function parseStatements( return $stmts; } - public static function clearLexer() : void + public static function clearLexer(): void { self::$lexer = null; } diff --git a/src/Psalm/Internal/Scanner/DocblockParser.php b/src/Psalm/Internal/Scanner/DocblockParser.php index 7e464d00707..cd1b8b74cf3 100644 --- a/src/Psalm/Internal/Scanner/DocblockParser.php +++ b/src/Psalm/Internal/Scanner/DocblockParser.php @@ -26,7 +26,7 @@ class DocblockParser * $offsetStart is the absolute position of the docblock in the file. It'll be used to add to the position of some * special tags (like `psalm-suppress`) for future uses */ - public static function parse(string $docblock, int $offsetStart) : ParsedDocblock + public static function parse(string $docblock, int $offsetStart): ParsedDocblock { // Strip off comments. $docblock = trim($docblock); @@ -141,7 +141,7 @@ public static function parse(string $docblock, int $offsetStart) : ParsedDocbloc return $parsed; } - private static function resolveTags(ParsedDocblock $docblock) : void + private static function resolveTags(ParsedDocblock $docblock): void { if (isset($docblock->tags['template']) || isset($docblock->tags['psalm-template']) diff --git a/src/Psalm/Internal/Scanner/ParsedDocblock.php b/src/Psalm/Internal/Scanner/ParsedDocblock.php index 9beb83739ba..26c5b01363c 100644 --- a/src/Psalm/Internal/Scanner/ParsedDocblock.php +++ b/src/Psalm/Internal/Scanner/ParsedDocblock.php @@ -32,7 +32,7 @@ public function __construct(string $description, array $tags, string $first_line $this->first_line_padding = $first_line_padding; } - public function render(string $left_padding) : string + public function render(string $left_padding): string { $doc_comment_text = '/**' . "\n"; diff --git a/src/Psalm/Internal/Scanner/PhpStormMetaScanner.php b/src/Psalm/Internal/Scanner/PhpStormMetaScanner.php index 7d393311f98..31f366ad82a 100644 --- a/src/Psalm/Internal/Scanner/PhpStormMetaScanner.php +++ b/src/Psalm/Internal/Scanner/PhpStormMetaScanner.php @@ -261,7 +261,7 @@ function ( ) use ( $map, $offset - ) : Type\Union { + ): Type\Union { $statements_analyzer = $event->getStatementsSource(); $call_args = $event->getCallArgs(); $function_id = $event->getFunctionId(); @@ -314,7 +314,7 @@ function ( FunctionReturnTypeProviderEvent $event ) use ( $type_offset - ) : Type\Union { + ): Type\Union { $statements_analyzer = $event->getStatementsSource(); $call_args = $event->getCallArgs(); $function_id = $event->getFunctionId(); @@ -348,7 +348,7 @@ function ( FunctionReturnTypeProviderEvent $event ) use ( $element_type_offset - ) : Type\Union { + ): Type\Union { $statements_analyzer = $event->getStatementsSource(); $call_args = $event->getCallArgs(); $function_id = $event->getFunctionId(); diff --git a/src/Psalm/Internal/Stubs/Generator/ClassLikeStubGenerator.php b/src/Psalm/Internal/Stubs/Generator/ClassLikeStubGenerator.php index 55d19edca73..8a8105cbae5 100644 --- a/src/Psalm/Internal/Stubs/Generator/ClassLikeStubGenerator.php +++ b/src/Psalm/Internal/Stubs/Generator/ClassLikeStubGenerator.php @@ -110,7 +110,7 @@ public static function getClassLikeNode( /** * @return list */ - private static function getConstantNodes(\Psalm\Codebase $codebase, ClassLikeStorage $storage) : array + private static function getConstantNodes(\Psalm\Codebase $codebase, ClassLikeStorage $storage): array { $constant_nodes = []; @@ -149,7 +149,7 @@ private static function getConstantNodes(\Psalm\Codebase $codebase, ClassLikeSto /** * @return list */ - private static function getPropertyNodes(ClassLikeStorage $storage) : array + private static function getPropertyNodes(ClassLikeStorage $storage): array { $namespace_name = implode('\\', array_slice(explode('\\', $storage->name), 0, -1)); diff --git a/src/Psalm/Internal/Stubs/Generator/StubsGenerator.php b/src/Psalm/Internal/Stubs/Generator/StubsGenerator.php index 9d3d7820478..27ea916074f 100644 --- a/src/Psalm/Internal/Stubs/Generator/StubsGenerator.php +++ b/src/Psalm/Internal/Stubs/Generator/StubsGenerator.php @@ -30,7 +30,7 @@ public static function getAll( \Psalm\Codebase $codebase, \Psalm\Internal\Provider\ClassLikeStorageProvider $class_provider, \Psalm\Internal\Provider\FileStorageProvider $file_provider - ) : string { + ): string { $namespaced_nodes = []; $psalm_base = dirname(__DIR__, 5); diff --git a/src/Psalm/Internal/Type/ArrayType.php b/src/Psalm/Internal/Type/ArrayType.php index f176d29ace3..202996075a7 100644 --- a/src/Psalm/Internal/Type/ArrayType.php +++ b/src/Psalm/Internal/Type/ArrayType.php @@ -25,9 +25,6 @@ public function __construct(Type\Union $key, Type\Union $value, bool $is_list) $this->is_list = $is_list; } - /** - * @return self|null - */ public static function infer(Type\Atomic $type): ?self { if ($type instanceof Type\Atomic\TKeyedArray) { diff --git a/src/Psalm/Internal/Type/AssertionReconciler.php b/src/Psalm/Internal/Type/AssertionReconciler.php index e508f6e54a8..3aa250498c9 100644 --- a/src/Psalm/Internal/Type/AssertionReconciler.php +++ b/src/Psalm/Internal/Type/AssertionReconciler.php @@ -64,7 +64,7 @@ public static function reconcile( array $suppressed_issues = [], ?int &$failed_reconciliation = Reconciler::RECONCILIATION_OK, bool $negated = false - ) : Union { + ): Union { $codebase = $statements_analyzer->getCodebase(); $is_strict_equality = false; @@ -248,7 +248,7 @@ private static function getMissingType( bool $inside_loop, bool $is_equality, array $template_type_map - ) : Union { + ): Union { if (($assertion === 'isset' && !$is_negation) || ($assertion === 'empty' && $is_negation) ) { @@ -305,7 +305,7 @@ private static function refine( bool $is_loose_equality, array $suppressed_issues, int &$failed_reconciliation - ) : Union { + ): Union { $codebase = $statements_analyzer->getCodebase(); $old_var_type_string = $existing_var_type->getId(); @@ -599,7 +599,7 @@ private static function filterTypeWithAnother( array $template_type_map, bool &$has_match = false, bool &$any_scalar_type_match_found = false - ) : Type\Union { + ): Type\Union { $matching_atomic_types = []; $has_cloned_type = false; @@ -958,7 +958,7 @@ private static function handleLiteralEquality( bool $negated, ?CodeLocation $code_location, array $suppressed_issues - ) : Type\Union { + ): Type\Union { $value = substr($assertion, $bracket_pos + 1, -1); $scalar_type = substr($assertion, 0, $bracket_pos); diff --git a/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php index 69d1f273c1d..12a2de22540 100644 --- a/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ArrayTypeComparator.php @@ -31,7 +31,7 @@ public static function isContainedBy( Type\Atomic $container_type_part, bool $allow_interface_equality, ?TypeComparisonResult $atomic_comparison_result - ) : bool { + ): bool { $all_types_contain = true; $is_empty_array = $input_type_part->equals( diff --git a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php index 7f1354e25c7..8b658ff75c2 100644 --- a/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/AtomicTypeComparator.php @@ -50,7 +50,7 @@ public static function isContainedBy( bool $allow_interface_equality = false, bool $allow_float_int_equality = true, ?TypeComparisonResult $atomic_comparison_result = null - ) : bool { + ): bool { if (($container_type_part instanceof TTemplateParam || ($container_type_part instanceof TNamedObject @@ -668,7 +668,7 @@ public static function canBeIdentical( Type\Atomic $type1_part, Type\Atomic $type2_part, bool $allow_interface_equality = true - ) : bool { + ): bool { if ((get_class($type1_part) === TList::class && $type2_part instanceof Type\Atomic\TNonEmptyList) || (get_class($type2_part) === TList::class diff --git a/src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php b/src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php index b9893e20d63..c86f81ceb03 100644 --- a/src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/CallableTypeComparator.php @@ -41,7 +41,7 @@ public static function isContainedBy( Type\Atomic $input_type_part, Type\Atomic $container_type_part, ?TypeComparisonResult $atomic_comparison_result - ) : bool { + ): bool { if ($container_type_part->is_pure && !$input_type_part->is_pure) { if ($atomic_comparison_result) { $atomic_comparison_result->type_coerced = $input_type_part->is_pure === null; @@ -135,7 +135,7 @@ public static function isNotExplicitlyCallableTypeCallable( Type\Atomic $input_type_part, TCallable $container_type_part, ?TypeComparisonResult $atomic_comparison_result - ) : bool { + ): bool { if ($input_type_part instanceof TList) { if ($input_type_part->type_param->isMixed() || $input_type_part->type_param->hasScalar() diff --git a/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php b/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php index da6ca9be5eb..afc0d2c15f9 100644 --- a/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ClassLikeStringComparator.php @@ -26,7 +26,7 @@ public static function isContainedBy( Scalar $container_type_part, bool $allow_interface_equality, ?TypeComparisonResult $atomic_comparison_result = null - ) : bool { + ): bool { if ($container_type_part instanceof TLiteralClassString && $input_type_part instanceof TLiteralClassString ) { diff --git a/src/Psalm/Internal/Type/Comparator/GenericTypeComparator.php b/src/Psalm/Internal/Type/Comparator/GenericTypeComparator.php index b66df37882b..89efd338f66 100644 --- a/src/Psalm/Internal/Type/Comparator/GenericTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/GenericTypeComparator.php @@ -27,7 +27,7 @@ public static function isContainedBy( Type\Atomic $container_type_part, bool $allow_interface_equality = false, ?TypeComparisonResult $atomic_comparison_result = null - ) : bool { + ): bool { $all_types_contain = true; $container_was_iterable = false; diff --git a/src/Psalm/Internal/Type/Comparator/IntegerRangeComparator.php b/src/Psalm/Internal/Type/Comparator/IntegerRangeComparator.php index 8357c246fee..557e822961f 100644 --- a/src/Psalm/Internal/Type/Comparator/IntegerRangeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/IntegerRangeComparator.php @@ -24,7 +24,7 @@ class IntegerRangeComparator public static function isContainedBy( TIntRange $input_type_part, TIntRange $container_type_part - ) : bool { + ): bool { $is_input_min = $input_type_part->min_bound === null; $is_input_max = $input_type_part->max_bound === null; $is_container_min = $container_type_part->min_bound === null; @@ -48,7 +48,7 @@ public static function isContainedBy( public static function isContainedByUnion( TIntRange $input_type_part, Union $container_type - ) : bool { + ): bool { $container_atomic_types = $container_type->getAtomicTypes(); $reduced_range = clone $input_type_part; diff --git a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php index 256d4bdd6f8..616ebd15146 100644 --- a/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php +++ b/src/Psalm/Internal/Type/Comparator/KeyedArrayComparator.php @@ -25,7 +25,7 @@ public static function isContainedBy( Type\Atomic $container_type_part, bool $allow_interface_equality, ?TypeComparisonResult $atomic_comparison_result - ) : bool { + ): bool { $all_types_contain = true; foreach ($container_type_part->properties as $key => $container_property_type) { @@ -90,7 +90,7 @@ public static function isContainedByObjectWithProperties( TObjectWithProperties $container_type_part, bool $allow_interface_equality, ?TypeComparisonResult $atomic_comparison_result - ) : bool { + ): bool { $all_types_contain = true; foreach ($container_type_part->properties as $property_name => $container_property_type) { diff --git a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php index 1cfcb5315cc..d8e5ab92b0c 100644 --- a/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/ScalarTypeComparator.php @@ -59,7 +59,7 @@ public static function isContainedBy( bool $allow_interface_equality = false, bool $allow_float_int_equality = true, ?TypeComparisonResult $atomic_comparison_result = null - ) : bool { + ): bool { if (get_class($container_type_part) === TString::class && $input_type_part instanceof TString ) { diff --git a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php index 55b0c02b055..87c7f9ff9e6 100644 --- a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php @@ -37,7 +37,7 @@ public static function isContainedBy( ?TypeComparisonResult $union_comparison_result = null, bool $allow_interface_equality = false, bool $allow_float_int_equality = true - ) : bool { + ): bool { if ($container_type->isMixed()) { return true; } diff --git a/src/Psalm/Internal/Type/ParseTree.php b/src/Psalm/Internal/Type/ParseTree.php index 21e02d4e93c..ac65fa30df2 100644 --- a/src/Psalm/Internal/Type/ParseTree.php +++ b/src/Psalm/Internal/Type/ParseTree.php @@ -31,7 +31,7 @@ public function __destruct() $this->parent = null; } - public function cleanParents() : void + public function cleanParents(): void { foreach ($this->children as $child) { $child->cleanParents(); diff --git a/src/Psalm/Internal/Type/ParseTreeCreator.php b/src/Psalm/Internal/Type/ParseTreeCreator.php index 95b812274de..56ce3d33ae6 100644 --- a/src/Psalm/Internal/Type/ParseTreeCreator.php +++ b/src/Psalm/Internal/Type/ParseTreeCreator.php @@ -41,7 +41,7 @@ public function __construct(array $type_tokens) $this->current_leaf = $this->parse_tree; } - public function create() : ParseTree + public function create(): ParseTree { while ($this->t < $this->type_token_count) { $type_token = $this->type_tokens[$this->t]; @@ -150,7 +150,7 @@ public function create() : ParseTree /** * @param array{0: string, 1: int} $current_token */ - private function createMethodParam(array $current_token, ParseTree $current_parent) : void + private function createMethodParam(array $current_token, ParseTree $current_parent): void { $byref = false; $variadic = false; @@ -216,7 +216,7 @@ private function createMethodParam(array $current_token, ParseTree $current_pare $this->current_leaf = $new_parent_leaf; } - private function handleOpenSquareBracket() : void + private function handleOpenSquareBracket(): void { if ($this->current_leaf instanceof ParseTree\Root) { throw new TypeParseTreeException('Unexpected token ['); @@ -267,7 +267,7 @@ private function handleOpenSquareBracket() : void ++$this->t; } - private function handleOpenRoundBracket() : void + private function handleOpenRoundBracket(): void { if ($this->current_leaf instanceof ParseTree\Value) { throw new TypeParseTreeException('Unrecognised token ('); @@ -291,7 +291,7 @@ private function handleOpenRoundBracket() : void $this->current_leaf = $new_leaf; } - private function handleClosedRoundBracket() : void + private function handleClosedRoundBracket(): void { $prev_token = $this->t > 0 ? $this->type_tokens[$this->t - 1] : null; @@ -319,7 +319,7 @@ private function handleClosedRoundBracket() : void } } - private function handleComma() : void + private function handleComma(): void { if ($this->current_leaf instanceof ParseTree\Root) { throw new TypeParseTreeException('Unexpected token ,'); @@ -356,7 +356,7 @@ private function handleComma() : void } /** @param array{0: string, 1: int} $type_token */ - private function handleEllipsisOrEquals(array $type_token) : void + private function handleEllipsisOrEquals(array $type_token): void { $prev_token = $this->t > 0 ? $this->type_tokens[$this->t - 1] : null; @@ -408,7 +408,7 @@ private function handleEllipsisOrEquals(array $type_token) : void $this->current_leaf = $new_leaf; } - private function handleColon() : void + private function handleColon(): void { if ($this->current_leaf instanceof ParseTree\Root) { throw new TypeParseTreeException('Unexpected token :'); @@ -493,7 +493,7 @@ private function handleColon() : void $this->current_leaf = $new_parent_leaf; } - private function handleSpace() : void + private function handleSpace(): void { if ($this->current_leaf instanceof ParseTree\Root) { throw new TypeParseTreeException('Unexpected space'); @@ -525,7 +525,7 @@ private function handleSpace() : void $this->createMethodParam($next_token, $current_parent); } - private function handleQuestionMark() : void + private function handleQuestionMark(): void { $next_token = $this->t + 1 < $this->type_token_count ? $this->type_tokens[$this->t + 1] : null; @@ -584,7 +584,7 @@ private function handleQuestionMark() : void } } - private function handleBar() : void + private function handleBar(): void { if ($this->current_leaf instanceof ParseTree\Root) { throw new TypeParseTreeException('Unexpected token |'); @@ -637,7 +637,7 @@ private function handleBar() : void $this->current_leaf = $new_parent_leaf; } - private function handleAmpersand() : void + private function handleAmpersand(): void { if ($this->current_leaf instanceof ParseTree\Root) { throw new TypeParseTreeException( @@ -672,7 +672,7 @@ private function handleAmpersand() : void } /** @param array{0: string, 1: int} $type_token */ - private function handleIsOrAs(array $type_token) : void + private function handleIsOrAs(array $type_token): void { if ($this->t === 0) { $this->handleValue($type_token); @@ -715,7 +715,7 @@ private function handleIsOrAs(array $type_token) : void } /** @param array{0: string, 1: int, 2?: string} $type_token */ - private function handleValue(array $type_token) : void + private function handleValue(array $type_token): void { $new_parent = !$this->current_leaf instanceof ParseTree\Root ? $this->current_leaf : null; diff --git a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php index bcefd233d10..f9637c81206 100644 --- a/src/Psalm/Internal/Type/SimpleAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleAssertionReconciler.php @@ -78,7 +78,7 @@ public static function reconcile( bool $is_equality = false, bool $is_strict_equality = false, bool $inside_loop = false - ) : ?Type\Union { + ): ?Type\Union { if ($assertion === 'mixed' && $existing_var_type->hasMixed()) { return $existing_var_type; } @@ -466,7 +466,7 @@ private static function reconcileIsset( int &$failed_reconciliation, bool $is_equality, bool $inside_loop - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); // if key references an array offset @@ -531,7 +531,7 @@ private static function reconcileNonEmptyCountable( int &$failed_reconciliation, bool $is_equality, ?int $min_count - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); if ($existing_var_type->hasType('array')) { @@ -610,7 +610,7 @@ private static function reconcileNonEmptyCountable( private static function reconcileExactlyCountable( Union $existing_var_type, int $count - ) : Union { + ): Union { if ($existing_var_type->hasType('array')) { $array_atomic_type = $existing_var_type->getAtomicTypes()['array']; @@ -652,7 +652,7 @@ private static function reconcilePositiveNumeric( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $did_remove_type = false; @@ -731,7 +731,7 @@ private static function reconcileHasMethod( ?CodeLocation $code_location, array $suppressed_issues, int &$failed_reconciliation - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -836,7 +836,7 @@ private static function reconcileString( int &$failed_reconciliation, bool $is_equality, bool $is_strict_equality - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -930,7 +930,7 @@ private static function reconcileInt( int &$failed_reconciliation, bool $is_equality, bool $is_strict_equality - ) : Union { + ): Union { if ($existing_var_type->hasMixed()) { if ($is_equality && !$is_strict_equality) { return $existing_var_type; @@ -1027,7 +1027,7 @@ private static function reconcileBool( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { if ($existing_var_type->hasMixed()) { return Type::getBool(); } @@ -1106,7 +1106,7 @@ private static function reconcileScalar( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { if ($existing_var_type->hasMixed()) { return Type::getScalar(); } @@ -1181,7 +1181,7 @@ private static function reconcileNumeric( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { if ($existing_var_type->hasMixed()) { return Type::getNumeric(); } @@ -1273,7 +1273,7 @@ private static function reconcileObject( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { if ($existing_var_type->hasMixed()) { return Type::getObject(); } @@ -1366,7 +1366,7 @@ private static function reconcileResource( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { if ($existing_var_type->hasMixed()) { return Type::getResource(); } @@ -1424,7 +1424,7 @@ private static function reconcileCountable( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -1493,7 +1493,7 @@ private static function reconcileIterable( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -1553,7 +1553,7 @@ private static function reconcileInArray( ?CodeLocation $code_location, array $suppressed_issues, int &$failed_reconciliation - ) : Union { + ): Union { try { $new_var_type = Type::parseString($assertion); } catch (TypeParseTreeException $e) { @@ -1590,7 +1590,7 @@ private static function reconcileInArray( private static function reconcileHasArrayKey( Union $existing_var_type, string $assertion - ) : Union { + ): Union { foreach ($existing_var_type->getAtomicTypes() as $atomic_type) { if ($atomic_type instanceof Type\Atomic\TKeyedArray) { $is_class_string = false; @@ -1619,7 +1619,7 @@ private static function reconcileSuperiorTo( Union $existing_var_type, string $assertion, bool $inside_loop - ) : Union { + ): Union { $assertion_value = (int)$assertion; foreach ($existing_var_type->getAtomicTypes() as $atomic_type) { if ($inside_loop) { @@ -1669,7 +1669,7 @@ private static function reconcileInferiorTo( Union $existing_var_type, string $assertion, bool $inside_loop - ) : Union { + ): Union { $assertion_value = (int)$assertion; foreach ($existing_var_type->getAtomicTypes() as $atomic_type) { if ($inside_loop) { @@ -1725,7 +1725,7 @@ private static function reconcileTraversable( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -1795,7 +1795,7 @@ private static function reconcileArray( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -1891,7 +1891,7 @@ private static function reconcileList( int &$failed_reconciliation, bool $is_equality, bool $is_non_empty - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -1996,7 +1996,7 @@ private static function reconcileStringArrayAccess( array $suppressed_issues, int &$failed_reconciliation, bool $inside_loop - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -2061,7 +2061,7 @@ private static function reconcileIntArrayAccess( array $suppressed_issues, int &$failed_reconciliation, bool $inside_loop - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -2121,7 +2121,7 @@ private static function reconcileCallable( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Union { + ): Union { if ($existing_var_type->hasMixed()) { return Type::parseString('callable'); } @@ -2231,7 +2231,7 @@ private static function reconcileFalsyOrEmpty( array $suppressed_issues, int &$failed_reconciliation, bool $recursive_check - ) : Union { + ): Union { $old_var_type_string = $existing_var_type->getId(); $did_remove_type = $existing_var_type->possibly_undefined @@ -2408,7 +2408,7 @@ private static function reconcileClassConstant( string $class_constant_expression, Union $existing_type, int &$failed_reconciliation - ) : Union { + ): Union { if (strpos($class_constant_expression, '::') === false) { return $existing_type; } diff --git a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php index ec8f2dee521..7439299e760 100644 --- a/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/SimpleNegatedAssertionReconciler.php @@ -47,8 +47,6 @@ class SimpleNegatedAssertionReconciler extends Reconciler /** * @param string[] $suppressed_issues * @param 0|1|2 $failed_reconciliation - * - * @return Type\Union */ public static function reconcile( string $assertion, @@ -61,7 +59,7 @@ public static function reconcile( bool $is_equality = false, bool $is_strict_equality = false, bool $inside_loop = false - ) : ?Type\Union { + ): ?Type\Union { if ($assertion === 'object' && !$existing_var_type->hasMixed()) { return self::reconcileObject( $existing_var_type, @@ -266,7 +264,7 @@ public static function reconcile( private static function reconcileCallable( Type\Union $existing_var_type - ) : Type\Union { + ): Type\Union { foreach ($existing_var_type->getAtomicTypes() as $atomic_key => $type) { if ($type instanceof Type\Atomic\TLiteralString && InternalCallMapHandler::inCallMap($type->value) @@ -294,7 +292,7 @@ private static function reconcileBool( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $non_bool_types = []; $did_remove_type = false; @@ -363,7 +361,7 @@ private static function reconcileNonEmptyCountable( int &$failed_reconciliation, bool $is_equality, ?int $min_count - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $existing_var_atomic_types = $existing_var_type->getAtomicTypes(); @@ -435,7 +433,7 @@ private static function reconcileNull( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $did_remove_type = false; @@ -502,7 +500,7 @@ private static function reconcileFalse( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $did_remove_type = $existing_var_type->hasScalar(); @@ -572,7 +570,7 @@ private static function reconcileFalsyOrEmpty( bool $is_equality, bool $is_strict_equality, bool $recursive_check - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); //empty is used a lot to check for array offset existence, so we have to silent errors a lot @@ -769,7 +767,7 @@ private static function reconcileScalar( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $non_scalar_types = []; $did_remove_type = false; @@ -855,7 +853,7 @@ private static function reconcileObject( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $non_object_types = []; $did_remove_type = false; @@ -956,7 +954,7 @@ private static function reconcileNumeric( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $non_numeric_types = []; $did_remove_type = $existing_var_type->hasString() @@ -1046,7 +1044,7 @@ private static function reconcileInt( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $non_int_types = []; $did_remove_type = false; @@ -1146,7 +1144,7 @@ private static function reconcileFloat( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $non_float_types = []; $did_remove_type = false; @@ -1241,7 +1239,7 @@ private static function reconcileString( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $non_string_types = []; $did_remove_type = $existing_var_type->hasScalar(); @@ -1345,7 +1343,7 @@ private static function reconcileArray( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $non_array_types = []; $did_remove_type = $existing_var_type->hasScalar(); @@ -1446,7 +1444,7 @@ private static function reconcileResource( array $suppressed_issues, int &$failed_reconciliation, bool $is_equality - ) : Type\Union { + ): Type\Union { $old_var_type_string = $existing_var_type->getId(); $did_remove_type = false; diff --git a/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php b/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php index 396f3eca4f8..2447d7a3475 100644 --- a/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php +++ b/src/Psalm/Internal/Type/TemplateInferredTypeReplacer.php @@ -29,7 +29,7 @@ public static function replace( Union $union, TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { $keys_to_unset = []; $new_types = []; diff --git a/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php b/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php index d89460b4bef..a824079d4af 100644 --- a/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php +++ b/src/Psalm/Internal/Type/TemplateStandinTypeReplacer.php @@ -49,7 +49,7 @@ public static function replace( bool $add_lower_bound = false, ?string $bound_equality_classlike = null, int $depth = 1 - ) : Union { + ): Union { $atomic_types = []; $original_atomic_types = $union_type->getAtomicTypes(); @@ -148,7 +148,7 @@ private static function handleAtomicStandin( int $depth, bool $was_single, bool &$had_template - ) : array { + ): array { if ($bracket_pos = strpos($key, '<')) { $key = substr($key, 0, $bracket_pos); } @@ -358,7 +358,7 @@ private static function findMatchingAtomicTypesForTemplate( Codebase $codebase, ?StatementsAnalyzer $statements_analyzer, Union $input_type - ) : array { + ): array { $matching_atomic_types = []; foreach ($input_type->getAtomicTypes() as $input_key => $atomic_input_type) { @@ -525,7 +525,7 @@ private static function handleTemplateParamStandin( ?string $bound_equality_classlike, int $depth, bool &$had_template - ) : array { + ): array { if ($atomic_type->defining_class === $calling_class) { return [$atomic_type]; } @@ -880,7 +880,7 @@ public static function handleTemplateParamClassStandin( int $depth, bool $was_single, bool &$had_template - ) : array { + ): array { if ($atomic_type->defining_class === $calling_class) { return [$atomic_type]; } @@ -1017,7 +1017,7 @@ public static function getRootTemplateType( string $defining_class, array $visited_classes, ?Codebase $codebase - ) : ?Union { + ): ?Union { if (isset($visited_classes[$defining_class])) { return null; } @@ -1117,7 +1117,7 @@ public static function getMappedGenericTypeParams( Atomic $input_type_part, Atomic $container_type_part, ?array &$container_type_params_covariant = null - ) : array { + ): array { $input_type_params = $input_type_part->type_params; try { diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index 96a100d11be..e51000984b6 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -1277,7 +1277,7 @@ function ($int): bool { /** * @return array */ - private static function getSharedTypes(TypeCombination $combination, Codebase $codebase) : array + private static function getSharedTypes(TypeCombination $combination, Codebase $codebase): array { /** @var array|null */ $shared_classlikes = null; @@ -1347,7 +1347,7 @@ private static function getClassLikes(Codebase $codebase, string $fq_classlike_n private static function handleKeyedArrayEntries( TypeCombination $combination, bool $overwrite_empty_array - ) : array { + ): array { $new_types = []; if ($combination->array_type_params @@ -1442,7 +1442,7 @@ private static function getArrayTypeFromGenericParams( bool $allow_mixed_union, Atomic $type, array $generic_type_params - ) : Atomic { + ): Atomic { if ($combination->objectlike_entries) { $objectlike_generic_type = null; diff --git a/src/Psalm/Internal/Type/TypeExpander.php b/src/Psalm/Internal/Type/TypeExpander.php index 92eaae4e433..e1b31c29eed 100644 --- a/src/Psalm/Internal/Type/TypeExpander.php +++ b/src/Psalm/Internal/Type/TypeExpander.php @@ -808,7 +808,7 @@ private static function expandConditional( if ($number_of_types > 1) { $all_conditional_return_types = array_filter( $all_conditional_return_types, - static function (Atomic $atomic_type) : bool { + static function (Atomic $atomic_type): bool { return !($atomic_type instanceof TEmpty || $atomic_type instanceof TNever); } @@ -820,7 +820,7 @@ static function (Atomic $atomic_type) : bool { if ($number_of_types > 1) { $all_conditional_return_types = array_filter( $all_conditional_return_types, - static function (Atomic $atomic_type) : bool { + static function (Atomic $atomic_type): bool { return !$atomic_type instanceof Atomic\TVoid; } ); diff --git a/src/Psalm/Internal/Type/TypeParser.php b/src/Psalm/Internal/Type/TypeParser.php index d863d50faf5..5666b714f00 100644 --- a/src/Psalm/Internal/Type/TypeParser.php +++ b/src/Psalm/Internal/Type/TypeParser.php @@ -363,7 +363,7 @@ private static function getGenericParamClass( string $param_name, Union $as, string $defining_class - ) : Atomic\TTemplateParamClass { + ): Atomic\TTemplateParamClass { if ($as->hasMixed()) { return new Atomic\TTemplateParamClass( $param_name, @@ -442,7 +442,7 @@ private static function getGenericParamClass( * @param non-empty-list $potential_ints * @return non-empty-list */ - public static function getComputedIntsFromMask(array $potential_ints) : array + public static function getComputedIntsFromMask(array $potential_ints): array { /** @var list */ $potential_values = []; @@ -845,7 +845,6 @@ private static function getTypeFromGenericTree( /** * @param array> $template_type_map * @param array $type_aliases - * @return Union * @throws TypeParseTreeException */ private static function getTypeFromUnionTree( @@ -909,7 +908,6 @@ private static function getTypeFromUnionTree( /** * @param array> $template_type_map * @param array $type_aliases - * @return Atomic * @throws TypeParseTreeException */ private static function getTypeFromIntersectionTree( @@ -917,7 +915,7 @@ private static function getTypeFromIntersectionTree( Codebase $codebase, array $template_type_map, array $type_aliases - ) { + ): Atomic { $intersection_types = array_map( function (ParseTree $child_tree) use ($codebase, $template_type_map, $type_aliases) { $atomic_type = self::getTypeFromTree( @@ -1152,7 +1150,6 @@ function (ParseTree $child_tree) use ( /** * @param array> $template_type_map - * @return Atomic\TTemplateIndexedAccess * @throws TypeParseTreeException */ private static function getTypeFromIndexAccessTree( diff --git a/src/Psalm/Internal/Type/TypeTokenizer.php b/src/Psalm/Internal/Type/TypeTokenizer.php index 81839e524f9..e05082af883 100644 --- a/src/Psalm/Internal/Type/TypeTokenizer.php +++ b/src/Psalm/Internal/Type/TypeTokenizer.php @@ -307,7 +307,7 @@ public static function tokenize(string $string_type, bool $ignore_space = true): public static function fixScalarTerms( string $type_string, ?array $php_version = null - ) : string { + ): string { $type_string_lc = strtolower($type_string); switch ($type_string_lc) { @@ -503,7 +503,7 @@ public static function getFullyQualifiedTokens( return $type_tokens; } - public static function clearCache() : void + public static function clearCache(): void { self::$memoized_tokens = []; } diff --git a/src/Psalm/Internal/TypeVisitor/ContainsClassLikeVisitor.php b/src/Psalm/Internal/TypeVisitor/ContainsClassLikeVisitor.php index 96b739a7075..bde8233b5f7 100644 --- a/src/Psalm/Internal/TypeVisitor/ContainsClassLikeVisitor.php +++ b/src/Psalm/Internal/TypeVisitor/ContainsClassLikeVisitor.php @@ -29,7 +29,7 @@ public function __construct(string $fq_classlike_name) $this->fq_classlike_name = $fq_classlike_name; } - protected function enterNode(TypeNode $type) : ?int + protected function enterNode(TypeNode $type): ?int { if ($type instanceof TNamedObject) { if (strtolower($type->value) === $this->fq_classlike_name) { @@ -55,7 +55,7 @@ protected function enterNode(TypeNode $type) : ?int return null; } - public function matches() : bool + public function matches(): bool { return $this->contains_classlike; } diff --git a/src/Psalm/Internal/TypeVisitor/ContainsLiteralVisitor.php b/src/Psalm/Internal/TypeVisitor/ContainsLiteralVisitor.php index 78bd21ef173..08ecd7a5519 100644 --- a/src/Psalm/Internal/TypeVisitor/ContainsLiteralVisitor.php +++ b/src/Psalm/Internal/TypeVisitor/ContainsLiteralVisitor.php @@ -17,7 +17,7 @@ class ContainsLiteralVisitor extends NodeVisitor */ private $contains_literal = false; - protected function enterNode(TypeNode $type) : ?int + protected function enterNode(TypeNode $type): ?int { if ($type instanceof TLiteralString || $type instanceof TLiteralInt @@ -37,7 +37,7 @@ protected function enterNode(TypeNode $type) : ?int return null; } - public function matches() : bool + public function matches(): bool { return $this->contains_literal; } diff --git a/src/Psalm/Internal/TypeVisitor/FromDocblockSetter.php b/src/Psalm/Internal/TypeVisitor/FromDocblockSetter.php index 0e7570bcb32..0f42115298d 100644 --- a/src/Psalm/Internal/TypeVisitor/FromDocblockSetter.php +++ b/src/Psalm/Internal/TypeVisitor/FromDocblockSetter.php @@ -15,7 +15,7 @@ class FromDocblockSetter extends NodeVisitor * @param Atomic|Union $type * @return self::STOP_TRAVERSAL|self::DONT_TRAVERSE_CHILDREN|null */ - protected function enterNode(TypeNode $type) : ?int + protected function enterNode(TypeNode $type): ?int { $type->from_docblock = true; diff --git a/src/Psalm/Internal/TypeVisitor/TemplateTypeCollector.php b/src/Psalm/Internal/TypeVisitor/TemplateTypeCollector.php index 1db2a284233..cad45122070 100644 --- a/src/Psalm/Internal/TypeVisitor/TemplateTypeCollector.php +++ b/src/Psalm/Internal/TypeVisitor/TemplateTypeCollector.php @@ -16,7 +16,7 @@ class TemplateTypeCollector extends NodeVisitor */ private $template_types = []; - protected function enterNode(TypeNode $type) : ?int + protected function enterNode(TypeNode $type): ?int { if ($type instanceof TTemplateParam) { $this->template_types[] = $type; @@ -42,7 +42,7 @@ protected function enterNode(TypeNode $type) : ?int /** * @return list */ - public function getTemplateTypes() : array + public function getTemplateTypes(): array { return $this->template_types; } diff --git a/src/Psalm/Internal/TypeVisitor/TypeChecker.php b/src/Psalm/Internal/TypeVisitor/TypeChecker.php index 2575d6f5b31..81a7f38b096 100644 --- a/src/Psalm/Internal/TypeVisitor/TypeChecker.php +++ b/src/Psalm/Internal/TypeVisitor/TypeChecker.php @@ -109,7 +109,7 @@ public function __construct( * @param Atomic|Union $type * @return self::STOP_TRAVERSAL|self::DONT_TRAVERSE_CHILDREN|null */ - protected function enterNode(TypeNode $type) : ?int + protected function enterNode(TypeNode $type): ?int { if ($type->checked) { return NodeVisitor::DONT_TRAVERSE_CHILDREN; @@ -140,12 +140,12 @@ protected function enterNode(TypeNode $type) : ?int return null; } - public function hasErrors() : bool + public function hasErrors(): bool { return $this->has_errors; } - private function checkNamedObject(TNamedObject $atomic) : void + private function checkNamedObject(TNamedObject $atomic): void { $codebase = $this->source->getCodebase(); @@ -212,7 +212,7 @@ private function checkNamedObject(TNamedObject $atomic) : void } } - private function checkGenericParams(TGenericObject $atomic) : void + private function checkGenericParams(TGenericObject $atomic): void { $codebase = $this->source->getCodebase(); @@ -293,7 +293,7 @@ private function checkGenericParams(TGenericObject $atomic) : void } } - public function checkScalarClassConstant(TClassConstant $atomic) : void + public function checkScalarClassConstant(TClassConstant $atomic): void { $fq_classlike_name = $atomic->fq_classlike_name === 'self' ? $this->source->getClassName() @@ -352,7 +352,7 @@ public function checkScalarClassConstant(TClassConstant $atomic) : void } } - public function checkTemplateParam(TTemplateParam $atomic) : void + public function checkTemplateParam(TTemplateParam $atomic): void { if ($this->prevent_template_covariance && strpos($atomic->defining_class, 'fn-') !== 0 @@ -392,7 +392,7 @@ public function checkTemplateParam(TTemplateParam $atomic) : void } } - public function checkResource(TResource $atomic) : void + public function checkResource(TResource $atomic): void { if (!$atomic->from_docblock) { IssueBuffer::maybeAdd( diff --git a/src/Psalm/Internal/TypeVisitor/TypeScanner.php b/src/Psalm/Internal/TypeVisitor/TypeScanner.php index 985bfdebdc6..e5e0e3aae3a 100644 --- a/src/Psalm/Internal/TypeVisitor/TypeScanner.php +++ b/src/Psalm/Internal/TypeVisitor/TypeScanner.php @@ -32,7 +32,7 @@ public function __construct( $this->phantom_classes = $phantom_classes; } - protected function enterNode(TypeNode $type) : ?int + protected function enterNode(TypeNode $type): ?int { if ($type instanceof TNamedObject) { $fq_classlike_name_lc = strtolower($type->value); diff --git a/src/Psalm/Issue/MixedIssue.php b/src/Psalm/Issue/MixedIssue.php index ded7a3d8fd9..fccd646d136 100644 --- a/src/Psalm/Issue/MixedIssue.php +++ b/src/Psalm/Issue/MixedIssue.php @@ -5,7 +5,7 @@ interface MixedIssue { - public function getMixedOriginMessage() : string; + public function getMixedOriginMessage(): string; - public function getOriginalLocation() : ?CodeLocation; + public function getOriginalLocation(): ?CodeLocation; } diff --git a/src/Psalm/Issue/MixedIssueTrait.php b/src/Psalm/Issue/MixedIssueTrait.php index b2070de361e..d1b54792196 100644 --- a/src/Psalm/Issue/MixedIssueTrait.php +++ b/src/Psalm/Issue/MixedIssueTrait.php @@ -21,7 +21,7 @@ public function __construct( $this->origin_location = $origin_location; } - public function getMixedOriginMessage() : string + public function getMixedOriginMessage(): string { return $this->message . ($this->origin_location @@ -29,7 +29,7 @@ public function getMixedOriginMessage() : string : ''); } - public function getOriginalLocation() : ?CodeLocation + public function getOriginalLocation(): ?CodeLocation { return $this->origin_location; } diff --git a/src/Psalm/Issue/TaintedInput.php b/src/Psalm/Issue/TaintedInput.php index 12f592db984..88147dd0cfa 100644 --- a/src/Psalm/Issue/TaintedInput.php +++ b/src/Psalm/Issue/TaintedInput.php @@ -57,7 +57,7 @@ public function getTaintTrace(): array public static function nodeToDataFlowNodeData( CodeLocation $location, string $label - ) : DataFlowNodeData { + ): DataFlowNodeData { $selection_bounds = $location->getSelectionBounds(); $snippet_bounds = $location->getSnippetBounds(); @@ -76,7 +76,7 @@ public static function nodeToDataFlowNodeData( ); } - public function getJourneyMessage() : string + public function getJourneyMessage(): string { return $this->message . ' in path: ' . $this->journey_text; } diff --git a/src/Psalm/IssueBuffer.php b/src/Psalm/IssueBuffer.php index 4a720f7e026..9d3837e32da 100644 --- a/src/Psalm/IssueBuffer.php +++ b/src/Psalm/IssueBuffer.php @@ -149,7 +149,7 @@ public static function maybeAdd(CodeIssue $e, array $suppressed_issues = [], boo /** * This is part of the findUnusedPsalmSuppress feature */ - public static function addUnusedSuppression(string $file_path, int $offset, string $issue_type) : void + public static function addUnusedSuppression(string $file_path, int $offset, string $issue_type): void { if (strpos($issue_type, 'Tainted') === 0) { return; @@ -173,7 +173,7 @@ public static function addUnusedSuppression(string $file_path, int $offset, stri * - The issue is included in the list of issues to be suppressed in param * @param string[] $suppressed_issues */ - public static function isSuppressed(CodeIssue $e, array $suppressed_issues = []) : bool + public static function isSuppressed(CodeIssue $e, array $suppressed_issues = []): bool { $config = Config::getInstance(); @@ -329,7 +329,7 @@ public static function add(CodeIssue $e, bool $is_fixable = false): bool /** * This will try to remove an issue that has been added for emission */ - public static function remove(string $file_path, string $issue_type, int $file_offset) : void + public static function remove(string $file_path, string $issue_type, int $file_offset): void { if (!isset(self::$issues_data[$file_path])) { return; @@ -350,7 +350,7 @@ public static function remove(string $file_path, string $issue_type, int $file_o } } - public static function addFixableIssue(string $issue_type) : void + public static function addFixableIssue(string $issue_type): void { if (isset(self::$fixable_issue_counts[$issue_type])) { self::$fixable_issue_counts[$issue_type]++; @@ -386,7 +386,7 @@ public static function getFixableIssues(): array /** * @param array $fixable_issue_counts */ - public static function addFixableIssues(array $fixable_issue_counts) : void + public static function addFixableIssues(array $fixable_issue_counts): void { foreach ($fixable_issue_counts as $issue_type => $count) { if (isset(self::$fixable_issue_counts[$issue_type])) { @@ -400,7 +400,7 @@ public static function addFixableIssues(array $fixable_issue_counts) : void /** * @return array> */ - public static function getUnusedSuppressions() : array + public static function getUnusedSuppressions(): array { return self::$unused_suppressions; } @@ -408,7 +408,7 @@ public static function getUnusedSuppressions() : array /** * @return array> */ - public static function getUsedSuppressions() : array + public static function getUsedSuppressions(): array { return self::$used_suppressions; } @@ -416,7 +416,7 @@ public static function getUsedSuppressions() : array /** * @param array> $unused_suppressions */ - public static function addUnusedSuppressions(array $unused_suppressions) : void + public static function addUnusedSuppressions(array $unused_suppressions): void { self::$unused_suppressions += $unused_suppressions; } @@ -424,7 +424,7 @@ public static function addUnusedSuppressions(array $unused_suppressions) : void /** * @param array> $used_suppressions */ - public static function addUsedSuppressions(array $used_suppressions) : void + public static function addUsedSuppressions(array $used_suppressions): void { foreach ($used_suppressions as $file => $offsets) { if (!isset(self::$used_suppressions[$file])) { @@ -435,7 +435,7 @@ public static function addUsedSuppressions(array $used_suppressions) : void } } - public static function processUnusedSuppressions(FileProvider $file_provider) : void + public static function processUnusedSuppressions(FileProvider $file_provider): void { $config = Config::getInstance(); @@ -539,7 +539,7 @@ public static function finish( foreach (self::$issues_data as $file_path => $file_issues) { usort( $file_issues, - function (IssueData $d1, IssueData $d2) : int { + function (IssueData $d1, IssueData $d2): int { if ($d1->file_path === $d2->file_path) { if ($d1->line_from === $d2->line_from) { if ($d1->column_from === $d2->column_from) { diff --git a/src/Psalm/NodeTypeProvider.php b/src/Psalm/NodeTypeProvider.php index d89802f9699..afd0e15dca6 100644 --- a/src/Psalm/NodeTypeProvider.php +++ b/src/Psalm/NodeTypeProvider.php @@ -10,10 +10,10 @@ interface NodeTypeProvider /** * @param PhpParser\Node\Expr|PhpParser\Node\Name|PhpParser\Node\Stmt\Return_ $node */ - public function setType(PhpParser\NodeAbstract $node, Union $type) : void; + public function setType(PhpParser\NodeAbstract $node, Union $type): void; /** * @param PhpParser\Node\Expr|PhpParser\Node\Name|PhpParser\Node\Stmt\Return_ $node */ - public function getType(PhpParser\NodeAbstract $node) : ?Union; + public function getType(PhpParser\NodeAbstract $node): ?Union; } diff --git a/src/Psalm/Plugin/EventHandler/AfterClassLikeAnalysisInterface.php b/src/Psalm/Plugin/EventHandler/AfterClassLikeAnalysisInterface.php index 912dc29fdf8..100c12be1f5 100644 --- a/src/Psalm/Plugin/EventHandler/AfterClassLikeAnalysisInterface.php +++ b/src/Psalm/Plugin/EventHandler/AfterClassLikeAnalysisInterface.php @@ -9,6 +9,7 @@ interface AfterClassLikeAnalysisInterface * Called after a statement has been checked * * @return null|false + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint */ public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event); } diff --git a/src/Psalm/Plugin/EventHandler/AfterClassLikeVisitInterface.php b/src/Psalm/Plugin/EventHandler/AfterClassLikeVisitInterface.php index 99b110ec526..8bc2f778650 100644 --- a/src/Psalm/Plugin/EventHandler/AfterClassLikeVisitInterface.php +++ b/src/Psalm/Plugin/EventHandler/AfterClassLikeVisitInterface.php @@ -7,6 +7,7 @@ interface AfterClassLikeVisitInterface { /** * @return void + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint */ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event); } diff --git a/src/Psalm/Plugin/EventHandler/AfterCodebasePopulatedInterface.php b/src/Psalm/Plugin/EventHandler/AfterCodebasePopulatedInterface.php index 21977bf40c6..26cfaf40dc8 100644 --- a/src/Psalm/Plugin/EventHandler/AfterCodebasePopulatedInterface.php +++ b/src/Psalm/Plugin/EventHandler/AfterCodebasePopulatedInterface.php @@ -9,6 +9,7 @@ interface AfterCodebasePopulatedInterface * Called after codebase has been populated * * @return void + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint */ public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event); } diff --git a/src/Psalm/Plugin/EventHandler/FunctionExistenceProviderInterface.php b/src/Psalm/Plugin/EventHandler/FunctionExistenceProviderInterface.php index 332797a52b1..2c9536be70a 100644 --- a/src/Psalm/Plugin/EventHandler/FunctionExistenceProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/FunctionExistenceProviderInterface.php @@ -8,7 +8,7 @@ interface FunctionExistenceProviderInterface /** * @return array */ - public static function getFunctionIds() : array; + public static function getFunctionIds(): array; /** * Use this hook for informing whether or not a global function exists. If you know the function does diff --git a/src/Psalm/Plugin/EventHandler/FunctionParamsProviderInterface.php b/src/Psalm/Plugin/EventHandler/FunctionParamsProviderInterface.php index 1b1bc978755..3f3cb75a399 100644 --- a/src/Psalm/Plugin/EventHandler/FunctionParamsProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/FunctionParamsProviderInterface.php @@ -9,7 +9,7 @@ interface FunctionParamsProviderInterface /** * @return array */ - public static function getFunctionIds() : array; + public static function getFunctionIds(): array; /** * @return ?array diff --git a/src/Psalm/Plugin/EventHandler/FunctionReturnTypeProviderInterface.php b/src/Psalm/Plugin/EventHandler/FunctionReturnTypeProviderInterface.php index 45e47669cb8..76469c1eb44 100644 --- a/src/Psalm/Plugin/EventHandler/FunctionReturnTypeProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/FunctionReturnTypeProviderInterface.php @@ -9,7 +9,7 @@ interface FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array; + public static function getFunctionIds(): array; /** * Use this hook for providing custom return type logic. If this plugin does not know what a function should diff --git a/src/Psalm/Plugin/EventHandler/MethodExistenceProviderInterface.php b/src/Psalm/Plugin/EventHandler/MethodExistenceProviderInterface.php index 49abe814386..bb993b5da1d 100644 --- a/src/Psalm/Plugin/EventHandler/MethodExistenceProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/MethodExistenceProviderInterface.php @@ -8,7 +8,7 @@ interface MethodExistenceProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; /** * Use this hook for informing whether or not a method exists on a given object. If you know the method does diff --git a/src/Psalm/Plugin/EventHandler/MethodParamsProviderInterface.php b/src/Psalm/Plugin/EventHandler/MethodParamsProviderInterface.php index c0a86bec28b..6cc943384a2 100644 --- a/src/Psalm/Plugin/EventHandler/MethodParamsProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/MethodParamsProviderInterface.php @@ -9,7 +9,7 @@ interface MethodParamsProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; /** * @return ?array diff --git a/src/Psalm/Plugin/EventHandler/MethodReturnTypeProviderInterface.php b/src/Psalm/Plugin/EventHandler/MethodReturnTypeProviderInterface.php index 87a6210ae46..96eec10177f 100644 --- a/src/Psalm/Plugin/EventHandler/MethodReturnTypeProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/MethodReturnTypeProviderInterface.php @@ -9,7 +9,7 @@ interface MethodReturnTypeProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; /** * Use this hook for providing custom return type logic. If this plugin does not know what a method should return diff --git a/src/Psalm/Plugin/EventHandler/MethodVisibilityProviderInterface.php b/src/Psalm/Plugin/EventHandler/MethodVisibilityProviderInterface.php index 0aa483a96a4..8299eb0eec3 100644 --- a/src/Psalm/Plugin/EventHandler/MethodVisibilityProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/MethodVisibilityProviderInterface.php @@ -8,7 +8,7 @@ interface MethodVisibilityProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; public static function isMethodVisible(MethodVisibilityProviderEvent $event): ?bool; } diff --git a/src/Psalm/Plugin/EventHandler/PropertyExistenceProviderInterface.php b/src/Psalm/Plugin/EventHandler/PropertyExistenceProviderInterface.php index 5ee80e8e130..d19dd1e03d6 100644 --- a/src/Psalm/Plugin/EventHandler/PropertyExistenceProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/PropertyExistenceProviderInterface.php @@ -8,7 +8,7 @@ interface PropertyExistenceProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; /** * Use this hook for informing whether or not a property exists on a given object. If you know the property does diff --git a/src/Psalm/Plugin/EventHandler/PropertyTypeProviderInterface.php b/src/Psalm/Plugin/EventHandler/PropertyTypeProviderInterface.php index 114a1bbd168..badff8176e3 100644 --- a/src/Psalm/Plugin/EventHandler/PropertyTypeProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/PropertyTypeProviderInterface.php @@ -9,7 +9,7 @@ interface PropertyTypeProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; public static function getPropertyType(PropertyTypeProviderEvent $event): ?Type\Union; } diff --git a/src/Psalm/Plugin/EventHandler/PropertyVisibilityProviderInterface.php b/src/Psalm/Plugin/EventHandler/PropertyVisibilityProviderInterface.php index 69afa20f677..e273e945ab6 100644 --- a/src/Psalm/Plugin/EventHandler/PropertyVisibilityProviderInterface.php +++ b/src/Psalm/Plugin/EventHandler/PropertyVisibilityProviderInterface.php @@ -8,7 +8,7 @@ interface PropertyVisibilityProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; public static function isPropertyVisible(PropertyVisibilityProviderEvent $event): ?bool; } diff --git a/src/Psalm/Plugin/Hook/AfterClassLikeAnalysisInterface.php b/src/Psalm/Plugin/Hook/AfterClassLikeAnalysisInterface.php index 36cff635eec..093089d5e17 100644 --- a/src/Psalm/Plugin/Hook/AfterClassLikeAnalysisInterface.php +++ b/src/Psalm/Plugin/Hook/AfterClassLikeAnalysisInterface.php @@ -16,6 +16,7 @@ interface AfterClassLikeAnalysisInterface * @param FileManipulation[] $file_replacements * * @return null|false + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint */ public static function afterStatementAnalysis( Node\Stmt\ClassLike $stmt, diff --git a/src/Psalm/Plugin/Hook/AfterClassLikeVisitInterface.php b/src/Psalm/Plugin/Hook/AfterClassLikeVisitInterface.php index aaeb3265b5d..84f0406e751 100644 --- a/src/Psalm/Plugin/Hook/AfterClassLikeVisitInterface.php +++ b/src/Psalm/Plugin/Hook/AfterClassLikeVisitInterface.php @@ -14,6 +14,7 @@ interface AfterClassLikeVisitInterface * @param FileManipulation[] $file_replacements * * @return void + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint */ public static function afterClassLikeVisit( ClassLike $stmt, diff --git a/src/Psalm/Plugin/Hook/AfterCodebasePopulatedInterface.php b/src/Psalm/Plugin/Hook/AfterCodebasePopulatedInterface.php index e43e74b24d5..b8b93e60b57 100644 --- a/src/Psalm/Plugin/Hook/AfterCodebasePopulatedInterface.php +++ b/src/Psalm/Plugin/Hook/AfterCodebasePopulatedInterface.php @@ -10,6 +10,7 @@ interface AfterCodebasePopulatedInterface * Called after codebase has been populated * * @return void + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint */ public static function afterCodebasePopulated(Codebase $codebase); } diff --git a/src/Psalm/Plugin/Hook/FunctionExistenceProviderInterface.php b/src/Psalm/Plugin/Hook/FunctionExistenceProviderInterface.php index 2ab339a507d..fffccfaa7cd 100644 --- a/src/Psalm/Plugin/Hook/FunctionExistenceProviderInterface.php +++ b/src/Psalm/Plugin/Hook/FunctionExistenceProviderInterface.php @@ -9,7 +9,7 @@ interface FunctionExistenceProviderInterface /** * @return array */ - public static function getFunctionIds() : array; + public static function getFunctionIds(): array; /** * Use this hook for informing whether or not a global function exists. If you know the function does diff --git a/src/Psalm/Plugin/Hook/FunctionParamsProviderInterface.php b/src/Psalm/Plugin/Hook/FunctionParamsProviderInterface.php index ee017e29199..5ef3c5d46f9 100644 --- a/src/Psalm/Plugin/Hook/FunctionParamsProviderInterface.php +++ b/src/Psalm/Plugin/Hook/FunctionParamsProviderInterface.php @@ -13,7 +13,7 @@ interface FunctionParamsProviderInterface /** * @return array */ - public static function getFunctionIds() : array; + public static function getFunctionIds(): array; /** * @param list $call_args diff --git a/src/Psalm/Plugin/Hook/FunctionReturnTypeProviderInterface.php b/src/Psalm/Plugin/Hook/FunctionReturnTypeProviderInterface.php index a98b18a97b7..3461e67cae7 100644 --- a/src/Psalm/Plugin/Hook/FunctionReturnTypeProviderInterface.php +++ b/src/Psalm/Plugin/Hook/FunctionReturnTypeProviderInterface.php @@ -13,7 +13,7 @@ interface FunctionReturnTypeProviderInterface /** * @return array */ - public static function getFunctionIds() : array; + public static function getFunctionIds(): array; /** * Use this hook for providing custom return type logic. If this plugin does not know what a function should diff --git a/src/Psalm/Plugin/Hook/MethodExistenceProviderInterface.php b/src/Psalm/Plugin/Hook/MethodExistenceProviderInterface.php index 9ba0bcda223..7e588bc9a65 100644 --- a/src/Psalm/Plugin/Hook/MethodExistenceProviderInterface.php +++ b/src/Psalm/Plugin/Hook/MethodExistenceProviderInterface.php @@ -10,7 +10,7 @@ interface MethodExistenceProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; /** * Use this hook for informing whether or not a method exists on a given object. If you know the method does diff --git a/src/Psalm/Plugin/Hook/MethodParamsProviderInterface.php b/src/Psalm/Plugin/Hook/MethodParamsProviderInterface.php index 86c3f4f182d..594624080c1 100644 --- a/src/Psalm/Plugin/Hook/MethodParamsProviderInterface.php +++ b/src/Psalm/Plugin/Hook/MethodParamsProviderInterface.php @@ -13,7 +13,7 @@ interface MethodParamsProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; /** * @param list $call_args diff --git a/src/Psalm/Plugin/Hook/MethodReturnTypeProviderInterface.php b/src/Psalm/Plugin/Hook/MethodReturnTypeProviderInterface.php index 940759ff10d..d1867edc851 100644 --- a/src/Psalm/Plugin/Hook/MethodReturnTypeProviderInterface.php +++ b/src/Psalm/Plugin/Hook/MethodReturnTypeProviderInterface.php @@ -13,7 +13,7 @@ interface MethodReturnTypeProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; /** * Use this hook for providing custom return type logic. If this plugin does not know what a method should return diff --git a/src/Psalm/Plugin/Hook/MethodVisibilityProviderInterface.php b/src/Psalm/Plugin/Hook/MethodVisibilityProviderInterface.php index d747d94b16e..9715ff6df47 100644 --- a/src/Psalm/Plugin/Hook/MethodVisibilityProviderInterface.php +++ b/src/Psalm/Plugin/Hook/MethodVisibilityProviderInterface.php @@ -11,7 +11,7 @@ interface MethodVisibilityProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; public static function isMethodVisible( StatementsSource $source, diff --git a/src/Psalm/Plugin/Hook/PropertyExistenceProviderInterface.php b/src/Psalm/Plugin/Hook/PropertyExistenceProviderInterface.php index d4d35135224..88a2723ff7c 100644 --- a/src/Psalm/Plugin/Hook/PropertyExistenceProviderInterface.php +++ b/src/Psalm/Plugin/Hook/PropertyExistenceProviderInterface.php @@ -11,7 +11,7 @@ interface PropertyExistenceProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; /** * Use this hook for informing whether or not a property exists on a given object. If you know the property does diff --git a/src/Psalm/Plugin/Hook/PropertyTypeProviderInterface.php b/src/Psalm/Plugin/Hook/PropertyTypeProviderInterface.php index ca4cdd94801..9cb4c3f6b90 100644 --- a/src/Psalm/Plugin/Hook/PropertyTypeProviderInterface.php +++ b/src/Psalm/Plugin/Hook/PropertyTypeProviderInterface.php @@ -11,7 +11,7 @@ interface PropertyTypeProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; public static function getPropertyType( string $fq_classlike_name, diff --git a/src/Psalm/Plugin/Hook/PropertyVisibilityProviderInterface.php b/src/Psalm/Plugin/Hook/PropertyVisibilityProviderInterface.php index 49ceff939c9..db7c44dc133 100644 --- a/src/Psalm/Plugin/Hook/PropertyVisibilityProviderInterface.php +++ b/src/Psalm/Plugin/Hook/PropertyVisibilityProviderInterface.php @@ -11,7 +11,7 @@ interface PropertyVisibilityProviderInterface /** * @return array */ - public static function getClassLikeNames() : array; + public static function getClassLikeNames(): array; public static function isPropertyVisible( StatementsSource $source, diff --git a/src/Psalm/Plugin/Hook/StringInterpreterInterface.php b/src/Psalm/Plugin/Hook/StringInterpreterInterface.php index ad39bee3887..03f2d3b9f31 100644 --- a/src/Psalm/Plugin/Hook/StringInterpreterInterface.php +++ b/src/Psalm/Plugin/Hook/StringInterpreterInterface.php @@ -11,5 +11,5 @@ interface StringInterpreterInterface */ public static function getTypeFromValue( string $value - ) : ?Type\Atomic\TLiteralString; + ): ?Type\Atomic\TLiteralString; } diff --git a/src/Psalm/Plugin/Shepherd.php b/src/Psalm/Plugin/Shepherd.php index 9af1ac6c746..75d42d04fd8 100644 --- a/src/Psalm/Plugin/Shepherd.php +++ b/src/Psalm/Plugin/Shepherd.php @@ -62,7 +62,7 @@ public static function afterAnalysis( if ($build_info) { $normalized_data = $issues === [] ? [] : array_filter( array_merge(...array_values($issues)), - static function (IssueData $i) : bool { + static function (IssueData $i): bool { return $i->severity === 'error'; } ); @@ -133,7 +133,7 @@ static function (IssueData $i) : bool { * * @psalm-pure */ - public static function getCurlErrorMessage($ch) : string + public static function getCurlErrorMessage($ch): string { /** * @psalm-suppress MixedArgument diff --git a/src/Psalm/Progress/DebugProgress.php b/src/Psalm/Progress/DebugProgress.php index 64a30ffa6bd..fb691c3216f 100644 --- a/src/Psalm/Progress/DebugProgress.php +++ b/src/Psalm/Progress/DebugProgress.php @@ -32,7 +32,7 @@ public function startAlteringFiles(): void $this->write('Updating files...' . "\n"); } - public function alterFileDone(string $file_name) : void + public function alterFileDone(string $file_name): void { $this->write('Altered ' . $file_name . "\n"); } diff --git a/src/Psalm/Progress/DefaultProgress.php b/src/Psalm/Progress/DefaultProgress.php index 07d8136a29b..49587828101 100644 --- a/src/Psalm/Progress/DefaultProgress.php +++ b/src/Psalm/Progress/DefaultProgress.php @@ -57,7 +57,7 @@ public function taskDone(int $level): void * * @see https://en.wikipedia.org/wiki/Block_Elements */ - private static function renderInnerProgressBar(int $length, float $p) : string + private static function renderInnerProgressBar(int $length, float $p): string { $current_float = $p * $length; $current = (int)$current_float; diff --git a/src/Psalm/Progress/LongProgress.php b/src/Psalm/Progress/LongProgress.php index 570b186b604..b6e95c7e590 100644 --- a/src/Psalm/Progress/LongProgress.php +++ b/src/Psalm/Progress/LongProgress.php @@ -47,7 +47,7 @@ public function startAlteringFiles(): void $this->write('Altering files...' . "\n"); } - public function alterFileDone(string $file_name) : void + public function alterFileDone(string $file_name): void { $this->write('Altered ' . $file_name . "\n"); } @@ -83,7 +83,7 @@ public function finish(): void $this->write(PHP_EOL); } - protected function getOverview() : string + protected function getOverview(): string { if ($this->number_of_tasks === null) { throw new LogicException('Progress::start() should be called before Progress::startDone()'); diff --git a/src/Psalm/Progress/Progress.php b/src/Psalm/Progress/Progress.php index d45027ea033..51cc17853e4 100644 --- a/src/Psalm/Progress/Progress.php +++ b/src/Psalm/Progress/Progress.php @@ -55,7 +55,7 @@ public function write(string $message): void fwrite(STDERR, $message); } - protected static function doesTerminalSupportUtf8() : bool + protected static function doesTerminalSupportUtf8(): bool { if (stripos(PHP_OS, 'WIN') === 0) { if (!function_exists('sapi_windows_cp_is_utf8') || !sapi_windows_cp_is_utf8()) { diff --git a/src/Psalm/Report.php b/src/Psalm/Report.php index fba9e5a361a..bf3c53b22b1 100644 --- a/src/Psalm/Report.php +++ b/src/Psalm/Report.php @@ -89,7 +89,7 @@ public function __construct( if (!$report_options->show_info) { $this->issues_data = array_filter( $issues_data, - function ($issue_data) : bool { + function ($issue_data): bool { return $issue_data->severity !== Config::REPORT_INFO; } ); diff --git a/src/Psalm/Report/CodeClimateReport.php b/src/Psalm/Report/CodeClimateReport.php index 822bafb08de..cdd1458b720 100644 --- a/src/Psalm/Report/CodeClimateReport.php +++ b/src/Psalm/Report/CodeClimateReport.php @@ -68,7 +68,6 @@ function (IssueData $issue): array { /** * convert our own severity to CodeClimate format * Values can be : info, minor, major, critical, or blocker - * @return string */ protected function convertSeverity(string $input): string { diff --git a/src/Psalm/Report/ConsoleReport.php b/src/Psalm/Report/ConsoleReport.php index 0fec3284e42..cfc3d8c5980 100644 --- a/src/Psalm/Report/ConsoleReport.php +++ b/src/Psalm/Report/ConsoleReport.php @@ -78,7 +78,7 @@ private function format(IssueData $issue_data): string /** * @param non-empty-list $taint_trace */ - private function getTaintSnippets(array $taint_trace) : string + private function getTaintSnippets(array $taint_trace): string { $snippets = ''; diff --git a/src/Psalm/Report/PhpStormReport.php b/src/Psalm/Report/PhpStormReport.php index 761531a7f6a..b35d617fa9f 100644 --- a/src/Psalm/Report/PhpStormReport.php +++ b/src/Psalm/Report/PhpStormReport.php @@ -62,7 +62,7 @@ private function format(IssueData $issue_data): string /** * @param non-empty-list $taint_trace */ - private function getTaintSnippets(array $taint_trace) : string + private function getTaintSnippets(array $taint_trace): string { $snippets = ''; diff --git a/src/Psalm/SourceControl/Git/CommitInfo.php b/src/Psalm/SourceControl/Git/CommitInfo.php index e6597f4cea7..caccd07c37d 100644 --- a/src/Psalm/SourceControl/Git/CommitInfo.php +++ b/src/Psalm/SourceControl/Git/CommitInfo.php @@ -57,7 +57,7 @@ class CommitInfo */ protected $date; - public function toArray() : array + public function toArray(): array { return [ 'id' => $this->id, @@ -75,7 +75,7 @@ public function toArray() : array /** * Set commit ID. */ - public function setId(string $id) : self + public function setId(string $id): self { $this->id = $id; @@ -94,7 +94,7 @@ public function getId(): ?string /** * Set author name. */ - public function setAuthorName(string $author_name) : self + public function setAuthorName(string $author_name): self { $this->author_name = $author_name; @@ -114,7 +114,7 @@ public function getAuthorName(): ?string * Set author email. * */ - public function setAuthorEmail(string $author_email) : self + public function setAuthorEmail(string $author_email): self { $this->author_email = $author_email; @@ -133,7 +133,7 @@ public function getAuthorEmail(): ?string /** * Set committer name. */ - public function setCommitterName(string $committer_name) : self + public function setCommitterName(string $committer_name): self { $this->committer_name = $committer_name; @@ -152,7 +152,7 @@ public function getCommitterName(): ?string /** * Set committer email. */ - public function setCommitterEmail(string $committer_email) : self + public function setCommitterEmail(string $committer_email): self { $this->committer_email = $committer_email; @@ -171,7 +171,7 @@ public function getCommitterEmail(): ?string /** * Set commit message. */ - public function setMessage(string $message) : self + public function setMessage(string $message): self { $this->message = $message; @@ -190,7 +190,7 @@ public function getMessage(): ?string /** * Set commit date */ - public function setDate(int $date) : self + public function setDate(int $date): self { $this->date = $date; diff --git a/src/Psalm/SourceControl/Git/GitInfo.php b/src/Psalm/SourceControl/Git/GitInfo.php index 6dd2566cf8c..982aa708aad 100644 --- a/src/Psalm/SourceControl/Git/GitInfo.php +++ b/src/Psalm/SourceControl/Git/GitInfo.php @@ -63,7 +63,7 @@ public function __construct(string $branch, CommitInfo $head, array $remotes) $this->remotes = $remotes; } - public function toArray() : array + public function toArray(): array { $remotes = []; @@ -84,7 +84,7 @@ public function toArray() : array * Return branch name. * */ - public function getBranch() : string + public function getBranch(): string { return $this->branch; } @@ -93,7 +93,7 @@ public function getBranch() : string * Return HEAD commit. * */ - public function getHead() : CommitInfo + public function getHead(): CommitInfo { return $this->head; } @@ -103,7 +103,7 @@ public function getHead() : CommitInfo * * @return RemoteInfo[] */ - public function getRemotes() : array + public function getRemotes(): array { return $this->remotes; } diff --git a/src/Psalm/SourceControl/Git/RemoteInfo.php b/src/Psalm/SourceControl/Git/RemoteInfo.php index 2b5ae9c4f6a..f504b30bd44 100644 --- a/src/Psalm/SourceControl/Git/RemoteInfo.php +++ b/src/Psalm/SourceControl/Git/RemoteInfo.php @@ -22,7 +22,7 @@ class RemoteInfo */ protected $url; - public function toArray() : array + public function toArray(): array { return [ 'name' => $this->name, diff --git a/src/Psalm/SourceControl/SourceControlInfo.php b/src/Psalm/SourceControl/SourceControlInfo.php index ed60dc87d47..d9f58ea372e 100644 --- a/src/Psalm/SourceControl/SourceControlInfo.php +++ b/src/Psalm/SourceControl/SourceControlInfo.php @@ -3,5 +3,5 @@ abstract class SourceControlInfo { - abstract public function toArray() : array; + abstract public function toArray(): array; } diff --git a/src/Psalm/StatementsSource.php b/src/Psalm/StatementsSource.php index c83ebe9fafb..7bfc967e1a1 100644 --- a/src/Psalm/StatementsSource.php +++ b/src/Psalm/StatementsSource.php @@ -38,7 +38,7 @@ public function isStatic(): bool; public function getSource(): StatementsSource; - public function getCodebase() : Codebase; + public function getCodebase(): Codebase; /** * Get a list of suppressed issues @@ -57,5 +57,5 @@ public function addSuppressedIssues(array $new_issues): void; */ public function removeSuppressedIssues(array $new_issues): void; - public function getNodeTypeProvider() : NodeTypeProvider; + public function getNodeTypeProvider(): NodeTypeProvider; } diff --git a/src/Psalm/Storage/Assertion.php b/src/Psalm/Storage/Assertion.php index fba345cf60f..c01cda7ca1e 100644 --- a/src/Psalm/Storage/Assertion.php +++ b/src/Psalm/Storage/Assertion.php @@ -43,7 +43,7 @@ public function getUntemplatedCopy( array $inferred_lower_bounds, ?string $this_var_id, ?Codebase $codebase - ) : self { + ): self { return new Assertion( is_string($this->var_id) && $this_var_id ? str_replace('$this->', $this_var_id . '->', $this->var_id) @@ -54,7 +54,7 @@ public function getUntemplatedCopy( * * @return array{0: string} */ - function (array $rules) use ($inferred_lower_bounds, $codebase) : array { + function (array $rules) use ($inferred_lower_bounds, $codebase): array { $first_rule = $rules[0]; if ($inferred_lower_bounds) { diff --git a/src/Psalm/Storage/FunctionLikeParameter.php b/src/Psalm/Storage/FunctionLikeParameter.php index f187cf4b29d..8b27a646adb 100644 --- a/src/Psalm/Storage/FunctionLikeParameter.php +++ b/src/Psalm/Storage/FunctionLikeParameter.php @@ -136,7 +136,7 @@ public function __construct( $this->default_type = $default_type; } - public function getId() : string + public function getId(): string { return ($this->type ? $this->type->getId() : 'mixed') . ($this->is_variadic ? '...' : '') diff --git a/src/Psalm/Storage/FunctionLikeStorage.php b/src/Psalm/Storage/FunctionLikeStorage.php index 293f60b2920..4fab9a7b6b7 100644 --- a/src/Psalm/Storage/FunctionLikeStorage.php +++ b/src/Psalm/Storage/FunctionLikeStorage.php @@ -250,7 +250,7 @@ public function getSignature(bool $allow_newlines): string $symbol_text = 'function ' . $this->cased_name . '(' . ($newlines ? "\n" : '') . implode( ',' . ($newlines ? "\n" : ' '), array_map( - function (FunctionLikeParameter $param) use ($newlines) : string { + function (FunctionLikeParameter $param) use ($newlines): string { return ($newlines ? ' ' : '') . ($param->type ?: 'mixed') . ' $' . $param->name; }, $this->params diff --git a/src/Psalm/Storage/PropertyStorage.php b/src/Psalm/Storage/PropertyStorage.php index 9fdd06fb4e4..b6208f2d2bf 100644 --- a/src/Psalm/Storage/PropertyStorage.php +++ b/src/Psalm/Storage/PropertyStorage.php @@ -106,7 +106,7 @@ class PropertyStorage */ public $description; - public function getInfo() : string + public function getInfo(): string { switch ($this->visibility) { case ClassLikeAnalyzer::VISIBILITY_PRIVATE: diff --git a/src/Psalm/Type.php b/src/Psalm/Type.php index f512e536b28..aaa3667d014 100644 --- a/src/Psalm/Type.php +++ b/src/Psalm/Type.php @@ -86,7 +86,7 @@ public static function parseString( public static function getFQCLNFromString( string $class, Aliases $aliases - ) : string { + ): string { if ($class === '') { throw new InvalidArgumentException('$class cannot be empty'); } @@ -125,7 +125,7 @@ public static function getStringFromFQCLN( ?string $this_class, bool $allow_self = false, bool $was_static = false - ) : string { + ): string { if ($allow_self && $value === $this_class) { if ($was_static) { return 'static'; @@ -427,7 +427,7 @@ public static function getResource(): Union /** * @param non-empty-list $union_types */ - public static function combineUnionTypeArray(array $union_types, ?Codebase $codebase) : Type\Union + public static function combineUnionTypeArray(array $union_types, ?Codebase $codebase): Type\Union { $first_type = array_pop($union_types); diff --git a/src/Psalm/Type/Atomic.php b/src/Psalm/Type/Atomic.php index d2a617be30f..7e39f434a58 100644 --- a/src/Psalm/Type/Atomic.php +++ b/src/Psalm/Type/Atomic.php @@ -320,7 +320,7 @@ public static function create( return new TNamedObject($value); } - abstract public function getKey(bool $include_extra = true) : string; + abstract public function getKey(bool $include_extra = true): string; public function isNumericType(): bool { @@ -398,7 +398,7 @@ public function hasTraversableInterface(Codebase $codebase): bool $this->extra_types && array_filter( $this->extra_types, - function (Atomic $a) use ($codebase) : bool { + function (Atomic $a) use ($codebase): bool { return $a->hasTraversableInterface($codebase); } ) @@ -423,7 +423,7 @@ public function hasCountableInterface(Codebase $codebase): bool $this->extra_types && array_filter( $this->extra_types, - function (Atomic $a) use ($codebase) : bool { + function (Atomic $a) use ($codebase): bool { return $a->hasCountableInterface($codebase); } ) @@ -464,7 +464,7 @@ public function hasArrayAccessInterface(Codebase $codebase): bool $this->extra_types && array_filter( $this->extra_types, - function (Atomic $a) use ($codebase) : bool { + function (Atomic $a) use ($codebase): bool { return $a->hasArrayAccessInterface($codebase); } ) @@ -472,12 +472,12 @@ function (Atomic $a) use ($codebase) : bool { ); } - public function getChildNodes() : array + public function getChildNodes(): array { return []; } - public function replaceClassLike(string $old, string $new) : void + public function replaceClassLike(string $old, string $new): void { if ($this instanceof TNamedObject) { if (strtolower($this->value) === $old) { @@ -620,14 +620,14 @@ public function replaceTemplateTypesWithStandins( bool $replace = true, bool $add_lower_bound = false, int $depth = 0 - ) : self { + ): self { return $this; } public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { // do nothing } diff --git a/src/Psalm/Type/Atomic/CallableTrait.php b/src/Psalm/Type/Atomic/CallableTrait.php index bb05faee7cd..9b1224ce6c4 100644 --- a/src/Psalm/Type/Atomic/CallableTrait.php +++ b/src/Psalm/Type/Atomic/CallableTrait.php @@ -191,7 +191,7 @@ public function replaceTemplateTypesWithStandins( bool $replace = true, bool $add_lower_bound = false, int $depth = 0 - ) : Atomic { + ): Atomic { $callable = clone $this; if ($callable->params) { @@ -248,7 +248,7 @@ public function replaceTemplateTypesWithStandins( public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { if ($this->params) { foreach ($this->params as $param) { if (!$param->type) { @@ -275,7 +275,7 @@ public function replaceTemplateTypesWithArgTypes( /** * @return list */ - public function getChildNodes() : array + public function getChildNodes(): array { $child_nodes = []; diff --git a/src/Psalm/Type/Atomic/DependentType.php b/src/Psalm/Type/Atomic/DependentType.php index 76f6514ad96..0d5dada6bdd 100644 --- a/src/Psalm/Type/Atomic/DependentType.php +++ b/src/Psalm/Type/Atomic/DependentType.php @@ -5,10 +5,10 @@ interface DependentType { - public function getVarId() : string; + public function getVarId(): string; /** * This returns a replacement type for when the dependent data is invalidated */ - public function getReplacement() : Atomic; + public function getReplacement(): Atomic; } diff --git a/src/Psalm/Type/Atomic/GenericTrait.php b/src/Psalm/Type/Atomic/GenericTrait.php index a22c37536a3..d3db7b1b396 100644 --- a/src/Psalm/Type/Atomic/GenericTrait.php +++ b/src/Psalm/Type/Atomic/GenericTrait.php @@ -175,7 +175,7 @@ public function __clone() /** * @return array */ - public function getChildNodes() : array + public function getChildNodes(): array { return $this->type_params; } @@ -191,7 +191,7 @@ public function replaceTemplateTypesWithStandins( bool $replace = true, bool $add_lower_bound = false, int $depth = 0 - ) : Atomic { + ): Atomic { if ($input_type instanceof Atomic\TList) { $input_type = new Atomic\TArray([Type::getInt(), $input_type->type_param]); } @@ -263,7 +263,7 @@ public function replaceTemplateTypesWithStandins( public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { foreach ($this->type_params as $offset => $type_param) { TemplateInferredTypeReplacer::replace( $type_param, diff --git a/src/Psalm/Type/Atomic/HasIntersectionTrait.php b/src/Psalm/Type/Atomic/HasIntersectionTrait.php index a74137c1790..5865647c799 100644 --- a/src/Psalm/Type/Atomic/HasIntersectionTrait.php +++ b/src/Psalm/Type/Atomic/HasIntersectionTrait.php @@ -25,7 +25,7 @@ private function getNamespacedIntersectionTypes( array $aliased_classes, ?string $this_class, bool $use_phpdoc_format - ) : string { + ): string { if (!$this->extra_types) { return ''; } @@ -59,7 +59,7 @@ function (Atomic $extra_type) use ( /** * @param TNamedObject|TTemplateParam|TIterable|TObjectWithProperties $type */ - public function addIntersectionType(Type\Atomic $type) : void + public function addIntersectionType(Type\Atomic $type): void { $this->extra_types[$type->getKey()] = $type; } @@ -67,7 +67,7 @@ public function addIntersectionType(Type\Atomic $type) : void /** * @return array|null */ - public function getIntersectionTypes() : ?array + public function getIntersectionTypes(): ?array { return $this->extra_types; } @@ -75,7 +75,7 @@ public function getIntersectionTypes() : ?array public function replaceIntersectionTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { if (!$this->extra_types) { return; } diff --git a/src/Psalm/Type/Atomic/TClassString.php b/src/Psalm/Type/Atomic/TClassString.php index 5474107046e..96768f22b92 100644 --- a/src/Psalm/Type/Atomic/TClassString.php +++ b/src/Psalm/Type/Atomic/TClassString.php @@ -108,7 +108,7 @@ public function canBeFullyExpressedInPhp(int $php_major_version, int $php_minor_ return false; } - public function getChildNodes() : array + public function getChildNodes(): array { return $this->as_type ? [$this->as_type] : []; } @@ -124,7 +124,7 @@ public function replaceTemplateTypesWithStandins( bool $replace = true, bool $add_lower_bound = false, int $depth = 0 - ) : Atomic { + ): Atomic { $class_string = clone $this; if (!$class_string->as_type) { diff --git a/src/Psalm/Type/Atomic/TClassStringMap.php b/src/Psalm/Type/Atomic/TClassStringMap.php index 82807ed823d..aa48e0cbe0b 100644 --- a/src/Psalm/Type/Atomic/TClassStringMap.php +++ b/src/Psalm/Type/Atomic/TClassStringMap.php @@ -145,7 +145,7 @@ public function replaceTemplateTypesWithStandins( bool $replace = true, bool $add_lower_bound = false, int $depth = 0 - ) : Atomic { + ): Atomic { $map = clone $this; foreach ([Type::getString(), $map->value_param] as $offset => $type_param) { @@ -198,7 +198,7 @@ public function replaceTemplateTypesWithStandins( public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { TemplateInferredTypeReplacer::replace( $this->value_param, $template_result, @@ -206,7 +206,7 @@ public function replaceTemplateTypesWithArgTypes( ); } - public function getChildNodes() : array + public function getChildNodes(): array { return [$this->value_param]; } @@ -229,7 +229,7 @@ public function getAssertionString(bool $exact = false): string return $this->getKey(); } - public function getStandinKeyParam() : Type\Union + public function getStandinKeyParam(): Type\Union { return new Type\Union([ new TTemplateParamClass( diff --git a/src/Psalm/Type/Atomic/TConditional.php b/src/Psalm/Type/Atomic/TConditional.php index bd0f358eccb..f8fce9e3c7b 100644 --- a/src/Psalm/Type/Atomic/TConditional.php +++ b/src/Psalm/Type/Atomic/TConditional.php @@ -124,7 +124,7 @@ public function toNamespacedString( return ''; } - public function getChildNodes() : array + public function getChildNodes(): array { return [$this->conditional_type, $this->if_type, $this->else_type]; } @@ -137,7 +137,7 @@ public function canBeFullyExpressedInPhp(int $php_major_version, int $php_minor_ public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { TemplateInferredTypeReplacer::replace( $this->conditional_type, $template_result, diff --git a/src/Psalm/Type/Atomic/TDependentGetClass.php b/src/Psalm/Type/Atomic/TDependentGetClass.php index 1881f5fba80..11b1bbd032d 100644 --- a/src/Psalm/Type/Atomic/TDependentGetClass.php +++ b/src/Psalm/Type/Atomic/TDependentGetClass.php @@ -45,12 +45,12 @@ public function getKey(bool $include_extra = true): string . '>'; } - public function getVarId() : string + public function getVarId(): string { return $this->typeof; } - public function getReplacement() : Atomic + public function getReplacement(): Atomic { return new TClassString(); } diff --git a/src/Psalm/Type/Atomic/TDependentGetDebugType.php b/src/Psalm/Type/Atomic/TDependentGetDebugType.php index 6bd789331a1..f922e02ba6f 100644 --- a/src/Psalm/Type/Atomic/TDependentGetDebugType.php +++ b/src/Psalm/Type/Atomic/TDependentGetDebugType.php @@ -28,12 +28,12 @@ public function getKey(bool $include_extra = true): string return 'get-debug-type-of<' . $this->typeof . '>'; } - public function getVarId() : string + public function getVarId(): string { return $this->typeof; } - public function getReplacement() : Atomic + public function getReplacement(): Atomic { return new TString(); } diff --git a/src/Psalm/Type/Atomic/TDependentListKey.php b/src/Psalm/Type/Atomic/TDependentListKey.php index 28da6d7a416..a77ad68eb3c 100644 --- a/src/Psalm/Type/Atomic/TDependentListKey.php +++ b/src/Psalm/Type/Atomic/TDependentListKey.php @@ -28,7 +28,7 @@ public function getId(bool $nested = false): string return 'list-key<' . $this->var_id . '>'; } - public function getVarId() : string + public function getVarId(): string { return $this->var_id; } @@ -38,7 +38,7 @@ public function getAssertionString(bool $exact = false): string return 'int'; } - public function getReplacement() : Atomic + public function getReplacement(): Atomic { return new TInt(); } diff --git a/src/Psalm/Type/Atomic/TGenericObject.php b/src/Psalm/Type/Atomic/TGenericObject.php index ef4effe2822..69d96ef73ba 100644 --- a/src/Psalm/Type/Atomic/TGenericObject.php +++ b/src/Psalm/Type/Atomic/TGenericObject.php @@ -107,7 +107,7 @@ public function getAssertionString(bool $exact = false): string return $this->value; } - public function getChildNodes() : array + public function getChildNodes(): array { return array_merge($this->type_params, $this->extra_types ?? []); } diff --git a/src/Psalm/Type/Atomic/TIterable.php b/src/Psalm/Type/Atomic/TIterable.php index f604240d5f4..0c035e033b1 100644 --- a/src/Psalm/Type/Atomic/TIterable.php +++ b/src/Psalm/Type/Atomic/TIterable.php @@ -121,7 +121,7 @@ public function equals(Atomic $other_type, bool $ensure_source_equality): bool return true; } - public function getChildNodes() : array + public function getChildNodes(): array { return array_merge($this->type_params, $this->extra_types ?? []); } diff --git a/src/Psalm/Type/Atomic/TKeyedArray.php b/src/Psalm/Type/Atomic/TKeyedArray.php index 483d28354e4..432f921f383 100644 --- a/src/Psalm/Type/Atomic/TKeyedArray.php +++ b/src/Psalm/Type/Atomic/TKeyedArray.php @@ -316,7 +316,7 @@ public function replaceTemplateTypesWithStandins( bool $replace = true, bool $add_lower_bound = false, int $depth = 0 - ) : Atomic { + ): Atomic { $object_like = clone $this; foreach ($this->properties as $offset => $property) { @@ -350,7 +350,7 @@ public function replaceTemplateTypesWithStandins( public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { foreach ($this->properties as $property) { TemplateInferredTypeReplacer::replace( $property, @@ -360,7 +360,7 @@ public function replaceTemplateTypesWithArgTypes( } } - public function getChildNodes() : array + public function getChildNodes(): array { return $this->properties; } @@ -397,7 +397,7 @@ public function getAssertionString(bool $exact = false): string return $this->getKey(); } - public function getList() : TNonEmptyList + public function getList(): TNonEmptyList { if (!$this->is_list) { throw new UnexpectedValueException('Object-like array must be a list for conversion'); diff --git a/src/Psalm/Type/Atomic/TList.php b/src/Psalm/Type/Atomic/TList.php index a50432b808d..f6e240056e9 100644 --- a/src/Psalm/Type/Atomic/TList.php +++ b/src/Psalm/Type/Atomic/TList.php @@ -118,7 +118,7 @@ public function replaceTemplateTypesWithStandins( bool $replace = true, bool $add_lower_bound = false, int $depth = 0 - ) : Atomic { + ): Atomic { $list = clone $this; foreach ([Type::getInt(), $list->type_param] as $offset => $type_param) { @@ -171,7 +171,7 @@ public function replaceTemplateTypesWithStandins( public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { TemplateInferredTypeReplacer::replace( $this->type_param, $template_result, @@ -201,7 +201,7 @@ public function getAssertionString(bool $exact = false): string return $this->toNamespacedString(null, [], null, false); } - public function getChildNodes() : array + public function getChildNodes(): array { return [$this->type_param]; } diff --git a/src/Psalm/Type/Atomic/TLiteralString.php b/src/Psalm/Type/Atomic/TLiteralString.php index e59c92e414f..11690e0f7fa 100644 --- a/src/Psalm/Type/Atomic/TLiteralString.php +++ b/src/Psalm/Type/Atomic/TLiteralString.php @@ -18,7 +18,7 @@ public function __construct(string $value) $this->value = $value; } - public function getKey(bool $include_extra = true) : string + public function getKey(bool $include_extra = true): string { return 'string(' . $this->value . ')'; } diff --git a/src/Psalm/Type/Atomic/TNamedObject.php b/src/Psalm/Type/Atomic/TNamedObject.php index 0e57467f809..9ae4a7e6fb3 100644 --- a/src/Psalm/Type/Atomic/TNamedObject.php +++ b/src/Psalm/Type/Atomic/TNamedObject.php @@ -148,11 +148,11 @@ public function canBeFullyExpressedInPhp(int $php_major_version, int $php_minor_ public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { $this->replaceIntersectionTemplateTypesWithArgTypes($template_result, $codebase); } - public function getChildNodes() : array + public function getChildNodes(): array { return $this->extra_types ?? []; } diff --git a/src/Psalm/Type/Atomic/TObjectWithProperties.php b/src/Psalm/Type/Atomic/TObjectWithProperties.php index 90d555059a4..be6285a859b 100644 --- a/src/Psalm/Type/Atomic/TObjectWithProperties.php +++ b/src/Psalm/Type/Atomic/TObjectWithProperties.php @@ -228,7 +228,7 @@ public function replaceTemplateTypesWithStandins( bool $replace = true, bool $add_lower_bound = false, int $depth = 0 - ) : Atomic { + ): Atomic { $object_like = clone $this; foreach ($this->properties as $offset => $property) { @@ -262,7 +262,7 @@ public function replaceTemplateTypesWithStandins( public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { foreach ($this->properties as $property) { TemplateInferredTypeReplacer::replace( $property, @@ -272,7 +272,7 @@ public function replaceTemplateTypesWithArgTypes( } } - public function getChildNodes() : array + public function getChildNodes(): array { return array_merge($this->properties, $this->extra_types !== null ? array_values($this->extra_types) : []); } diff --git a/src/Psalm/Type/Atomic/TString.php b/src/Psalm/Type/Atomic/TString.php index 2d059e9e417..4da08f58342 100644 --- a/src/Psalm/Type/Atomic/TString.php +++ b/src/Psalm/Type/Atomic/TString.php @@ -24,7 +24,7 @@ public function __toString(): string return 'string'; } - public function getKey(bool $include_extra = true) : string + public function getKey(bool $include_extra = true): string { return 'string'; } diff --git a/src/Psalm/Type/Atomic/TTemplateParam.php b/src/Psalm/Type/Atomic/TTemplateParam.php index e3cdcaac329..4fbf84243cc 100644 --- a/src/Psalm/Type/Atomic/TTemplateParam.php +++ b/src/Psalm/Type/Atomic/TTemplateParam.php @@ -115,7 +115,7 @@ public function toNamespacedString( return $this->param_name . $intersection_types; } - public function getChildNodes() : array + public function getChildNodes(): array { return [$this->as]; } @@ -128,7 +128,7 @@ public function canBeFullyExpressedInPhp(int $php_major_version, int $php_minor_ public function replaceTemplateTypesWithArgTypes( TemplateResult $template_result, ?Codebase $codebase - ) : void { + ): void { $this->replaceIntersectionTemplateTypesWithArgTypes($template_result, $codebase); } } diff --git a/src/Psalm/Type/NodeVisitor.php b/src/Psalm/Type/NodeVisitor.php index 19db1cab066..afd0dd53c87 100644 --- a/src/Psalm/Type/NodeVisitor.php +++ b/src/Psalm/Type/NodeVisitor.php @@ -9,12 +9,12 @@ abstract class NodeVisitor /** * @return self::STOP_TRAVERSAL|self::DONT_TRAVERSE_CHILDREN|null */ - abstract protected function enterNode(TypeNode $type) : ?int; + abstract protected function enterNode(TypeNode $type): ?int; /** * @return bool - true if we want to continue traversal, false otherwise */ - public function traverse(TypeNode $node) : bool + public function traverse(TypeNode $node): bool { $visitor_result = $this->enterNode($node); @@ -38,7 +38,7 @@ public function traverse(TypeNode $node) : bool /** * @param array $nodes */ - public function traverseArray(array $nodes) : void + public function traverseArray(array $nodes): void { foreach ($nodes as $node) { if ($this->traverse($node) === false) { diff --git a/src/Psalm/Type/Reconciler.php b/src/Psalm/Type/Reconciler.php index 22d034226e9..78b4c31ade6 100644 --- a/src/Psalm/Type/Reconciler.php +++ b/src/Psalm/Type/Reconciler.php @@ -325,7 +325,7 @@ public static function reconcileKeyedTypes( * * @return array>> */ - private static function addNestedAssertions(array $new_types, array $existing_types) : array + private static function addNestedAssertions(array $new_types, array $existing_types): array { foreach ($new_types as $nk => $type) { if (strpos($nk, '[') || strpos($nk, '->')) { @@ -823,7 +823,7 @@ private static function getPropertyType( Codebase $codebase, string $fq_class_name, string $property_name - ) : ?Type\Union { + ): ?Type\Union { $property_id = $fq_class_name . '::$' . $property_name; if (!$codebase->properties->propertyExists($property_id, true)) { @@ -1080,7 +1080,7 @@ private static function adjustTKeyedArrayType( } } - protected static function refineArrayKey(Union $key_type) : void + protected static function refineArrayKey(Union $key_type): void { foreach ($key_type->getAtomicTypes() as $key => $cat) { if ($cat instanceof TTemplateParam) { diff --git a/src/Psalm/Type/TypeNode.php b/src/Psalm/Type/TypeNode.php index 7a90b7f4616..24de98f7538 100644 --- a/src/Psalm/Type/TypeNode.php +++ b/src/Psalm/Type/TypeNode.php @@ -6,5 +6,5 @@ interface TypeNode /** * @return array */ - public function getChildNodes() : array; + public function getChildNodes(): array; } diff --git a/src/Psalm/Type/Union.php b/src/Psalm/Type/Union.php index 1e5a61c5837..a268f1aeaea 100644 --- a/src/Psalm/Type/Union.php +++ b/src/Psalm/Type/Union.php @@ -245,7 +245,7 @@ public function __construct(array $types) /** * @param non-empty-array $types */ - public function replaceTypes(array $types) : void + public function replaceTypes(array $types): void { $this->types = $types; } @@ -352,7 +352,7 @@ public function __toString(): string return implode('|', $types); } - public function getKey() : string + public function getKey(): string { $types = []; @@ -660,7 +660,7 @@ public function hasClassStringMap(): bool return isset($this->types['array']) && $this->types['array'] instanceof Atomic\TClassStringMap; } - public function isTemplatedClassString() : bool + public function isTemplatedClassString(): bool { return $this->isSingle() && count( @@ -673,7 +673,7 @@ function ($type): bool { ) === 1; } - public function hasArrayAccessInterface(Codebase $codebase) : bool + public function hasArrayAccessInterface(Codebase $codebase): bool { return (bool)array_filter( $this->types, @@ -892,7 +892,7 @@ public function hasTemplate(): bool { return (bool) array_filter( $this->types, - function (Atomic $type) : bool { + function (Atomic $type): bool { return $type instanceof Type\Atomic\TTemplateParam || ($type instanceof Type\Atomic\TNamedObject && $type->extra_types @@ -911,7 +911,7 @@ public function hasConditional(): bool { return (bool) array_filter( $this->types, - function (Atomic $type) : bool { + function (Atomic $type): bool { return $type instanceof Type\Atomic\TConditional; } ); @@ -921,7 +921,7 @@ public function hasTemplateOrStatic(): bool { return (bool) array_filter( $this->types, - function (Atomic $type) : bool { + function (Atomic $type): bool { return $type instanceof Type\Atomic\TTemplateParam || ($type instanceof Type\Atomic\TNamedObject && ($type->was_static @@ -1397,7 +1397,7 @@ public function getSingleStringLiteral(): TLiteralString return reset($this->literal_string_types); } - public function allStringLiterals() : bool + public function allStringLiterals(): bool { foreach ($this->types as $atomic_key_type) { if (!$atomic_key_type instanceof TLiteralString) { @@ -1408,7 +1408,7 @@ public function allStringLiterals() : bool return true; } - public function allIntLiterals() : bool + public function allIntLiterals(): bool { foreach ($this->types as $atomic_key_type) { if (!$atomic_key_type instanceof TLiteralInt) { @@ -1419,7 +1419,7 @@ public function allIntLiterals() : bool return true; } - public function allLiterals() : bool + public function allLiterals(): bool { foreach ($this->types as $atomic_key_type) { if (!$atomic_key_type instanceof TLiteralString @@ -1437,7 +1437,7 @@ public function allLiterals() : bool return true; } - public function hasLiteralValue() : bool + public function hasLiteralValue(): bool { return $this->literal_int_types || $this->literal_string_types @@ -1492,7 +1492,7 @@ public function check( bool $inherited = false, bool $prevent_template_covariance = false, ?string $calling_method_id = null - ) : bool { + ): bool { if ($this->checked) { return true; } @@ -1536,7 +1536,7 @@ public function queueClassLikesForScanning( /** * @param lowercase-string $fq_class_like_name */ - public function containsClassLike(string $fq_class_like_name) : bool + public function containsClassLike(string $fq_class_like_name): bool { $classlike_visitor = new ContainsClassLikeVisitor($fq_class_like_name); @@ -1545,7 +1545,7 @@ public function containsClassLike(string $fq_class_like_name) : bool return $classlike_visitor->matches(); } - public function containsAnyLiteral() : bool + public function containsAnyLiteral(): bool { $literal_visitor = new ContainsLiteralVisitor(); @@ -1573,7 +1573,7 @@ public function setFromDocblock(): void (new FromDocblockSetter())->traverseArray($this->types); } - public function replaceClassLike(string $old, string $new) : void + public function replaceClassLike(string $old, string $new): void { foreach ($this->types as $key => $atomic_type) { $atomic_type->replaceClassLike($old, $new); @@ -1686,7 +1686,7 @@ public function getLiteralFloats(): array /** * @return array */ - public function getChildNodes() : array + public function getChildNodes(): array { return $this->types; } diff --git a/src/command_functions.php b/src/command_functions.php index 3369a00fe1e..4a797d8ab7e 100644 --- a/src/command_functions.php +++ b/src/command_functions.php @@ -24,7 +24,7 @@ function getVendorDir(string $current_dir): string * @return list * @deprecated going to be removed in Psalm 5 */ -function getArguments() : array +function getArguments(): array { return CliUtils::getArguments(); } @@ -67,7 +67,7 @@ function initialiseConfig( } /** @deprecated going to be removed in Psalm 5 */ -function update_config_file(Config $config, string $config_file_path, string $baseline_path) : void +function update_config_file(Config $config, string $config_file_path, string $baseline_path): void { CliUtils::updateConfigFile($config, $config_file_path, $baseline_path); } diff --git a/src/spl_object_id.php b/src/spl_object_id.php index cb1dfd0d137..02d15dc6f3f 100644 --- a/src/spl_object_id.php +++ b/src/spl_object_id.php @@ -14,7 +14,7 @@ * @param object $object * @return int The object id */ - function spl_object_id($object) : int + function spl_object_id($object): int { return runkit_object_id($object); } @@ -25,7 +25,7 @@ function spl_object_id($object) : int * @param object $object * @return int (The object id, XORed with a random number) */ - function spl_object_id($object) : int + function spl_object_id($object): int { $hash = spl_object_hash($object); // Fit this into a php long (32-bit or 64-bit signed int). @@ -40,7 +40,7 @@ function spl_object_id($object) : int * @param object $object * @return int (The object id, XORed with a random number) */ - function spl_object_id($object) : int + function spl_object_id($object): int { $hash = spl_object_hash($object); // Fit this into a php long (32-bit or 64-bit signed int). diff --git a/tests/AlgebraTest.php b/tests/AlgebraTest.php index 621c036102a..c34ad854d5f 100644 --- a/tests/AlgebraTest.php +++ b/tests/AlgebraTest.php @@ -203,7 +203,7 @@ public function testSimplifyCNFWithUselessTermAndOneInMiddle(): void $this->assertSame(['$b' => ['!falsy']], $simplified_formula[0]->possibilities); } - public function testGroupImpossibilities() : void + public function testGroupImpossibilities(): void { $clause1 = (new Clause( [ diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index 45c0e9135c0..98a2ec81d5c 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -339,7 +339,7 @@ public function foo(): void {} * @psalm-ignore-nullable-return */ function makeA() { - return rand(0, 1) ? new A(): null; + return rand(0, 1) ? new A() : null; } function takeA(A $_a): void { } diff --git a/tests/ArrayAccessTest.php b/tests/ArrayAccessTest.php index cdf8d22bc01..cf2302a0ef5 100644 --- a/tests/ArrayAccessTest.php +++ b/tests/ArrayAccessTest.php @@ -144,7 +144,7 @@ function foo(array $arr) : void { $this->analyzeFile('somefile.php', new Context()); } - public function testNoIssueAfterManyIssets() : void + public function testNoIssueAfterManyIssets(): void { Config::getInstance()->ensure_array_int_offsets_exist = true; @@ -208,7 +208,7 @@ function takesList(array $arr) : void { $this->analyzeFile('somefile.php', new Context()); } - public function testEnsureOffsetExistsAfterArrayPush() : void + public function testEnsureOffsetExistsAfterArrayPush(): void { Config::getInstance()->ensure_array_int_offsets_exist = true; diff --git a/tests/BadFormatTest.php b/tests/BadFormatTest.php index a0f8f73eeb1..5c052f4dd17 100644 --- a/tests/BadFormatTest.php +++ b/tests/BadFormatTest.php @@ -93,7 +93,7 @@ interface B {}' $this->analyzeFile('somefile.php', new Context()); } - public function testBadArray() : void + public function testBadArray(): void { $this->expectExceptionMessage('ParseError - somefile.php:2'); $this->expectException(CodeException::class); diff --git a/tests/CodebaseTest.php b/tests/CodebaseTest.php index 7ad11f2c284..84ba487fd96 100644 --- a/tests/CodebaseTest.php +++ b/tests/CodebaseTest.php @@ -21,7 +21,7 @@ class CodebaseTest extends TestCase /** @var Codebase */ private $codebase; - public function setUp() : void + public function setUp(): void { parent::setUp(); $this->codebase = $this->project_analyzer->getCodebase(); @@ -46,7 +46,7 @@ public function isTypeContainedByType(string $input, string $container, bool $ex } /** @return iterable */ - public function typeContainments() + public function typeContainments(): iterable { yield ['int', 'int|string', true]; yield ['int|string', 'int', false]; @@ -76,7 +76,7 @@ public function canTypeBeContainedByType(string $input, string $container, bool } /** @return iterable */ - public function typeIntersections() + public function typeIntersections(): iterable { yield ['int', 'int|string', true]; yield ['int|string', 'int', true]; @@ -115,7 +115,7 @@ public function getKeyValueParamsForTraversableObject(string $input, array $expe } /** @return iterable */ - public function iterableParams() + public function iterableParams(): iterable { yield ['iterable', ['int', 'string']]; yield ['iterable', ['int|string', 'bool|float']]; @@ -146,6 +146,7 @@ public function m(int $_i = 1) {} $hook = new class implements AfterClassLikeVisitInterface { /** * @return void + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint */ public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event) { diff --git a/tests/Config/ConfigFileTest.php b/tests/Config/ConfigFileTest.php index 417274f1b9f..7a3cc0e604b 100644 --- a/tests/Config/ConfigFileTest.php +++ b/tests/Config/ConfigFileTest.php @@ -22,13 +22,13 @@ class ConfigFileTest extends TestCase /** @var string */ private $file_path; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->file_path = tempnam(sys_get_temp_dir(), 'psalm-test-config'); } - public function tearDown() : void + public function tearDown(): void { @unlink($this->file_path); } diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php index fc51ade8b8b..b77e573cf5e 100644 --- a/tests/Config/ConfigTest.php +++ b/tests/Config/ConfigTest.php @@ -46,7 +46,7 @@ class ConfigTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public static function setUpBeforeClass() : void + public static function setUpBeforeClass(): void { self::$config = new TestConfig(); @@ -59,7 +59,7 @@ public static function setUpBeforeClass() : void } } - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->file_provider = new FakeFileProvider(); @@ -1266,7 +1266,7 @@ function example() : void { $this->analyzeFile($file_path, new Context()); } - public function testNotIgnoredException() : void + public function testNotIgnoredException(): void { $this->expectException(CodeException::class); $this->expectExceptionMessage('MissingThrowsDocblock'); diff --git a/tests/Config/CreatorTest.php b/tests/Config/CreatorTest.php index 1316636a358..ed437917c9e 100644 --- a/tests/Config/CreatorTest.php +++ b/tests/Config/CreatorTest.php @@ -10,11 +10,11 @@ class CreatorTest extends TestCase { - public static function setUpBeforeClass() : void + public static function setUpBeforeClass(): void { } - public function setUp() : void + public function setUp(): void { } diff --git a/tests/Config/Plugin/Hook/FooMethodProvider.php b/tests/Config/Plugin/Hook/FooMethodProvider.php index 7072713460e..7f9dc4cc32c 100644 --- a/tests/Config/Plugin/Hook/FooMethodProvider.php +++ b/tests/Config/Plugin/Hook/FooMethodProvider.php @@ -20,7 +20,7 @@ class FooMethodProvider implements /** * @return array */ - public static function getClassLikeNames() : array + public static function getClassLikeNames(): array { return ['Ns\Foo']; } diff --git a/tests/Config/Plugin/Hook/FooPropertyProvider.php b/tests/Config/Plugin/Hook/FooPropertyProvider.php index 56b9b401755..2bfb3a7c159 100644 --- a/tests/Config/Plugin/Hook/FooPropertyProvider.php +++ b/tests/Config/Plugin/Hook/FooPropertyProvider.php @@ -17,7 +17,7 @@ class FooPropertyProvider implements /** * @return array */ - public static function getClassLikeNames() : array + public static function getClassLikeNames(): array { return ['Ns\Foo']; } diff --git a/tests/Config/Plugin/Hook/MagicFunctionProvider.php b/tests/Config/Plugin/Hook/MagicFunctionProvider.php index df5da3fc7b0..8b9e4815e96 100644 --- a/tests/Config/Plugin/Hook/MagicFunctionProvider.php +++ b/tests/Config/Plugin/Hook/MagicFunctionProvider.php @@ -18,7 +18,7 @@ class MagicFunctionProvider implements /** * @return array */ - public static function getFunctionIds() : array + public static function getFunctionIds(): array { return ['magicfunction']; } diff --git a/tests/Config/Plugin/Hook/SqlStringProvider.php b/tests/Config/Plugin/Hook/SqlStringProvider.php index 648af9bc6f4..06986050acf 100644 --- a/tests/Config/Plugin/Hook/SqlStringProvider.php +++ b/tests/Config/Plugin/Hook/SqlStringProvider.php @@ -12,7 +12,7 @@ class SqlStringProvider implements StringInterpreterInterface { - public static function getTypeFromValue(StringInterpreterEvent $event) : ?TLiteralString + public static function getTypeFromValue(StringInterpreterEvent $event): ?TLiteralString { $value = $event->getValue(); if (stripos($value, 'select ') !== false) { diff --git a/tests/Config/Plugin/Hook/StringProvider/TSqlSelectString.php b/tests/Config/Plugin/Hook/StringProvider/TSqlSelectString.php index 9a32b11204c..95453eeacd8 100644 --- a/tests/Config/Plugin/Hook/StringProvider/TSqlSelectString.php +++ b/tests/Config/Plugin/Hook/StringProvider/TSqlSelectString.php @@ -8,7 +8,7 @@ */ class TSqlSelectString extends TLiteralString { - public function getKey(bool $include_extra = true) : string + public function getKey(bool $include_extra = true): string { return 'sql-select-string'; } diff --git a/tests/Config/PluginListTest.php b/tests/Config/PluginListTest.php index eaae3eb3a57..8f801b51742 100644 --- a/tests/Config/PluginListTest.php +++ b/tests/Config/PluginListTest.php @@ -25,7 +25,7 @@ class PluginListTest extends TestCase /** @var ObjectProphecy */ private $composer_lock; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/Config/PluginTest.php b/tests/Config/PluginTest.php index f0c4d6eec07..ccd93ec443a 100644 --- a/tests/Config/PluginTest.php +++ b/tests/Config/PluginTest.php @@ -51,7 +51,7 @@ class PluginTest extends TestCase /** @var TestConfig */ protected static $config; - public static function setUpBeforeClass() : void + public static function setUpBeforeClass(): void { self::$config = new TestConfig(); @@ -64,7 +64,7 @@ public static function setUpBeforeClass() : void } } - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->file_provider = new FakeFileProvider(); @@ -550,7 +550,10 @@ public function testAfterCodebasePopulatedHookIsLoaded(): void ); $hook = new class implements AfterCodebasePopulatedInterface { - /** @return void */ + /** + * @return void + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint + */ public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event) { } @@ -625,13 +628,17 @@ public function testAfterClassLikeAnalysisLegacyHookIsLoaded(): void ); $hook = new class implements AfterClassLikeVisitInterface { + /** + * @return void + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint + */ public static function afterClassLikeVisit( ClassLike $stmt, ClassLikeStorage $storage, FileSource $statements_source, Codebase $codebase, array &$file_replacements = [] - ): void { + ) { } }; @@ -997,7 +1004,7 @@ public function testPluginFilenameCanBeAbsolute(): void $this->project_analyzer->getCodebase()->config->initializePlugins($this->project_analyzer); } - public function testPluginInvalidAbsoluteFilenameThrowsException() : void + public function testPluginInvalidAbsoluteFilenameThrowsException(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('does-not-exist/plugins/StringChecker.php'); diff --git a/tests/DocumentationTest.php b/tests/DocumentationTest.php index f23370f45b8..5edae652b68 100644 --- a/tests/DocumentationTest.php +++ b/tests/DocumentationTest.php @@ -127,7 +127,7 @@ private static function getCodeBlocksFromDocs(): array return $issue_code; } - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/ErrorBaselineTest.php b/tests/ErrorBaselineTest.php index 421a4889599..5d2eb81127e 100644 --- a/tests/ErrorBaselineTest.php +++ b/tests/ErrorBaselineTest.php @@ -20,7 +20,7 @@ class ErrorBaselineTest extends TestCase /** @var ObjectProphecy */ private $fileProvider; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->fileProvider = $this->prophesize(FileProvider::class); diff --git a/tests/FileManipulation/ClassConstantMoveTest.php b/tests/FileManipulation/ClassConstantMoveTest.php index 2b5f0174a05..bd88add019a 100644 --- a/tests/FileManipulation/ClassConstantMoveTest.php +++ b/tests/FileManipulation/ClassConstantMoveTest.php @@ -17,7 +17,7 @@ class ClassConstantMoveTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/FileManipulation/ClassMoveTest.php b/tests/FileManipulation/ClassMoveTest.php index 045ed28c395..871e82bfe3a 100644 --- a/tests/FileManipulation/ClassMoveTest.php +++ b/tests/FileManipulation/ClassMoveTest.php @@ -17,7 +17,7 @@ class ClassMoveTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/FileManipulation/FileManipulationTestCase.php b/tests/FileManipulation/FileManipulationTestCase.php index d478364fe45..96126b81f2f 100644 --- a/tests/FileManipulation/FileManipulationTestCase.php +++ b/tests/FileManipulation/FileManipulationTestCase.php @@ -17,7 +17,7 @@ abstract class FileManipulationTestCase extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/FileManipulation/MethodMoveTest.php b/tests/FileManipulation/MethodMoveTest.php index 1b9c0334b10..4a6bd3e6edd 100644 --- a/tests/FileManipulation/MethodMoveTest.php +++ b/tests/FileManipulation/MethodMoveTest.php @@ -17,7 +17,7 @@ class MethodMoveTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/FileManipulation/NamespaceMoveTest.php b/tests/FileManipulation/NamespaceMoveTest.php index 502e24651d5..a2e9742158b 100644 --- a/tests/FileManipulation/NamespaceMoveTest.php +++ b/tests/FileManipulation/NamespaceMoveTest.php @@ -17,7 +17,7 @@ class NamespaceMoveTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/FileManipulation/PropertyMoveTest.php b/tests/FileManipulation/PropertyMoveTest.php index e5e9f517f31..c5d6fb3b4e6 100644 --- a/tests/FileManipulation/PropertyMoveTest.php +++ b/tests/FileManipulation/PropertyMoveTest.php @@ -17,7 +17,7 @@ class PropertyMoveTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/FileReferenceTest.php b/tests/FileReferenceTest.php index e7e59387b06..7ce7426e3db 100644 --- a/tests/FileReferenceTest.php +++ b/tests/FileReferenceTest.php @@ -17,7 +17,7 @@ class FileReferenceTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/FileUpdates/AnalyzedMethodTest.php b/tests/FileUpdates/AnalyzedMethodTest.php index 3b91cedcd0b..7080728c707 100644 --- a/tests/FileUpdates/AnalyzedMethodTest.php +++ b/tests/FileUpdates/AnalyzedMethodTest.php @@ -19,7 +19,7 @@ class AnalyzedMethodTest extends TestCase { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/FileUpdates/CachedStorageTest.php b/tests/FileUpdates/CachedStorageTest.php index f19f84a23a5..9f2b056ca67 100644 --- a/tests/FileUpdates/CachedStorageTest.php +++ b/tests/FileUpdates/CachedStorageTest.php @@ -20,7 +20,7 @@ class CachedStorageTest extends TestCase { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/FileUpdates/ErrorAfterUpdateTest.php b/tests/FileUpdates/ErrorAfterUpdateTest.php index 49e3c70104e..911c0f4a16f 100644 --- a/tests/FileUpdates/ErrorAfterUpdateTest.php +++ b/tests/FileUpdates/ErrorAfterUpdateTest.php @@ -21,7 +21,7 @@ class ErrorAfterUpdateTest extends TestCase { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/FileUpdates/ErrorFixTest.php b/tests/FileUpdates/ErrorFixTest.php index 406be8fc11b..8ca05dc441c 100644 --- a/tests/FileUpdates/ErrorFixTest.php +++ b/tests/FileUpdates/ErrorFixTest.php @@ -20,7 +20,7 @@ class ErrorFixTest extends TestCase { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/FileUpdates/TemporaryUpdateTest.php b/tests/FileUpdates/TemporaryUpdateTest.php index 689278e9d09..acf50e86b97 100644 --- a/tests/FileUpdates/TemporaryUpdateTest.php +++ b/tests/FileUpdates/TemporaryUpdateTest.php @@ -23,7 +23,7 @@ class TemporaryUpdateTest extends TestCase { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/Internal/Provider/ProjectCacheProvider.php b/tests/Internal/Provider/ProjectCacheProvider.php index ec4b9f9cc41..01e987ec5a1 100644 --- a/tests/Internal/Provider/ProjectCacheProvider.php +++ b/tests/Internal/Provider/ProjectCacheProvider.php @@ -29,12 +29,12 @@ public function canDiffFiles(): bool return $this->last_run > 0; } - public function hasLockfileChanged() : bool + public function hasLockfileChanged(): bool { return false; } - public function updateComposerLockHash() : void + public function updateComposerLockHash(): void { } } diff --git a/tests/JsonOutputTest.php b/tests/JsonOutputTest.php index b5a74427419..56ee0375788 100644 --- a/tests/JsonOutputTest.php +++ b/tests/JsonOutputTest.php @@ -15,7 +15,7 @@ class JsonOutputTest extends TestCase { - public function setUp() : void + public function setUp(): void { // `TestCase::setUp()` creates its own ProjectAnalyzer and Config instance, but we don't want to do that in this // case, so don't run a `parent::setUp()` call here. diff --git a/tests/LanguageServer/CompletionTest.php b/tests/LanguageServer/CompletionTest.php index 37bbe5ff7d3..1f59eee6d1f 100644 --- a/tests/LanguageServer/CompletionTest.php +++ b/tests/LanguageServer/CompletionTest.php @@ -17,7 +17,7 @@ class CompletionTest extends TestCase { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/LanguageServer/FileMapTest.php b/tests/LanguageServer/FileMapTest.php index d5bc0d14c69..a668792366b 100644 --- a/tests/LanguageServer/FileMapTest.php +++ b/tests/LanguageServer/FileMapTest.php @@ -15,7 +15,7 @@ class FileMapTest extends TestCase { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/LanguageServer/SymbolLookupTest.php b/tests/LanguageServer/SymbolLookupTest.php index 504245fbcee..7055dd8b54b 100644 --- a/tests/LanguageServer/SymbolLookupTest.php +++ b/tests/LanguageServer/SymbolLookupTest.php @@ -15,7 +15,7 @@ class SymbolLookupTest extends TestCase { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/Loop/WhileTest.php b/tests/Loop/WhileTest.php index 301416a6e67..84aa2ee5878 100644 --- a/tests/Loop/WhileTest.php +++ b/tests/Loop/WhileTest.php @@ -35,7 +35,7 @@ class A { public $parent; public function __construct() { - $this->parent = rand(0, 1) ? new A(): new B(); + $this->parent = rand(0, 1) ? new A() : new B(); } } @@ -60,7 +60,7 @@ class A { public $parent; public function __construct() { - $this->parent = rand(0, 1) ? new A(): new B(); + $this->parent = rand(0, 1) ? new A() : new B(); } } @@ -87,7 +87,7 @@ class A { public $parent; public function __construct() { - $this->parent = rand(0, 1) ? new A(): null; + $this->parent = rand(0, 1) ? new A() : null; } } @@ -111,7 +111,7 @@ class A { public $parent; public function __construct() { - $this->parent = rand(0, 1) ? new A(): null; + $this->parent = rand(0, 1) ? new A() : null; } } diff --git a/tests/MagicMethodAnnotationTest.php b/tests/MagicMethodAnnotationTest.php index 3472164c08c..d451ff6a147 100644 --- a/tests/MagicMethodAnnotationTest.php +++ b/tests/MagicMethodAnnotationTest.php @@ -123,7 +123,7 @@ class Child extends ParentClass {} $this->assertSame('Child', (string) $context->vars_in_scope['$child']); } - public function testOverrideExceptionMethodReturn() : void + public function testOverrideExceptionMethodReturn(): void { Config::getInstance()->use_phpdoc_method_without_magic_or_parent = true; diff --git a/tests/MatchTest.php b/tests/MatchTest.php index 1c58dedf823..ac3d12126c4 100644 --- a/tests/MatchTest.php +++ b/tests/MatchTest.php @@ -96,7 +96,7 @@ class A {} class B {} - $a = rand(0, 10) ? new A(): new B(); + $a = rand(0, 10) ? new A() : new B(); $a = match (get_class($a)) { A::class => $a->barBar(), @@ -111,7 +111,7 @@ class B {} class A {} class B {} - $a = rand(0, 10) ? new A(): new B(); + $a = rand(0, 10) ? new A() : new B(); $a = match (get_class($a)) { C::class => 5, diff --git a/tests/MethodSignatureTest.php b/tests/MethodSignatureTest.php index 473a2fef8d0..fb20a18badd 100644 --- a/tests/MethodSignatureTest.php +++ b/tests/MethodSignatureTest.php @@ -280,7 +280,7 @@ public function __soapCall( $this->analyzeFile('somefile.php', new Context()); } - public function testExtendDocblockParamTypeWithWrongParam() : void + public function testExtendDocblockParamTypeWithWrongParam(): void { $this->expectException(CodeException::class); $this->expectExceptionMessage('MethodSignatureMismatch'); diff --git a/tests/ProjectCheckerTest.php b/tests/ProjectCheckerTest.php index abe7a78ae72..e05ab1909ca 100644 --- a/tests/ProjectCheckerTest.php +++ b/tests/ProjectCheckerTest.php @@ -39,7 +39,7 @@ class ProjectCheckerTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public static function setUpBeforeClass() : void + public static function setUpBeforeClass(): void { self::$config = new TestConfig(); @@ -52,7 +52,7 @@ public static function setUpBeforeClass() : void } } - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->file_provider = new FakeFileProvider(); @@ -124,7 +124,10 @@ public function testAfterCodebasePopulatedIsInvoked(): void /** @var bool */ public static $called = false; - /** @return void */ + /** + * @return void + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint + */ public static function afterCodebasePopulated(AfterCodebasePopulatedEvent $event) { self::$called = true; diff --git a/tests/PropertyTypeTest.php b/tests/PropertyTypeTest.php index 87bfa085079..01e7a23b1cd 100644 --- a/tests/PropertyTypeTest.php +++ b/tests/PropertyTypeTest.php @@ -414,7 +414,7 @@ class B { public $foo = ""; } - $a = rand(0, 10) ? new A(): (rand(0, 10) ? new B(): null); + $a = rand(0, 10) ? new A(): (rand(0, 10) ? new B() : null); $b = null; if ($a instanceof A || $a instanceof B) { @@ -435,7 +435,7 @@ class B { public $foo = ""; } - $a = rand(0, 10) ? new A(): new B(); + $a = rand(0, 10) ? new A() : new B(); if (rand(0, 1)) { $a = null; } @@ -463,7 +463,7 @@ class B { public $bb; } - $b = rand(0, 10) ? new A(): new B(); + $b = rand(0, 10) ? new A() : new B(); if ($b instanceof B && isset($b->bb) && $b->bb->aa === "aa") { echo $b->bb->aa; @@ -2759,7 +2759,7 @@ class Foo { public $foo = ""; } - $a = rand(0, 10) ? new Foo(): null; + $a = rand(0, 10) ? new Foo() : null; $a->foo = "hello";', 'error_message' => 'PossiblyNullPropertyAssignment', @@ -2778,7 +2778,7 @@ class Foo { public $foo = ""; } - $a = rand(0, 10) ? new Foo(): null; + $a = rand(0, 10) ? new Foo() : null; echo $a->foo;', 'error_message' => 'PossiblyNullPropertyFetch', diff --git a/tests/PsalmPluginTest.php b/tests/PsalmPluginTest.php index a73870ccebf..4820f98b711 100644 --- a/tests/PsalmPluginTest.php +++ b/tests/PsalmPluginTest.php @@ -31,7 +31,7 @@ class PsalmPluginTest extends TestCase /** @var Application */ private $app; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->plugin_list = $this->prophesize(PluginList::class); diff --git a/tests/ReportOutputTest.php b/tests/ReportOutputTest.php index 0d9cb6cbe12..34294e031da 100644 --- a/tests/ReportOutputTest.php +++ b/tests/ReportOutputTest.php @@ -26,7 +26,7 @@ class ReportOutputTest extends TestCase { - public function setUp() : void + public function setUp(): void { // `TestCase::setUp()` creates its own ProjectAnalyzer and Config instance, but we don't want to do that in this // case, so don't run a `parent::setUp()` call here. @@ -70,7 +70,7 @@ public function testReportFormatException(): void ProjectAnalyzer::getFileReportOptions(['/tmp/report.log']); } - public function analyzeTaintFlowFilesForReport() : void + public function analyzeTaintFlowFilesForReport(): void { $vulnerable_file_contents = ' 50 ? new One(): null; + $baz = rand(0,100) > 50 ? new One() : null; // should have no effect if ($baz === null) { diff --git a/tests/StubTest.php b/tests/StubTest.php index 8dfffe62a9b..863caad0b9f 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -29,7 +29,7 @@ class StubTest extends TestCase /** @var TestConfig */ protected static $config; - public static function setUpBeforeClass() : void + public static function setUpBeforeClass(): void { self::$config = new TestConfig(); @@ -42,7 +42,7 @@ public static function setUpBeforeClass() : void } } - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->file_provider = new FakeFileProvider(); @@ -1122,7 +1122,7 @@ class C extends B {}' $this->analyzeFile($file_path, new Context()); } - public function testInheritedMethodUsedInStub() : void + public function testInheritedMethodUsedInStub(): void { $this->project_analyzer = $this->getProjectAnalyzerWithConfig( TestConfig::loadFromXML( diff --git a/tests/SwitchTypeTest.php b/tests/SwitchTypeTest.php index 85b6df4cee2..b95412631d1 100644 --- a/tests/SwitchTypeTest.php +++ b/tests/SwitchTypeTest.php @@ -37,7 +37,7 @@ public function barBar() { } } - $a = rand(0, 10) ? new A(): new B(); + $a = rand(0, 10) ? new A() : new B(); switch (get_class($a)) { case A::class: @@ -1145,7 +1145,7 @@ public function barBar() { } } - $a = rand(0, 10) ? new A(): new B(); + $a = rand(0, 10) ? new A() : new B(); switch (get_class($a)) { case A::class: @@ -1159,7 +1159,7 @@ public function barBar() { class A {} class B {} - $a = rand(0, 10) ? new A(): new B(); + $a = rand(0, 10) ? new A() : new B(); switch (get_class($a)) { case C::class: diff --git a/tests/TestCase.php b/tests/TestCase.php index 47d9739e52e..95a62caa2ef 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -43,7 +43,7 @@ class TestCase extends BaseTestCase /** @var Config */ protected $testConfig; - public static function setUpBeforeClass() : void + public static function setUpBeforeClass(): void { ini_set('memory_limit', '-1'); @@ -59,12 +59,12 @@ public static function setUpBeforeClass() : void self::$src_dir_path = getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR; } - protected function makeConfig() : Config + protected function makeConfig(): Config { return new TestConfig(); } - public function setUp() : void + public function setUp(): void { parent::setUp(); @@ -87,7 +87,7 @@ public function setUp() : void $this->project_analyzer->setPhpVersion('7.4', 'tests'); } - public function tearDown() : void + public function tearDown(): void { unset($this->project_analyzer, $this->file_provider, $this->testConfig); RuntimeCaches::clearAll(); diff --git a/tests/TestConfig.php b/tests/TestConfig.php index 83ffa5c5467..ef8e51d1083 100644 --- a/tests/TestConfig.php +++ b/tests/TestConfig.php @@ -44,7 +44,7 @@ public function __construct() $this->collectPredefinedFunctions(); } - protected function getContents() : string + protected function getContents(): string { return ' diff --git a/tests/ThrowsAnnotationTest.php b/tests/ThrowsAnnotationTest.php index 31dbbb80633..657f165289e 100644 --- a/tests/ThrowsAnnotationTest.php +++ b/tests/ThrowsAnnotationTest.php @@ -7,7 +7,7 @@ class ThrowsAnnotationTest extends TestCase { - public function testUndefinedClassAsThrows() : void + public function testUndefinedClassAsThrows(): void { $this->expectExceptionMessage('UndefinedDocblockClass - somefile.php:3:28'); $this->expectException(CodeException::class); @@ -26,7 +26,7 @@ function bar() : void {}' $this->analyzeFile('somefile.php', $context); } - public function testNonThrowableClassAsThrows() : void + public function testNonThrowableClassAsThrows(): void { $this->expectExceptionMessage('InvalidThrow'); $this->expectException(CodeException::class); @@ -47,7 +47,7 @@ function bar() : void {}' $this->analyzeFile('somefile.php', $context); } - public function testInheritedThrowableClassAsThrows() : void + public function testInheritedThrowableClassAsThrows(): void { $this->addFile( 'somefile.php', diff --git a/tests/TypeComparatorTest.php b/tests/TypeComparatorTest.php index 6176046e4ea..db7d948b14f 100644 --- a/tests/TypeComparatorTest.php +++ b/tests/TypeComparatorTest.php @@ -16,7 +16,7 @@ class TypeComparatorTest extends TestCase { - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->file_provider = new FakeFileProvider(); diff --git a/tests/TypeParseTest.php b/tests/TypeParseTest.php index 5f150dc62c6..186f94baac6 100644 --- a/tests/TypeParseTest.php +++ b/tests/TypeParseTest.php @@ -19,7 +19,7 @@ class TypeParseTest extends TestCase { - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); $this->file_provider = new FakeFileProvider(); @@ -212,7 +212,7 @@ public function testIntersectionOfTKeyedArrayWithConflictingProperties(): void Type::parseString('array{a: string}&array{a: int}'); } - public function testIntersectionOfTwoRegularArrays() : void + public function testIntersectionOfTwoRegularArrays(): void { $this->expectException(TypeParseTreeException::class); Type::parseString('string[]&array'); @@ -236,7 +236,7 @@ public function testIntersectionOfTKeyedArrayAndObject(): void Type::parseString('array{a: int}&T1'); } - public function testIterableContainingTKeyedArray() : void + public function testIterableContainingTKeyedArray(): void { $this->assertSame('iterable', Type::parseString('iterable')->getId()); } @@ -559,7 +559,7 @@ public function testConditionalTypeWithCallableReturningBoolElseBool(): void ); } - public function testConditionalTypeWithGenerics() : void + public function testConditionalTypeWithGenerics(): void { $this->assertSame( '(T is string ? string : array)', @@ -571,7 +571,7 @@ public function testConditionalTypeWithGenerics() : void ); } - public function testConditionalTypeWithCallableBracketed() : void + public function testConditionalTypeWithCallableBracketed(): void { $this->assertSame( '(T is string ? callable(string, string):string : callable(mixed...):mixed)', @@ -583,7 +583,7 @@ public function testConditionalTypeWithCallableBracketed() : void ); } - public function testConditionalTypeWithCallableNotBracketed() : void + public function testConditionalTypeWithCallableNotBracketed(): void { $this->assertSame( '(T is string ? callable(string, string):string : callable(mixed...):mixed)', @@ -780,7 +780,7 @@ public function testValueOfClassConstant(): void ); } - public function testClassStringMap() : void + public function testClassStringMap(): void { $this->assertSame( 'class-string-map', @@ -817,7 +817,7 @@ public function testEnum(): void $this->assertSame($resolved_type->getId(), $docblock_type->getId()); } - public function testEmptyString() : void + public function testEmptyString(): void { $docblock_type = Type::parseString('""|"admin"|"fun"'); @@ -974,7 +974,7 @@ public function testReflectionTypeParse(): void { if (!function_exists('Psalm\Tests\someFunction')) { /** @psalm-suppress UnusedParam */ - function someFunction(string $param, array $param2, ?int $param3 = null) : string + function someFunction(string $param, array $param2, ?int $param3 = null): string { return 'hello'; } diff --git a/tests/TypeReconciliation/ConditionalTest.php b/tests/TypeReconciliation/ConditionalTest.php index 3471c8cbd29..9274f573eec 100644 --- a/tests/TypeReconciliation/ConditionalTest.php +++ b/tests/TypeReconciliation/ConditionalTest.php @@ -232,7 +232,7 @@ function makeC(): C { return new D(); } - $a = rand(0, 1) ? makeA(): makeC(); + $a = rand(0, 1) ? makeA() : makeC(); if ($a instanceof B || $a instanceof D) { }', ], @@ -277,7 +277,7 @@ function foo($a) { ' [ ' 0) { echo $a + 3; @@ -2858,7 +2858,7 @@ class A { } class A { } class B { } class C { } - $a = rand(0, 10) > 5 ? new A(): new B(); + $a = rand(0, 10) > 5 ? new A() : new B(); if ($a instanceof A) { } elseif ($a instanceof C) { }', diff --git a/tests/TypeReconciliation/ReconcilerTest.php b/tests/TypeReconciliation/ReconcilerTest.php index 0d28f776e0d..65982f09068 100644 --- a/tests/TypeReconciliation/ReconcilerTest.php +++ b/tests/TypeReconciliation/ReconcilerTest.php @@ -18,7 +18,7 @@ class ReconcilerTest extends TestCase /** @var StatementsAnalyzer */ protected $statements_analyzer; - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/TypeReconciliation/ScopeTest.php b/tests/TypeReconciliation/ScopeTest.php index 95a27b9abeb..254e212f8f1 100644 --- a/tests/TypeReconciliation/ScopeTest.php +++ b/tests/TypeReconciliation/ScopeTest.php @@ -64,7 +64,7 @@ public function __toString(): string { } } - $a = rand(0, 10) === 5 ? new A(): null; + $a = rand(0, 10) === 5 ? new A() : null; if (rand(0, 1)) { diff --git a/tests/TypeReconciliation/TypeTest.php b/tests/TypeReconciliation/TypeTest.php index b0e685e3710..b44b2a400da 100644 --- a/tests/TypeReconciliation/TypeTest.php +++ b/tests/TypeReconciliation/TypeTest.php @@ -28,7 +28,7 @@ public function fooFoo() {} class B { /** @return void */ public function barBar(A $a = null) { - $b = $a ? $a->fooFoo(): null; + $b = $a ? $a->fooFoo() : null; } }', ], @@ -104,7 +104,7 @@ class B { /** @return void */ public function barBar(A $a = null) { $this->a = $a; - $b = $this->a ? $this->a->fooFoo(): null; + $b = $this->a ? $this->a->fooFoo() : null; } }', ], diff --git a/tests/TypeReconciliation/ValueTest.php b/tests/TypeReconciliation/ValueTest.php index 740d14237d3..a24bd6e8db8 100644 --- a/tests/TypeReconciliation/ValueTest.php +++ b/tests/TypeReconciliation/ValueTest.php @@ -16,7 +16,7 @@ class ValueTest extends TestCase use InvalidCodeAnalysisTestTrait; use ValidCodeAnalysisTestTrait; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/UnusedCodeTest.php b/tests/UnusedCodeTest.php index 3df3da209c3..996b9647fbe 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -22,7 +22,7 @@ class UnusedCodeTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll(); diff --git a/tests/UnusedVariableTest.php b/tests/UnusedVariableTest.php index fc133117aec..229b4be7c21 100644 --- a/tests/UnusedVariableTest.php +++ b/tests/UnusedVariableTest.php @@ -20,7 +20,7 @@ class UnusedVariableTest extends TestCase /** @var ProjectAnalyzer */ protected $project_analyzer; - public function setUp() : void + public function setUp(): void { RuntimeCaches::clearAll();