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
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
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
Bruce Weirdan
ee34d15b4d
SA and CS fixes
2022-11-26 00:18:45 -04:00
Bruce Weirdan
1555554d9f
Centralize version data access
...
Obtaining package version data from within a scoped PHAR file is a
complicated topic, and it's been alternatively broken and fixed multiple
times.
This change moves version data access to a single class, so that we can
fix it there should we need to.
The rest of the code can just rely on PSALM_VERSION constant (which will
be made unscoped in a further commit) or call `VersionUtils` methods.
2022-11-25 23:48:54 -04:00
orklah
45ed177693
Merge pull request #8766 from Chi-teck/regexp-validation
...
Suppress errors when validation regexps
2022-11-25 20:20:15 +01: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
Ivan
ae285a3f9b
Suppress errors when validation regexps
2022-11-25 17:54:44 +00:00
Matthew Brown
a0e4468a9a
Simplify assertions generated by an array_key_exists check ( #8763 )
2022-11-25 12:16:37 -05:00
Bruce Weirdan
0b1af26011
Merge pull request #8755 from weirdan/switch-from-prophecy-to-mockery
2022-11-25 03:42:58 -04:00
Bruce Weirdan
c417af7d44
CS fix
2022-11-25 03:35:47 -04:00
Bruce Weirdan
6c77daf1f4
Upgrade mockery plugin
...
and other assorted fixes for PHP 8.2
2022-11-25 03:33:10 -04:00