Skip to content

Commit a1c7f80

Browse files
committed
Document ClassLike/FunctionLike conversions
1 parent 8eea230 commit a1c7f80

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: doc/2_Usage_of_basic_components.markdown

+6
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ without the `PhpParser\Node\` prefix and `\` replaced with `_`. It also does not
206206
It is possible to associate custom metadata with a node using the `setAttribute()` method. This data
207207
can then be retrieved using `hasAttribute()`, `getAttribute()` and `getAttributes()`.
208208

209+
`ClassLike` and `FunctionLike` statements can be converted between each other easily because their
210+
constructor `__construct($name, array $subNodes = [], array $attributes = [])` takes subnodes and
211+
attributes both of which are easy to retrieve, for example
212+
`new ClassMethod($someName, get_object_vars($node), $node->getAttributes())` will convert any
213+
`FunctionLike` into a `ClassMethod`.
214+
209215
By default, the parser adds the `startLine`, `endLine`, `startTokenPos`, `endTokenPos`,
210216
`startFilePos`, `endFilePos` and `comments` attributes. `comments` is an array of
211217
`PhpParser\Comment[\Doc]` instances.

0 commit comments

Comments
 (0)