diff --git a/docs/contributing/adding_issues.md b/docs/contributing/adding_issues.md index b609d872837..065c746bc9a 100644 --- a/docs/contributing/adding_issues.md +++ b/docs/contributing/adding_issues.md @@ -32,7 +32,7 @@ There a number of abstract classes you can extend: * `FunctionIssue` - issue related to a specific function. Can be suppressed with `referencedFunction` attribute. * `ArgumentIssue` - issue related to a specific argument. Can be targeted with `referencedFunction` attribute. * `MethodIssue` - issue related to a specific method. Can be targeted with `referencedMethod` attribute. -* `ClassConstantIssue` - issue related ot a specific class constant. Can be targeted with `referencedConstant`. +* `ClassConstantIssue` - issue related to a specific class constant. Can be targeted with `referencedConstant`. * `VariableIssue` - issue for a specific variable. Targeted with `referencedVariable` ## Add a `config.xsd` entry diff --git a/docs/contributing/philosophy.md b/docs/contributing/philosophy.md index f43f4fbb4fa..c0ad4fca515 100644 --- a/docs/contributing/philosophy.md +++ b/docs/contributing/philosophy.md @@ -38,7 +38,7 @@ All other functionality – the language server, security analysis, manipulating Psalm is almost always run on PHP code that parses a lint check (`php -l `) – i.e. syntactically-correct code. Psalm is not a replacement for that syntax check. -Given Psalm is almost always used on syntatically-correct code it should use a parser built for that purpose, and `nikic/php-parser` is the gold-standard. +Given Psalm is almost always used on syntactically-correct code it should use a parser built for that purpose, and `nikic/php-parser` is the gold-standard. Where Psalm needs to run on syntactically-incorrect code (e.g. in language server mode) Psalm should still use the same parser (and work around any issues that it produces). diff --git a/docs/running_psalm/installation.md b/docs/running_psalm/installation.md index 071ba3f5dc0..862a394ac50 100644 --- a/docs/running_psalm/installation.md +++ b/docs/running_psalm/installation.md @@ -38,7 +38,7 @@ Read more about plugins in [Using Plugins chapter](plugins/using_plugins.md). Sometimes your project can conflict with one or more of Psalm’s dependencies. In that case you may find the Phar (a self-contained PHP executable) useful. -The Phar can be downloaded from Github: +The Phar can be downloaded from GitHub: ```bash wget https://github.com/vimeo/psalm/releases/latest/download/psalm.phar diff --git a/docs/running_psalm/issues/DirectConstructorCall.md b/docs/running_psalm/issues/DirectConstructorCall.md index 75ca384dda6..6906428d4fc 100644 --- a/docs/running_psalm/issues/DirectConstructorCall.md +++ b/docs/running_psalm/issues/DirectConstructorCall.md @@ -1,6 +1,6 @@ # DirectConstructorCall -Emitted when `__construct()` is called directly as a method. Constructors are supposed to be called implicitely, as a result of `new ClassName` statement. +Emitted when `__construct()` is called directly as a method. Constructors are supposed to be called implicitly, as a result of `new ClassName` statement. ```php */ diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index 2fd7cd1b5a7..92cf5132e3e 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -300,7 +300,7 @@ private static function checkFunctionLikeTypeMatches( $readonly_template_result = new TemplateResult($class_generic_params, []); // This flag ensures that the template results will never be written to - // It also supercedes the `$add_lower_bounds` flag so that closure params + // It also supersedes the `$add_lower_bounds` flag so that closure params // don’t get overwritten $readonly_template_result->readonly = true; diff --git a/src/Psalm/Internal/Cli/Psalm.php b/src/Psalm/Internal/Cli/Psalm.php index 99d87b52269..a3230f0cecb 100644 --- a/src/Psalm/Internal/Cli/Psalm.php +++ b/src/Psalm/Internal/Cli/Psalm.php @@ -905,7 +905,7 @@ private static function restart(array $options, int $threads, Progress $progress $ini_handler->disableExtensions([ 'uopz', - // extesions that are incompatible with JIT (they are also usually make Psalm slow) + // extensions that are incompatible with JIT (they are also usually make Psalm slow) 'pcov', 'blackfire', ]); diff --git a/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php b/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php index e2c4ae99cf6..1d6ce8d5055 100644 --- a/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php +++ b/src/Psalm/Internal/ExecutionEnvironment/BuildInfoCollector.php @@ -245,7 +245,7 @@ protected function fillScrutinizer(): self } /** - * Fill Github Actions environment variables. + * Fill GitHub Actions environment variables. * * @return $this * @psalm-suppress PossiblyUndefinedStringArrayOffset diff --git a/src/Psalm/Internal/LanguageServer/Server/Workspace.php b/src/Psalm/Internal/LanguageServer/Server/Workspace.php index 75c810cf800..1cabf12a616 100644 --- a/src/Psalm/Internal/LanguageServer/Server/Workspace.php +++ b/src/Psalm/Internal/LanguageServer/Server/Workspace.php @@ -98,7 +98,7 @@ public function didChangeWatchedFiles(array $changes): void continue; } - //If the file is currently open then dont analize it because its tracked in didChange + //If the file is currently open then dont analyze it because its tracked in didChange if (!$this->codebase->file_provider->isOpen($file_path)) { $this->server->queueClosedFileAnalysis($file_path, $change->uri); } diff --git a/src/Psalm/Internal/Type/AssertionReconciler.php b/src/Psalm/Internal/Type/AssertionReconciler.php index d82a5c07384..f78e0caeebe 100644 --- a/src/Psalm/Internal/Type/AssertionReconciler.php +++ b/src/Psalm/Internal/Type/AssertionReconciler.php @@ -515,7 +515,7 @@ private static function refine( } /** - * This method receives two types. The goal is to use datas in the new type to reduce the existing_type to a more + * This method receives two types. The goal is to use data in the new type to reduce the existing_type to a more * precise version. For example: new is `array` old is `list` so the result is `list` */ private static function filterTypeWithAnother( diff --git a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php index f83427ea101..b2092c8724d 100644 --- a/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php +++ b/src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php @@ -468,7 +468,7 @@ public static function canExpressionTypesBeIdentical( foreach (self::getTypeParts($codebase, $type1) as $type1_part) { foreach (self::getTypeParts($codebase, $type2) as $type2_part) { //special case for TIntRange because it can contain a part of another TIntRange. - //For exemple int<0,10> and int<5, 15> can be identical but none contain the other + //For example int<0,10> and int<5, 15> can be identical but none contain the other if ($type1_part instanceof TIntRange && $type2_part instanceof TIntRange) { $intersection_range = TIntRange::intersectIntRanges( $type1_part, diff --git a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php index 88be51f72e1..d2f89528a1b 100644 --- a/src/Psalm/Internal/Type/NegatedAssertionReconciler.php +++ b/src/Psalm/Internal/Type/NegatedAssertionReconciler.php @@ -205,7 +205,7 @@ public static function reconcile( && $assertion_type instanceof TNamedObject && isset($existing_var_type->getAtomicTypes()[$assertion_type->getKey()]) ) { - // checking if two types share a common parent is not enough to guarantee childs are instanceof each other + // checking if two types share a common parent is not enough to guarantee children are instanceof each other // fall through } elseif ($existing_var_type->isArray() && ($assertion->getAtomicType() instanceof TArray diff --git a/src/Psalm/Internal/Type/TypeParser.php b/src/Psalm/Internal/Type/TypeParser.php index 877f10855b7..b47fc8f23d7 100644 --- a/src/Psalm/Internal/Type/TypeParser.php +++ b/src/Psalm/Internal/Type/TypeParser.php @@ -717,7 +717,7 @@ private static function getTypeFromGenericTree( } if ($generic_type_value === 'arraylike-object') { - $array_acccess = new TGenericObject('ArrayAccess', $generic_params, false, false, [], $from_docblock); + $array_access = new TGenericObject('ArrayAccess', $generic_params, false, false, [], $from_docblock); $countable = new TNamedObject('Countable', false, false, [], $from_docblock); return new TGenericObject( 'Traversable', @@ -725,7 +725,7 @@ private static function getTypeFromGenericTree( false, false, [ - $array_acccess->getKey() => $array_acccess, + $array_access->getKey() => $array_access, $countable->getKey() => $countable, ], $from_docblock, diff --git a/src/Psalm/Type/Atomic.php b/src/Psalm/Type/Atomic.php index 7add3b2675f..08f45dd0d7b 100644 --- a/src/Psalm/Type/Atomic.php +++ b/src/Psalm/Type/Atomic.php @@ -701,7 +701,7 @@ final public function __toString(): string } /** - * This is the true identifier for the type. It defaults to self::getKey() but can be overrided to be more precise + * This is the true identifier for the type. It defaults to self::getKey() but can be overridden to be more precise */ public function getId(bool $exact = true, bool $nested = false): string { diff --git a/src/Psalm/Type/Atomic/TKeyedArray.php b/src/Psalm/Type/Atomic/TKeyedArray.php index 848ba5f6d5c..9006790baa4 100644 --- a/src/Psalm/Type/Atomic/TKeyedArray.php +++ b/src/Psalm/Type/Atomic/TKeyedArray.php @@ -715,7 +715,7 @@ private function escapeAndQuote($name) } if (preg_match('/^-?[1-9][0-9]*$/', $name) - && (string)(int) $name !== $name // overflow occured + && (string)(int) $name !== $name // overflow occurred ) { $quote = true; } diff --git a/src/Psalm/Type/Atomic/TPropertiesOf.php b/src/Psalm/Type/Atomic/TPropertiesOf.php index 49da46df53d..2a286b9c745 100644 --- a/src/Psalm/Type/Atomic/TPropertiesOf.php +++ b/src/Psalm/Type/Atomic/TPropertiesOf.php @@ -6,7 +6,7 @@ /** * Type that resolves to a keyed-array with properties of a class as keys and - * their apropriate types as values. + * their appropriate types as values. * * @psalm-type TokenName = 'properties-of'|'public-properties-of'|'protected-properties-of'|'private-properties-of' * @psalm-immutable @@ -15,7 +15,7 @@ final class TPropertiesOf extends Atomic { // These should match the values of // `Psalm\Internal\Analyzer\ClassLikeAnalyzer::VISIBILITY_*`, as they are - // used to compared against properties visibililty. + // used to compared against properties visibility. public const VISIBILITY_PUBLIC = 1; public const VISIBILITY_PROTECTED = 2; public const VISIBILITY_PRIVATE = 3; diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index f059c4d5c52..79e5cd9a358 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -492,7 +492,7 @@ function example(string $_x) : void {}', $arr["a"]();', ], - 'multipeLineGenericArray' => [ + 'multipleLineGenericArray' => [ 'code' => ' [ + 'multipleLineGenericArray2' => [ 'code' => ' 'DOMElement|null', ], ], - 'getOnArrayAcccess' => [ + 'getOnArrayAccess' => [ 'code' => ' $a */ function foo(ArrayAccess $a) : string { diff --git a/tests/ArrayFunctionCallTest.php b/tests/ArrayFunctionCallTest.php index 6abaf96ba68..d4d36571066 100644 --- a/tests/ArrayFunctionCallTest.php +++ b/tests/ArrayFunctionCallTest.php @@ -1164,7 +1164,7 @@ function mapdef(string $_a, int $_b = 0): string { ', 'assertions' => [ '$a===' => 'list{0, 0, 0}', - // Techinically this doesn't cover the case of running on 8.0 but nvm + // Technically this doesn't cover the case of running on 8.0 but nvm '$b===' => 'array{-1: 0, 0: 0, 1: 0}', '$c===' => 'array{-2: 0, 0: 0, 1: 0}', ], @@ -2700,7 +2700,7 @@ function takes_non_empty_array(array $input): void {} public function providerInvalidCodeParse(): iterable { return [ - 'arrayFilterUseMethodOnInferrableInt' => [ + 'arrayFilterUseMethodOnInferableInt' => [ 'code' => 'foo(); });', 'error_message' => 'InvalidMethodCall', @@ -2746,7 +2746,7 @@ public function providerInvalidCodeParse(): iterable array_filter($arg, "strlen", ARRAY_FILTER_USE_KEY);', 'error_message' => 'InvalidScalarArgument', ], - 'arrayMapUseMethodOnInferrableInt' => [ + 'arrayMapUseMethodOnInferableInt' => [ 'code' => 'foo(); }, [1, 2, 3, 4]);', 'error_message' => 'InvalidMethodCall', diff --git a/tests/AssertAnnotationTest.php b/tests/AssertAnnotationTest.php index 5263a5267a0..49cb12e1f65 100644 --- a/tests/AssertAnnotationTest.php +++ b/tests/AssertAnnotationTest.php @@ -90,7 +90,7 @@ function requiresString(string $_str): void {} $this->analyzeFile('somefile.php', new Context()); } - public function testAssertsAllongCallStaticMethodWork(): void + public function testAssertsAlongCallStaticMethodWork(): void { $this->addFile( 'somefile.php', @@ -150,7 +150,7 @@ function assertNotSame($expected, $actual) : void {} public function providerValidCodeParse(): iterable { return [ - 'implictAssertInstanceOfB' => [ + 'implicitAssertInstanceOfB' => [ 'code' => ' [ + 'implicitAssertInstanceOfInterface' => [ 'code' => ' 'InvalidArgument', ], - 'inexistantCallableinCallableString' => [ + 'inexistentCallableinCallableString' => [ 'code' => ' [ + 'classAliasOnNonexistentClass' => [ 'code' => ' 'CircularReference', ], - 'preventAbstractInstantiationDefiniteClasss' => [ + 'preventAbstractInstantiationDefiniteClass' => [ 'code' => ' [], 'php_version' => '8.1', ], - 'arrowFunctionReturnsNeverImplictly' => [ + 'arrowFunctionReturnsNeverImplicitly' => [ 'code' => ' [], 'php_version' => '8.1', ], - 'arrowFunctionReturnsNeverExplictly' => [ + 'arrowFunctionReturnsNeverExplicitly' => [ 'code' => ' [], 'php_version' => '8.1', ], - 'returnValueofNonExistantConstant' => [ + 'returnValueofNonExistentConstant' => [ 'code' => ' 'UnresolvableConstant', ], - 'takeKeyofNonExistantConstant' => [ + 'takeKeyofNonExistentConstant' => [ 'code' => ' 'DeprecatedProperty', ], diff --git a/tests/ErrorBaselineTest.php b/tests/ErrorBaselineTest.php index 3b4741f5883..ee94c407cd4 100644 --- a/tests/ErrorBaselineTest.php +++ b/tests/ErrorBaselineTest.php @@ -353,26 +353,26 @@ public function testCreateShouldAggregateIssuesPerFile(): void $this->assertSame( 3, count($file1Issues[0]->getElementsByTagName('code')), - 'MixedAssignment should have occured 3 times', + 'MixedAssignment should have occurred 3 times', ); $this->assertSame('MixedOperand', $file1Issues[1]->tagName); $this->assertSame( 1, count($file1Issues[1]->getElementsByTagName('code')), - 'MixedOperand should have occured 1 time', + 'MixedOperand should have occurred 1 time', ); $this->assertSame('MixedAssignment', $file2Issues[0]->tagName); $this->assertSame( 2, count($file2Issues[0]->getElementsByTagName('code')), - 'MixedAssignment should have occured 2 times', + 'MixedAssignment should have occurred 2 times', ); $this->assertSame('TypeCoercion', $file2Issues[1]->tagName); $this->assertSame( 1, count($file2Issues[1]->getElementsByTagName('code')), - 'TypeCoercion should have occured 1 time', + 'TypeCoercion should have occurred 1 time', ); return true; diff --git a/tests/IssueBufferTest.php b/tests/IssueBufferTest.php index d167cf59317..9e43b997e88 100644 --- a/tests/IssueBufferTest.php +++ b/tests/IssueBufferTest.php @@ -118,14 +118,14 @@ public function testFinishDoesNotCorruptInternalState(): void $codebase->analyzer = $analyzer; $codebase->config = $config; - $projectAnalzyer = $this->createMock(ProjectAnalyzer::class); - $projectAnalzyer->method('getCodebase')->willReturn($codebase); + $projectAnalyzer = $this->createMock(ProjectAnalyzer::class); + $projectAnalyzer->method('getCodebase')->willReturn($codebase); - $projectAnalzyer->stdout_report_options = new ReportOptions(); - $projectAnalzyer->generated_report_options = []; + $projectAnalyzer->stdout_report_options = new ReportOptions(); + $projectAnalyzer->generated_report_options = []; ob_start(); - IssueBuffer::finish($projectAnalzyer, false, microtime(true), false, $baseline); + IssueBuffer::finish($projectAnalyzer, false, microtime(true), false, $baseline); $output = ob_get_clean(); $this->assertStringNotContainsString("ERROR", $output, "all issues baselined"); IssueBuffer::clear(); diff --git a/tests/Loop/ForeachTest.php b/tests/Loop/ForeachTest.php index 0777815cb5e..d0c272c5a4f 100644 --- a/tests/Loop/ForeachTest.php +++ b/tests/Loop/ForeachTest.php @@ -428,7 +428,7 @@ function getStrings(): array { 'MixedAssignment', ], ], - 'noMixedAssigmentWithIfAssertion' => [ + 'noMixedAssignmentWithIfAssertion' => [ 'code' => ' [ + 'noMixedAssignmentWithAssertion' => [ 'code' => ' [ + 'assignedConditionallyReassignedToMixedInLoop' => [ 'code' => 'analyzeFile('somefile.php', $context); } - public function testOverrideParentClassRetunType(): void + public function testOverrideParentClassReturnType(): void { Config::getInstance()->use_phpdoc_method_without_magic_or_parent = true; @@ -1738,7 +1738,7 @@ public function otherMethod(): void {} /** @var A & B $b */ $b = new B(); - $b->nonExistantMethod(); + $b->nonExistentMethod(); ', ); diff --git a/tests/MethodSignatureTest.php b/tests/MethodSignatureTest.php index c4bbce5882a..4c763c711fe 100644 --- a/tests/MethodSignatureTest.php +++ b/tests/MethodSignatureTest.php @@ -743,7 +743,7 @@ public function getPrevious(): ?\Throwable; public function getTraceAsString(): string; }', ], - 'allowExecptionToStringWithNoType' => [ + 'allowExceptionToStringWithNoType' => [ 'code' => ' [ + 'allowExceptionToStringIn71' => [ 'code' => ' ' [ + 'allowMixedAssignmentWhenDesired' => [ 'code' => ' [ + 'uninitializedPropertySuppressPropertyNotSetInConstructor' => [ 'code' => ' [], 'ignored_issues' => ['PropertyNotSetInConstructor'], ], - 'unitializedPropertySuppressPropertyNotSetInAbstractConstructor' => [ + 'uninitializedPropertySuppressPropertyNotSetInAbstractConstructor' => [ 'code' => 'foo;', ], - 'promotedPublicPropertyWitoutDefault' => [ + 'promotedPublicPropertyWithoutDefault' => [ 'code' => ' 'InvalidPropertyAssignmentValue', ], - 'unitializedProperty' => [ + 'uninitializedProperty' => [ 'code' => ' 'UninitializedProperty', ], - 'unitializedPropertyWithoutType' => [ + 'uninitializedPropertyWithoutType' => [ 'code' => ' 'UninitializedProperty', 'ignored_issues' => ['MixedArgument', 'MissingPropertyType'], ], - 'unitializedObjectProperty' => [ + 'uninitializedObjectProperty' => [ 'code' => ' 'InaccessibleProperty', ], - 'readonlyPropertySetInConstructorAndAlsoAnotherMethodInSublass' => [ + 'readonlyPropertySetInConstructorAndAlsoAnotherMethodInSubclass' => [ 'code' => ' [ + 'implicitIteratorTemplating' => [ 'code' => ' @@ -2089,7 +2089,7 @@ public function getValue() } }', ], - 'extendsArryObjectGetIterator' => [ + 'extendsArrayObjectGetIterator' => [ 'code' => ' [ + 'classTemplateSelf' => [ 'code' => 'entity = $qux; diff --git a/tests/Template/ConditionalReturnTypeTest.php b/tests/Template/ConditionalReturnTypeTest.php index bc5e88777da..2f41046b7aa 100644 --- a/tests/Template/ConditionalReturnTypeTest.php +++ b/tests/Template/ConditionalReturnTypeTest.php @@ -652,7 +652,7 @@ function get(string $name) { '$expect_mixed_from_literal' => 'mixed', ], ], - 'isArryCheckOnTemplate' => [ + 'isArrayCheckOnTemplate' => [ 'code' => ' @@ -885,7 +885,7 @@ function getSomethingElse() 'ignored_issues' => [], 'php_version' => '7.2', ], - 'ineritedConditionalTemplatedReturnType' => [ + 'inheritedConditionalTemplatedReturnType' => [ 'code' => ' 'string, string', ], - 'SKIPPED-noCrashWhenOnUnparseableTemplatedAssertion' => [ + 'SKIPPED-noCrashWhenOnUnparsableTemplatedAssertion' => [ 'code' => ' 'list<1|2>', ], ], - 'callableWithReturnTypeTypeAliasWithinBackets' => [ + 'callableWithReturnTypeTypeAliasWithinBrackets' => [ 'code' => 'assertSame('array', (string) Type::parseString('array')); } - public function testNonEmptyArrray(): void + public function testNonEmptyArray(): void { $this->assertSame('non-empty-array', (string) Type::parseString('non-empty-array')); } @@ -152,7 +152,7 @@ public function testNullOrIntersection(): void $this->assertSame('I1&I2|null', (string) Type::parseString('null|I1&I2')); } - public function testInteratorAndTraversable(): void + public function testIteratorAndTraversable(): void { $this->assertSame('Iterator&Traversable', (string) Type::parseString('Iterator&Traversable')); } diff --git a/tests/TypeReconciliation/ArrayKeyExistsTest.php b/tests/TypeReconciliation/ArrayKeyExistsTest.php index 4317379eb7b..c1d30ac5d44 100644 --- a/tests/TypeReconciliation/ArrayKeyExistsTest.php +++ b/tests/TypeReconciliation/ArrayKeyExistsTest.php @@ -155,7 +155,7 @@ function bar(?string $key): bool { echo $a[0]; }', ], - 'arrayKeyExistsShoudldNotModifyIntType' => [ + 'arrayKeyExistsShouldNotModifyIntType' => [ 'code' => ' [ + 'looseEqualityShouldNotConvertMixedToString' => [ 'code' => ' */ - public function providerTestReconcilation(): array + public function providerTestReconciliation(): array { return [ 'notNullWithObject' => ['SomeClass', new IsNotType(new TNull()), 'SomeClass'], diff --git a/tests/UnusedVariableTest.php b/tests/UnusedVariableTest.php index 15bf8b182a3..729ef095f5b 100644 --- a/tests/UnusedVariableTest.php +++ b/tests/UnusedVariableTest.php @@ -2314,7 +2314,7 @@ function foo(int &$d): void { $d += $l; }', ], - 'mixedArrayAccessMighBeObject' => [ + 'mixedArrayAccessMightBeObject' => [ 'code' => '