1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00
Commit Graph

14329 Commits

Author SHA1 Message Date
Ivan Sidorov
4c645e186c Resolve tests for StaticInvocation and NonStaticSelfCall
The code has been moved from down to up.

Resolved problems:
```
1) MagicMethodAnnotationTest::testInvalidCode with data set "staticInvocationWithInstanceMethodFoo"
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.

2) MagicMethodAnnotationTest::testInvalidCode with data set "nonStaticSelfCallWithInstanceMethodFoo"
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
6f17469b24 Failed tests for StaticInvocation and NonStaticSelfCall
Failed tests:
```
1) MagicMethodAnnotationTest::testInvalidCode with data set "staticInvocationWithInstanceMethodFoo"
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.

2) MagicMethodAnnotationTest::testInvalidCode with data set "nonStaticSelfCallWithInstanceMethodFoo"
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
6009631567 Fix invalid test
This test has been failed with an error "UndefinedMethod".
This error is being issued correctly.

But so that this error would not interfere with the test, it was suppressed.

Fixed problem:
```
MagicMethodAnnotationTest::testValidCode with data set "magicStaticMethodInheritanceWithoutCallStatic"
Psalm\Exception\CodeException: UndefinedMethod - src/somefile.php:9:32 - Method B::bar does not exist
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
14316f55ba Resolve testAnnotationWithoutCallConfigWithExtendsWithStatic
Resolved error:
```
MagicMethodAnnotationTest::testAnnotationWithoutCallConfigWithExtendsWithStatic
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.
```

Appended problem:
```
MagicMethodAnnotationTest::testValidCode with data set "magicStaticMethodInheritanceWithoutCallStatic"
Psalm\Exception\CodeException: UndefinedMethod - src/somefile.php:9:32 - Method B::bar does not exist
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
4fce0700bf Failed and regression tests with usage config
Failed test:
```
1) MagicMethodAnnotationTest::testAnnotationWithoutCallConfigWithExtendsWithStatic
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
5f89fa1730 Resolved all tests
Resolved problem:

```
1) MagicMethodAnnotationTest::testSealAllMethodsSetToFalseWithStatic
Psalm\Exception\CodeException: UndefinedMagicMethod - somefile.php:8:15 - Magic method B::foo does not exist
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
0ba346c5a0 Delete code of replacing variable method_id
The main task for deleting:
```
$method_id = new MethodIdentifier(
    $fq_class_name,
    '__callstatic',
);
```

List of resolved problems:
```
1) Psalm\Tests\MagicMethodAnnotationTest::testNoSealAllMethodsWithStatic
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.

2) Psalm\Tests\MagicMethodAnnotationTest::testSealAllMethodsWithoutFooWithStatic
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.

3) Psalm\Tests\MagicMethodAnnotationTest::testInvalidCode with data set "inheritSealedMethodsWithStatic"
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.
```

Appended problem by that fix:
```
1) MagicMethodAnnotationTest::testSealAllMethodsSetToFalseWithStatic
Psalm\Exception\CodeException: UndefinedMagicMethod - somefile.php:8:15 - Magic method B::foo does not exist
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
df2067dd74 Resolve testReferencedMethods
Resolved problem:
```
FileReferenceTest::testReferencedMethods with data set "getClassReferences"
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
         'foo\b::__construct' => true
         'foo\c::foo' => true
     )
-    'foo\c::__construct' => Array &2 (
+    'foo\a::__callstatic' => Array &2 (
+        'foo\b::__construct' => true
+    )
+    'foo\c::__construct' => Array &3 (
         'foo\b::bar' => true
     )
 )
 ```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
2567a99347 Extract checking method "__callStatic" from block "if"
Appended problem by that commit:
```
1) FileReferenceTest::testReferencedMethods with data set "getClassReferences"
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
         'foo\b::__construct' => true
         'foo\c::foo' => true
     )
