Upgrade Guide to v6
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.
Supported PHP Versions
- v6 requires PHP 7.4 or higher (PHP 8+ recommended).
Breaking Changes & Removals
-
Removal of `::create` static method for type-based tags - The
createstatic method has been removed from tag classes that represent type definitions, such as@paramand@returntags. Most users will not be affected, as these methods are rarely used directly. The deprecation notice for these methods was present throughout v5. - Migration: - If you are instantiating these tag objects directly, use the tag factory or the recommended construction pattern instead. - Before: .. code-block:: php$tag = Param::create($body);
- - After:
$factory = \phpDocumentor\Reflection\DocBlock\Tags\Factory\StandardTagFactory::createInstance(); $tag = $factory->create('@param int $foo');
-
StandardTagFactory instantiation -
StandardTagFactorymust now be created viacreateInstance(). - Migration: - Before: .. code-block:: php$factory = new StandardTagFactory();
- - After:
$factory = StandardTagFactory::createInstance();
- Removed methods
-
Method::getArgumentshas been removed. -Method::createhas been removed. - Migration: - Refactor code to use the new API for method arguments and creation.
TypeResolver Upgrade
- Generics Support : The TypeResolver component now supports generics,
- which replaces the previous
Collectiontype handling. This allows for more accurate and expressive type definitions, such asMyClass<int, MyClass>orCollection<MyClass>, and improves compatibility with modern PHPDoc standards.
- For more details and advanced migration scenarios, consult the TypeResolver upgrade guide