|
| 1 | +Upgrade Guide to v6 |
| 2 | +=================== |
1 | 3 |
|
2 | | -Stop using ::create |
| 4 | +This guide helps you upgrade your project to ReflectionDocBlock v6. It covers breaking changes, removals, new features, and migration tips to ensure a smooth transition. |
3 | 5 |
|
4 | | -StandardTagFactory needs to be created via createInstance |
| 6 | +Supported PHP Versions |
| 7 | +---------------------- |
| 8 | +- v6 requires PHP 7.4 or higher (PHP 8+ recommended). |
5 | 9 |
|
6 | | -Method::getArguments removed |
7 | | -Method::create is removed |
| 10 | +Breaking Changes & Removals |
| 11 | +--------------------------- |
| 12 | +- **Removal of `::create` static method for type-based tags** |
| 13 | + - The `create` static method has been removed from tag classes that represent type definitions, such as `@param` and `@return` tags. Most users will not be affected, as these methods are rarely used directly. The deprecation notice for these methods was present throughout v5. |
| 14 | + - **Migration:** |
| 15 | + - If you are instantiating these tag objects directly, use the tag factory or the recommended construction pattern instead. |
| 16 | + - Before: |
| 17 | + .. code-block:: php |
| 18 | +
|
| 19 | + $tag = Param::create($body); |
| 20 | + - After: |
| 21 | + .. code-block:: php |
| 22 | +
|
| 23 | + $factory = \phpDocumentor\Reflection\DocBlock\Tags\Factory\StandardTagFactory::createInstance(); |
| 24 | + $tag = $factory->create('@param int $foo'); |
| 25 | +
|
| 26 | +- **StandardTagFactory instantiation** |
| 27 | + - `StandardTagFactory` must now be created via `createInstance()`. |
| 28 | + - **Migration:** |
| 29 | + - Before: |
| 30 | + .. code-block:: php |
| 31 | +
|
| 32 | + $factory = new StandardTagFactory(); |
| 33 | + - After: |
| 34 | + .. code-block:: php |
| 35 | +
|
| 36 | + $factory = StandardTagFactory::createInstance(); |
| 37 | +
|
| 38 | +- **Removed methods** |
| 39 | + - `Method::getArguments` has been removed. |
| 40 | + - `Method::create` has been removed. |
| 41 | + - **Migration:** |
| 42 | + - Refactor code to use the new API for method arguments and creation. |
| 43 | + |
| 44 | +TypeResolver Upgrade |
| 45 | +------------------- |
| 46 | +- **Generics Support**: The TypeResolver component now supports generics, |
| 47 | + which replaces the previous `Collection` type handling. This allows |
| 48 | + for more accurate and expressive type definitions, such as `MyClass<int, MyClass>` or `Collection<MyClass>`, |
| 49 | + and improves compatibility with modern PHPDoc standards. |
| 50 | + |
| 51 | +- For more details and advanced migration scenarios, consult the `TypeResolver upgrade guide <https://docs.phpdoc.org/components/type-resolver/guides/upgrade-v1-to-v2.html#upgrade-to-version-2>`_ |
0 commit comments