1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-12 17:27:28 +01:00
Commit Graph

543 Commits

Author SHA1 Message Date
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
ralila
6ee3d44092 Conversion of misc 2021-12-14 02:52:44 +01:00
ralila
c0adde8f45 Conversion of Psalm\CodeLocation\DocblockTypeLocation|Raw 2021-12-14 02:31:26 +01:00
ralila
e06d4ab5ac Conversion of Psalm\Exception\*Exception 2021-12-14 02:31:26 +01:00
AndrolGenhald
bfe7f96b56 Allow suppressing UnusedPsalmSuppress, remove unused suppressions. 2021-12-11 13:23:00 -06:00
AndrolGenhald
b29fc6ad3c Allow operator overloading for Decimal extension (fixes #3938). 2021-12-08 10:59:37 -06:00
rarila
39402c233d
Return type hints (#7065)
Co-authored-by: ralila <>
2021-12-05 19:51:26 +02:00
ralila
f833085a15 Fix fqn usage in php-doc 2021-12-04 03:37:19 +01:00
ralila
30a65685a2 Import instead of using fqn classes 2021-12-03 21:40:18 +01:00
ralila
7c32325e03 Import instead of using fqn constants 2021-12-03 21:25:22 +01:00
ralila
2a956498bf Import instead of using fqn functions 2021-12-03 21:07:25 +01:00
ralila
245920e53c Import instead of using fqn 2021-12-03 20:11:20 +01:00
Bruce Weirdan
d19aad7db1
Display target PHP version
Historically it was often not quite clear to users what PHP version
Psalm assumes, and why. This PR addresses this issue by printing the
version and where we got it from right before scanning the files.
2021-11-27 02:18:09 +02:00
Kamil Tekiela
d922808e8f Create mysqli.phpstub
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
2021-11-24 22:30:22 +00:00
AlessandroMinoccheri
ddc13a0dba using lenght istead of count for php 7.1 compatibility 2021-11-23 21:32:55 +01:00
Bruce Weirdan
01d07f9392
Report deprecated elements 2021-11-14 04:55:28 +02:00
orklah
1464e8f91e make ignore falsable/nullable dependent on the config 2021-11-13 11:37:22 +01:00