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

8544 Commits

Author SHA1 Message Date
Bruce Weirdan
161519883a
Merge pull request #7623 from weirdan/finalize-types 2022-02-11 00:27:10 +02:00
Matthew Brown
c885dbcbe0 Prevent duplicate type comparison errors 2022-02-10 01:04:14 -05:00
Bruce Weirdan
7c344366a3
Fix RedundantCondition 2022-02-10 01:44:50 +02:00
Bruce Weirdan
26e238cdc5
Finalize types nodes 2022-02-10 01:44:25 +02:00
orklah
9984397766
Merge pull request #7622 from orklah/assertions
consistency in AssertionFinder
2022-02-09 22:53:28 +01:00
orklah
511177556b only remove int from array-key if we're dealing with a general Int 2022-02-09 22:46:41 +01:00
orklah
a236aa2a41 only remove int from array-key if we're dealing with a general Int 2022-02-09 22:44:26 +01:00
Matthew Brown
2eca28c912 Remove more unused code from LoopAnalyzer 2022-02-09 16:37:15 -05:00
orklah
1c74774c40 consistency 2022-02-09 21:48:33 +01:00
orklah
0f1efa9079 documentation 2022-02-09 21:15:22 +01:00
Matthew Brown
5575fa1e32 Remove unnecessary method 2022-02-09 12:18:15 -05:00
Office
432d0be658 load phpredis stubs 2022-02-09 15:56:51 +01:00
Bruce Weirdan
21e6371ce2
Strip colours from success message
Fixes vimeo/psalm#7619
2022-02-09 15:35:40 +02:00
Matthew Brown
9d8b6d641b Remove more unused code 2022-02-08 18:20:14 -05:00
Matthew Brown
48b702b76a Remove some unnecessary code 2022-02-08 17:12:18 -05:00
Matthew Brown
e130dd9b1c Fix too-long line 2022-02-08 16:28:21 -05:00
Matthew Brown
e35e6fe992 Improve naming of variables 2022-02-08 16:25:33 -05:00
Matthew Brown
457abc6e13 Don’t subtract int from array-key if not equality 2022-02-08 11:24:05 -05:00
Matthew Brown
13824d5a33 Fix awkward workaround for loop assignment map 2022-02-08 10:59:29 -05:00
Matthew Brown
eda8e04a81 Narrow graph arrayfetch dataflow 2022-02-08 10:59:29 -05:00
Bruce Weirdan
b25a93e753
Finalize virtual nodes 2022-02-07 02:05:47 +02:00
Bruce Weirdan
958d1ca695
Finalize storages 2022-02-06 23:09:03 +02:00
Bruce Weirdan
a331ac0b21
Finalize issues 2022-02-06 00:27:18 +02:00
Bruce Weirdan
3e837cabd0
Finalize (and internalize) more classes 2022-02-05 23:51:03 +02:00
Tomasz Kusy
124aa22fe9 Resolve __DIR__ / __FILE__ when const/variable is used for include CS fix fix fix :) 2022-02-04 20:27:45 +01:00
Tomasz Kusy
8da45aa7d8 Resolve __DIR__ / __FILE__ when const/variable is used for include CS fix fix 2022-02-04 20:26:06 +01:00
Tomasz Kusy
b73f2c96d8 Resolve __DIR__ / __FILE__ when const/variable is used for include CS fix 2022-02-04 19:43:55 +01:00
Tomasz Kusy
bcbfbed072 Resolve __DIR__ / __FILE__ when const/variable is used for include 2022-02-04 19:39:39 +01:00
Matthew Brown
3a298d028e Rename getArrayVarId to getExtendedVarId 2022-02-04 12:49:12 -05:00
AndrolGenhald
5b469ca577 Fix crash when assigning reference to unknown array offset. 2022-02-04 08:32:35 -06:00
AndrolGenhald
588d9e08bc Fix extension capitalization issue, add extensions to version message. 2022-02-03 11:34:50 -06:00
phptest2
582624a932
improving error message for Could not resolve config path
$directory_path is false, so better use $prospective_directory_path in the error message.
2022-02-03 17:58:12 +01:00
Matthew Brown
8098755ce5 Remove comma 2022-02-02 11:29:31 -05:00
Matthew Brown
b382d7db3c Remove some unnecessary code around taint analysis 2022-02-02 11:25:03 -05:00
Matthew Brown
2b81990259 Simplify var naming 2022-02-02 11:25:02 -05:00
Vincent
3c3e692e7e AtomicStaticCallAnalyzer: clear tmp var from context (fix #7556) 2022-02-02 13:51:54 +01:00
orklah
1c2ffc81c2 tweaks 2022-02-01 22:49:20 +01:00
Bruce Weirdan
dadb1f2167
Merge pull request #7539 from vimeo/revert-7363-81_returntypewillchange 2022-02-01 01:03:09 +02:00
Bruce Weirdan
f61193b798
Reinstate MethodSignatureMustProvideReturnType
It's never emitted, but is there for BC.
2022-01-31 23:38:15 +02:00
orklah
68e67aeb10
Merge pull request #7546 from orklah/impure-callable
Handle first class callable on unknown functions
2022-01-31 22:02:35 +01:00
orklah
2e01e9b7cd
Merge pull request #7396 from Patrick-Remy/feat/key-of-value-of-improvements
feat: make key-of/value-of usable with non-const arrays
2022-01-31 21:39:01 +01:00
orklah
a598efb4ab Handle first class callable on unknown functions 2022-01-31 21:36:01 +01:00
adrew
e284b91b82 Remove redundant flag from SimpleTypeInferer 2022-01-31 23:03:34 +03:00
adrew
121a801616 Fix object constant inference 2022-01-31 23:03:34 +03:00
orklah
48e09ab308 fix 2022-01-31 20:55:53 +01:00
Patrick Remy
51d4bf556a
fix: replace template args in key-of/value-of
Extend TTemplateKeyOf from Atomic instead of Scalar, to ensure it is
only compared in AtomicTypeComparator to reduce duplicate code.
2022-01-31 20:53:36 +01:00
orklah
fc281672ea fix wrong detection of purity 2022-01-31 20:52:25 +01:00
Matthew Brown
fcfd4d30f3 Simplify passing in template result for calls 2022-01-31 09:36:40 -05:00
Bruce Weirdan
603714518b
Revert "PHP 8.1: Report missing typehints in overridden native methods" 2022-01-31 14:37:42 +02:00
ada778e8df
Remove unused field 2022-01-31 10:06:32 +01:00
8d0c1c62e8
Ensure all template parameters are specified in classes, interfaces, traits 2022-01-31 10:06:31 +01:00
Bruce Weirdan
997592de64
Merge pull request #7530 from ohader/issue-7528 2022-01-31 10:36:47 +02:00
Bruce Weirdan
b51cb75f76
Merge pull request #7535 from ohader/issue-7534 2022-01-31 10:34:57 +02:00
Oliver Hader
c4c7138329
Update src/Psalm/Plugin/EventHandler/Event/BeforeStatementAnalysisEvent.php
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2022-01-31 07:53:44 +01:00
Oliver Hader
ffafccc2ca
Update src/Psalm/Plugin/EventHandler/BeforeAddIssueInterface.php
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2022-01-31 07:52:33 +01:00
Oliver Hader
995ecd0964
Update src/Psalm/Plugin/EventHandler/Event/BeforeAddIssueEvent.php
Co-authored-by: Bruce Weirdan <weirdan@gmail.com>
2022-01-31 07:52:24 +01:00
Oliver Hader
6fd31cb5fa
[TASK] Remove deprecated AfterFunctionLikeAnalysisEvent::getClasslikeStorage 2022-01-31 00:34:03 +02:00
Bruce Weirdan
a2977a5ca9
Merge branch '4.x' into upstream-master 2022-01-31 00:16:27 +02:00
Oliver Hader
ff07a8d662
[TASK] Use final event class declarations 2022-01-30 19:29:12 +01:00
Oliver Hader
f5986950a2
[FEATURE] Introduce BeforeStatementAnalysisEvent
As counterpart to existing `AfterStatementAnalysisEvent` - invoked in
`\Psalm\Internal\Analyzer\StatementsAnalyzer` - this changed introcued
a corresponding `BeforeStatementAnalysisEvent`.

Resolves: #7534
2022-01-30 19:27:19 +01:00
orklah
31941d15e2
Merge pull request #7533 from orklah/emptyBack
add back empty keyword
2022-01-30 18:56:22 +01:00
orklah
84d9b5e10c add back empty 2022-01-30 18:43:44 +01:00
Oliver Hader
e3602bbfe1
[FEATURE] Allow to intercept adding issue in IssueBuffer
This change introduces new `BeforeAddIssueEvent` which is invoked
from `IssueBuffer::add`, which allows to collect and intercept code
issue in a generic way.

Resolves: #7528
2022-01-30 17:46:08 +01:00
Oliver Hader
1e072cb904
[TASK] Add AfterFunctionLikeAnalysisEvent::getFunctionlikeStorage
AfterFunctionLikeAnalysisEvent's method `getClasslikeStorage` actually
returned the current `FunctionLikeStorage`. This change streamlines the
naming and adds corresponding `getFunctionlikeStorage` method.

Method `getClasslikeStorage` is deprecated in will be removed
in Psalm v5.0.
2022-01-30 16:55:39 +01:00
orklah
f93bd10c61
Merge pull request #7517 from orklah/fixEmptyArray
Fix empty array
2022-01-30 16:14:24 +01:00
orklah
0592c03cda fix issues resulting from previous commit 2022-01-30 16:05:38 +01:00
orklah
5a3735b90a Change code so it handles what it was designed for 2022-01-30 16:05:22 +01:00
Vincent Langlet
854a3412fe Use function 2022-01-30 15:32:55 +01:00
Vincent Langlet
cd3213201d Fix 2022-01-30 15:30:40 +01: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
Matthew Brown
faaf7690f6
Remove mic-drop hack from if analysis (#7484)
* Remove mic-drop hack from if analysis

* Remove more special handling

* Remove some unnecessary ElseAnalyzer code

* Add back necessary code

* Fix return type of method never returning null

* Add a comment

* Simplify && handling

* Add comments to make stuff clearer

* Move if-specfic logic to more appropriate setting
2022-01-28 18:30:47 -05:00
orklah
048025b1d6
Merge pull request #7511 from orklah/literal-inequality
improve literal inequality with ranges and rework GreaterThan/LessThan assertions
2022-01-28 22:27:09 +01:00
orklah
66ccf93109 fix CS 2022-01-28 22:21:30 +01:00
orklah
3b73654db7 handle literal inequality with ints 2022-01-28 21:59:30 +01:00
orklah
4609bc4e25
Merge pull request #7471 from klimick/function-dynamic-storage-provider
Function dynamic storage provider
2022-01-28 18:46:26 +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
adrew
70cea447c8 Fix CS 2022-01-28 15:18:30 +03:00
adrew
1a8367a273 Add some doc about DynamicFunctionStorageProvider 2022-01-28 15:18:30 +03:00
adrew
dd0e00e153 Renaming all occurrences of "function dynamic storage" to "dynamic function storage" 2022-01-28 15:18:30 +03:00
adrew
e5dae6a901 Prevent first-class-callable handling with FunctionDynamicStorageProvider 2022-01-28 15:18:30 +03:00
adrew
de2257ecd3 Make ArgTypeInferer constructor internal 2022-01-28 15:18:30 +03:00
adrew
46f695993b Make FunctionDynamicStorageProviderEvent final 2022-01-28 15:18:30 +03:00
adrew
693b295c01 Improve ArgTypeInferer 2022-01-28 15:18:30 +03:00
adrew
9b383a5a19 Try to create public api for new hook 2022-01-28 15:18:30 +03:00
adrew
3c22ecfa98 Remove args pre-analysis before run params provider hook 2022-01-28 15:18:30 +03:00
adrew
89c6a70dda Simplify dynamic storage handling in FunctionCallAnalyzer 2022-01-28 15:18:30 +03:00
adrew
a4e56ae288 Fix method name 2022-01-28 15:18:30 +03:00
adrew
ce1cec5d3a Using FuncCall instead of list<Arg> in FunctionDynamicStorageProvider for more flexibility 2022-01-28 15:18:30 +03:00
adrew
e93c90bc89 Fix double run FunctionDynamicStorageProvider for already analysed function 2022-01-28 15:18:29 +03:00
adrew
ec9b2288cc Fix CS 2022-01-28 15:18:29 +03:00
adrew
438be03414 Ability to provide dynamically created function storage via plugin hook 2022-01-28 15:18:29 +03:00
AndrolGenhald
282518ce5f Fix failing case in ClassConstAnalyzer and add test. 2022-01-27 21:50:36 -06:00
AndrolGenhald
35353c6931 Re-add failing assert, enable assertions on CI. 2022-01-27 21:29:43 -06:00
Matthew Brown
1a6f968e15 Remove dodgy assertion cc @AndrolGenhald
This assertion broke tests when assertions were turned on
2022-01-27 20:58:35 -05:00
Patrick Remy
51cab704c4
fix: key-of/value-of handle nested template params 2022-01-28 00:04:21 +01: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
Patrick Remy
f87e429e58
fix: infer key-of/value-of type if still templated
Not in all cases the TemplateParam gets replaced before type checking,
in these cases, use the defined `as` type.
Refactor to extract key/value type of array union to method.
2022-01-27 22:39:50 +01:00
Patrick Remy
8cd5ccd076
feat: make value-of<T> capable for template types 2022-01-27 22:28:40 +01:00
Patrick Remy
dff8869685
style: remove unused use statement 2022-01-27 22:28:40 +01:00
Patrick Remy
ce1feb1ebf
style: remove unused variable declaration 2022-01-27 22:28:40 +01:00
Patrick Remy
8f0244aa7e
style: add use statement for array_push 2022-01-27 22:28:40 +01:00
Patrick Remy
1f28d025c3
feat: allow unions for key-of/value-of
Add tests for TValueOfArray.
2022-01-27 22:28:24 +01:00
Patrick Remy
2880d046ce
feat: make key-of/value-of usable with non-const arrays 2022-01-27 22:22:14 +01:00
orklah
9168cef2d4 Merge remote-tracking branch 'upstream/4.x' into upstream-master6 2022-01-26 21:06:25 +01:00
Matthew Brown
0825c0c07b Remove unnecessary check 2022-01-26 14:29:17 -05:00
b30121ba1c
Deprecate template_extended_count 2022-01-26 20:21:00 +01:00
AndrolGenhald
e268a05307 Minor fixes after rebasing. 2022-01-26 12:57:19 -06:00
AndrolGenhald
740a10141d Fix crash when a reference is reassigned in a loop. 2022-01-26 12:56:17 -06:00
AndrolGenhald
57b99be519 Improve reference support for assertions, array offsets, and properties. 2022-01-26 12:55:47 -06:00
AndrolGenhald
7694eb8d08 Work around phpcs impossible syntax issue.
phpcs want `as` to have a single space before it, but it also wants the line indented.
Worked around by assigning to another variable.
2022-01-26 12:55:47 -06:00
AndrolGenhald
bf606202f8 Remove impossible TODO. 2022-01-26 12:55:47 -06:00
AndrolGenhald
3c7d176f87 Minor CS fix, phrasing improvement, fix test. 2022-01-26 12:55:47 -06:00
AndrolGenhald
f9450656e1 Add support for references and improve UnusedVariable checks (fixes #7254). 2022-01-26 12:55:47 -06:00
orklah
66343dee7b
Merge pull request #7154 from AndrolGenhald/feature/class-const-improvements
Improve class constant static analysis
2022-01-26 19:44:26 +01:00
Bruce Weirdan
bf22dcf7ed
Merge pull request #7491 from weirdan/lock-event-classes 2022-01-26 13:34:22 +02:00
Bruce Weirdan
7503f23b4c
Lock event classes
This makes all event (`Psalm\Plugin\EventHandler\Event\*`) classes
`final`, allowing us to add methods to them without breaking BC.

Additionally all constructors of those classes are made `@internal` as
plugins are not supposed to emit events.
2022-01-26 02:24:32 +02:00
AndrolGenhald
a208623fa7 Fix trailing commas for PHP < 8.0. 2022-01-25 17:09:51 -06:00
AndrolGenhald
ba8234dd2c Fix crash due to unresolvable constant. 2022-01-25 17:03:13 -06:00
AndrolGenhald
0b81f46bb1 Fixes after rebasing. 2022-01-25 15:31:09 -06:00
AndrolGenhald
0edf260d8b Improve class constant static analysis.
Add class const covariance support (fixes #5589).
Add check for overriding const from interface in PHP < 8.1 (fixes #7108).
Add check for ambiguous const inheritance.
2022-01-25 15:20:17 -06:00
orklah
204d09b271 fix error with 0 being considered positive 2022-01-25 21:54:55 +01:00
orklah
3f799fc5fd fix CS issue 2022-01-25 20:58:40 +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
ElisDN
9f01c16ae9 Fix array_replace type 2022-01-25 15:22:50 +03:00
Matthew Brown
c974f23852 Simplify context references 2022-01-24 16:35:42 -05:00
Matthew Brown
18f5446924 Remove unnecessary hack embedding IfScope in Context object 2022-01-24 14:00:20 -05:00
Matthew Brown
61d450a267 Fix combination of templated types 2022-01-24 13:56:32 -05:00
Matthew Brown
8ee10ef78c Fix indentation 2022-01-24 13:22:18 -05:00
Matthew Brown
944b281cbe Prevent negation from removing unmatched template vars 2022-01-24 13:20:02 -05:00
Matthew Brown
c7d938bbbe Remove unnecessary code in Context::removeDescendants 2022-01-24 10:34:48 -05:00
orklah
f1c4b62f5c
Merge pull request #7414 from b2pweb/call-docblock-method-using-parent
Add support of docblock method using parent keyword
2022-01-24 13:02:57 +01:00
orklah
0619b404e5
Merge pull request #7390 from VincentLanglet/exceptionCode
Add Exception->getCode() return type provider
2022-01-24 12:56:57 +01:00
Bruce Weirdan
3a6dc9b458
Merge pull request #7431 from zoonru/disable_suppress_all 2022-01-24 11:25:32 +02:00
Vincent Langlet
9905baeceb Add flagfrom_calculation 2022-01-24 09:31:10 +01:00
Vincent
280de4bc98 Fix undefined parent method call (ref #7414) 2022-01-24 09:17:29 +01:00
Matthew Brown
ab2b77d9f5 Fix unnecessary array merge
This operation is already performed on line 420
2022-01-23 23:17:51 -05:00
orklah
63b802bff4 remove TPositiveInt 2022-01-23 23:49:23 +01:00
orklah
7c4f08067b Merge remote-tracking branch 'upstream/4.x' into upstream-master5 2022-01-23 23:44:04 +01:00
orklah
3649712c66 deprecate TPositiveInt 2022-01-23 23:26:24 +01:00
orklah
c90cffd382
Merge pull request #7472 from orklah/intrange
remove TPositiveInt usage for TIntRange
2022-01-23 22:04:33 +01:00
orklah
a7b72b865f remove TPositiveInt usage for TIntRange 2022-01-23 22:04:18 +01:00
orklah
5e41e1445e
Merge pull request #7470 from orklah/array_is_list2
reconcile two arrays by intersecting them
2022-01-23 20:36:04 +01:00
orklah
70142427bc reconcile two arrays by combining them 2022-01-23 20:22:12 +01:00
Matthew Brown
865a9f81bc Remove nullability from properties that don’t need them 2022-01-23 14:18:53 -05:00
orklah
82d84b0b3a fix internal properties on interfaces 2022-01-23 13:08:35 +01:00
AndrolGenhald
1f1f1c53fe Fix CS issue due to rebase. 2022-01-22 17:09:50 -06:00
AndrolGenhald
0fe2f6f951 Refactor existing method to reduce redundant code. 2022-01-22 17:06:54 -06:00
AndrolGenhald
7d256975e4 Fix cs/psalm errors after rebase. 2022-01-22 17:06:54 -06:00
AndrolGenhald
1686f28a37 Default to using inferred type unless in late static binding context. 2022-01-22 17:06:54 -06:00
AndrolGenhald
c61bde87a0 Suppress PossiblyUnusedProperty, will be used in the future. 2022-01-22 17:06:54 -06:00
AndrolGenhald
0fb0632e0d Infer type from known ternary condition. 2022-01-22 17:06:54 -06:00
AndrolGenhald
558208e44e Add type checking for class const assignments, fix several other const issues. 2022-01-22 17:06:54 -06:00
AndrolGenhald
c877ce031e Use inferred type instead of annotated type where possible. 2022-01-22 17:06:54 -06:00
AndrolGenhald
df314658a5 Fix trailing comma. 2022-01-22 17:06:54 -06:00
AndrolGenhald
c18a155f77 Support type annotations for class consts (fixes #942). 2022-01-22 17:06:53 -06:00
AndrolGenhald
01868a9766 Mark loadXdebugStub as deprecated (removed in #7107). 2022-01-22 16:03:35 -06:00
orklah
e0d3c3f217
Merge pull request #7463 from orklah/Properties
fix code where the offset was wrong
2022-01-22 21:24:59 +01:00
orklah
c3ad520b1b
Merge pull request #7110 from AndrolGenhald/bugfix/stub-parent-class
Fix stub parent class not loaded.
2022-01-22 21:17:07 +01:00
orklah
2d8ef787f3 remove files that were wrongly reintroduced 2022-01-22 21:14:05 +01:00
orklah
b9655457da fix code where the offset was wrong 2022-01-22 21:09:37 +01:00
AndrolGenhald
3510f55e31 Check for indirect circular dependencies with stubbed parents. 2022-01-22 13:56:10 -06:00
AndrolGenhald
9a064c04cf Fix invalid trailing comma. 2022-01-22 13:56:10 -06:00
AndrolGenhald
2262cb65d3 Check for circular references with stubbed classes. 2022-01-22 13:56:08 -06:00
AndrolGenhald
db67d2c6e8 Add support for checking parent classes and interfaces from stubs. 2022-01-22 13:54:42 -06:00
orklah
0e891f25ad refactor description of types in Atomic 2022-01-22 19:34:57 +01:00
orklah
0bf3c43908
Merge pull request #7455 from ohader/issue-6788-4x
!!! Deprecate \Psalm\Plugin\RegistrationInterface methods
2022-01-22 18:35:39 +01:00
orklah
841d4f4429 improve support for enum_exists 2022-01-22 18:27:24 +01:00
orklah
070a1cc7a3 fix merge induced errors 2022-01-22 18:05:32 +01:00
orklah
af1888b631 Merge remote-tracking branch 'upstream/4.x' into upstream-master4 2022-01-22 17:48:42 +01:00
orklah
73af019110 fix a weird case 2022-01-22 17:45:40 +01:00
orklah
997d5d5f5f handle two more cases of firstClassCallable 2022-01-22 17:37:35 +01:00
orklah
d1a946c221
Merge pull request #7454 from petewalker/feat/native-intersections
feat: Handle native intersection types
2022-01-22 11:18:54 +01:00
Pete Walker
be6ce777ff
chore: Better exception messages 2022-01-22 10:12:48 +00:00
Pete Walker
057a99c9f1
fix: Tests / minor bug 2022-01-22 00:00:45 +00:00
Pete Walker
41a3807693
fix: Lint issue 2022-01-21 17:39:01 +00:00
Pete Walker
299eca4daa
fix: Add PHP version checks / more tests 2022-01-21 17:31:48 +00:00
Toon Verwerft
6b789bb5a7 [TypeProvider] Provide argument types during FunctionParamsProviderEvent 2022-01-21 16:32:40 +01:00
Oliver Hader
c34e32f60e
!!! Deprecate \Psalm\Plugin\RegistrationInterface methods
Following \Psalm\Plugin\RegistrationInterface methods are deprecated
+ addFileTypeScanner
+ addFileTypeAnalyzer

Following \Psalm\PluginRegistrationSocket methods are deprecated
+ addFileTypeScanner
+ getAdditionalFileTypeScanners
+ addFileTypeAnalyzer
+ getAdditionalFileTypeAnalyzers
+ getAdditionalFileExtensions
+ addFileExtension

Mentioned methods will be removed in Psalm v5.0, corresponding
functionality will be provided by following new interfaces and classes
+ \Psalm\Plugin\FileExtensionsInterface
+ \Psalm\PluginFileExtensionsSocket

Related: #6788
2022-01-21 14:51:36 +01:00
Pete Walker
a3bdf1ba8c
feat: Handle native intersection types
Adds native intersection type handling to psalm, removing the previous `UnexpectedValueException`.

Where an intersection is found in the parse tree, the types are resolved using the existing `Type::intersectUnionTypes` function, which I assume is being used when they're encountered in the existing docblock annotations.

I've added a handful of tests to cover this, but they're certainly not exhaustive. Are there any specific edge cases I should target?

This change feels way too simple... so apologies if I've missed something fundamental..!
2022-01-21 12:59:55 +00:00
orklah
35577dfd28 fix typo 2022-01-21 00:29:22 +01:00
orklah
f9b26acf6e Array key exists assert both ways 2022-01-21 00:26:37 +01:00
orklah
f9e392316f remove unused imports 2022-01-21 00:17:06 +01:00
orklah
fe9d3f02a8 nitpicks 2022-01-20 23:47:41 +01:00
Matthew Brown
0a81f8cd6c
Use objects, not strings, for assertions (#7410)
* Use objects, not strings, for assertions

* Remove unnecessary param

* Remove some unnecessary checks

* Fix bad find/replace

* Add note about assertions no longer stored as strings in UPGRADING.md
2022-01-20 17:33:06 -05:00
orklah
6f1a5e8a47
Merge pull request #7417 from klimick/partially-applied-closure-inference
Contextual type inference for high order function arg
2022-01-20 21:03:46 +01:00
orklah
2f052a8781
Merge pull request #7437 from orklah/mb_internal_encoding
create a return type provider for mb_internal_encoding
2022-01-20 20:51:08 +01:00
orklah
2aeaadee5b
Merge pull request #7442 from M1ke/m1ke/config-threads
Allow config to define thread count
2022-01-20 19:39:00 +01:00
Matthew Brown
1ff3161584 Remove array_unique call 2022-01-20 11:36:18 -05:00
Matthew Brown
70479444e3 Remove untested likely-unnecessary code 2022-01-20 11:29:36 -05:00
Matthew Brown
473631fb34 Remove unused & untested code in AlgebraAnalyzer 2022-01-20 11:16:33 -05:00
m1ke
6107148fce Alter order of precedence and upated docs to match 2022-01-20 15:24:21 +00:00
m1ke
0dc4249d43 Fix phpcs 2022-01-20 10:09:15 +00:00
m1ke
2fdae4ae16 Use config threads if lower than detected threads 2022-01-20 09:50:01 +00:00
m1ke
1b8f337748 Allow psalm to load threads from the config 2022-01-20 09:49:45 +00:00
Vincent Quatrevieux
c7bfc03a6b
Merge branch '4.x' into call-docblock-method-using-parent 2022-01-20 08:59:50 +01:00
orklah
ac858e353d create a return type provider for mb_internal_encoding 2022-01-19 21:45:44 +01:00
orklah
5a6dccd4a9
Merge pull request #7420 from orklah/remove-old-things
Remove forbidEcho
2022-01-19 20:32:19 +01:00
orklah
bbfdd57d5c
Merge pull request #7363 from zoonru/81_returntypewillchange
PHP 8.1: Report missing typehints in overridden native methods
2022-01-19 20:31:54 +01:00
Vincent
f7252417e4 Fix typing (ref #7430) 2022-01-19 13:49:41 +01:00
4cfe1a0773
Add configuration option to disable @psalm-suppress all 2022-01-19 13:24:26 +01:00
1914be4ca1
Rollback 2022-01-19 12:44:55 +01:00
38945018f5
Run analysis on all PHP versions 2022-01-19 12:39:08 +01:00
d970661182
Add separate issue 2022-01-19 12:20:50 +01:00
e54d666a2e
cs-fix 2022-01-19 12:06:38 +01:00
d8be15a83d
More legacy php changes 2022-01-19 12:06:38 +01:00
c98930d6ce
Fix syntax 2022-01-19 12:06:38 +01:00
cee9eb0ead
PHP 8.1: Report missing typehints in overridden native methods 2022-01-19 12:06:35 +01:00
Vincent
7b25ca75f4 Resolve generics of inherited pseudo methods (fix #7419) 2022-01-19 11:45:19 +01:00
adrew
5fb1df8de7 Fix psalm issues in CallableTypeComparator 2022-01-19 00:48:50 +03:00
adrew
7e623ed48e Upcast invokable to callable during hof arg analysis 2022-01-19 00:37:05 +03:00
adrew
fca72ee151 Fix psalm issues 2022-01-18 22:05:32 +03:00
orklah
477c0113c2 Merge remote-tracking branch 'upstream/4.x' into upstream-master3 2022-01-18 18:37:04 +01:00
orklah
dceaa117cf remove forbidEcho 2022-01-18 18:25:18 +01:00
orklah
5f749c8a33 remove forbidEcho 2022-01-18 18:14:39 +01:00
adrew
6e1957e40a Support higher order func arg inference for static and instance calls 2022-01-18 18:45:28 +03:00
adrew
12648f4c9e Comments for describe how works higher order func arg inference 2022-01-18 13:36:16 +03:00
adrew
ffdf97c44d Remove unused function 2022-01-18 13:17:50 +03:00
adrew
a0bda8683a Rename method 2022-01-18 13:13:17 +03:00
adrew
6f9b6f8538 Fix psalm issues 2022-01-18 12:53:39 +03:00
adrew
cce1f9a407 Some refactoring and doc for high order function argument handling 2022-01-18 12:44:36 +03:00
adrew
00ce1107d3 Infer partially applied closure arg by previous function arg 2022-01-18 03:02:21 +03:00
Fabien Villepinte
c9eafa15ad Improve signature of DOMDocument::loadXML() 2022-01-17 22:52:58 +00:00
Vincent
09fc43a4d8 Add support of docblock method using parent keyword (fix #7411) 2022-01-17 19:26:42 +01:00
Ricardo Boss
26dd4c5b8f
Try to provide literal int types when possible (fixes #6966) (#7071)
* Fixed vimeo/psalm#6966

* Only accept >= 0 values for mode argument in round()

* Made round() only return float or literal float values and remove unneeded test

* Registered RoundReturnTypeProvider

* Updated cast analyzer to handle single string literal int values as literal ints

* Fixed psalm errors

* Fix invalid property accesses

* Addressed comments

* Added Tests

* Marked RoundReturnTypeProvider as internal

* Fixed CS
2022-01-16 21:33:04 +01:00
andrew
10012c9e09 Fix self parsing for psalm-if-this-is and psalm-self-out 2022-01-16 16:11:40 +03:00
orklah
de824d6724
Merge pull request #7403 from orklah/readonly_phpdoc_promoted
support @readonly for promoted properties
2022-01-16 09:38:37 +01:00
orklah
e26e022428 support @readonly for promoted properties 2022-01-16 09:31:58 +01:00
orklah
3c726e76df
Merge pull request #7401 from orklah/getObjectVarsNoValue
Psalm can't be sure get_object_vars will return an empty array unless object is known AND final
2022-01-15 23:27:33 +01:00
orklah
bf9845a4aa Psalm can't be sure get_object_vars will return an empty array unless object is known AND final 2022-01-15 21:36:46 +01:00
orklah
dc1132a915 Better Handling of TPositiveInt combined with TIntRange 2022-01-15 21:29:24 +01:00
orklah
5b82082bbd Merge remote-tracking branch 'upstream/4.x' into upstream-master2 2022-01-15 20:21:00 +01:00
Matthew Brown
dd8df37572 Remove never-used assertion check 2022-01-15 13:38:00 -05:00
orklah
4e27889736
Merge pull request #7384 from tm1000/bugfix/catch-additional-InvalidArgumentException
Catch additional InvalidArgumentException
2022-01-15 11:32:15 +01:00
orklah
9a9243e5fe
Merge pull request #7385 from b2pweb/handle-template-on-pseudo-method
Add support of template for docblock methods
2022-01-15 11:26:03 +01:00
orklah
75947c97c6
Merge pull request #7391 from b2pweb/docblock-method-inheritance
Handle inherited docblock method
2022-01-15 11:24:06 +01:00
orklah
fb30d831c6
Merge pull request #7398 from orklah/reconciliation
use Reconciler::RECONCILIATION_*
2022-01-14 21:44:16 +01:00
orklah
b3e7f12933 Prevent NoValue when there is no phpdoc 2022-01-14 21:39:23 +01:00
orklah
d2faa5b94f fix errors after merge 2022-01-14 21:13:34 +01:00
orklah
b633619a2c Merge remote-tracking branch 'upstream/4.x' into upstream-master 2022-01-14 21:01:25 +01:00
orklah
4a85fed181 use Reconciler::RECONCILIATION_* 2022-01-14 19:39:18 +01:00
orklah
9ac77e9512
Merge pull request #6521 from orklah/callable-non-falsy
TCallableString is non-falsy (0 can't be a functionlike name)
2022-01-14 19:38:41 +01:00
orklah
d786e9deef deprecate attribute forbidEcho 2022-01-14 19:31:03 +01:00
orklah
93fe3e81d4
Merge pull request #7304 from orklah/classconst5
Refactor Reconciler::handleLiteralEquality
2022-01-14 19:16:23 +01:00
Vincent
a52362465b Handle inherited docblock method (fix #7198) 2022-01-14 10:30:09 +01:00
Vincent Langlet
9f84da4d6f Try another strategy 2022-01-13 23:57:02 +01:00