Skip to content

Commit 8a232e0

Browse files
committed
Add docs for v1 to v2 migration
1 parent 034c3c2 commit 8a232e0

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

docs/generics.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
========
2+
Generics
3+
========
4+
5+
This project is capable of parsing generics notation as used by PHPStan. But it has some limitations, in regards to
6+
PHPStan. The main difference is that PHPStan does scan your whole codebase to find out what types are used in generics,
7+
while this library only parses the types as they are given to it.
8+
9+
This means that if you use a generic type like.
10+
11+
.. code:: php
12+
13+
namespace MyApp;
14+
15+
/**
16+
* @template T of Item
17+
*/
18+
class Collection {
19+
20+
/**
21+
* @return T[]
22+
*/
23+
public function getItems() : array {
24+
// ...
25+
}
26+
}
27+
28+
The type resolver will not be able to determine what ``T`` is. In fact there is no difference between ``T`` and any other relative
29+
used classname like ``Item``. The resolver will handle ``T`` as a normal class name. In this example it will resolve ``T`` to ``\MyApp\T``.

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ third party developers.
1515

1616
index
1717
getting-started
18+
generics
19+
upgrade-v1-to-v2

docs/upgrade-v1-to-v2.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
====================
2+
Upgrade to Version 2
3+
====================
4+
5+
Version 2 of the Type Resolver introduces several breaking changes and new features. This guide will help you
6+
upgrade your codebase to be compatible with the latest version. The usage of the TypeResolver remains the same. However,
7+
some classes have been moved or replaced, and the minimum PHP version requirement has been raised.
8+
9+
PHP Version
10+
-----------
11+
12+
Version 2 requires PHP 7.4 or higher. We have been supporting PHP 7.3 in version 1, but due to changing constraints
13+
in our dependencies, we have had to raise the minimum PHP version. At the moment of writing this, PHP 7.3 is used by 2%
14+
of all installations of this package according to Packagist. We believe this is a reasonable trade-off to ensure we
15+
can continue to deliver new features and improvements.
16+
17+
Moved classes
18+
-------------
19+
20+
- ``phpDocumentor\Reflection\Types\InterfaceString`` => :php:class:`phpDocumentor\Reflection\PseudoTypes\InterfaceString`
21+
- ``phpDocumentor\Reflection\Types\ClassString`` => :php:class:`phpDocumentor\Reflection\PseudoTypes\ClassString`
22+
- ``phpDocumentor\Reflection\Types\ArrayKey`` => :php:class:`phpDocumentor\Reflection\PseudoTypes\ArrayKey`
23+
- ``phpDocumentor\Reflection\Types\True_`` => :php:class:`phpDocumentor\Reflection\PseudoTypes\True_`
24+
- ``phpDocumentor\Reflection\Types\False_`` => :php:class:`phpDocumentor\Reflection\PseudoTypes\False_`
25+
26+
Replaced classes
27+
-----------------
28+
29+
- ``phpDocumentor\Reflection\Types\Collection`` => :php:class:`phpDocumentor\Reflection\PseudoTypes\Generic`
30+
31+
Since the introduction of generics in PHP this library was not capable of parsing them correctly. The old Collection
32+
was blocking the use of generics. The new Generic type is a representation of generics like supported in the eco system.
33+
34+
Changed implementations
35+
-----------------------
36+
37+
:php:class:`phpDocumentor\Reflection\PseudoTypes\InterfaceString`, :php:class:`phpDocumentor\Reflection\PseudoTypes\ClassString` and
38+
:php:class:`phpDocumentor\Reflection\PseudoTypes\TraitString` are no longer returning a :php:class:`phpDocumentor\Reflection\Fqsen` since
39+
support for generics these classes can have type arguments like any other generic.
40+

0 commit comments

Comments
 (0)