1 | <?php |
||
28 | class NodesFactory |
||
29 | { |
||
30 | /** |
||
31 | * Parser used to parse the code to nodes. |
||
32 | * |
||
33 | * @var Parser |
||
34 | */ |
||
35 | private $parser; |
||
36 | |||
37 | /** |
||
38 | * Containing a number of visitors to do some post processing steps on nodes. |
||
39 | * |
||
40 | * @var NodeTraverser |
||
41 | */ |
||
42 | private $traverser; |
||
43 | |||
44 | /** |
||
45 | * Initializes the object. |
||
46 | * |
||
47 | * @param Parser $parser used to parse the code |
||
48 | * @param NodeTraverser $traverser used to do some post processing on the nodes |
||
49 | */ |
||
50 | public function __construct(Parser $parser, NodeTraverser $traverser) |
||
55 | |||
56 | /** |
||
57 | * Creates a new instance of NodeFactory with default Parser ands Traverser. |
||
58 | * |
||
59 | * @param int $kind One of ParserFactory::PREFER_PHP7, |
||
60 | * ParserFactory::PREFER_PHP5, ParserFactory::ONLY_PHP7 or ParserFactory::ONLY_PHP5 |
||
61 | * @return static |
||
62 | */ |
||
63 | public static function createInstance($kind = ParserFactory::PREFER_PHP7): self |
||
71 | |||
72 | /** |
||
73 | * Will convert the provided code to nodes. |
||
74 | * |
||
75 | * @param string $code code to process. |
||
76 | * @return Node[] |
||
77 | */ |
||
78 | public function create(string $code): array |
||
83 | } |
||
84 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.