Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update master from 5.x #10750

Merged
merged 49 commits into from
Feb 26, 2024
Merged

Update master from 5.x #10750

merged 49 commits into from
Feb 26, 2024

Conversation

weirdan
Copy link
Collaborator

@weirdan weirdan commented Feb 25, 2024

  • Failed and regression tests for magic static methods
  • Add argument with_pseudo for method finding
  • Add issue message for magic methods
  • Extract checking method "__callStatic" from block "if"
  • Resolve testReferencedMethods
  • Delete code of replacing variable method_id
  • Resolved all tests
  • Failed and regression tests with usage config
  • Resolve testAnnotationWithoutCallConfigWithExtendsWithStatic
  • Fix invalid test
  • Failed tests for StaticInvocation and NonStaticSelfCall
  • Resolve tests for StaticInvocation and NonStaticSelfCall
  • Support for testing with the creation of a list of issues
  • Failed and regression tests with creation of a list of issues
  • Resolve tests with creation of a list of issues
  • Fix message in TestCase::assertHasIssueType
  • Use snake_case in TestCase::assertHasIssueType
  • Rename to TestCase::assertHasIssue
  • Fix description in InvalidCodeAnalysisWithIssuesTestTrait
  • Fix description InvalidCodeAnalysisWithIssuesTestTrait
  • Failed and regression tests with suppression "UndefinedMethod"
  • Resolve tests with suppression "UndefinedMethod"
  • Fix non-empty-lowercase-string handling with literal non-lowercase strings
  • Revert Fix combination of non-falsy-string and falsy literal #10039 and fix type and test
  • Update PHP 8.2 stubs to include SensitiveParameterValue
  • Add list of statements to BeforeFileAnalysisEvent
  • Drop superfluous fetching of statements from event
  • Revert "Allow tainted numerics except for 'html' and 'has_quotes'"
  • Fix RiskyTruthyFalsyComparison reporting irrelevant errors when there is no explicit truthy/falsy type
  • code style whitespace fixes including for unrelated tests
  • Allow Override attribute to be used in pure contexts
  • Catch missing classlike exceptions during scanning
  • Add more tests for native intersection types in class properties
  • Use TaintKind/TaintKindGroup constants instead of string values
  • Fix loading stubs from phar file on Windows
  • Skip symlink test on Windows

issidorov and others added 30 commits February 13, 2024 17:25
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.
```
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
     )
 )
```
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
     )
 )
 ```
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
```
Resolved problem:

```
1) MagicMethodAnnotationTest::testSealAllMethodsSetToFalseWithStatic
Psalm\Exception\CodeException: UndefinedMagicMethod - somefile.php:8:15 - Magic method B::foo does not exist
```
Failed test:
```
1) MagicMethodAnnotationTest::testAnnotationWithoutCallConfigWithExtendsWithStatic
Failed asserting that exception of type "Psalm\Exception\CodeException" is thrown.
```
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
```
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
```
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.
```
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.
```
Description of motivation.

We currently have two different behaviors for the code related to
"CodeException":

```
$codebase->config->throw_exception = true; // or false
```

If "throw_exception" is set to `true`, code execution stops.

If "throw_exception" is set to `false`, the code may continue
to execute, and an error may potentially occur.

This commit allows testing for the second case, when the value of
"throw_exception" will be "false".
Failed tests:
```
1) Psalm\Tests\MagicMethodAnnotationTest::testInvalidCodeWithIssues with data set "staticInvocationWithMagicMethodFoo"
UnexpectedValueException: Cannot get method params for A::foo

2) Psalm\Tests\MagicMethodAnnotationTest::testInvalidCodeWithIssues with data set "nonStaticSelfCallWithMagicMethodFoo"
UnexpectedValueException: Cannot get method params for B::foo
```
Resolved problems:
```
1) Psalm\Tests\MagicMethodAnnotationTest::testInvalidCodeWithIssues with data set "staticInvocationWithMagicMethodFoo"
UnexpectedValueException: Cannot get method params for A::foo

2) Psalm\Tests\MagicMethodAnnotationTest::testInvalidCodeWithIssues with data set "nonStaticSelfCallWithMagicMethodFoo"
UnexpectedValueException: Cannot get method params for B::foo
```
Apply suggestions from code review.

Co-authored-by: Bruce Weirdan <[email protected]>
Apply suggestions from code review.

Failed tests:
```
1) MagicMethodAnnotationTest::testValidCode with data set "magicStaticMethodInheritanceWithoutCallStatic"
Psalm\Exception\CodeException: UnusedPsalmSuppress - src/somefile.php:9:58 - This suppression is never used

2) MagicMethodAnnotationTest::testValidCode with data set "magicStaticMethodInheritanceWithoutCallStatic_WithReturnAndManyArgs"
Psalm\Exception\CodeException: TooManyArguments - src/somefile.php:9:6 - Too many arguments for B::bar - expecting 0 but saw 2
```

Co-authored-by: Bruce Weirdan <[email protected]>
Apply suggestions from code review.

Resolved problems:
```
1) MagicMethodAnnotationTest::testValidCode with data set "magicStaticMethodInheritanceWithoutCallStatic"
Psalm\Exception\CodeException: UnusedPsalmSuppress - src/somefile.php:9:58 - This suppression is never used

2) MagicMethodAnnotationTest::testValidCode with data set "magicStaticMethodInheritanceWithoutCallStatic_WithReturnAndManyArgs"
Psalm\Exception\CodeException: TooManyArguments - src/somefile.php:9:6 - Too many arguments for B::bar - expecting 0 but saw 2
```
…rings

* Fix vimeo#9782 and related issues
* add explicit handling for non-falsy-string to not fallback non-falsy-string and 0 to string
weirdan and others added 18 commits February 20, 2024 07:07
…e-context

Allow `Override` attribute to be used in pure contexts
This may resolve vimeo#10706, although I'm not exactly convinced it's the
best way.
Use TaintKind/TaintKindGroup constants instead of string values
Fixes vimeo#6449

Symlinks on Windows are rare (and quite unreliable)
…rom-phar-on-windows

Fix loading stubs from phar file on Windows
@weirdan weirdan added the release:internal The PR will be included in 'Internal changes' section of the release notes label Feb 25, 2024
@weirdan weirdan requested review from danog and orklah February 25, 2024 14:35
@weirdan weirdan force-pushed the update-master branch 2 times, most recently from 4273e3b to 33140d2 Compare February 25, 2024 14:43
@weirdan weirdan marked this pull request as ready for review February 25, 2024 15:08
@weirdan weirdan merged commit b940c7e into vimeo:master Feb 26, 2024
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:internal The PR will be included in 'Internal changes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants