Alies Lapatsin
a051090658
Merge remote-tracking branch 'origin/cleaunup-unsupported-extentions-message' into cleaunup-unsupported-extentions-message
2023-01-10 19:29:39 +01:00
Alies Lapatsin
69b6409feb
Fix coding-style issues
2023-01-10 19:24:33 +01:00
Alies Lapatsin
e21e38d5ac
Merge branch 'master' into cleaunup-unsupported-extentions-message
2023-01-10 18:59:58 +01:00
Vincent QUATREVIEUX
e5f297ddbb
fix: Handle template type on promoted property #8951
2023-01-10 10:41:48 +01:00
orklah
9366c5ed32
Merge pull request #9012 from kkmuffme/ignore-missingfile-error-for-file_exists-files
...
dont report MissingFile error when file_exists is validated beforehand
2023-01-09 23:33:04 +01:00
Alies Lapatsin
2626827876
Merge branch 'master' into cleaunup-unsupported-extentions-message
2023-01-09 17:39:56 +04:00
Alies Lapatsin
8b23919241
Extend a list of php ext, supported by CallMap files
2023-01-09 14:31:17 +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
Alies Lapatsin
f197d137d6
Internal: use more specific types
2023-01-06 00:27:01 +04:00
Alies Lapatsin
ce8dcdfee7
Do not list core and bundled extensions as unsupported
2023-01-05 18:42:38 +04:00
kkmuffme
2bfdf9bc68
code style
2023-01-05 09:44:23 +01:00
kkmuffme
ea1ece5cd0
fix "No return statements were found" not reporting
2023-01-05 09:44:23 +01:00
kkmuffme
b85d6374fe
Revert "Fix psalter bug changing to native types even when backwards incompatible is false"
...
This reverts commit 98e22c27fff7be6a143406abe8b2cdd54d02283b.
2023-01-05 09:44:23 +01:00
kkmuffme
a0aff18bd8
Fix psalter bug changing to native types even when backwards incompatible is false
2023-01-05 09:43:19 +01:00
kkmuffme
6b9816071c
suppress psalm bug
2023-01-05 09:43:19 +01:00
kkmuffme
4c0cae7cd0
code style
2023-01-05 09:43:19 +01:00
kkmuffme
13f6258a06
class overrides stubbed should be ignored too
2023-01-05 09:43:19 +01:00
kkmuffme
67e6cb8142
fix void => null wrong condition
...
* fix void => null to greedy suppressing errors in never cases
* fix test allowNoReturnInSubclassWithNullableReturnType to not fail
2023-01-05 09:43:19 +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
kkmuffme
4dd92fb795
fix implicit return type
...
* fix implicit void return type errors https://psalm.dev/r/b0e397c14e
* fix void + never = null return type error https://psalm.dev/r/6f227ae9b9
* fixes https://github.com/vimeo/psalm/issues/8912 and https://github.com/vimeo/psalm/issues/8862
2023-01-05 09:43:19 +01:00
kkmuffme
166df8a99f
dont report MissingFile error when file_exists is validated beforehand
...
Fix https://github.com/vimeo/psalm/issues/3886
2023-01-05 09:32:36 +01:00
orklah
7d6a48ab14
Merge pull request #9044 from kkmuffme/absolute-autoloader-path-not-working
...
fix autoloader not working with absolute path
2023-01-04 22:11:38 +01:00
kkmuffme
1a0c0fe5c5
relative path as absolute paths autoloader legacy issue
2023-01-03 15:35:57 +01:00
kkmuffme
76f90e62f2
code style
2023-01-03 15:21:15 +01:00
kkmuffme
8fe00cf609
fix autoloader not working with absolute path
2023-01-03 15:13:38 +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
ef1264bd46
Merge pull request #9030 from kkmuffme/psalm-scope-this-doesnt-work-with-FQCN-leading-backslash
...
fix @psalm-scope-this not working with FQCN with leading backslash
2022-12-31 12:08:20 +01:00
orklah
406946d4c4
Merge pull request #9031 from danog/misc_fixes
...
Misc fixes
2022-12-30 21:28:11 +01:00
4b00095b31
cs-fix
2022-12-30 21:06:03 +01:00
0b67844420
Improve variable naming and improve docs
2022-12-30 21:00:38 +01:00
kkmuffme
fcf42840f3
fix @psalm-scope-this not working with FQCN with leading backslash
2022-12-30 18:30:31 +01:00
orklah
6353143eaf
Merge pull request #9021 from orklah/nonempty-reconcile
...
Non empty reconciliation
2022-12-29 22:35:12 +01:00
orklah
2efa6aefac
Merge pull request #9025 from kkmuffme/fix-method-phpdoc-errors-reported-for-stubs-instead-of-files
...
fixes return type issues of methods reported for the wrong file
2022-12-29 20:13:38 +01:00
orklah
5a6e8cb8e7
Merge pull request #9023 from kkmuffme/fix-union-never-wrong-return-type
...
Fix never return union type wrong condition
2022-12-29 20:11:38 +01:00
kkmuffme
9130ee2614
fixes return type issues of methods reported for the wrong file
...
fixes return type issues of methods reported for the wrong file
Fix #8457
See https://github.com/vimeo/psalm/pull/8503 which fixed this issue for functions
2022-12-29 18:55:15 +01:00
kkmuffme
ac8f892d13
Fix never return union type wrong condition
...
Fix never return union type wrong condition
Related https://github.com/vimeo/psalm/pull/8624
2022-12-29 18:50:58 +01:00
kkmuffme
efc87277d1
fix never return for MethodCalls
...
Related:
https://github.com/vimeo/psalm/pull/8902 https://github.com/vimeo/psalm/pull/8624
2022-12-29 18:49:58 +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
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
a8fd349e07
fix #7809
2022-12-28 23:29:33 +01: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
a0a9d979d5
remove useless import
2022-12-28 20:47:50 +01:00
orklah
fa4891ce58
create proper TClosure instead of TNamedObject with a Closure value
2022-12-28 20:42:59 +01:00
orklah
e52664deea
Add getAtomicType for IsNotAClass for proper negation Reconciliation
2022-12-28 19:04:23 +01:00
Marco Pivetta
04999b172a
Refined explode()
types
...
Fixes #5039
This patch removes the need for a custom function return type
provider for `explode()`, and instead replaces all that with a single
stub for the `explode()` function, which provides types for some of
the most common `$limit` input values.
With this change, the `$delimiter` is enforced to be a `non-empty-string`,
which will lead to downstream consumers having to adjust some code accordingly,
but that shouldn't affect the most common scenario of exploding a string
based with a constant `literal-string` delimiter, which most PHP devs tend to do.
This change didn't come with an accompanying test, since that would be a bit
wasteful, but it was verified locally with following script:
```php
<?php
$possible0 = explode(',', 'hello, world', -100);
$possible1 = explode(',', 'hello, world', -1);
$possible2 = explode(',', 'hello, world', 0);
$possible3 = explode(',', 'hello, world', 1);
$possible4 = explode(',', 'hello, world', 2);
$possible5 = explode(',', 'hello, world', 3);
$possible6 = explode(',', 'hello, world', 4);
try {
$impossible1 = explode('', '', -1);
} catch (Throwable $impossible1) {}
$traced = [$possible0, $possible1, $possible2, $possible3, $possible4, $possible5, $possible6, $impossible1];
/** @psalm-trace $traced */
var_dump($traced);
return $traced;
```
Running psalm locally, this produces:
```
psalm on feature/#5039-more-refined-types-for-explode-core-function [?] via 🐘 v8.1.13 via ❄️ impure (nix-shell)
❯ ./psalm --no-cache explode.php
Target PHP version: 7.4 (inferred from composer.json) Extensions enabled: dom, simplexml (unsupported extensions: ctype, json, libxml, mbstring, tokenizer)
Scanning files...
Analyzing files...
░
To whom it may concern: Psalm cannot detect unused classes, methods and properties
when analyzing individual files and folders. Run on the full project to enable
complete unused code detection.
ERROR: InvalidArgument - explode.php:11:28 - Argument 1 of explode expects non-empty-string, but '' provided (see https://psalm.dev/004 )
$impossible1 = explode('', '', -1);
ERROR: PossiblyUndefinedGlobalVariable - explode.php:14:96 - Possibly undefined global variable $impossible1 defined in try block (see https://psalm.dev/126 )
$traced = [$possible0, $possible1, $possible2, $possible3, $possible4, $possible5, $possible6, $impossible1];
ERROR: ForbiddenCode - explode.php:18:1 - Unsafe var_dump (see https://psalm.dev/002 )
/** @psalm-trace $traced */
var_dump($traced);
ERROR: Trace - explode.php:18:1 - $traced: list{0: array<never, never>, 1: non-empty-list<string>, 2: list{string}, 3: list{string}, 4: array{0: string, 1?: string}, 5: array{0: string, 1?: string, 2?: string}, 6: non-empty-list<string>, 7?: Throwable|non-empty-list<string>} (see https://psalm.dev/224 )
/** @psalm-trace $traced */
var_dump($traced);
------------------------------
4 errors found
------------------------------
Checks took 6.31 seconds and used 265.386MB of memory
Psalm was unable to infer types in the codebase
```
The actual runtime behavior on PHP 8.x: https://3v4l.org/0NKlW
```
array(8) {
[0]=>
array(0) {
}
[1]=>
array(1) {
[0]=>
string(5) "hello"
}
[2]=>
array(1) {
[0]=>
string(12) "hello, world"
}
[3]=>
array(1) {
[0]=>
string(12) "hello, world"
}
[4]=>
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(6) " world"
}
[5]=>
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(6) " world"
}
[6]=>
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(6) " world"
}
[7]=>
object(ValueError)#1 (7) {
["message":protected]=>
string(51) "explode(): Argument #1 ($separator) cannot be empty"
["string":"Error":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(9) "/in/0NKlW"
["line":protected]=>
int(11)
["trace":"Error":private]=>
array(1) {
[0]=>
array(4) {
["file"]=>
string(9) "/in/0NKlW"
["line"]=>
int(11)
["function"]=>
string(7) "explode"
["args"]=>
array(3) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
int(-1)
}
}
}
["previous":"Error":private]=>
NULL
}
}
```
On PHP 7:
```
Warning: explode(): Empty delimiter in /in/0NKlW on line 11
array(8) {
[0]=>
array(0) {
}
[1]=>
array(1) {
[0]=>
string(5) "hello"
}
[2]=>
array(1) {
[0]=>
string(12) "hello, world"
}
[3]=>
array(1) {
[0]=>
string(12) "hello, world"
}
[4]=>
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(6) " world"
}
[5]=>
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(6) " world"
}
[6]=>
array(2) {
[0]=>
string(5) "hello"
[1]=>
string(6) " world"
}
[7]=>
bool(false)
}
```
2022-12-28 17:11:40 +01:00
Theodore Brown
e4b0343f76
Fix PHPCS trailing comma
2022-12-28 09:35:34 -06: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
Vincent Langlet
a263e5d42c
Simplify
2022-12-28 09:30:41 +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
040737de24
Fix non-empty-list class
2022-12-25 11:45:56 +06:00
fluffycondor
a077bd4351
Make http_response_header possibly undefined
2022-12-25 11:38:51 +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
06010b40ce
Fix
2022-12-24 13:24:28 +01:00
Jack Worman
703a1e1698
@psalm-api
2022-12-23 16:13:46 -06:00
Bruce Weirdan
bf6ef6466e
Improve invalid references
message in @psalm-type
...
Fixes vimeo/psalm#8842
2022-12-23 14:52:08 -04:00
orklah
1cde7e4031
Merge pull request #8792 from emmanuelGuiton/master
...
Fixes vimeo#8112
2022-12-22 22:11:42 +01:00
Bruce Weirdan
7924a52a62
Drop symfony/polyfill-php80 dependency
2022-12-22 13:06:21 -04: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
dd721a27c5
Revert
2022-12-21 14:04:42 +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
Jack Worman
b2ccf2487e
Add Codebase to remaining events
2022-12-20 17:18:50 -06: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
02cd829b7d
Fix bug
2022-12-20 13:28:47 +01:00
8013b0eea2
Replace some LNumber usages
2022-12-19 22:14:32 +01:00
750e2da542
Cleanup
2022-12-19 21:29:13 +01:00
dc5a4576a5
Fix
2022-12-19 21:25:06 +01:00
8b4d5f871c
Fix
2022-12-19 21:16:03 +01:00
4fb5a615f1
Fix tests
2022-12-19 19:24:03 +01:00
ab2692fdd3
Update
2022-12-19 18:31:43 +01:00
4ea5329087
Never assign never to an array
2022-12-19 17:49:09 +01:00
2617b68ca9
Simplify
2022-12-19 17:40:45 +01:00
ce06f4e0d0
Fix
2022-12-19 17:27:49 +01:00
b9424a88cb
Update
2022-12-19 17:22:00 +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
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
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
bccda92f31
Skip intersection of template types during inheritance check
2022-12-18 17:12:04 +01:00
c454a181cc
Fixes
2022-12-18 15:00:15 +01:00
b83226a0db
More array_merge improvements
2022-12-18 14:37:19 +01:00
orklah
a76a1d1a52
Merge pull request #8916 from jack-worman/Remove_useless_ifs
...
Remove useless ifs
2022-12-17 15:54:28 +01:00
orklah
62ced63375
Merge pull request #8910 from jack-worman/Last_property_typehints
...
Last property typehints
2022-12-17 15:53:36 +01:00
Jack Worman
2f677f600b
CS fixes
2022-12-17 08:13:32 -06:00
Jack Worman
30a8f71958
Remove useless ifs
2022-12-16 22:00:34 -06: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
9ce31a7709
Re-add short closure sniff
2022-12-16 17:02:10 -06:00
orklah
5afc3282d4
Merge pull request #8902 from kkmuffme/fix-never-static-calls
...
fix return type never for static function calls
2022-12-16 22:06:19 +01:00
Jack Worman
a52f35e5e1
Even more property typehints
2022-12-16 13:24:21 -06:00
2c00c64304
Bypass bug
2022-12-16 19:18:33 +01:00
f5b6889c32
Fix
2022-12-16 18:39:35 +01: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
kkmuffme
eeb0c06173
fix return type never for static function calls
2022-12-16 11:55:31 +01:00
orklah
f4d70384ee
Merge pull request #8885 from lptn/php-ext-with-deprecation
...
Deprecation message on loading php-ext stubs without explicitly declaring them as dependency or in a config
2022-12-15 21:17:38 +01:00
Bruce Weirdan
e7a4fd98e5
Fix SA issues
2022-12-15 00:18:53 -04:00
Jack Worman
76a7c7da4a
Added SlevomatCodingStandard.TypeHints.PropertyTypeHint sniff
2022-12-14 20:43:26 -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
0939e63323
Add @internal tag and fix php-cs-fixer mistake
2022-12-14 08:06:37 -06:00
Jack Worman
749ce58c27
Add more property typehints
2022-12-13 21:34:34 -06:00
Jack Worman
36fa162d6d
Use php-cs-fixer to clean up docblocks
2022-12-13 20:46:43 -06:00
Jack Worman
fc2df8e8ae
Add more property typehints
2022-12-13 20:20: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
794ca9362a
Merge pull request #8887 from jack-worman/Use_rector_to_add_property_typehints
...
Use rector to add property typehints
2022-12-13 19:58:43 +01:00
Bruce Weirdan
d0e335ab29
Replace unmaintained openlss/lib-array2xml
with spatie/array-to-xml
...
Fixes vimeo/psalm#8852
2022-12-13 05:27:55 -04:00
Alies Lapatsin
1115cfb980
Merge branch 'master' into php-ext-with-deprecation
...
# Conflicts:
# src/Psalm/Config.php
2022-12-12 23:49:01 +01: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
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
Jack Worman
dd0d8300b1
Use rector to add property typehints
2022-12-11 17:25:23 -06:00
Alies Lapatsin
c8b6b0b504
Remove unused @psalm-suppress
2022-12-11 15:10:43 +01:00
Alies Lapatsin
a8046a8682
Simplify array type declaration
2022-12-11 15:01:34 +01:00
Alies Lapatsin
729eb59169
Remove an excessive array shape annotation
2022-12-11 14:55:42 +01:00
Alies Lapatsin
5e95d13157
Make Psalm about stub file for random (core) extension
2022-12-11 14:45:20 +01:00
Alies Lapatsin
74f65cba71
Make Psalm about stub file for redis extension
2022-12-11 14:39:29 +01:00
Alies Lapatsin
62c998b8cf
Load ext stubs using extension_loaded but display a deprecation note
2022-12-11 14:39:29 +01:00
Alies Lapatsin
0fd4c520de
Load ext stubs using extension_loaded but diaplay a deprecation note
2022-12-11 14:01:20 +01:00
Alies Lapatsin
ecfa81471a
Merge branch 'master' into php-ext
2022-12-11 13:58:18 +01:00
Bruce Weirdan
32eaf12d40
Prevent duplicate (Possibly)UnusedMethod/(Possibly)UnusedProperty
...
This also allows (Possibly)UnusedProperty to be suppressed with
`referencedProperty` attribute in psalm.xml
Fixes vimeo/psalm#8874
2022-12-11 05:49:09 -04:00
Alies Lapatsin
16ab9f786b
Unify a way how to load stubs for extentions
2022-12-10 17:02:47 +01:00
orklah
ef02ded050
Merge pull request #8833 from theofidry/feature/cpu-counter
...
Integrate FidryCpuCoreCounter
2022-12-10 12:14:50 +01:00
Bruce Weirdan
af549fa78a
Merge pull request #8854 from kkmuffme/fix-unsafe-file_get_contents
2022-12-09 23:20:10 -04:00
Bruce Weirdan
1750ec1b8a
Merge pull request #8876 from weirdan/fix-8873
...
Fixes https://github.com/vimeo/psalm/issues/8873
2022-12-09 22:08:27 -04:00
Bruce Weirdan
d19759cc23
Suppress irrelevant Psalm issue
...
We're not defining this property to use it, we're defining it to
suppress PHP deprecation warning
2022-12-09 21:57:03 -04:00
Bruce Weirdan
94003a3885
Fixed dynamic property on LanguageServer
...
Fixes vimeo/psalm#8873
2022-12-09 21:50:10 -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
Marco Pivetta
68d88c546b
Load PHP-version-specific stubs based on analysis PHP version, and only when visiting stub files
...
While `visitPreloadedStubFiles` seemed to work at first, it led to overriding symbols declared by
PHP itself too eagerly.
By only loading PHP-version-specific stubs in `visitStubFiles`, we ensure that the reflection-declared
symbols take priority, and that our stubs overlay on top of that, without actually replacing the
symbol entirely, but rather merging with its definition.
This fixes current test failures too, and works with the code examples
from https://github.com/vimeo/psalm/pull/8722#issuecomment-1339711882
2022-12-08 18:22:51 +01:00
Théo FIDRY
5d2b739a4e
Fix CS
2022-12-08 12:27:11 +01:00
Théo FIDRY
ba40e34947
Update to stable
2022-12-08 12:17:26 +01:00
Théo FIDRY
cfa570eba2
Merge remote-tracking branch 'upstream/master' into feature/cpu-counter
2022-12-08 12:15:09 +01:00
kkmuffme
d3ec894175
use safeFileGetContents in ProjectCacheProvider too
2022-12-07 19:57:52 +01:00
Marco Pivetta
042305107e
Always load preloaded stub files when the analysis version is compatible
...
Before this change, preloaded stubs would only be loaded when running on a PHP version lower than
the one that is in the stubs.
With this change, the analysis PHP version (defined via config, input parameter, or inferred from
the runtime) becomes authoritative.
Since the PHP-version-specific stubs are not just polyfills, but actually type refinements on top
of the PHP core symbols at hand, this change always loads them, so that it is possible to get more
precise type inference downstream.
This will likely lead to downstream breakages, because the stubs do indeed provide better type
resolution, but indeed formalizes the idea that these stubs will provide better value for finding
problems in analyzed code.
2022-12-07 15:48:59 +01:00
kkmuffme
1ee4b4aefa
remove file_get_contents that was incorrectly put in v5
2022-12-07 11:47:59 +01:00
Marco Pivetta
322cff6f43
Declaring more precise types and purity boundaries on ext-reflection
symbols in .phpstub
files
...
Also:
* added PHP 8.2 stubs
* refined types to make impossible scenarios more clear (like `ReflectionIntersectionType#allowsNull()`)
This is a first attempt at refining these types: the structure of these stubs is quite confusing to me,
so I don't know if this approach is correct, and if the stubs are merged together, or if entire symbols
need to be completely re-declared for each PHP version.
2022-12-06 11:08:30 +01:00
Alies Lapatsin
4b4b36df7d
Extend impure_functions list by socket functions
...
all of them returns boolean and can be ignored.
This prevents UnusedFunctionCall.
Note, socket errors can be fetched by:
- socket_strerror
- socket_last_error
2022-12-05 00:25:19 +01: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
Théo FIDRY
a444f286bb
Integrate FidryCpuCoreCounter
2022-12-04 20:24:18 +01:00
orklah
df4d3692ab
Merge pull request #8828 from orklah/generator
...
fix missing break handling in loop
2022-12-04 16:38:37 +01:00
orklah
2490230f1f
fix missing break handling in loop
2022-12-04 13:57:59 +01:00
Bruce Weirdan
45bf0d961c
Improve source autodiscovery failure message
...
The message we emitted previously did not provide any instructions on
how to resolve the issue, leaving users to guess what they need to do.
2022-12-04 04:34:08 -04: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
1dbdf7882c
Code style fix
2022-12-02 00:40:01 +00:00
Barney Laurance
ad57727593
Sort issue by position in codebase in ByIssueLevelAndTypeReport if level & type equal
...
PHP sorting only became stable in 8.0. For previous versions we would
still like duplicate issues to be sorted into a logical order.
2022-12-02 00:27:51 +00:00
Barney Laurance
54239838fe
Fix error in ByIssueLvelAndTypeReport heading
2022-12-02 00:17:27 +00:00
Barney Laurance
9e63bf6a4d
Minor code edits in ByIssueLevelAndType
2022-12-02 00:04:43 +00:00
Barney Laurance
3f5616672a
Add test for ByIsueLevelAndTypeReport
2022-12-01 23:27:53 +00:00
Barney Laurance
386aa27f4c
Improve issue level and type report
2022-12-01 23:00:48 +00:00
Barney Laurance
3bc3f1c273
Fix report name: Issue level, not issue severity
2022-12-01 22:11:29 +00:00
Barney Laurance
4fde49313e
Fix implicit constant visibility
2022-12-01 22:05:27 +00:00
Barney Laurance
aea1c5603d
Reduce function visibility
...
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2022-12-01 22:03:19 +00:00
Barney Laurance
32881a3c65
Add comments
2022-12-01 22:02:09 +00:00
Barney Laurance
6bde0d3a68
Delete unused code
2022-12-01 22:02:08 +00:00
Barney Laurance
b70d3e228e
WIP: Add new option --output-format=by-issue-severity to sort issues by level and type
2022-12-01 22:02:08 +00:00
orklah
433e272149
Merge pull request #8809 from danog/fix_8806
...
Fix #8806
2022-12-01 21:00:40 +01:00
796462961d
Fix
2022-12-01 20:18:07 +01:00
3150ad2b27
Fix #8806
2022-12-01 20:12:20 +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
3957eb753a
fix sealed array combination
2022-11-30 23:26:34 +01:00
orklah
bce4b55525
Merge pull request #8796 from orklah/reconcileFalse
...
handle true/false reconciliation consistently, fix #8795
2022-11-30 20:35:44 +01:00
orklah
40fa8282ee
CS fix
2022-11-30 20:18:09 +01:00
orklah
229f613b8e
handle true/false reconciliation consistently, fix #8795
2022-11-30 20:15:11 +01:00
9c35ed2eb7
Ignore non-existing classes during initial scan of intersection types
2022-11-30 17:33:58 +01:00
Emmanuel GUITON
fcbd23c801
Style fix.
2022-11-30 17:33:28 +01:00
Emmanuel GUITON
0d9d0ed60d
Fixes vimeo#8112
2022-11-30 17:17:38 +01:00
Bruce Weirdan
870f5817d2
Merge pull request #8789 from weirdan/defer-cache-directory-creation
...
Fixes https://github.com/vimeo/psalm/issues/4267
2022-11-30 10:52:17 -04:00
Bruce Weirdan
6b3dd56850
Defer cache directory creation until it's needed
...
Honestly, this is a bit of a hack, as we let `Config` to generate the
cache directory name and then reset it to null from the cli entrypoint.
Yet it's easier than passing a no-cache flag through so many layers of
static calls.
`$this->cache_directory_initialized` flag is used to make sure we
attempt to create the directory only once.
Fixes vimeo/psalm#4267
2022-11-29 04:16:59 -04:00
Bruce Weirdan
874eb7d2ce
Fix crashes when XML report is used on PHP 8.1
...
Fixes vimeo/psalm#8321
2022-11-28 18:01:35 -04:00
Bruce Weirdan
9d597cf370
Merge pull request #8782 from weirdan/check-runtime-requirements
...
Fixes https://github.com/vimeo/psalm/issues/7560
2022-11-27 20:00:28 -04:00
Bruce Weirdan
de96494fee
Allow omitting argument offsets for map-type overrides in phpstorm.meta
...
Fixes vimeo/psalm#8758
2022-11-27 16:36:34 -04:00
Bruce Weirdan
8fa35c2228
Variables should outlive namespaces ( #8779 )
...
Variables in PHP are not namespaced. In other words, namespaces share
the context with the file they are located in.
See https://3v4l.org/2qvrC
Fixes vimeo/psalm#8778
2022-11-27 10:45:40 -05:00
Bruce Weirdan
05b8e0eea6
Replace all references to static variables when moving class ( #8780 )
...
Previously `psalter` would only replace the first occurence of the
property access. Now it replaces all properties (by keeping the old name
unknown in the context).
2022-11-27 10:44:53 -05:00
Bruce Weirdan
03def00f27
Check runtime requirements
...
`vendor/autoload/check_platform.php` may be disabled by the user
`composer.json`, so we have to repeat the check for runtime
requirements.
Fixes vimeo/psalm#7560
2022-11-27 08:05:30 -04:00