Bruce Weirdan
4a5f433831
Merge pull request #10729 from ohader/revert-10242-5.x
2024-02-21 17:07:02 -04:00
Bruce Weirdan
3cd9658d29
Allow Override
attribute to be used in pure contexts
...
Fixes vimeo/psalm#10731
2024-02-21 12:25:30 +01:00
kkmuffme
e482c078a7
code style whitespace fixes including for unrelated tests
2024-02-20 22:28:12 +01:00
kkmuffme
9d8080096c
Fix RiskyTruthyFalsyComparison reporting irrelevant errors when there is no explicit truthy/falsy type
2024-02-20 22:28:12 +01:00
Oliver Hader
679aaf0939
Revert "Allow tainted numerics except for 'html' and 'has_quotes'"
2024-02-20 13:55:31 +01:00
kkmuffme
4ac18720aa
Revert https://github.com/vimeo/psalm/pull/10039 and fix type and test
2024-02-19 14:14:24 +01:00
kkmuffme
f035c00a21
Fix non-empty-lowercase-string handling with literal non-lowercase strings
...
* Fix https://github.com/vimeo/psalm/issues/9782 and related issues
* add explicit handling for non-falsy-string to not fallback non-falsy-string and 0 to string
2024-02-19 11:32:52 +01:00
Bruce Weirdan
d3c1222152
Merge pull request #10704 from issidorov/fix-detecting-magic-static-methods
2024-02-17 10:45:23 -04:00
Bruce Weirdan
03fcf68d9e
Allow multiple spaces between type name and type definition
2024-02-15 23:34:17 +01:00
893b60ed0d
Improve parsing of psalm-type
2024-02-15 23:34:16 +01:00
Ivan Sidorov
5a66742e70
Failed and regression tests with suppression "UndefinedMethod"
...
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 <weirdan@gmail.com>
2024-02-14 22:17:26 +00:00
Ivan Sidorov
37240624f6
Fix description InvalidCodeAnalysisWithIssuesTestTrait
...
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2024-02-14 22:17:26 +00:00
Ivan Sidorov
b7a20802da
Fix description in InvalidCodeAnalysisWithIssuesTestTrait
2024-02-14 15:47:10 +00:00
Ivan Sidorov
08a479aede
Rename to TestCase::assertHasIssue
2024-02-14 15:42:44 +00:00
Ivan Sidorov
cfd0fd1554
Use snake_case in TestCase::assertHasIssueType
2024-02-14 15:41:00 +00:00
Ivan Sidorov
db929912fe
Fix message in TestCase::assertHasIssueType
...
Apply suggestions from code review.
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2024-02-14 09:57:24 +03:00
Ivan Sidorov
9b6ef8beef
Failed and regression tests with creation of a list of issues
...
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
```
2024-02-13 17:25:16 +00:00
Ivan Sidorov
d588b3d251
Support for testing with the creation of a list of issues
...
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".
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
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
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
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
Bruce Weirdan
395f3f7862
Merge pull request #10690 from weirdan/9649-this-out-on-constructors
2024-02-11 16:34:25 -04: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
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
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
robchett
7289f642d9
Fix other assertion errors with union templates
2024-02-07 21:35:24 +00: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
1c36da6dda
Strip callmap prefixes from parameter names
...
Fixes vimeo/psalm#10662
2024-02-06 20:52:42 +01: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
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
Bruce Weirdan
5d671a4775
Merge pull request #10630 from kkmuffme/additional-fix-for-inconsistent-basedir
2024-02-05 15:01:51 -04:00
Bruce Weirdan
578046da4a
Merge pull request #10651 from edsrzf/missing-override
2024-02-05 07:16:40 -04:00
Bruce Weirdan
c40f232d31
Merge pull request #10629 from edsrzf/analyze-dynamic-fetches
2024-02-05 07:16:03 -04:00
Evan Shaw
4cec31eba9
Test for dynamic enum fetch
2024-02-05 21:56:30 +13:00
Evan Shaw
a827806709
ParseError for dynamic constants before PHP 8.3
2024-02-05 21:49:40 +13:00
Bruce Weirdan
ddb02b9e94
Merge pull request #10603 from weirdan/fix-existing_whatever-references
2024-02-05 01:05:38 -04:00
Bruce Weirdan
52eadab971
Late binding of enum cases
...
Resolves a number of long-standing bugs ('Failed to infer case value ...')
Fixes vimeo/psalm#10374
Fixes vimeo/psalm#10560
Fixes vimeo/psalm#10643
Fixes vimeo/psalm#8978
2024-02-05 04:12:19 +01:00
Bruce Weirdan
6d572a681c
Apply suggestions from code review
2024-02-04 20:43:08 +01:00
Bruce Weirdan
b2a2cd7884
Allow adding Closure
as a native property type
2024-02-04 19:20:54 +01:00
Bruce Weirdan
e8b47f7d42
Do not add callable
as a native property type
...
It's invalid in all PHP versions: https://3v4l.org/bXWo2
Also see php.net/manual/en/language.types.declarations.php#language.types.declarations.base.function
Fixes vimeo/psalm#10650
2024-02-04 18:52:20 +01:00
Evan Shaw
8396360d30
Emit MissingOverrideAttribute
2024-02-04 21:07:27 +13:00
Evan Shaw
c71ad2221c
Move Override tests to separate file
2024-02-04 21:07:27 +13:00
Evan Shaw
7d07e258a3
Add MissingOverrideAttribute issue
2024-02-04 21:07:22 +13:00
Evan Shaw
ea9cb44699
Emit InvalidOverride
2024-02-04 09:01:30 +13:00
Evan Shaw
07f4045ccd
Add InvalidOverride issue
2024-02-04 09:01:30 +13:00
robchett
9d4fd4011d
Support user defined types for psalm-check-type
2024-02-03 18:26:20 +00:00
robchett
526013e77e
Fix check-type when using reserved types from within a namespace
2024-02-03 18:09:23 +00:00
kkmuffme
47c52ad602
fix /src/psalm.xml not removed between tests and remove psalm.xml at the end of tests
2024-02-01 20:11:06 +01:00
kkmuffme
d4a5909e1f
Fix additional places where base_dir was broken due to missing separator
...
Improves upon https://github.com/vimeo/psalm/pull/10542 and https://github.com/vimeo/psalm/pull/10628
2024-02-01 20:11:06 +01:00
robchett
421cb0f7a1
Allow enum cases to be global constants
2024-02-01 18:38:46 +01:00
Evan Shaw
88c2e00d02
Analyze dynamic class const names
2024-02-01 17:40:25 +13:00
Evan Shaw
a66aace523
Analyze dynamic static property names
2024-02-01 17:31:15 +13:00
Bruce Weirdan
6140f6881c
Allow typedef imports from any classlike type
...
All we really need is for the source to be autoloadable, and it includes
all classlikes (interfaces, classes, enums and traits at the time of
writing).
2024-01-31 23:07:23 +01:00
Bruce Weirdan
9ec556bb14
Allow inline comments in typedef shapes
...
Fixes vimeo/psalm#10492
2024-01-31 22:03:36 +01:00
kkmuffme
551625aa4b
Fix https://github.com/vimeo/psalm/issues/10561 numeric input incorrect return type
2024-01-31 14:11:10 +01:00
fluffycondor
6aa2ddfe1c
Fix ownerDocument type
2024-01-31 16:10:51 +06:00
Bruce Weirdan
6d32d2f692
Allow importing typedefs from enums
...
Fixes vimeo/psalm#10416
2024-01-30 20:29:51 +01:00
Bruce Weirdan
ca9a12ddda
Report MissingConstructor
for natively typed mixed properties
...
Fixes vimeo/psalm#10589
2024-01-30 17:24:27 +01:00
Bruce Weirdan
b2aebd90a7
Fix test by preloading interface
2024-01-29 22:43:05 +01:00
Bruce Weirdan
e8763968a0
Un-ignore arrayobject::getiterator - appears it's been fixed too
2024-01-29 22:43:05 +01:00
Bruce Weirdan
c935cc307b
Un-ignore recursiveiteratoriterator::__construct
2024-01-29 22:43:05 +01:00
Bruce Weirdan
58b7139470
Reflection may reference interfaces and enums
2024-01-29 22:43:05 +01:00
Bruce Weirdan
f045730927
Merge pull request #10598 from weirdan/key_exists-is-an-alias-for-array_key_exists
2024-01-29 16:23:35 -04:00
Bruce Weirdan
fd1294eef4
Merge pull request #10599 from weirdan/allow-properties-on-intersections-with-enum-interfaces
2024-01-29 16:23:20 -04:00
Bruce Weirdan
67a91e05b2
Do not validate callable arguments in lenient contexts
...
Fixes vimeo/psalm#10453
2024-01-27 16:38:37 +01:00
Bruce Weirdan
c1e22ddcaa
Allow properties on intersections with enum interfaces
...
Fixes vimeo/psalm#10585
2024-01-27 14:37:26 +01:00
Bruce Weirdan
6e2effaf9a
key_exists()
is an alias for array_key_exists()
...
Fixes vimeo/psalm#10346
2024-01-27 13:41:43 +01:00
Ivan Sidorov
10402c426b
Partial revert "Fix auto completion by partial property or method"
...
Filtering is not necessary. Clients using LSP should filter the results themselves.
That's what it says in the documentation.
This reverts commit d6faff2844
.
2024-01-26 12:23:36 +00:00
orklah
25b07fb6e2
Merge pull request #10586 from klimick/fix-template-replacement
...
Fix template replacement edge case
2024-01-25 00:00:36 +01:00
klimick
c307bcbc76
Try to fix template replacement edge case
2024-01-22 13:36:08 +03:00
Evan Shaw
d3eb02a93b
Fix ClassTest case
2024-01-19 16:59:45 +13:00
Evan Shaw
eb7ce32f40
Fix TemporaryUpdateTest cases
2024-01-19 16:59:38 +13:00
Evan Shaw
d17757c422
Fix PropertyTypeTest case
2024-01-19 16:59:33 +13:00
f7edaa66ac
Fix #10552
2024-01-18 20:33:54 +01:00
94efd67515
Improve tests
2024-01-18 13:10:32 +01:00
23543218dc
Fix template, conditional array keys
2024-01-18 12:59:56 +01:00
kkmuffme
5643cf53d4
fix mixed test not actually checking mixed (since superglobals have a more specific type now)
2024-01-15 10:11:22 +01:00
kkmuffme
dca17bcb6a
unrelated fix spelling
2024-01-15 10:11:22 +01:00
kkmuffme
93dc2219e0
fix bugs in tests
2024-01-15 10:11:22 +01:00
kkmuffme
19b1a33a20
fix possibly undefined array key in keyed array doesnt include null when not validated
...
Fix https://psalm.dev/r/b153d0d248 to return 'a'|null instead of 'a' - this is required as otherwise empty would report RedundantCondition errors now which would bring back https://github.com/vimeo/psalm/issues/2681
2024-01-15 10:11:22 +01:00
kkmuffme
fb93aede12
create a separate issue type
2024-01-15 10:11:21 +01:00
kkmuffme
f3543ca9ab
add the fix for empty() too and fix empty returning bool on true/false only cases hiding errors when functions called
2024-01-15 10:11:21 +01:00
kkmuffme
d5b713e439
Fix https://github.com/vimeo/psalm/issues/10501 - report error for non-strict comparison on truthy+falsy union
2024-01-15 10:11:21 +01:00
orklah
b9583493b0
Merge pull request #10499 from kkmuffme/fix-empty-string-becomes-non-empty-string-when-literal-strings-disabled
...
Fix empty literal string becomes non-empty-string
2024-01-14 23:41:50 +01:00
orklah
6e8692513a
Merge pull request #10544 from kkmuffme/improve-extract-variable-assignments
...
add support for extract to set variables for keyed arrays and respect EXTR_SKIP
2024-01-14 23:40:39 +01:00
kkmuffme
f940c029e1
make basename & dirname return types more specific
2024-01-14 19:01:46 +01:00
kkmuffme
02467fbb6a
add support for extract to set variables for keyed arrays and respect EXTR_SKIP
2024-01-14 10:54:02 +01:00
kkmuffme
4c54b68f30
code style
2024-01-13 17:12:41 +01:00