Skip to content

Commit 02600c0

Browse files
committed
Add upgrade docs
1 parent 721f1e7 commit 02600c0

File tree

3 files changed

+59
-19
lines changed

3 files changed

+59
-19
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
Reconstitute a DocBlock
2-
==============================
1+
Reconstituting a DocBlock
2+
=========================
33

4-
ReflectionDocBlock not only allows you to read and interpret DocBlocks, but also to reconstruct them. This is useful if you need to add, remove, or modify tags in your codebase programmatically.
4+
ReflectionDocBlock not only allows you to read and parse DocBlocks, but also to reconstruct them. This is useful if you need to add, remove, or modify tags in your codebase programmatically. For example, you might want to update type information, add custom tags, or strip deprecated tags as part of a refactoring or code generation process.
5+
6+
Below is a practical example of how to reconstitute a DocBlock using this library:
57

68
.. literalinclude:: ../examples/03-reconstituting-a-docblock.php
79
:language: php
8-
:linenos:
9-
10+
:caption: examples/03-reconstituting-a-docblock.php

docs/index.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,17 @@ Quick Start Example
2121
-------------------
2222
Here's a minimal example of how to use ReflectionDocBlock in your project:
2323

24-
.. code-block:: php
25-
<?php
26-
use phpDocumentor\Reflection\DocBlockFactory;
24+
.. literalinclude:: examples/01-interpreting-a-simple-docblock.php
25+
:language: php
26+
:caption: examples/01-interpreting-a-simple-docblock.php
2727

28-
$factory = DocBlockFactory::createInstance();
29-
$docblock = $factory->create('/**\n * This is a summary.\n *\n * This is a description.\n */');
30-
31-
echo $docblock->getSummary(); // Outputs: This is a summary.
32-
33-
For more detailed usage and how-to guides, see the ``examples/`` directory.
28+
For more detailed usage and how-to guides, see the ``how-to/`` section.
3429

3530
.. toctree::
3631
:maxdepth: 2
3732
:hidden:
3833

3934
installation
4035
how-to/index
41-
migration-v6
36+
upgrade-to-v6
4237
contributing

docs/upgrade-to-v6.rst

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,51 @@
1+
Upgrade Guide to v6
2+
===================
13

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.
35

4-
StandardTagFactory needs to be created via createInstance
6+
Supported PHP Versions
7+
----------------------
8+
- v6 requires PHP 7.4 or higher (PHP 8+ recommended).
59

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

Comments
 (0)