1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 09:47:29 +01:00
Commit Graph

8599 Commits

Author SHA1 Message Date
Bitwise Operators
f782313c45 Add BitwiseNot and BooleanNot operators to SimpleTypeInferer. Should fix #8307. 2022-08-03 15:48:54 +02:00
24f7920e9a
Fix if propagation (#8326)
* Add failing unit test

* Fix test

* Revert "Add comment for skipped test"

This reverts commit e4f73beb08.

* Revert "Simplify context updates even more"

This reverts commit a32e63f131.

* Revert "Remove special handling for elseifs that breaks for else if"

This reverts commit d7d9ddc653.

* Fix test
2022-07-30 19:20:05 -04:00
Bruce Weirdan
c9e6b54050
CS fix 2022-07-29 23:08:11 -04:00
Bruce Weirdan
7444ea8e2d
Simplify some methods to keep Psalm happy 2022-07-29 23:01:49 -04:00
Bruce Weirdan
238b54abf8
Revert one particular replacement that confuses Psalm 2022-07-29 22:00:21 -04:00
Bruce Weirdan
58e87fa5e0
Applied ArraySpreadInsteadOfArrayMergeRector (take 2) 2022-07-29 18:17:21 -04:00
AndrolGenhald
148264305f
Merge pull request #8341 from someniatko/issue-7731
recognize `@psalm-allow-private-mutation` in PHP 8+ constructors
2022-07-29 09:31:20 -05:00
someniatko
0abde258fa #7731 - recognize @psalm-allow-private-mutation in PHP 8+ constructors 2022-07-29 16:50:56 +03:00
someniatko
0c652f72f6 #8330 - take into account that static type may have been unwrapped in ExistingAtomicStaticCallAnalyzer#hasStaticInType() 2022-07-29 12:31:37 +03:00
orklah
7c4228fb56
Merge pull request #8324 from Nicelocal/fix_union_assertions
Fix union assertions
2022-07-28 19:06:14 +02:00
7a7a7f6bc9
cs-fix 2022-07-28 12:05:13 +02:00
33d8f3a62d
Fix unit tests 2022-07-28 12:03:12 +02:00
abe58876a7
Fix 2022-07-27 20:32:44 +02:00
6ce32a48d5
Fix 2022-07-27 20:24:24 +02:00
68f3f246f5
Fix 2022-07-27 20:08:00 +02:00
1a4d68e53b
Make private 2022-07-27 18:56:24 +02:00
82e8c0dea8
Disable intersection of unrelated classes 2022-07-27 18:55:01 +02:00
c409675e3e
Fix intersection of final classes 2022-07-27 18:46:07 +02:00
c2a8d1bb06
cs 2022-07-27 18:00:24 +02:00
e19589117d
Fix unit test 2022-07-27 17:56:41 +02:00
09fb879428
Fix #8322, #8319 2022-07-27 17:42:48 +02:00
18106af5e5
Refactor 2022-07-27 14:39:34 +02:00
AndrolGenhald
094621d5bb Fix array-shape value type being mixed instead of single key being mixed. 2022-07-26 12:00:05 -05:00
AndrolGenhald
ee68184527 Fix key comparison when unpacking Traversables. 2022-07-26 12:00:05 -05:00
AndrolGenhald
2b389df270 Use count instead of empty. 2022-07-26 12:00:05 -05:00
AndrolGenhald
d54eebfe02 Fix various array spread issues.
- Correctly infer `array` and `list` instead of `non-empty-array` and `non-empty-list` (fixes #7296)
 - Add support for spreading string keys (fixes #7297).
 - Show issue when trying to unpack non-iterable
 - Show issue when trying to unpack iterable with non-array-key key
 - Re-added invalid PHP 8.0 tests removed in #6613
 - Unpacked lists with known keys will be inferred as eg `array{0: int, 1: int}<int<0, max>, int>` now but will still be treated as lists
 - Unpacked arrays with known keys will now be inferred as eg `array{a: string, b: string}<int, int>` instead of `array<int|string, int|string>`
2022-07-26 12:00:03 -05: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
Semyon
b1295d6894 Code style 2022-07-25 17:15:28 +03:00
AndrolGenhald
ba6270c06a Fix type reconciliation breaking Context::$references_in_scope (fixes #8289). 2022-07-21 14:27:21 -05:00
kkmuffme
e1b0255db8 fix triggerErrorExits not working
Fix https://github.com/vimeo/psalm/issues/8270
2022-07-21 12:54:47 +02:00
kkmuffme
233863dc0c circle CI error for unrelated code? 2022-07-21 11:36:55 +02:00
kkmuffme
bb760a2224 fix race conditions causing notices if directory does not exist 2022-07-21 11:36:16 +02:00
Oliver Hader
6c5e5f77fa
Avoid cloning undefined array index 2022-07-20 21:36:49 +02:00
orklah
85fe7e8bcf
Merge pull request #8283 from AndrolGenhald/feature/value-of-backed-enum
Allow `value-of` to work with backed enums (fixes #7874).
2022-07-20 18:03:58 +02:00
AndrolGenhald
66ebf4a55c Rename TKeyOfArray to TKeyOf. 2022-07-18 14:44:29 -05:00
AndrolGenhald
6505d8e6d5 Fix trailing comma for PHP 7.4. 2022-07-18 14:19:34 -05:00
AndrolGenhald
b51b5ac903 Allow value-of to work with backed enums (fixes #7874). 2022-07-18 14:10:06 -05:00
Matt Brown
a32e63f131 Simplify context updates even more 2022-07-17 13:11:32 -04:00
Matt Brown
d7d9ddc653 Remove special handling for elseifs that breaks for else if 2022-07-17 12:51:17 -04:00
Matt Brown
8c716f8be7 Support taints in new $_GET["a"] calls 2022-07-15 22:17:59 -04:00
AndrolGenhald
cac9ec957c
Merge pull request #8249 from someniatko/issue-8200
Improve inferring the "final" `static` type when calling static methods inside a different class
2022-07-14 16:41:01 -05:00
orklah
416b597d1c
Merge pull request #7994 from aszenz/4.x
Adds support for fixing missing throws doc block
2022-07-12 20:46:14 +02:00
someniatko
931b3bb18b #8200 - simplify ExistingAtomicStaticCallAnalyzer::hasStaticType() 2022-07-12 21:43:31 +03:00
someniatko
b3e673d7ec #8200 - flip logic of determining "source" of static type in ExistingAtomicStaticCallAnalyzer::getMethodReturnType() 2022-07-12 21:17:10 +03:00
someniatko
3a5054018b #8200 - generalize ExistingAtomicStaticCallAnalyzer::hasStaticInType() for non-object cases 2022-07-12 21:00:19 +03:00
someniatko
470885e4f1 #8200 - improve inferring the "final" static type when calling static methods inside a different class
differentiate between `static` defined in a class which CALLS a given static method, and `static` defined in the method which IS CALLED.
2022-07-12 13:51:28 +03:00
orklah
7f3d55dfa0
Merge pull request #8244 from jack-worman/CountReport
New "Count" Report Format
2022-07-11 18:55:01 +02:00
Jack Worman
3b76ac85dc Count Report Format 2022-07-10 17:50:50 -05:00
kkmuffme
a77f6fca12 use error_log 2022-07-10 12:04:42 +02:00
kkmuffme
7742d8a903 use lock to fix race condition 2022-07-10 10:03:18 +02:00
AndrolGenhald
285740a753 Merge branch '4.x' 2022-07-07 15:01:38 -05:00
Christian Schiffler
8ffab5eada Remove now obsolete casts 2022-07-06 08:59:19 +02:00
Christian Schiffler
ea9903a2c6 Fix variable annotation 2022-07-06 08:59:07 +02:00
Christian Schiffler
6305c21b5b Remove now obsolete loop
The class names in property map are now always lowercase
2022-06-29 09:23:45 +02:00
kkmuffme
90586083e6 check if file in cache already before adding
* reduces I/O by 30%
* minimal performance improvement (<0.5%)
2022-06-28 20:46:23 +02:00
kkmuffme
9082eab915 improve cache hash performance
* do not concatenate with timestamp as this is slow, since $file_contents may be big
* use file contents not file path for cache hash only to ensure it works if file_path not set but file_content is
* improves performance by ~5%
2022-06-28 20:45:03 +02:00
kkmuffme
57239a7c8e assign keys to variable for better performance
improves performance by ~1-1.5%
2022-06-28 20:40:43 +02:00
kkmuffme
4048bb9d8b only sort when necessary and faster hash
* sort is much more expensive than count, so we only sort if we have something to sort
* could implement for ksort too, but advantage there is minimal since we almost always have more than 1 possibility
* use same hash algorithm as in other places (= faster)
* reduces runtime by 2-3%
2022-06-28 20:40:43 +02:00
kkmuffme
4db928e923 split loop for better performance
* check isset for all elements first, as array_diff is much more expensive
* Improves performance by 1%
2022-06-28 20:40:43 +02:00
Tim Düsterhus
31ad16d29c
Stop using deprecated string interpolation syntax in StatementsProvider.php
This fixed the following PHP 8.2 deprecation:

> Uncaught RuntimeException: PHP Error: Using ${var} in strings is deprecated, use {$var} instead in …/vimeo/psalm/src/Psalm/Internal/Provider/StatementsProvider.php:140

see: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
2022-06-27 23:41:51 +02:00
orklah
7dff408b25
Merge pull request #8077 from boesing/bugfix/5657
Feature: allow non-union assertion types
2022-06-27 20:55:37 +02:00
orklah
47d83093c3
Merge pull request #8181 from Nicelocal/avoid_reparsing
Avoid re-parsing template types
2022-06-27 19:14:43 +02:00
Maximilian Bösing
df927d076d
qa: drop unnecessary ensure_source_equality check
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-27 18:19:34 +02:00
38089ebec3
Avoid re-parsing template types 2022-06-27 11:38:17 +02:00
orklah
06dd975cb5
Merge pull request #8174 from AndrolGenhald/fix-attribute-crash
Fix crash when redefining method with fewer params (fixes #8141).
2022-06-26 13:47:54 +02:00
AndrolGenhald
e751a27eaf Fix crash when redefining method with fewer params (fixes #8141). 2022-06-26 06:27:46 -05:00
orklah
b3038f0936
Merge pull request #8164 from AndrolGenhald/encapsed-literal-strings
Encapsed literal strings
2022-06-26 12:52:33 +02:00
orklah
a4ab664aee
Merge pull request #8165 from AndrolGenhald/stop-using-issuebuffer-add-😡
Improve @psalm-internal and prevent usage of IssueBuffer::add().
2022-06-25 10:12:10 +02:00
AndrolGenhald
b671117417 Improve @psalm-internal and prevent usage of IssueBuffer::add(). 2022-06-25 02:09:40 -05:00
AndrolGenhald
5ff54bce46 CS fix. 2022-06-24 21:03:33 -05:00
AndrolGenhald
3aea0987ef Fix non-empty encapsed string check. 2022-06-24 20:28:04 -05:00
AndrolGenhald
a804e459b6 PHP 7.1 compatibility. 2022-06-24 19:29:12 -05:00
AndrolGenhald
2559222f67 More interpolation and concatenation improvements. 2022-06-24 19:22:59 -05:00
orklah
8b7bc07ad6
Merge pull request #8155 from Nicelocal/prohibition_analyzer_clone
Run method call prohibition analyzer when cloning
2022-06-25 01:31:00 +02:00
AndrolGenhald
450409f045 Infer literal string from encapsed (interpolated) string. 2022-06-24 17:24:34 -05:00
Benjamin Morel
933714f6ad Add ReflectionProperty properties 2022-06-24 18:47:49 +02:00
7a5120c4f7
Run method call prohibition analyzer when cloning 2022-06-24 12:37:33 +02:00
Matt Brown
7be32f2020 Remove unused use 2022-06-23 21:30:12 -04:00
Matt Brown
e6c444410c Remove debug code 2022-06-23 18:03:33 -04:00
Matt Brown
15387d19cd Track taints in static properties 2022-06-23 16:43:42 -04:00
orklah
cbc597f80c
Merge pull request #8140 from AndrolGenhald/stubs-dom-simplexml
Update DOM stub and add separate SimpleXML stub
2022-06-22 18:52:45 +02:00
AndrolGenhald
c0de59c943 Add simplexml stub. 2022-06-22 01:15:43 -05:00
Matt Brown
710768e496 Remove comma 2022-06-21 14:59:01 -04:00
Matt Brown
6fa0da9e37 Fix minor taint analysis bug with nested array assignment 2022-06-21 12:42:32 -04:00
orklah
c60e0a890c
Merge pull request #8056 from kkmuffme/phpdoc-false-positives-for-partially-invalid
fix false positives for partially invalid phpdoc
2022-06-15 13:21:26 +02:00
f8724761b3
Fix parameter storage corruption 2022-06-13 10:28:33 +02:00
Maximilian Bösing
0d96766640
bugfix: single does not mean that only one single atomic type is stored within a union
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 19:39:13 +02:00
Maximilian Bösing
3fd7a8b6d7
qa: refactor code to avoid too many nesting levels
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 19:27:54 +02:00
Maximilian Bösing
7e033d8051
bugfix: do not extend the type - only narrow down
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 19:20:38 +02:00
Maximilian Bösing
ed1bb8a9a6
bugfix: in case the old type is already more accurate than the new type, do not consider the new type as a replacement
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 03:35:59 +02:00
Maximilian Bösing
02d4f0c614
feature: add more accurate equals checks for TLiteralFloat, TLiteralInt and TLiteralString
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 03:34:45 +02:00
Maximilian Bösing
6a73fbd1d2
bugfix: tighten the detection of types which narrow down other types
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 02:51:36 +02:00
Maximilian Bösing
4068f5cbb0
feature: add Union#allFloatLiterals as it was missing
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 02:50:48 +02:00
Maximilian Bösing
e13268f5c0
qa: use $assertion_var_id over $arg_var_id for better type reflection
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 01:33:13 +02:00
Maximilian Bösing
6c1ed90dc1
qa: ensure we use multiple isset to verify the existence of $arg_var_id
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 01:29:30 +02:00
Maximilian Bösing
c68b6e9d26
bugfix: only allow narrowing down types in case the old type is not single
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 01:21:38 +02:00
Maximilian Bösing
4ee1b3feb4
bugfix: only extend existing logic instead of hijacking it
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 01:15:46 +02:00
Maximilian Bösing
2d9133b35a
bugfix: overriding types based on assertions have to pass more checks
Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-12 00:32:36 +02:00
Maximilian Bösing
7c85e0c0d9
bugfix: only override templated values in case of literals
This will avoid issues with invalid intersection assertions.

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-11 23:30:52 +02:00
d352ae4e07
Skip native classlike aliases 2022-06-09 11:20:02 +02:00
Maximilian Bösing
40971ff57d
bugfix: allow non-single union types in assertions
fixes #5657

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
2022-06-09 00:26:34 +02:00
Matt Brown
a9775c656c Fix style 2022-06-08 16:03:27 -04:00
Matt Brown
6d09c3c794 Remove nonsensical taint analysis rule 2022-06-08 16:00:06 -04:00
orklah
02d5beecb0
Merge pull request #8051 from AndrolGenhald/bugfix/8048
Fix possibly empty array shape appearing non-empty (fixes #8048).
2022-06-08 19:22:12 +02:00
AndrolGenhald
af5c191e7b Fix generic object comparison to use template constraint as default (fixes #8068). 2022-06-07 19:12:36 -05:00
Bruce Weirdan
4e59398f77
Coerce null to empty string in array keys
Fixes vimeo/psalm#8063

Alters the fix for vimeo/psalm#2165 (1a48be8e9c)

/cc: @iluuu1994, @muglug
2022-06-06 17:41:42 -04:00
AndrolGenhald
34322b79dd Fix suppression comment. 2022-06-06 16:19:27 -05:00
kkmuffme
74671e3a3c fix false positives for partially incalid phpdoc 2022-06-05 12:16:01 +02:00
orklah
f47b4180fb
Merge pull request #8054 from kkmuffme/runtime-cache-origin-location
store origin location by ID to speed up psalm by up to 75%
2022-06-04 18:47:14 +02:00
kkmuffme
cb78f54d8a Performance: cut the selected_text from snippet
instead of from full text

50% faster than cutting from full text, improves performance up to 3% depending on file length and number of errors in file
2022-06-04 15:53:02 +02:00
kkmuffme
8b20708063 stores origin location by ID to speed up psalm by up to 75% in certain cases 2022-06-04 14:26:27 +02:00
AndrolGenhald
c271b1245e Fix possibly empty array shape appearing non-empty (fixes #8048). 2022-06-02 14:00:52 -05:00
AndrolGenhald
2f090e5722 Fix TypeCombiner::combine to not modify TIntRange arguments.
This keeps coming up in obscure places, hopefully this fixes it once and for all. I would reeeaaally love to have an immutable type system at some point...
2022-06-02 12:36:41 -05:00
AndrolGenhald
054ed300f0
Fix side effect when loading config. 2022-05-29 00:16:38 -04:00
Bruce Weirdan
fce4272226
PHP 7.4 fixes 2022-05-28 16:40:49 -04:00
Bruce Weirdan
5d21ff98b6
Suppress false posisitives 2022-05-28 16:34:53 -04:00
Bruce Weirdan
242ee344ec
CS fix 2022-05-28 16:26:08 -04:00
Bruce Weirdan
ff50516fbd
Post-merge fixes 2022-05-28 15:05:17 -04:00
Bruce Weirdan
e0acf22e40
Merge branch '4.x' into update-master 2022-05-28 14:49:12 -04:00
AndrolGenhald
6df50159a7 Fix trailing comma in parameter list for PHP 7.4. 2022-05-26 18:41:00 -05:00
AndrolGenhald
31b4dceaf4 Improve handling of unsupported references (fixes #8018). 2022-05-26 18:28:23 -05:00
orklah
06d8e3e399
Merge pull request #8011 from kkmuffme/performance-only-load-files-once
Performance only load files once
2022-05-26 18:03:08 +02:00
orklah
d94f56a88a
Merge pull request #8007 from kkmuffme/add-missing-igbinary-serialize-code
igbinary_serialize code was missing in file
2022-05-26 17:57:02 +02:00
kkmuffme
278e8777d9 dont strolower filename, since file names on linux are case sensitive 2022-05-25 14:12:15 +02:00
kkmuffme
06178d0a6b only load files once
* use static to keep opened files with content
* move position of file cache population to the place where we read files to ensure cache always gets populated and not on open only (since it's called directly in some places)
2022-05-25 13:53:32 +02:00
kkmuffme
5d8b5d197d micro-optimize condition
https://github.com/vimeo/psalm/pull/7997#pullrequestreview-983975049
2022-05-25 11:25:19 +02:00
kkmuffme
ed0db0f7ce igbinary_serialize code was missing in file 2022-05-25 10:52:41 +02:00
kkmuffme
acffb851f6 debug CI 2022-05-24 10:00:54 +02:00
kkmuffme
c1cef60e21 change cache hash type for better performance 2022-05-24 09:59:47 +02:00
asrar
e3f46d9a3c refactor: use list<string> 2022-05-23 19:45:33 +02:00
asrar
e28831dff8 feat: fix ci + preserve existing throws 2022-05-22 18:27:38 +02:00
asrar
c6854cf567 Adds support for fixing missing throws doc block 2022-05-21 17:39:51 +02:00
AndrolGenhald
80e94daefb Fix class const issue when using floats declared in future consts (fixes #7973).
- Calculate literal type for float arithmetic instead of only for int arithmetic
 - Fix copy/paste fail causing InvalidConstantAssignmentValue to be marked as fixable
2022-05-20 14:46:05 -05:00
Jerome TAMARELLE
afed93b6bd Fix conflict of option -c with shell completion 2022-05-20 09:42:57 +02:00
Matt Brown
990887148c Fix #7968 - combine and simplify types where necessary in ternary analysis 2022-05-19 22:32:14 -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
Theodore Brown
4eef964048 Infer object shape when array or scalar is cast to object
Also detect redundant object casts.

Fixes #7916, fixes #7934
2022-05-09 20:31:29 -05:00
Theodore Brown
6f3ceea7d0 Remove several unused use statements 2022-05-08 23:18:18 -05:00
Matt Brown
9c153de6da Fix LSP api discrepancies 2022-04-27 11:56:54 -04:00
Matt Brown
c260626ccd Fix style issues 2022-04-27 10:35:22 -04:00
Matt Brown
fccc366c1e Merge pull request #7887 from ging-dev/lsp-fixes
improve LSP
2022-04-27 10:13:17 -04:00
Matt Brown
84598077f8 better type safety and inference 2022-04-27 01:51:23 -04:00
Matt Brown
5b91506926 cache statements even without persistent parser cache 2022-04-27 01:50:13 -04:00
Matt Brown
d064d9fc6c Add test 2022-04-27 01:47:02 -04:00
Matt Brown
2ef993928c Document @psalm-ignore-variable-* 2022-04-27 01:46:13 -04:00
Matt Brown
a9e3c1fdc1 Fix namespaced min/max int range keyword issue introduced in #7775. 2022-04-27 01:44:57 -04: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
Matt Brown
043bbfbbb4 Remove useless array casting as CallMap for stream_select is reset. 2022-04-27 01:40:51 -04:00
Matt Brown
890375d908 Cast the read streams to an array while looping over as it can be NULL. 2022-04-27 01:39:30 -04:00
Matt Brown
d0524c2418 Forbid min bound greater than max bound in int range 2022-04-27 01:38:21 -04:00
Matt Brown
9cc2af56b4 Support Stringable before PhpToken autoloading 2022-04-27 01:36:17 -04:00
Matt Brown
d58736a550 fix #7747: DateInterval::createFromDateString can be false 2022-04-27 01:32:38 -04:00
orklah
038947eb08
Merge pull request #7887 from ging-dev/lsp-fixes
improve LSP
2022-04-26 22:23:00 +02:00
m1ke
70b44d566f Alter order of baseline option operations to allow updating custom baseline 2022-04-26 14:35:33 +01:00
ging-dev
cb10e845e0
improve LSP 2022-04-25 17:43:23 +07:00
orklah
2724c1dba9
Merge pull request #7872 from hirokinoue/float-template-arithmetics-4.x
don't emit issues when doing arithmetics on float templates
2022-04-19 19:35:57 +02:00
Vitaliy Ognev
6afdb0d9b6 better type safety and inference 2022-04-18 21:00:20 +03:00
Vitaliy Ognev
1dc2b3b026 cache statements even without persistent parser cache 2022-04-18 10:26:56 +03:00
hirokinoue
b132c3b751 fix error message 2022-04-16 14:05:40 +09:00
hirokinoue
a99532da5e code format 2022-04-16 14:05:31 +09:00
hirokinoue
23c3d87dcc don't emit issues when doing arithmetics on float templates 2022-04-16 14:05:20 +09:00
Anton Belyaev
e7c2c77ec2 Disable filepath formatting as a link for Drone CI's output 2022-04-11 23:19:55 +03:00
orklah
6d0cc07255
Merge pull request #7838 from VincentLanglet/sortTypes
Fix Incompatible types found for T (Stub&ProxyQueryInterface is not in ProxyQueryInterface&Stub)
2022-04-10 10:20:30 +02:00
Jeremiasz Major
5717516f2f
Remove @psalm-generator-return annotation 2022-04-09 22:15:37 +02:00
Aleksandr Zhuravlev
b4fdc3e326 Made most of callbacks static. Reworked some array_map() into foreach() 2022-04-09 21:58:26 +12:00
Matthew Brown
c8cc3f4607 Add a more homogenous solution 2022-04-06 12:10:11 -04:00
Matthew Brown
4cfab0c441 Fix/ignore dependency issues 2022-04-06 11:45:28 -04:00
Matthew Brown
ed0daaa234 Undo previous commit 2022-04-06 11:45:13 -04:00
Matthew Brown
f3135949fe Clone correct context 2022-04-06 11:36:26 -04:00
orklah
d176361028
Merge pull request #7844 from orklah/non-empty-string
fix refining lowercase string and non-empty-string together
2022-04-05 21:40:11 +02:00
orklah
b72f0564bc fix refining lowercase string and non-empty-string together 2022-04-05 21:05:23 +02:00
Thomas Landauer
587039fd1d Fixing CS 2022-04-03 11:41:39 +02:00
Vincent Langlet
590ac22ea2 Use another strategy 2022-04-03 09:16:00 +02:00
Vincent Langlet
3729c0d3ed Sort types when intersection is used 2022-04-02 22:08:44 +02:00
Thomas Landauer
e87c25c825 Second attempt of #7835 2022-04-02 14:57:56 +02:00
Michael Stilkerich
a696e559b7 Treat readline functions as impure 2022-04-01 16:13:55 +02:00
25105ff4c2
Remove unused suppress 2022-04-01 12:47:54 +02:00
b69e22a33b Add a few additional dupes 2022-04-01 12:19:29 +02:00
f0560728d8 Invert meaning of dupe_key 2022-04-01 12:19:29 +02:00
AndrolGenhald
0bdf9425e3 Fix namespaced min/max int range keyword issue introduced in #7775. 2022-03-30 16:08:14 -05:00
Jordi Boggiano
bbef5700d9
Without with 2022-03-23 14:50:14 +01:00
Jordi Boggiano
076a916401
Update docs on TIntMaskOf 2022-03-23 12:19:55 +01:00
orklah
80f972cc38
Merge pull request #7791 from ohader/issue-7771-4x
Avoid json_encode when serializing non-UTF8 literals
2022-03-16 19:00:49 +01:00
Matthew Brown
a9f4148db2 Rename referenced_var_ids to cond_referenced_var_ids
Also reduce usage — this was a holdover of the old way of tracking unused variables
2022-03-15 18:40:31 -04: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
Oliver Hader
2b3753676b
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-03-15 10:39:58 +01:00
orklah
32f10c392d
Merge pull request #7788 from AndrolGenhald/attribute-analysis-improvements
More attribute fixes.
2022-03-14 21:11:19 +01:00
AndrolGenhald
11f51f4c54 Use key-of instead of literal int union. 2022-03-14 15:05:33 -05:00
AndrolGenhald
08d4d797ef More attribute fixes. 2022-03-14 14:15:07 -05:00
orklah
83c534414e
Merge pull request #7787 from orklah/callable-string
restore callable-string Id
2022-03-14 20:11:56 +01:00
orklah
d1ce74bc79 fix name 2022-03-14 20:07:03 +01:00
Matthew Brown
e578413d3f Calculate upper bound ahead of time
This prevents generating large numbers of clauses we'll have to ignore anyway
2022-03-14 11:32:51 -04:00
Matthew Brown
77f47ede92 Remove ref to unused function 2022-03-14 10:40:46 -04:00
Matthew Brown
040122403d Clause sort should be normal, not reversed 2022-03-14 10:38:42 -04:00
Matthew Brown
8d5664d539 Remove unused line 2022-03-12 23:23:46 -05:00
Matthew Brown
76119237cc Fix #7776
When a new clause contains tautology it can be disregarded entirely
2022-03-12 23:21:42 -05:00
Matthew Brown
64d7792479 Fix too-long line 2022-03-12 22:37:06 -05:00
Matthew Brown
9c8e088917 Fix style 2022-03-12 22:33:58 -05:00
Matthew Brown
ed4782e0e0 Improve performance of large formula operations 2022-03-12 22:31:12 -05:00
Matthew Brown
427eecdcd8 Remove unnecessary switch statement code 2022-03-11 22:02:55 -05:00
fluffycondor
7240f01154
Code style 2022-03-11 23:02:11 +00:00
fluffycondor
cb5231463c
Make error message more verbose 2022-03-11 22:58:41 +00:00
fluffycondor
6bc90fa0a9
Fix error messages 2022-03-11 22:54:30 +00:00
Semyon
9beb0a62b2 Forbid min bound greater than max bound in int range 2022-03-11 17:26:59 +03:00
Semyon
a7e98f4bfc Forbid any non literal int in int range (except min and max named objects) 2022-03-11 17:26:07 +03:00
Matthew Brown
f0b214265c Remove slash 2022-03-07 16:09:03 -05:00
Matthew Brown
2a9ea7ea71 Support Stringable before PhpToken autoloading 2022-03-07 16:08:24 -05:00
Matthew Brown
4311386122 Add a bunch of necessary fixes to get phar scoping working on PHP 7.4 2022-03-07 16:06:38 -05:00
Matthew Brown
3dfe31b334 Fix path once more 2022-03-07 15:37:22 -05:00
Matthew Brown
03cd1c79e6 Fix path 2022-03-07 15:34:32 -05:00
Matthew Brown
34d6ef3b90 Use direct path 2022-03-07 15:33:16 -05:00
Matthew Brown
2034fc3f8b Hard-load stringable interface 2022-03-07 15:31:10 -05:00
Matthew Brown
4b0667bb14 Group some functionality together 2022-03-07 14:40:28 -05:00
Mateusz Cholewka
483d35980a check is value for sure is null 2022-03-07 14:07:16 +01:00
Mateusz Cholewka
d53f57b5f7 wrap row in union again
From: https://github.com/vimeo/psalm/pull/7760#discussion_r820264671

$result_element_type should be a Union, $row_shape is an Atomic
(a part of a Union). new Union([$row_shape]); should be ok
2022-03-06 21:28:48 +01:00
Mateusz Cholewka
56e65fd5ba skip creating unnecessary union 2022-03-06 17:07:56 +01:00
Mateusz Cholewka
88d49b9923 provide array column type for null column 2022-03-06 15:44:56 +01:00
Matthew Brown
9f9fefe7d6 Simplify loop logic a little 2022-03-02 18:49:57 -05:00
Matthew Brown
766fc174a3 Remove unnecessary $child_stmt 2022-03-02 17:34:56 -05:00
Matthew Brown
54edbdabf6 A little light refactoring 2022-03-02 17:27:58 -05:00
Abdul Malik Ikhsan
9666b90e41
Register openssl_sign function to impure functions
openssl_sign has $signature parameter that by reference that can re-used
2022-03-02 22:59:12 +07:00
orklah
cb158726a0
Merge pull request #7359 from Patrick-Remy/feat/properties-of
feat(types): add properties-of<T> type
2022-02-28 19:28:21 +01:00
Matthew Brown
569e97d5e9 Minor fix for single parent inheritance 2022-02-27 23:57:44 -05:00
Matthew Brown
d17d82e4e3 Simplify template population 2022-02-27 23:51:51 -05:00
orklah
2f3c150690 merge fixes 2022-02-26 21:28:15 +01:00
orklah
0fe6eaf5d9 Merge remote-tracking branch 'upstream/4.x' into upstream-master13 2022-02-26 21:26:59 +01:00
orklah
fc2c6ab4d5
Merge pull request #7727 from AndrolGenhald/attribute-analysis-improvements
Attribute analysis improvements
2022-02-24 21:34:05 +01:00
orklah
26bfc95b13 allow SimpleTypeInferer to infer non empty lists 2022-02-24 20:57:29 +01:00
Patrick Remy
51f3b9869b
docs: add properties-of type to plugins type system 2022-02-24 18:50:35 +01:00
AndrolGenhald
c82abe3017 Fix trailing commas for PHP 7. 2022-02-23 22:30:50 -06:00
AndrolGenhald
5f9a8c9240 Fix types. 2022-02-23 22:12:32 -06:00
AndrolGenhald
43764f0c3d Add Reflection getAttributes analysis. 2022-02-23 22:12:32 -06:00
AndrolGenhald
1387f94324 Attribute analysis improvements. 2022-02-23 22:12:32 -06:00
Patrick Remy
be49037d70
feat: add template support to properties-of<T> 2022-02-23 21:30:09 +01:00
orklah
3a85f49268
Merge pull request #7673 from VincentLanglet/pdoException
PDOException extends RuntimeException and can use int code errors
2022-02-23 13:45:57 +01:00
Patrick Remy
d81c74eb62
style: fix linting issues and failing tests 2022-02-22 20:13:24 +01:00
Bei Xiao
c9666bbeb5 Reduce method complexity 2022-02-22 20:50:43 +02:00
Patrick Remy
6e783d863d
feat: ignore static properties in properties-of<T> 2022-02-22 19:49:03 +01:00
Bei Xiao
6a3b5679fe Support interfaces extending enums 2022-02-22 16:04:56 +02:00
Aaron Piotrowski
97b5685f55
Fix first-class callable in loop 2022-02-21 18:37:20 -06:00
Patrick Remy
9c6deacc69
feat: expand properties-of to keyed array 2022-02-21 23:02:27 +01:00
Patrick Remy
30fac906c6
feat(types): add properties-of<T> type 2022-02-21 21:15:02 +01:00
orklah
1a5b120081
Merge pull request #7713 from AndrolGenhald/bugfix/self-in-attribute
Use current context when analyzing attributes
2022-02-21 18:50:22 +01:00
AndrolGenhald
04c0db5aff Use current context when analyzing attributes (fixes #7710). 2022-02-21 10:38:50 -06:00
m1ke
628bf584c2 Alter config file to actually load threads param 2022-02-21 11:07:21 +00:00
Bruce Weirdan
997bded2e3
Merge branch '4.x' into upstream-master 2022-02-21 01:08:21 +02:00
orklah
b8cda9eb00
Merge pull request #7684 from AndrolGenhald/bugfix/minor-reference-fixes
Fix some minor issues with references.
2022-02-20 23:21:56 +01:00
Bruce Weirdan
d7d846edc8
Merge branch '4.x' into upstream-master 2022-02-20 02:31:15 +02:00
Bruce Weirdan
97bd81cf5e
Merge pull request #7699 from AndrolGenhald/bugfix/int-range-unpacking 2022-02-19 00:04:32 +02:00
AndrolGenhald
9310a4ff5a Fix issues with int range unpacking and with min/max. 2022-02-18 15:55:26 -06:00
Bruce Weirdan
6a68287700
Merge pull request #7696 from AndrolGenhald/improve-bool-to-int-cast 2022-02-18 22:17:29 +02:00
AndrolGenhald
525a86e19d Improve bool to int casting. 2022-02-18 13:22:17 -06:00
AndrolGenhald
c1077f32d3 Improve documentation for InvalidGlobal to explain that it's sometimes valid. 2022-02-18 11:36:25 -06:00
AndrolGenhald
0476ca7844 Fix trailing commas for PHP < 7.3. 2022-02-18 08:44:51 -06:00
AndrolGenhald
ea2f452c25 Analyze attribute statements instead of constructing virtual statements. 2022-02-18 08:18:34 -06:00
a.dmitryuk
8e1e0d1e5e style-ci 2022-02-18 10:33:35 +07:00
a.dmitryuk
dc8764153e Throw exception if file_put_contents failed 2022-02-18 10:05:23 +07:00
AndrolGenhald
d09e420939 Add @psalm-check-type and @psalm-check-type-exact.
I initially added these as part of my TryAnalyzer rewrite to allow testing complicated `finally` types like this:
```
$foo = 1;
try {
        $foo = 2;
} catch (Exception $_) {
        $foo = 3;
} finally {
        $bar = $foo;
        /** @psalm-check-type-exact $bar = 1|2|3 */;
}
/** @psalm-check-type-exact $bar = 2|3 */;
```
Using the `'assertions'` in tests doesn't work since the type is different inside the `finally`.

I decided to extract the new annotation from the rest of my changes and do a separate pull request since I think others may find it useful, and it should be much easier to review than the entire TryAnalyzer rewrite.
2022-02-17 10:37:13 -06:00
AndrolGenhald
8f710cc37f Fix crash when data_flow_graph is null. 2022-02-17 10:34:34 -06:00
AndrolGenhald
580278d323 Fix some minor issues with references.
References assigned to properties on `$this` should never be unused.
Using a `@var` docblock before a reference should be allowed if it targets a variable instead of the assignment statement.
2022-02-17 09:31:33 -06:00
Matthew Brown
6af3b502df Remove unnecessary array assignment 2022-02-16 13:04:23 -05:00
Bruce Weirdan
e47752afb4
Merge pull request #7666 from AndrolGenhald/more-class-const-improvements
More class const improvements.
2022-02-16 03:43:37 +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
Vincent Langlet
694157b2e0 PDOException extends RuntimeException and can use int code errors 2022-02-14 21:04:10 +01:00
AndrolGenhald
cc2334f40d More class const improvements.
Add InvalidClassConstType issue as alternative to LessSpecificClassConstType when type isn't contravariant.
Handle final class consts (#6395).
Use double quotes for types in class const issues.
2022-02-13 17:19:25 -06:00
orklah
1142c818c2 Merge remote-tracking branch 'upstream/4.x' into upstream-master9 2022-02-14 00:10:28 +01:00
orklah
b796f4558a
Merge pull request #7665 from orklah/matchcount
fix count with match on arrays
2022-02-13 22:49:31 +01:00
orklah
97a6abd823 don't anonymize call to count to allow assertions on count to be retrieved 2022-02-13 22:38:38 +01:00
AndrolGenhald
fd0ecf2528 Rename variable to be consistent with existing convention. 2022-02-13 15:34:21 -06:00
AndrolGenhald
32c389482c Fix issue with nested try block and add more tests. 2022-02-13 15:30:06 -06:00
AndrolGenhald
7b1599d783 Fix false positive for unused variable in try (fixes #7613). 2022-02-13 15:14:59 -06:00
orklah
8a49caccac
Merge pull request #7663 from orklah/never2
Consistency for empty reconciliations
2022-02-13 20:01:45 +01:00
orklah
093d9b2821 allow use of an empty reconciliation if the type is from docblock 2022-02-13 19:44:12 +01:00
orklah
5f1b796af9 redundant condition 2022-02-13 19:38:44 +01:00
orklah
586c70c8d3 Reconcile IsNotType between EnumCase and NamedObject 2022-02-13 19:38:44 +01:00
orklah
cf25363fa1 empty reconciliation should return never or mixed depending of the source of the type 2022-02-13 19:36:09 +01:00
orklah
59d3d2aa31
Merge pull request #7655 from orklah/enumCollapsing
Enum collapsing
2022-02-13 11:01:07 +01:00
orklah
954884eb48 consistency between TernaryAnalyzer and IfElseAnalyzer 2022-02-13 10:52:22 +01:00
Bruce Weirdan
52ad607c96
Merge pull request #7661 from weirdan/fix-array_fill_keys 2022-02-13 11:05:05 +02:00
Bruce Weirdan
edddc87002
Merge branch '4.x' into upstream-master 2022-02-13 07:14:23 +02:00
Bruce Weirdan
4ee8a80a17
Use array_fill_keys
There was a number of calls to `array_map(fn()=>true, array_flip($array))` that got replaced with a simpler (and more performant) `array_fill_keys($array, true)`
2022-02-13 07:09:28 +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
60feb5fd71 allow collapsing enum cases under named object in combiner 2022-02-12 20:31:39 +01:00
orklah
1d224cebf7
Merge pull request #7651 from orklah/new
remove totallyTyped
2022-02-12 10:29:23 +01:00
orklah
a915ef5853 also remove a from_calculation flag which was scheduled for removal in Psalm 5 2022-02-12 10:19:39 +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
92aedd6f7f Fix cherry pick issues 2022-02-11 11:27:01 +00:00
m1ke
fc694d7a98 Allow psalm to load threads from the config 2022-02-11 11:23:17 +00:00
m1ke
a688bd6da3 Use config threads if lower than detected threads 2022-02-11 11:23:09 +00:00
m1ke
810880c71b Alter order of precedence and upated docs to match 2022-02-11 11:12:36 +00:00