1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00
Commit Graph

345 Commits

Author SHA1 Message Date
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
Brown
94b1161a80 Add skipped test; 2019-03-07 18:25:48 -05:00
Matthew Brown
ef0abf1c30 Fix #1411 - allow covariance on extended templates 2019-03-02 16:31:34 -05:00
Bruce Weirdan
9bdc9f774f More provider typing 2019-03-02 08:43:19 -05:00
Matthew Brown
619590aa71 Fix parsing of template of type with spaces
Fixes #1406
2019-03-01 09:20:59 -05:00
Matthew Brown
b3c5120d72 Fix #1403 - warn about duplicate templates 2019-02-28 23:43:55 -05:00
Brown
601f303de2 Fix position of invalid param 2019-02-27 16:00:44 -05:00
Brown
119687f934 Fix redundant condition message when negating a docblock type 2019-02-27 14:02:02 -05:00
Matthew Brown
6671e0dc7c Fix #1382 - flag unused docblocks 2019-02-23 11:02:04 -05:00
Matthew Brown
ce4f2e6334 Fix #1364 - use proper types for extended getIterator calls 2019-02-21 23:01:34 -05:00
Matthew Brown
f87827e812 Fix #1288 - prevent template names from clashing with real-world classes 2019-02-21 21:54:00 -05:00
Matthew Brown
62fb8035bf Fix #1309 - no PropertyNotSetInConstructor warnings for grandchild of class 2019-02-10 15:01:10 -05:00
Matthew Brown
6976528c7e Fix #1310 - check template defining class matches 2019-02-10 12:02:18 -05:00
bugreportuser
6c7819b438 Allow @psalm-template for classes 2019-02-09 11:15:25 -05:00
Matthew Brown
f4518d59e0 Fix #1303 - improve handling of class-string<Foo> type arg passed to class-string<T> param 2019-02-08 13:34:30 -05:00
Matthew Brown
98644f7a65 Allow more-specific template types to override mixed 2019-02-08 13:09:36 -05:00
Matthew Brown
88b4f8230c Remove parent call 2019-02-07 19:01:33 -05:00
Matthew Brown
6d0e78540a Only move issue once 2019-02-07 18:47:50 -05:00
Matthew Brown
dfe45e7d26 Fix #1290 - improve handling of more specific template 2019-02-06 15:56:40 -05:00
SignpostMarv
4a56688800 adding DIRECTORY_SEPARATOR to tests that fail under windows 2019-02-06 14:29:10 -05:00
Matthew Brown
d45326759f Fix #1287 - improve handling of templated intersection 2019-02-06 12:37:05 -05:00
Matthew Brown
020430c66f Recover better from union type errors in template names 2019-02-05 17:43:46 -05:00
Matthew Brown
899dd16e8f Be more strict about what can be a template as type 2019-02-05 17:26:34 -05:00
Matthew Brown
6d5c995458 Fix #1282 - allow generic self and static 2019-02-05 08:02:06 -05:00
Matthew Brown
ab22634d23 Fix #1274 - fix parent:: call to templated method 2019-02-04 00:52:31 -05:00
Brown
533b92e15a Fix #1269 - fill in object type 2019-02-01 14:13:21 -05:00
Brown
8b65acf15b Make return type mismatch more clear 2019-02-01 10:55:28 -05:00
Brown
d52fd70fd6 Fix invalid inheritance for SplObjectStorage 2019-01-30 13:48:05 -05:00
Brown
8c27bd77f6 Fix #1259 - add support for SplObjectStorage type params 2019-01-30 13:03:22 -05:00
Brown
819489e68d Add method that reflection doesn’t know exists 2019-01-28 17:09:23 -05:00
Brown
3e4c63eb9a Fix template extension in grandchildren 2019-01-28 16:56:42 -05:00
Matthew Brown
081ba4b204 Fix #1072 - add support for @use SomeTrait<T> 2019-01-27 23:12:40 -05:00
Matthew Brown
f67bab6d52 Restrict template-extends to actual extends 2019-01-27 21:00:27 -05:00
Matthew Brown
00e95cbd6b Understand that template class string transforms back to templated class
Fixes #1250
2019-01-27 15:08:17 -05:00
Matthew Brown
60e7587c2d Replace template types in object-like arrays 2019-01-27 14:20:41 -05:00
Matthew Brown
22ee72808a Remove a bunch of hacks around generic offsets
Also fixes #1245
2019-01-26 16:58:49 -05:00
Matthew Brown
fc8c96eccf Split out @extends template test 2019-01-25 22:33:42 -05:00