Alies Lapatsin
1115cfb980
Merge branch 'master' into php-ext-with-deprecation
...
# Conflicts:
# src/Psalm/Config.php
2022-12-12 23:49:01 +01: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
16ab9f786b
Unify a way how to load stubs for extentions
2022-12-10 17:02:47 +01: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
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
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
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
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
kkmuffme
4b20fd3e62
safe delete cache directory files
...
since we safeFileGetContents, it makes sense to also acquire lock before deleting, to avoid reading partial data
2022-11-15 19:54:43 +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
1986c8b4a8
Add support for strict arrays, fix type alias intersection, fix array_is_list assertion on non-lists ( #8395 )
...
* Immutable CodeLocation
* Remove excess clones
* Remove external clones
* Remove leftover clones
* Fix final clone issue
* Immutable storages
* Refactoring
* Fixes
* Fixes
* Fix
* Fix
* Fixes
* Simplify
* Fixes
* Fix
* Fixes
* Update
* Fix
* Cache global types
* Fix
* Update
* Update
* Fixes
* Fixes
* Refactor
* Fixes
* Fix
* Fix
* More caching
* Fix
* Fix
* Update
* Update
* Fix
* Fixes
* Update
* Refactor
* Update
* Fixes
* Break one more test
* Fix
* FIx
* Fix
* Fix
* Fix
* Fix
* Improve performance and readability
* Equivalent logic
* Fixes
* Revert
* Revert "Revert"
This reverts commit f9175100c8452c80559234200663fd4c4f4dd889.
* Fix
* Fix reference bug
* Make default TypeVisitor immutable
* Bugfix
* Remove clones
* Partial refactoring
* Refactoring
* Fixes
* Fix
* Fixes
* Fixes
* cs-fix
* Fix final bugs
* Add test
* Misc fixes
* Update
* Fixes
* Experiment with removing different property
* revert "Experiment with removing different property"
This reverts commit ac1156e077fc4ea633530d51096d27b6e88bfdf9.
* Uniform naming
* Uniform naming
* Hack hotfix
* Clean up $_FILES ref #8621
* Undo hack, try fixing properly
* Helper method
* Remove redundant call
* Partially fix bugs
* Cleanup
* Change defaults
* Fix bug
* Fix (?, hope this doesn't break anything else)
* cs-fix
* Review fixes
* Bugfix
* Bugfix
* Improve logic
* Add support for list{} and callable-list{} types, properly implement array_is_list assertions (fixes #8389 )
* Default to sealed arrays
* Fix array_merge bug
* Fixes
* Fix
* Sealed type checks
* Properly infer properties-of and get_object_vars on final classes
* Fix array_map zipping
* Fix tests
* Fixes
* Fixes
* Fix more stuff
* Recursively resolve type aliases
* Fix typo
* Fixes
* Fix array_is_list assertion on keyed array
* Add BC docs
* Fixes
* fix
* Update
* Update
* Update
* Update
* Seal arrays with count assertions
* Fix #8528
* Fix
* Update
* Improve sealed array foreach logic
* get_object_vars on template properties
* Fix sealed array assertion reconciler logic
* Improved reconciler
* Add tests
* Single source of truth for test types
* Fix tests
* Fixup tests
* Fixup tests
* Fixup tests
* Update
* Fix tests
* Fix tests
* Final fixes
* Fixes
* Use list syntax only when needed
* Fix tests
* Cs-fix
* Update docs
* Update docs
* Update docs
* Update docs
* Update docs
* Document missing types
* Update docs
* Improve class-string-map docs
* Update
* Update
* I love working on psalm :)
* Keep arrays unsealed by default
* Fixup tests
* Fix syntax mistake
* cs-fix
* Fix typo
* Re-import missing types
* Keep strict types only in return types
* argc/argv fixes
* argc/argv fixes
* Fix test
* Comment-out valinor code, pinging @romm pls merge https://github.com/CuyZ/Valinor/pull/246 so we can add valinor to the psalm docs :)
2022-11-05 22:34:42 +01:00
Alies Lapatsin
d9a08ec047
Add stubs for ext-random (PHP 8.2)
2022-11-02 15:59:56 +03:00
Thomas Gerbet
62e92fb0cf
Add stubs for ext-ffi
...
See #8612
2022-10-25 19:59:44 +02:00
748a74bb2c
Merge remote-tracking branch 'origin/4.x' into HEAD
2022-10-16 13:41:27 +02:00
kkmuffme
b1c0c2d8a1
add hideAllErrorsExceptPassedFiles config option
...
for files only (not directories, since that wouldn't make practical sense)
2022-09-24 10:44:01 +02:00
Matt Brown
6f298d2af2
Fix phpcs violations
2022-09-13 12:33:47 -04:00
kkmuffme
978f37e421
improve unlinking potential race condition
...
* fix rare race condition on file cache unlink
* remove unnecessary reset()
* improve code readability using variable
2022-09-11 10:28:16 +02:00
kkmuffme
8da5f5eb1a
use exceptions instead of error_log for ParserCacheProvider
...
* use exceptions instead of error_log for ParserCacheProvider like all other cache providers do
* remove duplicate code in ParserCacheProvider
* use same hash as other cache providers
* update Config.php cache directory creation to use same code as ParserCacheProvider
2022-09-11 10:22:48 +02:00
orklah
76cfb911b2
Merge pull request #8469 from kkmuffme/strictify-anchored-preg-replace
...
preg_replace with anchor will always only have 1 replacement
2022-09-08 20:01:16 +02:00
kkmuffme
d0984f4e47
fix psalm internal errors reported by new checks
2022-09-08 19:35:44 +02:00
kkmuffme
15046c932b
preg_replace with anchor will always only have 1 replacement, add limit for clarity and performance
2022-09-08 18:51:33 +02:00
orklah
d7cd84c4eb
Merge pull request #8302 from kkmuffme/fix-cache-directory-race-conditions
...
fix race conditions causing notices if directory does not exist
2022-07-25 19:04:37 +02:00
kkmuffme
e1b0255db8
fix triggerErrorExits not working
...
Fix https://github.com/vimeo/psalm/issues/8270
2022-07-21 12:54:47 +02:00
kkmuffme
bb760a2224
fix race conditions causing notices if directory does not exist
2022-07-21 11:36:16 +02:00
kkmuffme
a77f6fca12
use error_log
2022-07-10 12:04:42 +02:00
AndrolGenhald
c0de59c943
Add simplexml stub.
2022-06-22 01:15:43 -05:00
AndrolGenhald
054ed300f0
Fix side effect when loading config.
2022-05-29 00:16:38 -04:00
Bruce Weirdan
e0acf22e40
Merge branch '4.x' into update-master
2022-05-28 14:49:12 -04:00
Kevin van Sonsbeek
22080a1b15
bugfix/#7912: Added extension_loaded check for apcu and load internal stub on true
2022-05-17 23:45:42 +02:00
Matt Brown
20351c6667
Avoid json_encode when serializing non-UTF8 literals
...
`\Psalm\Internal\Clause::$hash` basically holds a hash on
arbitrary input literals, used for later comparison. Using
`json_encode` fails when dealing with non-UTF8 literals,
which has been replaced by plain PHP `serialize`.
Resolves : #7771
2022-04-27 01:42:37 -04:00
Aleksandr Zhuravlev
b4fdc3e326
Made most of callbacks static. Reworked some array_map() into foreach()
2022-04-09 21:58:26 +12:00
orklah
ebffd5258a
Merge pull request #7433 from zoonru/maximum_shaped_array_size
...
Add configuration for maximum size of shaped array
2022-03-15 21:19:05 +01:00
orklah
0fe6eaf5d9
Merge remote-tracking branch 'upstream/4.x' into upstream-master13
2022-02-26 21:26:59 +01:00
m1ke
628bf584c2
Alter config file to actually load threads param
2022-02-21 11:07:21 +00:00
Bruce Weirdan
d7d846edc8
Merge branch '4.x' into upstream-master
2022-02-20 02:31:15 +02:00
87d9a01f78
Add configuration for maximum size of shaped array
2022-02-15 14:09:08 +01:00
eb3df40fbb
Add option to disable @var parsing everywhere except for properties.
2022-02-15 10:04:56 +01:00
Bruce Weirdan
edddc87002
Merge branch '4.x' into upstream-master
2022-02-13 07:14:23 +02:00
Bruce Weirdan
dc776d3ada
Suppress false-positive
2022-02-13 00:48:58 +02:00
Bruce Weirdan
45a19b3f3c
Honour global function suppressions for UndefinedFunction
...
Fixes vimeo/psalm#7610
2022-02-13 00:22:55 +02:00
orklah
1d224cebf7
Merge pull request #7651 from orklah/new
...
remove totallyTyped
2022-02-12 10:29:23 +01:00
orklah
85fca56850
remove totallyTyped
2022-02-12 10:19:14 +01:00
orklah
6355597250
fix CS
2022-02-12 10:05:53 +01:00
orklah
e6d491a4ab
Merge remote-tracking branch 'upstream/master' into upstream-master7
2022-02-12 10:01:08 +01:00
orklah
fac55576ab
Merge remote-tracking branch 'upstream/4.x' into upstream-master7
2022-02-12 09:59:55 +01:00
orklah
a3852b8a55
Merge pull request #7650 from orklah/totallytyped
...
deprecate totallyTyped
2022-02-12 09:56:39 +01:00
orklah
dbf47b16c3
deprecate totallyTyped
2022-02-12 09:30:37 +01:00
orklah
c13a536386
Merge pull request #7614 from kkmuffme/add-phpredis-stubs
...
add phpredis stubs
2022-02-11 23:15:48 +01:00
sasezaki
c46818ac24
Removed unnecessary var annotation
2022-02-11 22:51:31 +01:00
sasezaki
d0baffb534
DOMElement instead of DomElement - https://php.net/DOMElement
...
to avoid composer-require-check reports false-positive,
just did - find src/ -type f -exec sed -i -e 's/DomElement/DOMElement/g' {} \;
2022-02-11 22:51:31 +01:00
m1ke
fc694d7a98
Allow psalm to load threads from the config
2022-02-11 11:23:17 +00:00
Office
432d0be658
load phpredis stubs
2022-02-09 15:56:51 +01:00
Bruce Weirdan
3e837cabd0
Finalize (and internalize) more classes
2022-02-05 23:51:03 +02:00
AndrolGenhald
588d9e08bc
Fix extension capitalization issue, add extensions to version message.
2022-02-03 11:34:50 -06:00
Oliver Hader
3fedb5cce6
Apply code styles
2022-01-30 13:06:02 +01:00
Oliver Hader
62a0ece035
!!! Allow plugins to modify Config::$fileExtensions early
...
ProjectAnalyzer consumed Config::$fileExtensions early in its
constructor - without having processed plugins' modifications,
registering their custom scanners or analyzer implementations.
This change
* adds new specific interface \Psalm\Plugin\FileExtensionsInterface
to be used by plugin implementations
* extracts file extension handling from \Psalm\PluginRegistrationSocket
and interface \Psalm\Plugin\RegistrationInterface to a new dedicated
\Psalm\PluginFileExtensionsSocket and new interface
\Psalm\Plugin\FileExtensionsInterface
!!! this is a breaking change in PluginRegistrationSocket !!!
* adds runtime in-memory cache for Config::$plugins
* calls new method Config::processPluginFileExtensions(), providing
modifications to file extension only early in ProjectAnalyzer
* adjusts documentation
2022-01-30 13:06:00 +01:00
orklah
2966f1c9d4
Merge pull request #7107 from AndrolGenhald/feature/5482-load-extensions-based-on-composer-config
...
Enable extensions based on composer.json instead of those loaded at runtime (fixes #5482 ).
2022-01-28 18:45:52 +01:00
AndrolGenhald
b473d812aa
Fix side effect when loading config.
2022-01-28 09:26:58 -06:00
AndrolGenhald
5c01913456
Remove deprecated loadXdebugStub attribute.
2022-01-27 16:55:20 -06:00
AndrolGenhald
c2b44ff073
Fix copy/paste fail and other psalm/cs issues, reduce duplication of literals.
2022-01-27 16:31:09 -06:00
AndrolGenhald
8132b57881
Add XML config options to enable/disable PHP extensions.
2022-01-27 16:31:05 -06:00
AndrolGenhald
2fe4fc397c
Enable extensions based on composer.json instead of those loaded at runtime ( fixes #5482 ).
2022-01-27 16:30:14 -06:00
orklah
9168cef2d4
Merge remote-tracking branch 'upstream/4.x' into upstream-master6
2022-01-26 21:06:25 +01:00
orklah
7c8441baec
Merge pull request #7123 from AndrolGenhald/feature/942-type-annotate-class-constants
...
Support type annotations for class consts (fixes #942 ).
2022-01-25 20:54:40 +01:00
Bruce Weirdan
3a6dc9b458
Merge pull request #7431 from zoonru/disable_suppress_all
2022-01-24 11:25:32 +02:00
orklah
7c4f08067b
Merge remote-tracking branch 'upstream/4.x' into upstream-master5
2022-01-23 23:44:04 +01:00
AndrolGenhald
558208e44e
Add type checking for class const assignments, fix several other const issues.
2022-01-22 17:06:54 -06:00
AndrolGenhald
01868a9766
Mark loadXdebugStub as deprecated (removed in #7107 ).
2022-01-22 16:03:35 -06:00
m1ke
1b8f337748
Allow psalm to load threads from the config
2022-01-20 09:49:45 +00:00
orklah
5a6dccd4a9
Merge pull request #7420 from orklah/remove-old-things
...
Remove forbidEcho
2022-01-19 20:32:19 +01:00
4cfe1a0773
Add configuration option to disable @psalm-suppress all
2022-01-19 13:24:26 +01:00
orklah
477c0113c2
Merge remote-tracking branch 'upstream/4.x' into upstream-master3
2022-01-18 18:37:04 +01:00
orklah
5f749c8a33
remove forbidEcho
2022-01-18 18:14:39 +01:00
Fabien Villepinte
c9eafa15ad
Improve signature of DOMDocument::loadXML()
2022-01-17 22:52:58 +00:00
orklah
b633619a2c
Merge remote-tracking branch 'upstream/4.x' into upstream-master
2022-01-14 21:01:25 +01:00
orklah
d786e9deef
deprecate attribute forbidEcho
2022-01-14 19:31:03 +01:00
orklah
af37af7d8c
Merge pull request #7242 from zoonru/seal_all_properties
...
PHP 8.2: seal all properties configuration
2022-01-10 21:36:31 +01:00
b530f23acc
PHP 8.2: seal all properties by default, add configuration key for lower versions
2022-01-10 10:11:28 +01:00
Wouter de Jong
e4e9edda27
Support multiple <issueHandlers> elements
...
This is likely to occur when including multiple Psalm config files.
2022-01-09 14:11:03 +01:00
Bruce Weirdan
1a1b5a9e6a
Merge branch '4.x' into upstream-master
2022-01-08 23:38:29 +02:00
Stefan Vetsch
7f2f0d99ec
Issue #7243 : Do not throw exception on xinclude with fallbacks
2022-01-07 09:40:19 +01:00
Bruce Weirdan
8726065d21
Applied ClosureToArrowFunctionRector
2022-01-06 00:48:04 +02:00
Bruce Weirdan
94395f18a4
Applied JsonThrowOnErrorRector
2022-01-05 19:32:43 +02:00
Bruce Weirdan
5758d31161
Apply literal number separator rector
...
I opted for customary 3-digit groups, except version id, where 2-digit
groups are used to match the version id encoding.
2022-01-05 01:00:05 +02:00
Bruce Weirdan
02b91cc54e
Replaced deprecated webmozart/path-util
2022-01-04 15:15:34 +02:00
Bruce Weirdan
55eb4b018b
Dropped removed config entries
2022-01-03 12:41:17 +02:00
Bruce Weirdan
966b6ae2b2
Merge pull request #6808 from orklah/exitFunctions3
2022-01-03 06:04:01 +02:00
Bruce Weirdan
f19e4cedc1
Merge pull request #6705 from orklah/phpstorm-generics-removal
2022-01-03 06:03:36 +02:00
orklah
b658b2738f
remove exitFunctions
2022-01-02 15:20:01 +02:00
orklah
4f7c1d05c1
remove support for allowPhpstormGenerics
2022-01-02 15:06:04 +02:00
orklah
8d6b781b3e
use consistent way to compare php version
2022-01-02 13:35:43 +02:00
edc797d1c2
Add docs
2021-12-30 11:56:16 +01:00