Bruce Weirdan
682943423e
Merge branch '5.7.x' into master
2023-02-24 15:54:48 -04:00
Yannick Gottschalk
0a0f900d4c
Fixed codestyle and psalm errors
2023-02-24 15:27:17 +01:00
Yannick Gottschalk
ad5bf62094
Fixes #9373
2023-02-24 13:32:04 +01:00
Yannick Gottschalk
98d3514197
Refs #9373 , partial fix
2023-02-24 10:17:27 +01: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
5f59f07163
Allow array
as magic method name
...
Fixes vimeo/psalm#9321
2023-02-24 02:23:09 -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
ea32d203b6
Disable opcache.preload
if it's enabled
...
Fixes vimeo/psalm#9382
Also reorganized the opcache settings check a bit and enforced
`opcache.jit_buffer_size`
2023-02-23 22:17:23 -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
e96a929451
Merge pull request #9383 from weirdan/process-psalm-api-on-methods
2023-02-23 04:00:42 -04:00
Bruce Weirdan
2e90cb6c6a
Process @psalm-api
tags on methods
2023-02-23 03:52:10 -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
a26d3edb73
Fix newly found issue
2023-02-22 21:16:33 -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
bf56db7623
Fixes
2023-02-23 01:40:30 +01: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
Alies Lapatsin
e6bcd054b1
Merge branch 'master' into simplify-shepherd
2023-02-22 02:55:40 +01:00
f665e719fb
Describe changes
2023-02-21 15:44:18 +01:00
Alies Lapatsin
df00fd17fc
Fix coding style issues
2023-02-21 12:49:19 +01:00
Alies Lapatsin
609c426133
Add DeprecatedMethod suppression
2023-02-21 12:40:23 +01:00
Alies Lapatsin
46c486b271
Fix output formatting
2023-02-21 12:16:11 +01:00
Alies Lapatsin
124569c8ef
Display debug info for all error responses
2023-02-21 12:13:52 +01:00
Alies Lapatsin
cabeb5b983
Bypass output overlap
...
like:
Shepherd error: https://custom-host.shepherd/hooks/psalm endpoint responded with 0 HTTP status code.
array (
Shepherd response: n/a
'url' => 'https://custom-host.shepherd/hooks/psalm ',
Please check shepherd endpoint — it should be a valid URL. cURL Debug info:
'content_type' => NULL,
'http_code' => 0,
'header_size' => 0,
'request_size' => 0,
'filetime' => -1,
'ssl_verify_result' => 0,
'redirect_count' => 0,
'total_time' => 0.025202,
'namelookup_time' => 0.0,
'connect_time' => 0.0,
'pretransfer_time' => 0.0,
'size_upload' => 0.0,
'size_download' => 0.0,
'speed_download' => 0.0,
'speed_upload' => 0.0,
'download_content_length' => -1.0,
'upload_content_length' => -1.0,
'starttransfer_time' => 0.0,
'redirect_time' => 0.0,
'redirect_url' => '',
'primary_ip' => '',
'certinfo' =>
array (
),
'primary_port' => 0,
'local_ip' => '',
'local_port' => 0,
'http_version' => 0,
'protocol' => 0,
'ssl_verifyresult' => 0,
'scheme' => '',
'appconnect_time_us' => 0,
'connect_time_us' => 0,
'namelookup_time_us' => 0,
'pretransfer_time_us' => 0,
'redirect_time_us' => 0,
'starttransfer_time_us' => 0,
'total_time_us' => 25202,
'effective_method' => 'POST',
)
2023-02-21 12:04:18 +01:00
Alies Lapatsin
6603d84dfb
Display debuging info for a 0 cURL HTTP status response
2023-02-21 11:56:57 +01:00
Alies Lapatsin
66ce363431
Prepend URL scheme for th legacy host
2023-02-21 11:13:20 +01:00
Alies Lapatsin
b78472c752
Display $endpoint on error message (simplify debugging)
2023-02-21 10:59:31 +01:00
575da79801
Fix #9363
2023-02-21 10:09:58 +01:00
Alies Lapatsin
6ba9b1bb17
Merge branch 'master' into simplify-shepherd
2023-02-21 09:30:21 +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
Evan Shaw
a03299f3d0
Include setrawcookie as an impure function
2023-02-21 14:24:05 +13:00
Bruce Weirdan
471a8c6a1d
Merge pull request #9354 from othercorey/fix-php74
2023-02-20 18:34:36 -04:00
Corey Taylor
c23de496cf
Replace use of DOMParentNode::append() with appendChild()
2023-02-20 14:45:04 -06:00
88a3d288de
Workaround arm64 opcache bug ( fixes #9350 )
2023-02-20 12:49:59 +01:00
Alies Lapatsin
547dfb4237
Merge branch 'master' into simplify-shepherd
2023-02-20 10:52:02 +01:00
Ismail Turan
bec8ddf525
fix (DateTime|DateTimeImmutable)::modify() return types
...
vimeo#9042 caused issues to any called method on an instance
of DateTime|DateTimeImmutable after calling the modify
method.
This fixes vimeo#9171
2023-02-20 08:47:05 +01:00
Bruce Weirdan
1b0f322bc7
Fix PsalmRestarter::restart()
signature
...
XdebugHandler v2 did not have the param type hint
Fixes vimeo/psalm#9345
2023-02-19 20:38:03 -04:00
5df21fe448
Always use 0x7FFEBFFF opcache optimization level ( fixes #9340 )
2023-02-19 16:57:23 +01:00
Evan Shaw
a25fe35584
Negated is_numeric narrows scalar type
2023-02-19 22:38:34 +13: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
5fe902bde5
Merge pull request #9326 from vimeo/prevent-jit-warnings
2023-02-18 18:22:59 -04:00
Gregor Harlan
80e781315a
RedundantCast
2023-02-18 12:58:40 +01:00
Bruce Weirdan
4f22c2e7c6
Propagate phantom classes to closure context
...
Fixes vimeo/psalm#9317
2023-02-18 01:52:10 -04:00
Bruce Weirdan
4d871fd241
Disable JIT-incompatible extensions to prevent warnings
...
This also enables JIT for `psalter` and syncs the list of disabled
extensions between `psalm`, `psalter` and `psalm-language-server`
2023-02-17 15:32:37 -04:00
Alies Lapatsin
d805f80f95
Merge branch 'master' into simplify-shepherd
2023-02-16 11:12:24 +01:00
Alies Lapatsin
2ddc54331d
Merge branch 'master' into disableExtensions-hides-warnings
2023-02-16 10:55:38 +01: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
cd5b743d6b
Fix newly found issues
2023-02-15 22:18:30 -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
Alies Lapatsin
9e9629c474
Fix check for supported php-ext
2023-02-15 22:34:06 +01:00
Alies Lapatsin
4da3252886
Merge branch 'master' into disableExtensions-hides-warnings
2023-02-15 22:01:38 +01: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
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
f1e04f2dc3
Reorganize Shepherd logic to improve redability and support custom endpoint
2023-02-14 20:01:37 +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
b54cefe33f
Emit warning if the opcache cannot be installed or JIT cannot be used
2023-02-13 18:32:54 -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
08f5b3592e
Merge pull request #9265 from weirdan/fix-opcache-loaded-twice
2023-02-12 22:42:44 -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
orklah
93267f298b
Merge pull request #9253 from kkmuffme/fix-lstat-bug-when-removing-cache-dir
...
fix lstat bug cache directory race condition
2023-02-11 12:24:00 +01:00
Bruce Weirdan
528ac003ce
Do not try tweaking JIT if it's not available
2023-02-11 07:04:17 -04:00
Bruce Weirdan
542cc343fc
Fix opcache being loaded twice
...
Fixes vimeo/psalm#9263
2023-02-11 06:42:48 -04: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
kkmuffme
78c3d6b436
fix lstat bug cache directory race condition
2023-02-09 09:27:51 +01: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
d7e0bc5d25
Always enable JIT
2023-02-07 18:13:41 +01:00
Bruce Weirdan
3c4a829f71
Fixed more CS issues
2023-02-07 11:20:02 -04:00
kkmuffme
9346b7f74b
find_unused_code CLI arg should not be overwritten by config file
2023-02-07 11:31:46 +01: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
Alies Lapatsin
a5a2daa993
Use early return
2023-02-02 22:15:26 +01:00
orklah
a56e08d4ff
Merge pull request #9207 from ging-dev/master
...
fix `didChange` event in LSP
2023-02-02 19:35:11 +01:00
Bruce Weirdan
fb65c79079
Fix newly discovered CS issues
2023-02-02 12:19:22 -04:00
ging-dev
79c3779033
fix didChange
event in LSP
2023-02-02 16:41:10 +07: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
3c38e02b62
allow dynamically changing configuration without restarting
2023-01-26 09:40:07 +00:00
Andrew Nagy
468e7e7d45
add cli command to turn off xdebug turnoff functionality, fix bug with docblock
2023-01-26 09:12:43 +00:00
Andrew Nagy
27c0caf2fb
Fixes #9180 allow baseline file
2023-01-25 18:13:27 +00: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
Andrew Nagy
b14ed73c0b
Merge tag '5.6.0' into feature/upgrade-lsp-v5
2023-01-25 17:08:24 +00:00
Bruce Weirdan
0682adf3e4
Merge pull request #9173 from shvlv/feature/support-class-constants-for-phpstorm-meta-override
2023-01-25 12:31:17 -04:00
Jack Worman
375cdeb636
cdata in baseline
2023-01-25 10:57:28 -05:00
Jack Worman
32581a71fd
cdata in baseline
2023-01-25 10:54:33 -05:00
40a05d574a
Improve error messages
2023-01-25 12:26:59 +01:00
247d30f74c
Detect duplicate keys in array shapes
2023-01-25 10:42:05 +01:00
shvlv
eca7079982
Fix Psalm errors
2023-01-25 11:32:41 +02: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
Alies Lapatsin
9d54de6a51
Use a new method to display warning
2023-01-24 06:50:09 +01:00
Alies Lapatsin
0cc770c947
Use a new method to display warning
2023-01-24 06:48:03 +01:00
Alies Lapatsin
b667db20e6
Merge branch 'master' into unify-deprecation-messages
2023-01-24 06:41:43 +01:00
Alies Lapatsin
68842a50c5
Use STDERR for Shepherd output, fixes #9168
2023-01-23 21:14:18 +01:00
Bruce Weirdan
f0df1192c4
Merge pull request #9164 from weirdan/do-not-allow-this-in-static-closures
...
Fixes https://github.com/vimeo/psalm/issues/9148
Fixes https://github.com/vimeo/psalm/issues/2813
2023-01-23 12:51:50 -04:00
Bruce Weirdan
bfce3a41e4
Closures that use $this
should not be static
2023-01-23 05:47:11 -04: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
Maarten Buis
2065f625cb
HEAD in all caps
2023-01-23 08:42:54 +01:00
Bruce Weirdan
2af7f51394
Suppress warnings when --no-output
is specified
2023-01-22 20:40:21 -04:00
Alies Lapatsin
73f90229bb
Merge branch 'master' into fix-shepherd-without-custom-domain
2023-01-22 13:03:40 +01: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
ca063a46d9
Use more readable for Psalm expressions
2023-01-20 09:39:39 +01:00
Alies Lapatsin
e3e1c92c07
Fix shepherd for default domain
...
When you run `psalm` like `psalm --shepherd`,
$options['shepherd'] === false
2023-01-18 21:28:01 +01:00
Alies Lapatsin
089b388c91
Unify deprecation messages
2023-01-18 21:19:30 +01:00
Alies Lapatsin
a1a2ecc957
Merge branch 'master' into unify-deprecation-messages
2023-01-18 21:14:02 +01:00
Alies Lapatsin
a28d825476
Do not display "Enabled extensions: " for empty ext list
2023-01-18 20:55:14 +01:00
Alies Lapatsin
2f385a9057
Unify deprecation messages
2023-01-18 20:54:49 +01:00
Alies Lapatsin
e6ea61c91b
Enhance error output for shephed
2023-01-18 19:59:09 +01:00
Alies Lapatsin
aac6ead2d9
Fix coding style issues
2023-01-18 19:06:51 +01:00
Alies Lapatsin
363a0b6b22
Add suppressions for using a deprecated property
2023-01-18 19:06:51 +01:00
Alies Lapatsin
d5e5dc0683
Fully support Psalm 5 behaviour
...
asked by orklah, see
https://github.com/vimeo/psalm/pull/9112#issuecomment-1383239821
2023-01-18 19:06:51 +01:00
Alies Lapatsin
291484df44
Return getCurlErrorMessage() method as it can be used outside
2023-01-18 19:06:51 +01:00
Alies Lapatsin
8e5715875a
Update cli help text
2023-01-18 19:06:51 +01:00
Alies Lapatsin
587ac6e018
Fix coding style issues
2023-01-18 19:06:51 +01:00
Alies Lapatsin
c95b0718c4
Properly process HTTP response codes from shepherd servers
2023-01-18 19:06:51 +01:00
Alies Lapatsin
09517d3176
Follow redirects when submitting shepherd reports
2023-01-18 19:06:51 +01:00
Alies Lapatsin
30ab11bae1
Use safer type operations with cli $options array
2023-01-18 19:06:32 +01:00
Alies Lapatsin
7e157cfe9d
Allow to specify a custom shepherd endpoint (instead of domain)
2023-01-18 19:06:32 +01:00
Jack Worman
56f6dfecc8
Report unused baseline entries
2023-01-17 22:02:21 -05:00
Jack Worman
f9aa2d5ad3
Support constants in traits
2023-01-17 16:37:44 -05:00
Ezequiel
602d3ed53e
Add missing int-range
aliases into the list of psalm reserved words
2023-01-13 11:15:01 -03:00
Alies Lapatsin
f471ba9f36
Merge branch 'master' into auto-load-random-ext-stub-on-php82
2023-01-12 18:54:08 +01:00
Alies Lapatsin
fc72214bfc
Automatically load stubs for random ext on PHP 8.2
2023-01-12 12:52:45 +01: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
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
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