1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 10:07:52 +01:00
Commit Graph

386 Commits

Author SHA1 Message Date
Matthew Brown
8926f1d050 Remove dupe test 2020-03-06 19:37:21 -05:00
Matthew Brown
b999037263 Fix #2928 - properly expand out skipped template inheritance 2020-03-06 19:24:47 -05:00
Brown
09137b0a32 Fix #2918 - fix contradiction issue with templated equality 2020-03-05 16:21:41 -05:00
Matthew Brown
f44c3488eb Keep track of which arg a given template was assigned from
Fixes #2900 - We only care about the depth of a templated match when templating from a particular argument. The next argument should essentially start afresh
2020-03-01 12:27:18 -05:00
Matthew Brown
e0d555e203 Allow function names to passed in as strings for callable template resolution 2020-02-29 15:43:45 -05:00
Matthew Brown
abb3800d20 Fix bad template replacement 2020-02-27 23:00:40 -05:00
Matthew Brown
1f19aed31b Fix support for replacing mocked types in own classes 2020-02-27 21:36:03 -05:00
Brown
35c1670602 Fix #2875 - treat intersections more similarly than before 2020-02-27 18:42:15 -05:00
Matthew Brown
746f8d4973 Prevent returning named object where template return assumed 2020-02-24 23:14:16 -05:00
Brown
712806b452 Fix #2874 - understand doubly-inherited interface templates 2020-02-24 17:58:44 -05:00
Matthew Brown
4707b21227 Fix tests 2020-02-21 22:15:25 -05:00
Brown
f4485cc529 Fix #2847 - use fully-qualified function name 2020-02-21 16:44:31 -05:00
Brown
b51863fc9b Fix #2848 - allow casting templated types 2020-02-21 15:17:35 -05:00
Brown
f44a0f9f4c Fix #2849 - allow object-like templated array comparison 2020-02-21 15:13:07 -05:00
Matthew Brown
9bdca3c706 Forbid array<mixed, ...> 2020-02-21 01:26:51 -05:00
Matthew Brown
00afcda5e0 Fix #2824 - allow unpacking of non-arrays with template params 2020-02-17 19:54:11 -05:00
Matthew Brown
d3bfb96431 Fix #2808 - improve yield type discernment 2020-02-15 10:47:07 -05:00
Matthew Brown
fb5a0c39cb Fix #2819 - improve negated assertions on templates 2020-02-14 11:18:47 -05:00
Matthew Brown
47ffb59241 Fix #2764 - iterate through all possible template types where necessary 2020-02-09 18:11:50 -05:00
Matthew Brown
b439a573ce Empty is also the bottom type 2020-02-08 11:40:22 -05:00
Matthew Brown
b26deb434d Fix #2771 - replace empty params with generic equivalents
Ref #2755
2020-02-08 11:17:24 -05:00
Brown
23f8967fb5 Fix conditional class-string template replacement 2020-02-06 19:40:18 -05:00
Brown
d5f71bf529 Localise template checks to class being tested 2020-02-06 16:38:45 -05:00
Brown
0fd0d01d2b Improve class-string templating 2020-02-06 14:35:36 -05:00
Brown
a16e03d992 Fix #2756 - narrow assertion templated type 2020-02-06 11:49:15 -05:00
Brown
50fc50fab0 Fix #2751 - allow static methods to inherit class templates 2020-02-05 11:19:40 -05:00
Matthew Brown
43c7b00cd0 Fix #2734 - allow is_a to operate on templated class-strings 2020-02-02 12:26:28 -05:00
Matthew Brown
8db4bc7691 Improve formatting of intersection error messages
Also reduce false positives on intersections of templates
2020-02-02 12:25:24 -05:00
Matthew Brown
b67f661604 Fix #2735 - interpret template check in context of class-string generation 2020-02-02 10:51:18 -05:00
Matthew Brown
6dbb911da1 Fix templating class-string unions 2020-02-01 15:02:44 -05:00
Brown
216d9256a1 Allow templated array_map callable inference
Fixes #2719
2020-01-30 17:13:46 -05:00
Brown
a2e1dfd64e Fix #2667 - don’t check inherited signature return types for accuracy 2020-01-21 11:07:44 -05:00
Matthew Brown
146dd461ef Fix #2569 - improve template return type checks 2020-01-07 21:08:13 -05:00
Brown
024ec38aa1 Fix #2567 - still remap params in some circumstances 2020-01-07 13:01:16 -05:00
Matthew Brown
2cd7f74efb Fix #2554 - treat templated class string as proper subtype of class string 2020-01-07 00:39:16 -05:00
Matthew Brown
137650fe6f Fix #2556 - don’t remap params if they’ve already been remapped once 2020-01-06 09:18:16 -05:00
Matthew Brown
086d141f5c Fix #2537 - allow complex intersection templates to be preserved 2020-01-01 13:51:54 -05:00
Matthew Brown
023c4bcef0 Fix #2532 - fix templating inside class method when calling templated method 2019-12-30 07:25:36 -05:00
Matthew Brown
2b88261ecd Fix templated assertion cc @vasily-kartashov
This is a good reason for you to skip 3.8.1
2019-12-29 11:57:54 -05:00
Matthew Brown
d3fb0181cb Fix #2527 - no crash when template cannot be resolved 2019-12-29 08:45:42 -05:00
Matthew Brown
55c2f7faa2 Fix #2508 - don’t replace templated types with generic ones inside own function 2019-12-28 18:38:02 -05:00
Matthew Brown
068afa09d3 Add very basic implementation for class-string-map
Fixes #1969
2019-12-27 12:49:28 -05:00
Matthew Brown
b78f273ccf Improve handling of template params a smidge 2019-12-27 11:49:44 -05:00
Matthew Brown
a4191171bf Fix #2483 - treat intersecting PHPDocs from interfaces better 2019-12-20 01:42:57 +00:00
Matthew Brown
cb797c6159 Fix inherited class methods as well
Ref #2478
2019-12-18 14:39:37 +00:00
Matthew Brown
49a3f89526 Fix #2478 - process trait template inheritance sensibly 2019-12-18 13:58:37 +00:00
Matthew Brown
bdbc758ddc Fix #2475 - allow iterable covariance 2019-12-16 07:16:35 -05:00
Matthew Brown
72f3c306d7 Fix #2471 - don’t erroneously template class-strings 2019-12-15 13:23:04 -05:00
Matthew Brown
ce2e5b27c0 Fix #2470 - only parameterise constructors according to inherited params 2019-12-14 11:38:09 -05:00
Matthew Brown
797a059a84 Prevent static methods using class instance template types 2019-12-14 09:40:09 -05:00
Matthew Brown
b48021dbfd Allow null return on template with null as type
Ref #2466
2019-12-13 21:56:43 -05:00
Matthew Brown
f40b6625eb Fix #2431 - allow null in template defaults 2019-12-13 21:40:09 -05:00
Matthew Brown
af52590fef Make test better 2019-12-11 00:42:09 -05:00
Matthew Brown
848cbbb487 Fix #2454 - build up template map to better understand passed-through data 2019-12-11 00:34:54 -05:00
Matthew Brown
8494f02008 Fix template handling when templating inside templated class 2019-12-10 00:50:36 -05:00
Brown
b78acf796f Fix #2445 - only generalise param when it’s generic 2019-12-09 10:58:09 -05:00
Matthew Brown
517aaac851 Fix #2432 - narrow template type after is_object check 2019-12-08 21:40:15 -05:00
Matthew Brown
d6a731be73 Fix #2441 - add error when @template type is missing 2019-12-08 21:19:29 -05:00
Matthew Brown
e3d108ebd9 Fix #2439 - fix templating of class-string<T>::returnsStatic 2019-12-08 21:12:25 -05:00
Matthew Brown
69e6624b16 Fix #2436 - fix templating of property types inside templated functions 2019-12-08 19:25:40 -05:00
Brown
d5f5c742ce Fix #2411 - allow use of covariant params in array returned value 2019-12-04 10:49:07 -05:00
Matthew Brown
27c9aa4286 Fix code and test 2019-12-01 10:43:51 -05:00
Matthew Brown
f21150b8ad Fix #2384 - fix resolution of @param-out template types 2019-12-01 10:40:53 -05:00
Matthew Brown
088228f119 Fix template default type issue 2019-11-30 12:54:08 -05:00
Matthew Brown
04879af105 Be less forgiving when extending builtin generic classes 2019-11-30 09:32:21 -05:00
Matthew Brown
d7c3ce2fa8 Fix test to be more accomodating 2019-11-30 01:28:02 -05:00
Matthew Brown
45bf8eee00 Add test that should always work 2019-11-29 11:25:29 -05:00
Matthew Brown
1e3ecb5fd0 Fix #2387 - ensure docblock return types are checked 2019-11-29 11:20:37 -05:00
Matthew Brown
a4e18f9b5e Fix #2386 - make generator params invariant 2019-11-29 01:44:31 -05:00
Bruce Weirdan
377e47c8bd Added WeakReference support (#2389) 2019-11-29 01:21:38 -05:00
Brown
532e2d64be Allow using covariant template in mutation-free context 2019-11-26 11:35:03 -05:00
Brown
a91d2ef572 Add space 2019-11-25 16:55:44 -05:00
Brown
736ccd84cd Allow more generic iterable when yielding
Fixes #2353
2019-11-25 16:12:44 -05:00
Brown
b693b726c7 Improve handling of default extended params 2019-11-14 12:12:09 -05:00
Brown
70b8df268d Fix template covariance calculation, use container covariance not inputs 2019-11-14 11:43:49 -05:00
Brown
23c37f829d Move covariant tests into their own place 2019-11-14 11:42:16 -05:00
Matthew Brown
0b1f83ff98 Fix #2346 - map covariance of templated return types when extending with more params 2019-11-14 07:45:20 -05:00
Matthew Brown
7012bedf4e Fix #2326 - substitute static more responsibly in generic objects 2019-11-12 08:01:22 -05:00
Matthew Brown
b1aae0d1a5 Fix more try/catch stuff 2019-11-12 00:52:10 -05:00
Brown
46d163996e Fix #2321 - prevent inferred template coercion 2019-11-11 09:14:34 -05:00
Brown
4e5af3490a Fix #2315 - allow Traversable->iterable templated casting 2019-11-08 13:11:01 -05:00
Brown
ac6256e645 Fix #2312, improve understanding of template replacement 2019-11-08 11:56:41 -05:00
Brown
3d7b34e7f6 Fix #2273 - ensure all template params are bound 2019-11-07 11:03:41 -05:00
Brown
86b6801066 Fix #2294 - detect invalid callble due to __invoke 2019-11-07 09:39:24 -05:00
Brown
64996f464e Prevent empty array workaround to #2308 2019-11-06 16:59:08 -05:00
Brown
3e98c800ec Fix #2309 - prevent closure-inferred generic template params overwriting parent ones 2019-11-06 13:13:02 -05:00
Brown
a8ed6ba9c4 Fix #2308 - prevent specialisation from bound params 2019-11-06 11:20:51 -05:00
Matthew Brown
b81a2d3852 Fix #2306 - allow nullable templated params to be compared to null 2019-11-05 18:37:46 -05:00
Brown
5c8cb37b0f Fix #2301 - do a naive projection of template params 2019-11-05 12:59:56 -05:00
Brown
4bf632bc23 Only extend covariant flag to vars without template param 2019-11-04 11:12:59 -05:00
Matthew Brown
5faebe2674 Fix templated assertion handling for static methods 2019-11-04 05:31:45 -05:00
Matthew Brown
8f421dc0bb Refactor template calculation out from Psalm\Type\Union 2019-11-03 21:27:40 -05:00
Matthew Brown
a82e35a59f Fix #2291 - extended covariant template param types should be treated as covariant 2019-11-01 18:25:07 +01:00
Matthew Brown
6517d0a5f5 Add test 2019-11-01 17:33:54 +01:00
Matthew Brown
bab7e46983 Fix #2281 - allow lists to accept list types 2019-11-01 13:35:16 +00:00
Matthew Brown
4845bbbd49 Improve solution to extended type juggling 2019-10-29 19:30:19 +00:00
Matthew Brown
8d7cdeb8ec Fix #2275 - allow extended templated types to bypass mixed type coercion rules 2019-10-29 10:07:34 +00:00
Brown
dda68228f3 Fix #2247 - don’t crash when yielding from class with too many template params 2019-10-18 11:01:16 -04:00
lhchavez
216f991b0c Normalize stringified type names (#2239)
This change makes stringified types more normalized. Concretely it sorts
all union types, reconciled types, and sorts the keys within object-like
types.
2019-10-17 01:14:33 -04:00
Brown
3f837a3493 Fix #2192 - allow static return value on templated object 2019-10-11 12:02:41 -04:00
Matthew Brown
0556f28a9f Fix #2224 - make sure literal strings are put into appropriate arrays when templating 2019-10-10 23:38:57 -04:00
Matthew Brown
c7600fde10 Fix #2217 - interpret callable self return type references properly 2019-10-09 07:40:42 -04:00
Brown
94001aad4a Fix #2208 - handle templated property types appropriately 2019-10-04 13:51:36 -04:00
Matthew Brown
4ec22cffca Fix #2184 - execute __invoke methods explicitly 2019-09-29 16:01:33 -04:00
Matthew Brown
9af8a9ac38 Fix #2181 - prevent class template types being wiped by anonymous class use 2019-09-27 12:58:32 -04:00
Brown
0972debfdd Add test for array assertion type 2019-09-26 15:57:51 -04:00
Matthew Brown
e7a69f715d Fix #2106 - add defining class to converted template 2019-09-07 13:44:47 -04:00
Matthew Brown
5d94e340ee Remove unused suppressions in tests 2019-08-18 15:34:32 -04:00
Brown
b5614d03f8 Add detection for unused function calls 2019-08-13 13:15:23 -04:00
Tyson Andre
b88fe2cfe0 Fix typos (#2003) 2019-08-11 17:13:43 -04:00
Matthew Brown
c356b579fd Prevent empty @template-extends docblock from being a fatal error
Fixes #1963
2019-07-28 16:47:06 -04:00
Matthew Brown
2c89a97f91 Fix #1970 - make sure reconciled types are templated 2019-07-25 08:33:27 -04:00
Matthew Brown
5a4a133f50 Fix #1970 - allow comparison to templated param class 2019-07-24 22:13:51 -04:00
Matthew Brown
76508e6d64 Improve behaviour of templated template assertions
Fixes #1956
2019-07-21 01:40:19 -04:00
Matthew Brown
3516b48173 Break out templated assertion tests 2019-07-21 01:10:33 -04:00
Matthew Brown
18da84c713 Fix #1937 - allow proper reconciliation on templated values 2019-07-15 01:26:08 -04:00
Brown
9aa0fd022c Fix potential coercion gotcha 2019-07-10 14:48:15 -04:00
Brown
2cb7625515 Fix #1932 - coerce empty array passed as template param to general 2019-07-10 13:54:06 -04:00
Brown
e7aadee88f Fix #1931 - narrow down property assignment 2019-07-10 13:49:11 -04:00
Brown
2c6854f403 Massage arg type after coerced param
Ref #1927
2019-07-10 12:12:51 -04:00
Brown
884a03078b Fix #1886 - derived types from templates in new calls should be coercable 2019-07-09 14:48:26 -04:00
Matthew Brown
e6bd30cc0b Allow closures to contain templated @var docblocks
Fixes #1865
2019-07-06 00:18:53 -04:00
Matthew Brown
cd33430616 Fix #1885 - allow comparison to templated class string 2019-07-05 22:57:38 -04:00
Matthew Brown
b4f03abca6 Fix #1886 - allow empty array to be coerced to a mixed one 2019-07-05 17:44:22 -04:00
Matthew Brown
da42be175f Apply PHPCS fixes
Fixes #1880
2019-07-05 16:27:53 -04:00
Matthew Brown
20b7ff1f9d Add unused test 2019-07-04 22:25:49 -04:00
Matthew Brown
9c95dfad44 Skip failing test 2019-07-04 16:44:06 -04:00
Matthew Brown
d0f6f85dba Fix #1899 - detect dead code after array assignment 2019-07-04 16:38:31 -04:00
Brown
ba121a94e7 Allow union of class-strings in signature
Ref #1851
2019-06-27 11:44:35 -04:00
LeSuisse
f29826b958 Fully qualify constants and function calls (#1849)
This should give a small performance boost.
Part of #1837.

The change is enforced via phpcs and can be autofixed
with phpcbf.
2019-06-26 16:52:29 -04:00
Brown
1864d9a2be Allow templated @var on return docblocks 2019-06-26 16:26:14 -04:00
Brown
16bf5f11e1 Fix #1845 - prevent string return when expecting template 2019-06-25 15:06:02 -04:00
Brown
6cb52d2d0e Move strings that reference T::class 2019-06-25 14:15:58 -04:00
Brown
e5016a4ffc Break out function class-string tests in a separate file 2019-06-25 14:13:00 -04:00
Brown
91686bef4b Improve robustness of template checks 2019-06-25 13:20:30 -04:00
Brown
4f9c040a15 Broke apart some large test files 2019-06-25 13:00:06 -04:00
Matthew Brown
5cb6fe14d7 Add support for doubly-extended non-template params 2019-06-24 23:57:19 -04:00
Matthew Brown
9d998bf3ac Fix handling of inherited method call 2019-06-24 23:43:06 -04:00
Matthew Brown
c0b86bd40d Use uppercase template_type_extends keys 2019-06-24 23:43:04 -04:00
Brown
23a3b0dbc0 Fix #1842 - prevent bad templated object returns 2019-06-24 19:07:29 -04:00
Brown
44d52c8649 Add a couple more tests for currently-working behaviour 2019-06-24 17:57:01 -04:00
Brown
fe5138f1a6 Move misplaced tests 2019-06-24 17:51:06 -04:00
Brown
69b05f5052 Improve handling of parent method calls 2019-06-24 17:45:10 -04:00
Brown
2a1ed6ca6a Prevent incorrect template being passed to function 2019-06-24 10:54:03 -04:00
Brown
a5a9da6e50 Fix #1818 - handle intersection when expanding template 2019-06-20 10:09:03 -04:00
Brown
0246f600f4 Fix #1813 - convert object&Foo into Foo after template resolution 2019-06-19 12:00:19 -04:00
Matthew Brown
42bafc1e64 Fix #1775 - allow true|false to be accepted as bool 2019-06-13 08:55:36 -04:00
Brown
9c4599a0f0 Add better support for inheriting docblocks 2019-06-11 11:19:57 -04:00
Brown
7cf8c362f0 Fix #1766 - interpret interface parent extends properly 2019-06-11 10:49:39 -04:00
Matthew Brown
395057c6df Fix #1738 - constrain template type when class-string<T> is a param 2019-06-08 11:08:08 -04:00
Matthew Brown
42cc201e9e Fix #1698 - better understand inherited docblock return types 2019-06-08 09:44:22 -04:00
Matthew Brown
b0678bdc74 Improve treatment of key-of
Ref #1698
2019-06-07 21:27:50 -04:00
Matthew Brown
2fa0f27872 Prevent LessSpecificImplementedReturnType with extended template 2019-06-07 18:42:26 -04:00
Brown
2f29dcce93 Fix #1728 - remove extra data in template-extends annotation 2019-06-03 10:28:54 -04:00
Brown
b19d256b14 Add better error message for templated key-of param 2019-05-28 14:23:22 -04:00
Brown
a89892a41f Prevent more broad template types being captured 2019-05-28 11:54:07 -04:00
Brown
cf02e9c22c Fix access on matched T[K] 2019-05-27 18:36:34 -04:00
Matthew Brown
052599192a Fix #1680 - narrow nullable templated matching 2019-05-25 12:44:47 -04:00
Matthew Brown
9fb96793cd Fix #1676 - don’t modify original param types with templated by-reference 2019-05-24 18:17:48 -04:00
Matthew Brown
62dacaf97b Also replace templated intersection types that aren’t direct templates
Ref #1675
2019-05-24 17:34:40 -04:00
Matthew Brown
7a48225184 Fix leaky template type 2019-05-24 13:35:14 -04:00
Matthew Brown
3e2b7163ca Fix #1674 - treat intersections more equally regardless of order 2019-05-24 12:48:37 -04:00
Matthew Brown
9e3724bb0c Prevent class-string<T> from assigning unknown type to mixed
Fixes #1672
2019-05-24 10:20:37 -04:00
Matthew Brown
c80f9d8ecd Add class-based support for key-of
Ref #762
2019-05-24 02:12:58 -04:00
Matthew Brown
574545e149 Add initial support for key-of<T>
Ref #762
2019-05-23 23:53:48 -04:00
Brown
56daa390fc Allow array access on @template T as array
Ref #1607
2019-05-23 18:06:22 -04:00
Brown
1c30270d89 Remove 7.4 syntax 2019-05-23 13:55:55 -04:00
Brown
888776cebd Fix duplicate test 2019-05-23 13:10:23 -04:00
Brown
034ea725e8 Coerce generic types from empty 2019-05-21 12:12:13 -04:00
Matthew Brown
ec2ee04fe8 Allow coercion from empty to array param 2019-05-21 12:12:13 -04:00
Brown
4035823d51 Fix #1652 - allow totally-templated intersections 2019-05-17 15:40:52 -04:00
Brown
4a434d9a2f Add separate issue for undefined classes in docblocks 2019-05-15 18:41:26 -04:00
Brown
f1d8b1e6e7 Prevent extending covariant template params
Fixes #1610
2019-05-14 18:51:30 -04:00
Brown
7fbbe964cb Fix #1609 - warn when using covariant template type as input 2019-05-14 18:17:38 -04:00
Brown
b7529e872b Consider intersections when combining generic types 2019-05-08 13:23:47 -04:00
Matthew Brown
4f8d6a50d8 Don’t emit MissingClosureReturnType when inside call and type can be inferred 2019-05-06 20:47:55 -04:00
Brown
fec1a60e90 Ref #1600 - partial fix inferring param types when none is available 2019-05-06 18:44:10 -04:00
Brown
751253ddf0 Fix #1603 - prevent invalid covariant template classes from being passed 2019-05-06 16:38:08 -04:00
Matthew Brown
ae531506de Fix #1591 - allow variable typed to string to be compared to literal in reverse order 2019-05-02 00:50:35 -04:00
Matthew Brown
59e53acd56 Fix new template class array key coercion to mixed - when we don’t know, assume bottom type 2019-04-26 07:54:21 -04:00
Brown
0e4c8ce482 Split apart TypeCoercion issues, allowing more granular issue filtering 2019-04-25 18:02:19 -04:00
Brown
1348d634ed Improve handling of variadic parameters 2019-04-09 13:58:49 -04:00
Matthew Brown
230680fd1c Fix #1513 - use correct param types when examining abstract trait methods 2019-03-28 22:47:17 -04:00
Brown
937eb42e8b Do not override parent return type 2019-03-28 10:43:49 -04:00
Brown
c022d49b1a Allow coercion from templated param to false 2019-03-28 10:19:02 -04:00
Brown
783f028f70 Fix #1498 - use template types from parent function 2019-03-25 11:25:43 -04:00
Matthew Brown
c772914910 Add some formatting 2019-03-23 14:27:54 -04:00
Brown
22fc0b5aa3 Fix #1482 - don’t substitute template params when no default present 2019-03-22 18:05:45 -04:00
Brown
cc568422d8 Fix #1488 - allow inheritance when dummy template exists 2019-03-22 16:29:30 -04:00
Brown
b9ba24929d Refactor storage of template names to prevent clashes 2019-03-22 15:59:10 -04:00
Brown
29666bf22e Fix #1489 - make sure you’re checking against known params 2019-03-21 18:28:25 -04:00
Brown
8ed5e661a4 Catch object passed to array-key 2019-03-19 11:43:37 -04:00
Matthew Brown
4865f66aeb Allow better comparisons for templated types 2019-03-17 18:52:42 -04:00
Matthew Brown
9ee4a7414b Fix #1461 - check interfaces when analysing abstract method call 2019-03-17 14:16:52 -04:00
Matthew Brown
ca765cba58 Fix errors caused by bad generic param counts
Fixes #1474
2019-03-17 12:20:57 -04:00
Matthew Brown
f5c6abb6a0 Allow capturing of class-string<T>
Fixes #1457
2019-03-17 10:19:15 -04:00
Matthew Brown
a0659a02f1 Fix #1418 - support templated union types 2019-03-16 11:15:25 -04:00
Matthew Brown
c22cdb0795 Fix #1459 - allow nullable templated comparison 2019-03-15 21:37:50 -04:00
Matthew Brown
312be71be1 Localise overridden templated param types 2019-03-14 10:11:45 -04:00
Matthew Brown
85f0fa6e7d Add support for literal templated defaults 2019-03-07 22:32:38 -05:00