Bruce Weirdan
d6b75057a4
Fix test
2023-02-15 03:02:34 -04:00
Bruce Weirdan
8c491e93e8
Flag class constant references where LHS is ordinary string
...
Fixes vimeo/psalm#2185
2023-02-15 02:57:00 -04:00
Bruce Weirdan
3f2ecaec7e
Allow @var
annotations on global vars
...
The actual code was extracted from `StaticAnalyzer`
Fixes vimeo/psalm#1111
2023-02-15 01:20:03 -04:00
Bruce Weirdan
a538439a87
Add option to skip callmap test
...
With this change, callmap tests can be skipped with
`--exclude-group=callmap`:
```console
$ php-noxdebug vendor/bin/paratest --passthru-php="-dmemory_limit=-1" --exclude-group=callmap
```
2023-02-15 00:30:45 -04:00
Bruce Weirdan
840250c534
Update expectations formatting
...
It's easier to read with consistent indentation
2023-02-14 21:59:01 -04:00
Bruce Weirdan
1ab02125b0
Added issue type and psalm.dev link to Emacs report
...
Fixes vimeo/psalm#8331
2023-02-14 21:19:29 -04:00
Alies Lapatsin
766d1487a9
Merge branch 'master' into disableExtensions-hides-warnings
2023-02-14 20:53:54 +01:00
Alies Lapatsin
cfa4450394
Do not display ext deprecation note when disableExtensions used
...
Fixes #8958
2023-02-14 12:34:49 +01:00
Bruce Weirdan
39c992c255
Emit issues for calls to is_a(string, class-string, false)
...
Fixes vimeo/psalm#4092
2023-02-14 02:25:46 -04:00
Bruce Weirdan
cee90fc071
Compare enum cases thoroughly
...
Fixes vimeo/psalm#7814
2023-02-13 22:39:33 -04:00
orklah
9921625691
Merge pull request #9278 from othercorey/fix-func-callmap
...
Fix remaining callmap functions
2023-02-13 07:10:43 +01:00
Corey Taylor
8fb290eb0d
Fix remaining callmap functions
2023-02-12 23:10:09 -06:00
Bruce Weirdan
873d79c5d7
Forbid overriding built-in enum methods
...
Fixes vimeo/psalm#9274
2023-02-13 00:37:59 -04:00
orklah
5d1fe88d3f
Merge pull request #9272 from weirdan/forbid-extending-some-interfaces
...
Forbid implementing some interfaces
2023-02-12 08:38:54 +01:00
Corey Taylor
42e301cf84
Update callmap types for php 8.2
2023-02-12 01:24:43 -06:00
Bruce Weirdan
085e8f6fb2
Forbid implementing some interfaces
...
- `Throwable` can only be implemented when classes extend one of
`Exception` or `Error`
- `UnitEnum` and `BackedEnum` cannot be implemented by user-defined
classes
Refs vimeo/psalm#7722
2023-02-12 02:48:50 -04:00
Corey Taylor
9547a5cba5
Fix several callmap function signatures
2023-02-11 04:53:11 -06:00
Bruce Weirdan
85d4acf3b3
Fix crash when int range boundary is overflown
...
Fixes vimeo/psalm#9114
2023-02-09 22:57:57 -04:00
Bruce Weirdan
954136679a
Fix crashes with invalid @psalm-check-type
syntax
...
Fixes vimeo/psalm#9201
2023-02-09 17:49:49 -04:00
Bruce Weirdan
1ee0f1bcb8
Merge pull request #9256 from othercorey/spoofchecker-callmap
...
fixes https://github.com/vimeo/psalm/issues/9254
2023-02-09 12:53:42 -04:00
Corey Taylor
b467a0a74e
Fix Spoofchecker callmaps
2023-02-09 10:38:39 -06:00
Bruce Weirdan
250d4d593e
Don't crash on unknown exceptions in @throws
docblock
...
Fixes vimeo/psalm#9248
2023-02-09 02:56:01 -04:00
Bruce Weirdan
3c4a829f71
Fixed more CS issues
2023-02-07 11:20:02 -04:00
Corey Taylor
e8ae1ec084
Convert callmaps resource types
2023-02-06 01:12:14 -06:00
Matthew Brown
d450b40da8
Remove some logic that didn't need to be there ( #9209 )
...
* Remove check to see what breaks
* Simplify following logic
* Add tests from @kkmuffme‘s branch
* Reduce scope of fix
* Clean up logic a little
* Add failing test
* Improvements
* Fix for non-Paradoxical Condition result
2023-02-03 21:08:16 -05:00
orklah
54cd529642
Merge pull request #9170 from mmcev106/filter-var-pure
...
Added @psalm-pure to filter_var()
2023-02-02 23:39:06 +01:00
Corey Taylor
f922e576c8
Fix xmlrpc callmap functions that were dropped in PHP 8.0
2023-02-02 12:21:31 -06:00
Bruce Weirdan
5d930a438a
Fix invalid test cases
2023-02-02 12:27:57 -04:00
Bruce Weirdan
fb65c79079
Fix newly discovered CS issues
2023-02-02 12:19:22 -04:00
Mark McEver
b5781c34e8
Fixed a case where the conditional taint, specialize, & flow features were not playing nicely together
2023-02-01 15:41:52 -06:00
Leo Viezens
7966fd574a
Merge branch 'master' into master
2023-01-30 15:38:29 +01:00
Alies Lapatsin
c55d297d0a
Fix coding style issue
2023-01-29 18:52:09 +01:00
Alies Lapatsin
c75e4bdb28
Merge remote-tracking branch 'origin/unify-deprecation-messages' into unify-deprecation-messages
2023-01-29 18:32:55 +01:00
Alies Lapatsin
7526d60f2a
Update assertion to reflect a new output
...
It reverts 588d9e08bc (diff-1ef46093f20172c4dc1cbe5a54e5b60c255082acd3f7c382dae621d8d23df404R172)
2023-01-29 18:32:31 +01:00
orklah
aec0edc618
Merge pull request #9177 from Nicelocal/duplicate_keys
...
Detect duplicate keys in array shapes
2023-01-25 18:37:22 +01:00
247d30f74c
Detect duplicate keys in array shapes
2023-01-25 10:42:05 +01:00
shvlv
6227943bfb
Allow to scan private constants
2023-01-24 13:31:58 +02:00
shvlv
d6aff3ed20
Parse class constant for PhpStorm Meta override
2023-01-24 12:24:52 +02:00
Bruce Weirdan
70f2fb7d1b
Check $this
in static closures
...
Fixes vimeo/psalm#9148
Fixes vimeo/psalm#2813
2023-01-23 05:16:12 -04:00
Bruce Weirdan
2af7f51394
Suppress warnings when --no-output
is specified
2023-01-22 20:40:21 -04:00
Anner Visser
d86fcf4a85
Narrow ->value of enum case(s) to only the possible values
...
Using $stmt_var_type to determine if we're dealing with a subset of the
enum cases. If so, we only consider those cases for the possible values.
Fixes #8568
Fixes #8812
2023-01-21 12:05:24 +01:00
orklah
9e34de59cb
Merge pull request #9156 from vimeo/indent-docblocks-in-tests
...
Indent docblocks in DocComment test
2023-01-21 00:09:43 +01:00
Bruce Weirdan
bf99b76798
Indent docblocks in DocComment test
...
Since heredocs in PHP 7.3+ automatically strip leading whitespace we can
fix the formatting for this test.
2023-01-20 18:15:07 -04:00
Jack Worman
787b9ae687
Fix dom_import_simplexml()
2023-01-18 18:31:54 -05:00
orklah
dfbd0458f4
Merge pull request #9130 from jack-worman/Report_unmatched_baseline_rules
...
Report unused baseline entries
2023-01-18 18:59:37 +01:00
orklah
466ff68dae
Merge pull request #9122 from othercorey/fix-returns
...
Fix remaining ignored CallMap return types that can be updated
2023-01-18 18:57:05 +01:00
Jack Worman
56f6dfecc8
Report unused baseline entries
2023-01-17 22:02:21 -05:00
Corey Taylor
cfaf763ba7
Fix remaining ignored CallMap return types that can be updated
2023-01-17 17:24:51 -06:00
Jack Worman
f9aa2d5ad3
Support constants in traits
2023-01-17 16:37:44 -05:00
Corey Taylor
66ee278de8
Update conditional test to use filter_input with mixed return
2023-01-15 07:43:26 -06:00
Corey Taylor
bbc522709b
Clean up more callmap return types
2023-01-15 03:57:22 -06:00
Ezequiel
423b1acbd6
Add tests for the remaining int-range
aliases
2023-01-13 11:15:24 -03:00
Emmanuel Guiton
a7c60072dd
Merge branch 'vimeo:master' into master
2023-01-11 13:17:45 +01:00
Emmanuel GUITON
7b212954a9
Additional test and fix when comparing nested templates (vimeo#9094).
2023-01-11 13:17:06 +01:00
Vincent QUATREVIEUX
e5f297ddbb
fix: Handle template type on promoted property #8951
2023-01-10 10:41:48 +01:00
Ryan Bonham
bf62ef8b72
Add assertions to check return types for get_headers
2023-01-09 08:39:19 -05:00
Ryan Bonham
0ba821116e
Fix bad conflict resolution during merge from master.
2023-01-07 19:32:04 -05:00
therealryanbonham
e4e52da218
Merge branch 'master' into 9066_fix_get_headers_signature
2023-01-07 19:27:01 -05:00
Ryan Bonham
ec2f93f33e
Add Test for get_headers associative param in php 7 and php8.
2023-01-07 19:25:04 -05:00
orklah
729c0ba5ed
Merge pull request #9061 from lptn/cleaner_assertions
...
Make it more clear what do we test from Psalm output
2023-01-07 23:16:08 +01:00
orklah
4ec4ed75a6
Merge pull request #9026 from kkmuffme/fix-never-void-combined-null-return-type-false-positives
...
fix implicit return type
2023-01-07 22:32:08 +01:00
Ryan Bonham
e7b5c99255
Remove 'get_headers' from InternalCallMapHandlerTest::$ignoredFunctions
2023-01-06 20:12:02 -05:00
Bruce Weirdan
afb8c8891b
fix I::cases()
where interface I extends BackedEnum
...
Fixes vimeo/psalm#9065
Inheritance in stubs seems to be broken
2023-01-05 21:35:47 -04:00
Alies Lapatsin
5ffb4f2938
Make it more clear what do we test from Psalm output
2023-01-05 18:12:29 +04:00
kkmuffme
d4301455a6
fix test should not change phpdoc to native type hint but keep phpdoc
2023-01-05 09:44:23 +01:00
kkmuffme
25cadb6776
add null to tests to fix invalid return type
2023-01-05 09:44:23 +01:00
kkmuffme
1341c15edc
fix TypeCombiner void => null from docblock missing property
...
* fix InvalidReturnType "Not all code paths of" when function returns null combined types (void, never) https://psalm.dev/r/db4e313898
* fix false positive InvalidReturnType for void|never phpdoc when function returns void and exits
2023-01-05 09:43:19 +01:00
Philip Hofstetter
bab17568dc
fix DateTime::modify() and DateTimeImmutable::modify() return types
...
even though the two methods return types are documented as returning
their respective types, in PHP they are in-fact returning `static`
internally in all versions of PHP currently supported by psalm.
This fixes #9042
2023-01-03 12:11:38 +01:00
orklah
e81823e193
Merge pull request #9035 from othercorey/iterator-returns
...
Fix iterator and exception callmaps
2023-01-01 11:22:39 +01:00
Corey Taylor
e779c5f741
Fix iterator and exception callmaps
2022-12-31 11:34:48 -06:00
kkmuffme
82f71a7ccb
add test
2022-12-31 00:18:08 +01:00
orklah
6353143eaf
Merge pull request #9021 from orklah/nonempty-reconcile
...
Non empty reconciliation
2022-12-29 22:35:12 +01:00
orklah
5bfb87c624
Merge pull request #9022 from Ocramius/fix/#8983-allow-large-union-types-in-array-type-inference
...
Better type inference and type checking for large union types used in array keys/values
2022-12-29 10:48:05 +01:00
orklah
790c30959d
Merge pull request #9016 from Ocramius/feature/#5039-more-refined-types-for-explode-core-function
...
Refined `explode()` types
2022-12-29 10:23:18 +01:00
Marco Pivetta
e6600fea21
Better type inference and type checking for large union types used in array keys/values
...
Fixes #8983
This patch adds a basic test showing that, when reaching a union type with 30 elements
or more, Psalm used to fail with an error, because the large union type got simplified
into a more general type as part of performance optimizations done in `TypeCombiner::combine()`.
This means that a type like `array<1|2|3|(etcetera...)|100, mixed>` was internally
simplified to `array<int, mixed>`, after reaching 30 elements or more, which in turn
led to problems and confusing errors when large union types are in play.
Such union types are relatively common in lookup-table-alike value objects.
By removing the hardcoded call-time limit of `30` types to be combined, we hereby
rely on the default `TypeCombiner::combine()` limit of `500` items, which is more
healthy.
This may come with some performance implications, but it is worth trying out, for
now.
Further parameters passed to `TypeCombiner::combine()` that were already matching
parameter default values were also omitted from the call-sites.
2022-12-29 10:05:23 +01:00
orklah
907729d83a
remove useless imports
2022-12-29 01:00:06 +01:00
orklah
ee98fac581
use Atomic to create the types
2022-12-29 00:51:09 +01:00
orklah
5a002c448b
fix non-empty reconciliation
2022-12-29 00:49:31 +01:00
orklah
9770e113c3
Merge pull request #9020 from orklah/isContainedbug
...
Is containedbug
2022-12-28 23:46:38 +01:00
orklah
a290729087
fix test
2022-12-28 23:33:28 +01:00
orklah
a8fd349e07
fix #7809
2022-12-28 23:29:33 +01:00
orklah
94f9d48bca
Merge pull request #9019 from mmcev106/prevent-erroneous-escapes
...
Prevent DB escaping functions from affecting non-sql taints
2022-12-28 21:32:12 +01:00
Mark McEver
53c3f1ebb3
Prevent other DB escaping functions from escaping non-sql taints
2022-12-28 14:19:01 -06:00
orklah
435acb823c
Merge pull request #9018 from orklah/TClosure
...
create proper TClosure instead of TNamedObject with a Closure value
2022-12-28 20:53:52 +01:00
orklah
fa4891ce58
create proper TClosure instead of TNamedObject with a Closure value
2022-12-28 20:42:59 +01:00
Mark McEver
69f31dcd4a
Prevent mysqli escaping functions from escaping non-sql taints
2022-12-28 13:39:01 -06:00
orklah
58853c00f8
add test
2022-12-28 19:13:03 +01:00
Marco Pivetta
45f743f851
Adjusted assertDifferentTypeOfArray
test to avoid intersecting incompatible string arrays
...
Getting one interesting failure caused by the `lowercase-string` refinement done before:
```
There was 1 error:
1) Psalm\Tests\AssertAnnotationTest::testValidCode with data set "assertDifferentTypeOfArray" ('<?php\n /*...ts[1];')
Psalm\Exception\CodeException: DocblockTypeContradiction - src/somefile.php:21:21 - Cannot resolve types for $parts - docblock-defined type list{0: lowercase-string, 1?: lowercase-string} does not contain list{string, string}
```
Happens on this bit:
```php
'assertDifferentTypeOfArray' => [
'code' => '<?php
/**
* @psalm-assert list{string, string} $value
* @param mixed $value
*/
function isStringTuple($value): void {
if (!is_array($value)
|| !isset($value[0])
|| !isset($value[1])
|| !is_string($value[0])
|| !is_string($value[1])
) {
throw new \Exception("bad");
}
}
$s = "";
$parts = explode(":", $s, 2);
isStringTuple($parts);
echo $parts[0];
echo $parts[1];',
],
```
If I change this to:
```
@psalm-assert list{lowercase-string, lowercase-string} $value
```
Then everything works: I'm wondering if this error has to do with array intersections, and whether suppressing it suffices.
For now, changing the input string, so it is not a `lowercase-string`, is sufficient.
2022-12-28 17:57:33 +01:00
Marco Pivetta
c0c0116809
Using list{0: string, 1?: string}
syntax for more precise array key types
...
Thanks to @orklah's feedback, the `explode()` return type is now much more precise too.
Ref: https://github.com/vimeo/psalm/pull/9016#discussion_r1058458616
2022-12-28 17:48:33 +01:00
Marco Pivetta
6341d7fef0
Adjusted existing tests to the new signature of explode()
...
Note how the signature became `array{0: string, 1?: string, 2?: string, array<int, string>}`,
which may be a side-effect of unions between a defined hashmap structure with array
keys, and `list<string>`.
2022-12-28 17:39:06 +01:00
orklah
dbcfe62c52
Merge pull request #8987 from jack-worman/Always_check_unused_methods_and_properties
...
Add @psalm-api annotation
2022-12-28 15:20:48 +01:00
orklah
d338b00cb7
Merge pull request #8999 from VincentLanglet/union
...
Preserve from_docblock in TypeCombiner
2022-12-28 10:08:12 +01:00
orklah
41ae518800
Merge pull request #9001 from fluffycondor/http_response_header-non-empty-list
...
Make `$http_response_header` a non-empty-list
2022-12-28 00:27:30 +01:00
Bruce Weirdan
52da29e389
Do not require return type on destructors in interfaces
...
Fixes vimeo/psalm#9008
2022-12-26 15:45:44 -04:00
Vincent Langlet
b1f1ca6d7e
Try
2022-12-25 19:11:54 +01:00
Vincent Langlet
a8ef02db5a
Real fix
2022-12-25 17:35:47 +01:00
fluffycondor
bfc00056e3
Add test
2022-12-25 11:50:09 +06:00
fluffycondor
032f01114e
Fix test
2022-12-25 11:41:34 +06:00
Jack Worman
1bb9eb4cfc
forbidden function bug and better get_defined_functions() signature
2022-12-24 12:34:40 -06:00
fluffycondor
69da58d578
Make http_response_header a non-empty-list of non-falsy-string
2022-12-25 00:02:58 +06:00