1 | <?php |
||
19 | class DictionaryObject extends AbstractObject implements IteratorAggregate |
||
20 | { |
||
21 | /** |
||
22 | * @var ObjectInterface[] |
||
23 | */ |
||
24 | private $objects; |
||
25 | |||
26 | /** |
||
27 | * @param ObjectInterface[] $objects |
||
28 | */ |
||
29 | public function __construct(array $objects) |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | public function writeToStream(SplFileObject $fileObject, $encryptionKey) |
||
51 | |||
52 | /** |
||
53 | * Checks whether an object with a given key eixsts. |
||
54 | * |
||
55 | * @param string $key |
||
56 | * @return bool |
||
57 | */ |
||
58 | public function has($key) |
||
62 | |||
63 | /** |
||
64 | * Returns an object with the given key. |
||
65 | * |
||
66 | * @param string $key |
||
67 | * @return ObjectInterface |
||
68 | * @throws OutOfBoundsException |
||
69 | */ |
||
70 | public function get($key) |
||
81 | |||
82 | /** |
||
83 | * Sets an object with the given key. |
||
84 | * |
||
85 | * @param string $key |
||
86 | * @param ObjectInterface $object |
||
87 | */ |
||
88 | public function set($key, ObjectInterface $object) |
||
92 | |||
93 | /** |
||
94 | * Removes an object with the given key. |
||
95 | * |
||
96 | * @param string $key |
||
97 | */ |
||
98 | public function remove($key) |
||
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | public function getIterator() |
||
112 | } |
||
113 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: