1 | <?php |
||
9 | class Definitions implements Arrayable, \Iterator { |
||
10 | |||
11 | /** @var Map */ |
||
12 | private $definitions; |
||
13 | |||
14 | 12 | public function __construct($contents = []) { |
|
15 | 12 | $this->parse($contents === null ? [] : $contents); |
|
16 | 12 | } |
|
17 | |||
18 | 12 | private function parse($contents) { |
|
19 | 12 | $data = CollectionUtils::toMap($contents); |
|
20 | |||
21 | 12 | $this->definitions = new Map(); |
|
22 | 12 | foreach ($data as $name => $prop) { |
|
23 | 6 | $this->definitions->set($name, new Schema($prop)); |
|
24 | 12 | } |
|
25 | 12 | } |
|
26 | |||
27 | 7 | public function toArray() { |
|
30 | |||
31 | 1 | public function size() { |
|
34 | |||
35 | /** |
||
36 | * Returns the schema for the given field |
||
37 | * |
||
38 | * @param string $name |
||
39 | * @return Schema |
||
40 | */ |
||
41 | 1 | public function get($name) { |
|
42 | 1 | if (!$this->definitions->has($name)) { |
|
43 | $this->definitions->set($name, new Schema()); |
||
44 | } |
||
45 | 1 | return $this->definitions->get($name); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * Sets the field |
||
50 | * |
||
51 | * @param string name |
||
52 | * @param Schema $schame |
||
|
|||
53 | */ |
||
54 | 1 | public function set($name, Schema $schema) { |
|
57 | |||
58 | /** |
||
59 | * Removes the given field |
||
60 | * |
||
61 | * @param string $name |
||
62 | */ |
||
63 | 1 | public function remove($name) { |
|
66 | |||
67 | /** |
||
68 | * Returns definitions has a schema with the given name |
||
69 | * |
||
70 | * @param string $name |
||
71 | * @return boolean |
||
72 | */ |
||
73 | 1 | public function has($name) { |
|
76 | |||
77 | /** |
||
78 | * Returns whether the given schema exists |
||
79 | * |
||
80 | * @param Schema $schema |
||
81 | * @return boolean |
||
82 | */ |
||
83 | 1 | public function contains(Schema $schema) { |
|
86 | |||
87 | public function current() { |
||
88 | return $this->definitions->current(); |
||
89 | } |
||
90 | |||
91 | public function key() { |
||
94 | |||
95 | public function next() { |
||
98 | |||
99 | public function rewind() { |
||
102 | |||
103 | public function valid() { |
||
106 | } |
||
107 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.