-    'foo\c::__construct' => Array &2 (
+    'foo\a::__callstatic' => Array &2 (
+        'foo\b::__construct' => true
+    )
+    'foo\c::__construct' => Array &3 (
         'foo\b::bar' => true
     )
 )
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
083b8e26db Add issue message for magic methods 2024-02-13 17:25:16 +00:00
Ivan Sidorov
29b4c38a94 Add argument with_pseudo for method finding 2024-02-13 17:25:16 +00:00
Ivan Sidorov
6e361aa9e6 Failed and regression tests for magic static methods
List failed tests:
```
1) Psalm\Tests\MagicMethodAnnotationTest::testNoSealAllMethodsWithStatic
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.

2) Psalm\Tests\MagicMethodAnnotationTest::testSealAllMethodsWithoutFooWithStatic
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.

3) Psalm\Tests\MagicMethodAnnotationTest::testInvalidCode with data set "inheritSealedMethodsWithStatic"
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.
```
2024-02-13 17:25:16 +00:00
Bruce Weirdan
fe2c67ec89
Merge pull request #10699 from staabm/taint-doc 2024-02-13 10:22:51 -04:00
Markus Staab
f5fb9498de Use IssueBuffer::maybeAdd() instead of throwing 2024-02-13 09:11:11 +01:00
Markus Staab
c3526b4463 fix test 2024-02-12 14:04:50 +01:00
Markus Staab
da69803823 Report invalid number of arguments for psalm-taint-* 2024-02-12 10:46:45 +01:00
Bruce Weirdan
395f3f7862
Merge pull request #10690 from weirdan/9649-this-out-on-constructors 2024-02-11 16:34:25 -04:00
Bruce Weirdan
13ebb91caf
Merge pull request #10691 from weirdan/10170-reports-unknown-static-methods-in-first-class-callables 2024-02-11 16:28:23 -04:00
Bruce Weirdan
a8c093aea2
Handle taking references to unspecified magic methods 2024-02-11 02:45:24 +01:00
Bruce Weirdan
d10e384338
Report first class callables generated for unknown static methods
Fixes vimeo/psalm#10170
2024-02-11 02:24:27 +01:00
Bruce Weirdan
def0489b98
Process @psalm-this-out on __construct() as well
Fixes vimeo/psalm#9649
2024-02-11 01:53:30 +01:00
Bruce Weirdan
ceaea625f3
Merge pull request #10675 from robchett/prevent_nullable_mixed 2024-02-10 14:20:36 -04:00
Bruce Weirdan
2a063ff843
Merge pull request #10686 from weirdan/forbid-constructor-return-values 2024-02-09 20:56:17 -04:00
Bruce Weirdan
6b405937ab
Forbid constructors from returning any values
Fixes vimeo/psalm#9713
2024-02-10 01:34:51 +01:00
Bruce Weirdan
ba4e312594
Merge pull request #10678 from weirdan/10669-class-consts-in-shapes 2024-02-09 13:00:19 -04:00
robchett
5579fd469b Prevent mixed|null when function param is mixed with a null default value 2024-02-08 20:22:57 +00:00
Bruce Weirdan
2f0b85ff65
Support parsing constants in shapes
Fixes vimeo/psalm#10669
2024-02-08 04:30:42 +01:00
Bruce Weirdan
fa5f15058b
Merge pull request #10091 from vudaltsov/improve-refelection-stubs 2024-02-07 22:18:56 -04:00
Bruce Weirdan
f9a23149fe
Merge pull request #10679 from weirdan/8323-dont-show-backtrace-in-InvalidDocblock-issue-message 2024-02-07 22:00:01 -04:00
Bruce Weirdan
6b6bed5850
Don't show backtrace in InvalidDocblock issue message
Fixes vimeo/psalm#8323
2024-02-08 01:20:57 +01:00
Bruce Weirdan
aedea60827
Merge pull request #10677 from robchett/template_union_object_incorrect_assertions 2024-02-07 18:25:02 -04:00
Bruce Weirdan
06dbd4e4d3
Merge pull request #10676 from weirdan/10667-narrow-ord-return-type 2024-02-07 17:41:43 -04:00
robchett
7289f642d9 Fix other assertion errors with union templates 2024-02-07 21:35:24 +00:00
robchett
2d48916f8a Fix is_object false positive when 'V as int|stdClass' 2024-02-07 21:14:58 +00:00
Bruce Weirdan
f9044cb4e4
Narrow ord() return type to int<0,255>
Fixes vimeo/psalm#10667
2024-02-07 21:49:59 +01:00
Valentin Udaltsov
f9ff9d34f0 Added ReflectionParameter::getPosition to CallMap_historical.php 2024-02-07 02:47:49 +03:00
Valentin Udaltsov
07a64f6894 Improved Reflection stubs
ReflectionParameter::getPosition() is non-negative-int.
ReflectionMethod name property is always non-empty-string.
ReflectionAttribute::getTarget() returns Attribute::TARGET_* instead of int-mask. Even for attributes of promoted properties (https://3v4l.org/rpM1t).
*::getAttributes() always returns a list (https://3v4l.org/LYAMb).
2024-02-07 02:39:56 +03:00
4a5dbcaebc
Merge pull request #10671 from danog/temp_revert
Revert partial mistakenly pushed fix
2024-02-06 23:52:24 +01:00
b42c273556 Revert partial mistakenly pushed fix
This reverts commit 7d19f30961.
2024-02-06 23:42:11 +01:00
7d19f30961
Fix #10667 2024-02-06 23:35:18 +01:00
Bruce Weirdan
b54e0b2fd6
Merge pull request #10666 from weirdan/10662-strip-callmap-prefixes-from-parameter-names 2024-02-06 16:07:48 -04:00
Bruce Weirdan
2fc2a37ca0
Merge pull request #10665 from issidorov/parsing-magic-methods 2024-02-06 16:00:22 -04:00
Bruce Weirdan
1c36da6dda
Strip callmap prefixes from parameter names
Fixes vimeo/psalm#10662
2024-02-06 20:52:42 +01:00
Ivan Sidorov
afaaa3d6df Fix parsing magic method annotations
Fix parsing for code:

```
/**
 * @method static (string|int)[] getArray()
 * @method static (callable() : string) getCallable()
 */
class MyClass {}
```

Resolved tests:

```
1) testMethodAnnotation with data set "static (string|int)[] getArray()"
2) testMethodAnnotation with data set "static (callable() : string) getCallable()"
```
2024-02-06 17:01:28 +00:00
Ivan Sidorov
6b3380b05f Regression and fail tests
List fail tests:

```
1) testMethodAnnotation with data set "static (string|int)[] getArray()"
Undefined array key 0

/workspaces/psalm/tests/ClassLikeDocblockParserTest.php:201

2) testMethodAnnotation with data set "static (callable() : string) getCallable()"
Undefined array key 0

/workspaces/psalm/tests/ClassLikeDocblockParserTest.php:201
```
2024-02-06 17:01:28 +00:00
Bruce Weirdan
508da9abd4
Merge pull request #10661 from vimeo/10018-flag-stdclass-constructor-with-arguments 2024-02-05 20:31:26 -04:00
Bruce Weirdan
62b525993d
Flag stdClass::__construct() calls that have arguments
Fixes vimeo/psalm#10018
2024-02-06 01:24:18 +01:00
Bruce Weirdan
46217057a1
Merge pull request #10659 from weirdan/7395-suppress-UndefinedClass-in-whatever_exists 2024-02-05 15:58:25 -04:00
Bruce Weirdan
b822c3339d
Suppress UndefinedClass in whatever_exists()
Fixes vimeo/psalm#7395
2024-02-05 20:44:09 +01:00
Bruce Weirdan
f40e23faef
Merge pull request #10655 from weirdan/late-binding-of-enum-properties 2024-02-05 15:17:42 -04:00