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
Vincent Langlet
ebd5727dec
Update type
2022-12-24 13:38:02 +01:00
Vincent Langlet
723001d814
Failing test
2022-12-24 13:17:08 +01:00
Jack Worman
703a1e1698
@psalm-api
2022-12-23 16:13:46 -06:00
orklah
597957989c
Merge pull request #8990 from othercorey/verify-param-nullable
...
Verify nullable callmap parameters
2022-12-23 18:30:27 +01:00
Corey Taylor
d6eca8c056
Verify nullable callmap parameters
2022-12-23 06:04:35 -06:00
Emmanuel GUITON
164e279d08
Fixed object comparison that aims to improve nested template analysis (vimeo#8112).
2022-12-22 15:16:17 +01:00
Emmanuel Guiton
b138107bf3
Merge branch 'vimeo:master' into master
2022-12-22 15:15:46 +01:00
Jack Worman
8e5904d624
Fix get_object_vars on enums
2022-12-21 22:51:53 -06:00
orklah
898aa90436
Merge pull request #8967 from jack-worman/Remove_occurrences
...
Remove occurrences from error baseline
2022-12-21 20:31:56 +01:00
e2a5ef1eb5
Revert
2022-12-21 14:05:05 +01:00
Jack Worman
896799dff4
Remove occurrences
2022-12-21 06:45:45 -06:00
Emmanuel GUITON
3364bd97e1
Additional code style fixes (vimeo#8112).
2022-12-21 11:51:42 +01:00
Emmanuel Guiton
94adf78c16
Merge branch 'vimeo:master' into master
2022-12-21 10:56:47 +01:00
Andrew Nagy
24017059ee
fix phpcs issues
2022-12-20 23:31:56 +00:00
Jack Worman
b2ccf2487e
Add Codebase to remaining events
2022-12-20 17:18:50 -06:00
Andrew Nagy
5f9487e9a9
async test case fixes
2022-12-20 21:26:25 +00:00
Andrew Nagy
30f8331da6
additional fixes
2022-12-20 21:25:04 +00:00
Andrew Nagy
f1b0c4fa6d
additional fixes
2022-12-20 21:16:29 +00:00
Andrew Nagy
b9791d24dc
fix some tests
2022-12-20 21:09:34 +00:00
Andrew Nagy
82d8974fe3
merge to v5
2022-12-20 20:52:25 +00:00
orklah
91081f77fd
Merge pull request #8781 from weirdan/8758-optional-offsets-in-phpstorm-meta
...
Allow omitting argument offsets for map-type overrides in phpstorm.meta
2022-12-20 19:38:51 +01:00
3549162acc
Update
2022-12-20 13:44:05 +01:00
02cd829b7d
Fix bug
2022-12-20 13:28:47 +01:00
825f46f9dc
Fix test
2022-12-19 22:23:31 +01:00
dc5a4576a5
Fix
2022-12-19 21:25:06 +01:00
194f71052c
Add failing test
2022-12-19 21:11:10 +01:00
4fb5a615f1
Fix tests
2022-12-19 19:24:03 +01:00
ab2692fdd3
Update
2022-12-19 18:31:43 +01:00
ec11254316
Update
2022-12-19 14:27:41 +01:00
e923229204
Fix array_merge
2022-12-19 14:01:00 +01:00
326ba91812
Update
2022-12-19 13:49:42 +01:00
8088f046cd
Fix
2022-12-19 13:10:17 +01:00
9d7dd20293
Fix some tests
2022-12-19 13:04:24 +01:00
b91ad2cb1d
Begin fixing #8942
2022-12-19 12:55:32 +01:00
bde77f7a95
Fixes
2022-12-19 12:29:27 +01:00
b691219da5
cs-fix
2022-12-19 12:09:20 +01:00
4e7ff473a5
Fix #8940
2022-12-19 12:06:57 +01:00
Theodore Brown
0f4db694df
Allow conditions inside loops to preserve or narrow int range
...
Fixes #7555 , fixes #8020 , fixes #8865
2022-12-18 17:35:14 -06:00
orklah
156c1089a9
Merge pull request #8927 from jack-worman/Trailing_commas
...
Trailing commas
2022-12-19 00:04:47 +01:00
Jack Worman
e7d4d697ac
Reflection class stub updates
2022-12-18 14:35:41 -06:00
Jack Worman
1c19260cdd
Require trailing commas
2022-12-18 13:20:31 -06:00
orklah
8223332185
Merge pull request #8926 from danog/fix_8925
...
Skip intersection of template types during inheritance check
2022-12-18 18:53:07 +01:00
orklah
da001c46cd
Merge pull request #8929 from danog/fix_8923
...
Fix #8923
2022-12-18 18:52:37 +01:00
2f5d0a4a9f
Fix #8923
2022-12-18 18:19:22 +01:00
70d1a5a3c5
Add test
2022-12-18 18:14:43 +01:00
c454a181cc
Fixes
2022-12-18 15:00:15 +01:00
098d5020d0
array_merge_recursive
2022-12-18 14:52:44 +01:00
1dd062a810
Fix #2481
2022-12-18 14:50:51 +01:00
b83226a0db
More array_merge improvements
2022-12-18 14:37:19 +01:00
fluffycondor
dd76a1e481
Fix tests
2022-12-18 16:57:36 +06:00
fluffycondor
6f230edc8b
Add one more test
2022-12-18 16:53:19 +06:00
fluffycondor
a8b249b786
Remove no longer necessary @vars
2022-12-18 16:53:19 +06:00
fluffycondor
987981b12a
Make sprintf return non-empty-string when arguments non-empty-strings too
2022-12-18 16:53:19 +06:00
orklah
62ced63375
Merge pull request #8910 from jack-worman/Last_property_typehints
...
Last property typehints
2022-12-17 15:53:36 +01:00
Bruce Weirdan
425d9fa8bf
Recognize casts from object-with-properties to array
...
Previously `(array)(object)['a' => 1, 'b' => 'foo']` would result in
`array<array-key, mixed>`. Now it would be inferred as
`array{a:1,b:foo,...<array-key,mixed>}`
2022-12-16 20:12:02 -04:00
Jack Worman
a52f35e5e1
Even more property typehints
2022-12-16 13:24:21 -06:00
992f26a8e7
Fix array_merge edge case
2022-12-16 18:10:46 +01:00
Leo Viezens
0ef7ec100a
#7387 Add asserting non-empty-string by strlen
2022-12-16 17:04:01 +01:00
orklah
5132de22e0
Merge pull request #8900 from othercorey/fix-unreflectable
...
Fix remaining invalid unreflectable methods
2022-12-15 21:19:10 +01:00
orklah
e69f88af5a
Merge pull request #8897 from jack-worman/Add_some_more_property_typehints
...
Add property typehints in Internal directory
2022-12-15 21:11:43 +01:00
Corey Taylor
067d0649ca
Fix remaining invalid unreflectable methods
2022-12-15 04:09:02 -06:00
Jack Worman
2b5407d2fb
Added SlevomatCodingStandard.TypeHints.ParameterTypeHint sniff and removed php-cs-fixer
2022-12-14 20:26:17 -06:00
Jack Worman
69658e8315
SlevomatCodingStandard.Commenting.DocCommentSpacing
2022-12-14 13:34:41 -06:00
Jack Worman
643542346b
Add codesniffer rules and expand php-cs-fixer to bin and test
2022-12-14 13:29:09 -06:00
Corey Taylor
902ea9d7e2
Fix DOM and Reflection unreflectable methods
2022-12-14 10:18:15 -06:00
027354cabc
Improve parsing of list shapes ( #8841 )
...
* Improve parsing of list shapes
* Improve logic
* One more test
* Fix tests
2022-12-13 22:30:40 +01:00
6347a21546
Literal inferring for array_column, array_combine, array_fill_keys, array_fill ( #8850 )
...
* Squash
* Remove BC break
* Suppress
* Possibly fix
* Fixes
* Fix test
* Implement literal array_column
* Improve array_column inference
* Improve logic
* Add array_combine return type provider
* Cleanup
* Fix #8868 (add array_fill_keys/array_fill return type)
* cs-fix
* Fix
2022-12-13 22:29:35 +01:00
cca276768e
List refactoring v5 ( #8820 )
...
* Squash
* Remove BC break
* Suppress
* Possibly fix
* Fixes
* Fix test
* Trigger build
* Update psl
* Update psl
* Fixes
* Fixes
* Cleanup
* fix
* Fix build
* Do not consider never when getting the max count
* Add assertion
* Cleanup
* Fix
* Cleanup
2022-12-13 21:40:19 +01:00
orklah
00706de18e
Merge pull request #8826 from othercorey/callmap-methods
...
Add validation for Class::Method names in CallMap
2022-12-13 18:47:23 +01:00
Corey Taylor
e57079f581
Add validation for Class::Method names in CallMap
2022-12-13 03:34:47 -06:00
orklah
72e7386eb5
Merge pull request #8722 from Ocramius/feature/#8720-improve-types-and-purity-for-reflection-symbols
...
Declaring more precise types and purity boundaries on `ext-reflection` symbols in `.phpstub` files
2022-12-12 21:27:47 +01:00
Bruce Weirdan
9db0eb3e03
InvalidEnumMethod requires PHP8.1+
2022-12-12 03:12:55 -04:00
Bruce Weirdan
19a1005bc3
Forbid most magic methods on enums
...
Fixes vimeo/psalm#8889
Additionally this fixes case-sensitivity of
MethodSignatureMustOmitReturnType issue
Fixes vimeo/psalm#8888
2022-12-12 03:03:20 -04:00
Bruce Weirdan
a4ff9eb204
Allow true
in native types
...
Fixes vimeo/psalm#8872
For `null` and `false`, we already allowed them even as standalone
types, even though PHP before 8.2 only allowed them as part of a union.
2022-12-09 20:17:09 -04:00
orklah
e4b64af599
Merge pull request #8861 from VincentLanglet/count
...
Precise count range
2022-12-09 00:41:00 +01:00
Vincent Langlet
f6051bc417
Precise count range
2022-12-08 16:44:10 +01:00
Marco Pivetta
30a49633a5
Corrected AttributeTest
expectation: ReflectionAttribute
s always come in a list
2022-12-07 15:44:38 +01:00
Mark McEver
9764803c55
Allowed taints to pass through urlencode()
2022-12-05 17:25:36 -06:00
orklah
cc9c67d7ee
Merge pull request #8834 from danog/fix_class_string_unions
...
Fix parsing of class string of unions
2022-12-04 20:44:41 +01:00
orklah
f3e1a2c0e4
impossible constructor
2022-12-04 20:33:05 +01:00
4c277052e3
Fix parsing of class string of unions
2022-12-04 20:28:53 +01:00
orklah
2490230f1f
fix missing break handling in loop
2022-12-04 13:57:59 +01:00
Corey Taylor
d9b651a126
Fix return types for date functions in callmap
2022-12-03 17:55:29 -06:00
Bruce Weirdan
a157743140
Prevent crashes on conditional traits
...
Fixes vimeo/psalm#7863
2022-12-03 01:21:10 -04:00
Bruce Weirdan
4d8af74d92
Don't crash when accessing immutable static property
...
Fixes vimeo/psalm#8313
2022-12-03 00:51:22 -04:00
Bruce Weirdan
7364988934
Fix crash when using phantom methods as first-class callable
...
Fixes vimeo/psalm#8377
2022-12-02 23:28:22 -04:00
Barney Laurance
a29f65ecfe
Fix too lax function visibility in test
2022-12-02 00:24:44 +00:00
Barney Laurance
6693421379
Code style fix
2022-12-02 00:24:05 +00:00
Barney Laurance
54239838fe
Fix error in ByIssueLvelAndTypeReport heading
2022-12-02 00:17:27 +00:00
Barney Laurance
699ee344d4
Indent heredoc in test
2022-12-02 00:14:43 +00:00
Barney Laurance
3f5616672a
Add test for ByIsueLevelAndTypeReport
2022-12-01 23:27:53 +00:00
orklah
433e272149
Merge pull request #8809 from danog/fix_8806
...
Fix #8806
2022-12-01 21:00:40 +01:00
7f15d47c19
Add tests
2022-12-01 20:14:37 +01:00
orklah
b4aa951caa
Merge pull request #8798 from orklah/min_count
...
fix sealed combination
2022-12-01 18:35:02 +01:00
kkmuffme
694b7d8975
check "never" return type more strictly
...
* require explicit "never" return type when function always exits, except if it only throws
* error if function does not exit, but return type explicitly contains "never"
* Fix: https://github.com/vimeo/psalm/issues/8175
* Fix: https://github.com/vimeo/psalm/issues/8178
2022-12-01 14:51:58 +01:00
orklah
2da4bf98d6
add test
2022-11-30 23:45:55 +01:00