Bruce Weirdan
8adaee61ad
Fix newly found issues
2023-03-11 05:23:49 -04:00
Bruce Weirdan
193a0dbe0e
Don't crash on unary minus overflow
...
Fixes vimeo/psalm#9464
2023-03-07 12:29:40 -04:00
Bruce Weirdan
36913b13d5
Support for readonly
classes
2023-03-03 04:04:12 -04:00
Andrew Nagy
7e9638b729
Merge branch 'master' of https://github.com/vimeo/psalm into feature/upgrade-lsp-v5
2023-03-02 18:10:13 +00:00
Andrew Nagy
6e109aadce
Merge tag '5.7.7' of https://github.com/vimeo/psalm into feature/upgrade-lsp-v5
2023-03-02 17:04:33 +00:00
Paweł Tomulik
78e6545d7f
fix #4460
2023-02-28 11:38:47 +01:00
ebakulin
67d26d3c51
added case with literal string
2023-02-28 00:22:34 +07:00
ebakulin
cf35b3ce0c
reworked one known operand case
2023-02-28 00:12:18 +07:00
ebakulin
31fcbd5f69
added case with one null type
2023-02-27 22:03:01 +07:00
Evan Shaw
f7eaa5daec
Preserve PossiblyUndefinedVariable when fixing UnusedVariable
2023-02-25 20:08:01 +13:00
Bruce Weirdan
caac14c4a4
Consistently report docblock issues on all classlikes
...
Fixes vimeo/psalm#9365
2023-02-24 03:31:00 -04:00
Bruce Weirdan
3f52ded9c3
Correctly process use aliases in @psalm-scope-this
...
Fixes vimeo/psalm#9386
2023-02-24 00:53:36 -04:00
Bruce Weirdan
2315c98a73
Merge pull request #9381 from weirdan/enforce-literal-string-length-limit
2023-02-23 16:47:53 -04:00
Yannick Gottschalk
f026226aa3
Fixes #9384
2023-02-23 17:23:46 +01:00
Bruce Weirdan
5dec7f3dc3
Enforce literal string length limit
...
Fixes vimeo/psalm#9376
Ensures:
* that we never have a literal string exceeding the length limit
* that we call string interpreter for all literal strings
2023-02-23 04:01:29 -04:00
Bruce Weirdan
d0a14005a8
Merge pull request #9380 from weirdan/array-in-foreach-is-not-empty
2023-02-23 02:20:46 -04:00
Bruce Weirdan
1769f8b9a4
Refine arrays in foreach
loops to non-empty-array
...
Fixes vimeo/psalm#9378
2023-02-22 20:44:50 -04:00
Javier Sanahuja
aee3665014
Fixes
2023-02-22 23:55:27 +01:00
Javier Sanahuja
fa39366cb4
Code style fix
2023-02-22 23:19:47 +01:00
Javier Sanahuja
4f83324a91
Support sizeof alias of count
2023-02-22 23:11:10 +01:00
f665e719fb
Describe changes
2023-02-21 15:44:18 +01:00
575da79801
Fix #9363
2023-02-21 10:09:58 +01:00
Bruce Weirdan
ac86981a79
Revert " #7387 Add asserting non-empty-string by strlen"
...
This reverts commit 0ef7ec100a
.
2023-02-20 23:07:22 -04:00
88a3d288de
Workaround arm64 opcache bug ( fixes #9350 )
2023-02-20 12:49:59 +01:00
Bruce Weirdan
73bad8967d
Forbid first-class callables in new
...
It's an invalid construct in PHP, not rejected by PHPParser for some
reaason.
Fixes vimeo/psalm#9335
2023-02-19 04:18:32 -04:00
Evan Shaw
c8393bd50d
Fix language server first-class callable crashes
2023-02-19 14:18:17 +13:00
Bruce Weirdan
4f22c2e7c6
Propagate phantom classes to closure context
...
Fixes vimeo/psalm#9317
2023-02-18 01:52:10 -04:00
Bruce Weirdan
1c2bc49838
Forbid non-null defaults for callable parameters
...
Fixes vimeo/psalm#3284
2023-02-16 01:36:06 -04:00
Bruce Weirdan
e6aa63731d
Flag docblock parameters that have no counterparts in function signature
...
Fixes vimeo/psalm#3166
2023-02-15 22:04:26 -04:00
Bruce Weirdan
01911a06b7
Deprecate FunctionLikeStorage::$unused_docblock_params
...
Refs vimeo/psalm#3166
2023-02-15 21:29:20 -04:00
Bruce Weirdan
ee823619b8
Flag direct constructor calls
...
Fixes vimeo/psalm#2975
2023-02-15 20:14:00 -04:00
Bruce Weirdan
c28d96e25c
Fixed issue message for missing @psalm-external-mutation-free
...
Fixes vimeo/psalm#8604
2023-02-15 03:58:50 -04:00
Bruce Weirdan
2bb590feb6
Allow suppressing MissingThrowsDocblock
for individual exceptions
...
Fixes vimeo/psalm#8638
2023-02-15 03:29:02 -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
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
873d79c5d7
Forbid overriding built-in enum methods
...
Fixes vimeo/psalm#9274
2023-02-13 00:37:59 -04: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
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
7ae8f9f24c
Merge pull request #9250 from weirdan/dont-crash-on-unknown-exceptions-in-throws-docblock
...
Fixes https://github.com/vimeo/psalm/issues/9248
2023-02-09 03:34:11 -04: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
Andrew Boyton
5d976900d1
Fix divide by a floating point zero
...
The code was failing when dividing by 0.0.
2023-02-09 11:55:06 +11:00
Bruce Weirdan
3c4a829f71
Fixed more CS issues
2023-02-07 11:20:02 -04: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
Matt Brown
234787bcd6
Fix logic bugs caught by better elseif checks
2023-02-03 00:30:42 -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
Bruce Weirdan
fb65c79079
Fix newly discovered CS issues
2023-02-02 12:19:22 -04:00
Mark McEver
77ea545244
Attempted to avoid a psalm warning that was not accurate
2023-02-01 15:50:36 -06: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
d49b35c92a
Merge branch 'master' into unify-deprecation-messages
2023-01-26 23:02:59 +01:00
Andrew Nagy
b14ed73c0b
Merge tag '5.6.0' into feature/upgrade-lsp-v5
2023-01-25 17:08:24 +00:00
40a05d574a
Improve error messages
2023-01-25 12:26:59 +01:00
Alies Lapatsin
b667db20e6
Merge branch 'master' into unify-deprecation-messages
2023-01-24 06:41:43 +01: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
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
Alies Lapatsin
a28d825476
Do not display "Enabled extensions: " for empty ext list
2023-01-18 20:55:14 +01:00
Alies Lapatsin
3b5d1a4856
Fix coding-style issue
2023-01-10 23:01:40 +01:00
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
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
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
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
kkmuffme
fcf42840f3
fix @psalm-scope-this not working with FQCN with leading backslash
2022-12-30 18:30:31 +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
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
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
Theodore Brown
e4b0343f76
Fix PHPCS trailing comma
2022-12-28 09:35:34 -06: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
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
Andrew Nagy
82d8974fe3
merge to v5
2022-12-20 20:52:25 +00: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
ab2692fdd3
Update
2022-12-19 18:31:43 +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
9d7dd20293
Fix some tests
2022-12-19 13:04:24 +01:00
b91ad2cb1d
Begin fixing #8942
2022-12-19 12:55:32 +01:00
Jack Worman
1c19260cdd
Require trailing commas
2022-12-18 13:20:31 -06: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
c454a181cc
Fixes
2022-12-18 15:00:15 +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
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
Jack Worman
76a7c7da4a
Added SlevomatCodingStandard.TypeHints.PropertyTypeHint sniff
2022-12-14 20:43:26 -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
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
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
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
a444f286bb
Integrate FidryCpuCoreCounter
2022-12-04 20:24:18 +01:00
orklah
2490230f1f
fix missing break handling in loop
2022-12-04 13:57:59 +01: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
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
Andrew Nagy
da66665de9
Merge branch '4.x' into feature/upgrade-lsp
2022-11-30 17:59:23 +00: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
Matthew Brown
1819a2d880
Add diagnostic message when shape fields are missing ( #8762 )
...
* Add a simple diagnostic for missing array shape fields
* Fix dumb mistakes
* Allow nested shape extra keys to prompt warning too
2022-11-26 11:26:36 -05:00
orklah
b9a532db26
Merge pull request #8754 from orklah/#8041
...
improve docs and phrasing about NoValue
2022-11-25 20:18:40 +01:00
orklah
2856ab1cdc
typo
...
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2022-11-25 20:18:27 +01:00
Matthew Brown
a0e4468a9a
Simplify assertions generated by an array_key_exists check ( #8763 )
2022-11-25 12:16:37 -05:00
orklah
4d358c4be9
improve docs and phrasing about NoValue
2022-11-24 20:49:34 +01:00
orklah
bca202bf5e
Merge pull request #8749 from Nicelocal/fix_8748
...
Fix #8748
2022-11-24 19:44:44 +01:00
85071b61a3
Fix #8748
2022-11-24 11:28:00 +01:00
orklah
3b6faf9638
Merge pull request #8737 from weirdan/enforce-arrow-function-formatting
...
Enforce arrow function formatting
2022-11-23 06:58:34 +01:00
54db59682d
Allow parameter types to be contained by a class template type ( #8731 )
...
* Allow parameter types to be contained by a class template type in function calls
* Specify PHP version of tests
* Fix tests
2022-11-23 00:14:30 -05:00
Bruce Weirdan
026354a18e
Enforce arrow function formatting
2022-11-23 00:08:29 -04:00
Bruce Weirdan
6554aa05a7
Emit MixedMethodCall
when calling new
on object
2022-11-19 17:29:35 -04:00
Bruce Weirdan
d7561919b2
Allow new
on objects
...
Fixes vimeo/psalm#8355
2022-11-19 16:53:07 -04:00
orklah
4e17585093
Merge pull request #8714 from kkmuffme/dont-rewrite-config-hash-to-cache-when-unchanged
...
Fix cache race condition due to missing repopulation of lock files cache
2022-11-18 22:08:37 +01:00
kkmuffme
ff49dfca1d
Fix lock files not updated when cache is cleared race condition
2022-11-17 09:31:02 +01:00
kkmuffme
17c246b827
code style
2022-11-15 10:51:44 +01:00
kkmuffme
d410c9d4bc
improve cache flush debug info and code if cache disabled
2022-11-15 10:39:52 +01:00
Matthew Brown
8d36bdc3ed
Make array shapes strict by default ( #8701 )
...
* Make array shapes strict by default
* Fix PSL tests
2022-11-11 20:14:21 -05:00
Bruce Weirdan
512ad832f3
TObjectWithProperties::$methods
have lowercase keys
...
Method names in PHP are case-insensitive.
2022-11-10 19:55:36 -04:00
Matthew Brown
d63da1f66e
Prevent array{a: Foo} going cleanly into array<Foo> ( #8691 )
...
* Prevent array{a: Foo} going cleanly into array<Foo>
* Add test for new behaviour
* Fix code style issues
* Allow unions to be cloned again
* Simplify params properties
2022-11-10 09:18:27 -05:00