Skip to content

Commit 46bd5e3

Browse files
authored
Prevent deprecation warnings (#70)
1 parent 5b979a1 commit 46bd5e3

2 files changed

Lines changed: 19 additions & 34 deletions

File tree

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
"test/annotation_loader.php"
4040
]
4141
},
42+
"config": {
43+
"allow-plugins": {
44+
"dealerdirect/phpcodesniffer-composer-installer": false,
45+
"hostnet/*": true
46+
}
47+
},
4248
"extra": {
4349
"class": "Hostnet\\Component\\AccessorGenerator\\Plugin"
4450
},

src/Collection/ImmutableCollection.php

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(Collection $collection)
4545
*
4646
* @throws \LogicException if the collection not cloned.
4747
*/
48-
public function add($element)
48+
public function add($element): bool
4949
{
5050
if ($this->is_clone) {
5151
return $this->collection->add($element);
@@ -61,7 +61,7 @@ public function add($element)
6161
*
6262
* @throws \LogicException if the collection is not cloned.
6363
*/
64-
public function clear()
64+
public function clear(): void
6565
{
6666
if (!$this->is_clone) {
6767
throw new \LogicException('This collection is immutable');
@@ -78,9 +78,6 @@ public function contains($element): bool
7878
return $this->collection->contains($element);
7979
}
8080

81-
/**
82-
* {@inheritdoc}
83-
*/
8481
public function isEmpty(): bool
8582
{
8683
return $this->collection->isEmpty();
@@ -90,6 +87,7 @@ public function isEmpty(): bool
9087
* Do not use, this collection is immutable.
9188
* {@inheritdoc}
9289
* @throws \LogicException if the collection is not cloned.
90+
* @return mixed
9391
*/
9492
public function remove($key)
9593
{
@@ -105,7 +103,7 @@ public function remove($key)
105103
* {@inheritdoc}
106104
* @throws \LogicException if the collection is not cloned.
107105
*/
108-
public function removeElement($element)
106+
public function removeElement($element): bool
109107
{
110108
if ($this->is_clone) {
111109
return $this->collection->removeElement($element);
@@ -146,7 +144,7 @@ public function getValues(): array
146144
return $this->collection->getValues();
147145
}
148146

149-
public function set($key, $value)
147+
public function set($key, $value): void
150148
{
151149
if (!$this->is_clone) {
152150
throw new \LogicException('This collection is immutable');
@@ -203,33 +201,21 @@ public function next()
203201
return $this->collection->next();
204202
}
205203

206-
/**
207-
* {@inheritdoc}
208-
*/
209204
public function exists(Closure $predicate): bool
210205
{
211206
return $this->collection->exists($predicate);
212207
}
213208

214-
/**
215-
* {@inheritdoc}
216-
*/
217209
public function filter(Closure $predicate): Collection
218210
{
219211
return $this->collection->filter($predicate);
220212
}
221213

222-
/**
223-
* {@inheritdoc}
224-
*/
225214
public function forAll(Closure $predicate): bool
226215
{
227216
return $this->collection->forAll($predicate);
228217
}
229218

230-
/**
231-
* {@inheritdoc}
232-
*/
233219
public function map(Closure $func): Collection
234220
{
235221
return $this->collection->map($func);
@@ -259,32 +245,28 @@ public function slice($offset, $length = null): array
259245
return $this->collection->slice($offset, $length);
260246
}
261247

262-
/**
263-
* {@inheritdoc}
264-
*/
265-
public function count()
248+
public function count(): int
266249
{
267250
return $this->collection->count();
268251
}
269252

270-
/**
271-
* {@inheritdoc}
272-
*/
273-
public function getIterator()
253+
public function getIterator(): \Traversable
274254
{
275255
return $this->collection->getIterator();
276256
}
277257

278258
/**
279259
* {@inheritdoc}
280260
*/
281-
public function offsetExists($offset)
261+
public function offsetExists($offset): bool
282262
{
283263
return $this->collection->offsetExists($offset);
284264
}
285265

286266
/**
287267
* {@inheritdoc}
268+
*
269+
* @return mixed
288270
*/
289271
public function offsetGet($offset)
290272
{
@@ -296,7 +278,7 @@ public function offsetGet($offset)
296278
* {@inheritdoc}
297279
* @throws \LogicException if the collection is not cloned.
298280
*/
299-
public function offsetSet($offset, $value)
281+
public function offsetSet($offset, $value): void
300282
{
301283
if (!$this->is_clone) {
302284
throw new \LogicException('This collection is immutable');
@@ -310,7 +292,7 @@ public function offsetSet($offset, $value)
310292
* {@inheritdoc}
311293
* @throws \LogicException if the collection is not cloned.
312294
*/
313-
public function offsetUnset($offset)
295+
public function offsetUnset($offset): void
314296
{
315297
if (!$this->is_clone) {
316298
throw new \LogicException('This collection is immutable');
@@ -319,10 +301,7 @@ public function offsetUnset($offset)
319301
$this->collection->offsetUnset($offset);
320302
}
321303

322-
/**
323-
* {@inheritdoc}
324-
*/
325-
public function matching(Criteria $criteria)
304+
public function matching(Criteria $criteria): Collection
326305
{
327306
return $this->collection->matching($criteria);
328307
}

0 commit comments

Comments
 (0)