-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
902899d
commit 8fd9667
Showing
4 changed files
with
178 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Bug5231; | ||
|
||
class SomeClass | ||
{ | ||
|
||
} | ||
|
||
// class with bug | ||
|
||
/** | ||
* annotation must be exists: | ||
* @method SomeClass[]|SomeParentCollection getSorted() | ||
*/ | ||
class SomeParentCollection implements \Iterator | ||
{ | ||
/** @var SomeClass[] */ | ||
protected $collection; | ||
|
||
public function findByName(string $name): ?SomeClass | ||
{ | ||
foreach ($this->collection as $item) { | ||
if ((string)$item === $name) { | ||
return $item; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
// must be exists! | ||
public function existsByKey(string $name): bool | ||
{ | ||
return $this->findByName($name) !== null; | ||
} | ||
|
||
public function getSorted(callable $comparator): self | ||
{ | ||
$sortedCollection = $this->collection; | ||
usort($sortedCollection, $comparator); | ||
|
||
$filtered = array_values($sortedCollection); | ||
|
||
return new static(...$filtered); | ||
} | ||
|
||
public function rewind(): void | ||
{ | ||
reset($this->collection); | ||
} | ||
|
||
public function current() | ||
{ | ||
return current($this->collection); | ||
} | ||
|
||
/** | ||
* @return bool|float|int|string|null | ||
*/ | ||
public function key() | ||
{ | ||
return key($this->collection); | ||
} | ||
|
||
/** | ||
* @return mixed|void | ||
*/ | ||
public function next() | ||
{ | ||
return next($this->collection); | ||
} | ||
|
||
public function valid(): bool | ||
{ | ||
return isset($this->collection[key($this->collection)]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
namespace Bug5231Two; | ||
|
||
class SomeClass | ||
{ | ||
|
||
} | ||
|
||
// class with bug | ||
|
||
/** | ||
* annotation must be exists: | ||
* @method SomeClass[]|SomeParentCollection getSorted() | ||
*/ | ||
class SomeParentCollection implements Iterator | ||
{ | ||
/** @var SomeClass[] */ | ||
protected $collection; | ||
|
||
public function findByName(string $name): ?SomeClass | ||
{ | ||
foreach ($this->collection as $item) { | ||
if ((string)$item === $name) { | ||
return $item; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
// must be exists! | ||
public function existsByKey(string $name): bool | ||
{ | ||
return $this->findByName($name) !== null; | ||
} | ||
|
||
public function getSorted(callable $comparator): self | ||
{ | ||
$sortedCollection = $this->collection; | ||
usort($sortedCollection, $comparator); | ||
|
||
$filtered = array_values($sortedCollection); | ||
|
||
return new static(...$filtered); | ||
} | ||
|
||
public function rewind(): void | ||
{ | ||
reset($this->collection); | ||
} | ||
|
||
public function current() | ||
{ | ||
return current($this->collection); | ||
} | ||
|
||
/** | ||
* @return bool|float|int|string|null | ||
*/ | ||
public function key() | ||
{ | ||
return key($this->collection); | ||
} | ||
|
||
/** | ||
* @return mixed|void | ||
*/ | ||
public function next() | ||
{ | ||
return next($this->collection); | ||
} | ||
|
||
public function valid(): bool | ||
{ | ||
return isset($this->collection[key($this->collection)]); | ||
} | ||
} |