-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes generics order for PriorityQueue and SplPriorityQueue
Closes #71 Previously implemented template order did not match those of native SplPriorityQueue, i.e. \SplPriorityQueue<TPriority, TValue> - instead the templates were back-to-front. - PriorityQueue order is fixed and a test case added - PriorityQueue value template renamed from `T` to `TValue` - SplPriorityQueue order fixed and test case added - Removes attempt to document internal array priority, adding resulting psalm issues to the baseline. Users will typically insert with an integer priority and shouldn't care that internally an array is used to represent priority - also, an array for \SplPriorityQueue priority is effectively an invalid argument according to stubs - this is better off in the baseline right? Signed-off-by: George Steel <[email protected]>
- Loading branch information
Showing
5 changed files
with
108 additions
and
29 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
43 changes: 43 additions & 0 deletions
43
test/StaticAnalysis/PriorityQueueGenericsShouldMatchSplPriorityQueue.php
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LaminasTest\Stdlib\StaticAnalysis; | ||
|
||
use Laminas\Stdlib\PriorityQueue; | ||
use SplPriorityQueue; | ||
|
||
use function array_values; | ||
use function iterator_to_array; | ||
|
||
final class PriorityQueueGenericsShouldMatchSplPriorityQueue | ||
{ | ||
/** @var PriorityQueue<int, string> */ | ||
private PriorityQueue $laminas; | ||
/** @var SplPriorityQueue<int, string> */ | ||
private SplPriorityQueue $native; | ||
|
||
/** | ||
* @param PriorityQueue<int, string> $laminas | ||
* @param SplPriorityQueue<int, string> $native | ||
*/ | ||
public function __construct( | ||
PriorityQueue $laminas, | ||
SplPriorityQueue $native | ||
) { | ||
$this->laminas = $laminas; | ||
$this->native = $native; | ||
} | ||
|
||
/** @return list<string> */ | ||
public function laminasList(): array | ||
{ | ||
return array_values(iterator_to_array($this->laminas)); | ||
} | ||
|
||
/** @return list<string> */ | ||
public function nativeList(): array | ||
{ | ||
return array_values(iterator_to_array($this->native)); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
test/StaticAnalysis/SplPriorityQueueGenericsShouldMatchNativeSplPriorityQueue.php
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LaminasTest\Stdlib\StaticAnalysis; | ||
|
||
use Laminas\Stdlib\SplPriorityQueue; | ||
use SplPriorityQueue as NativeSplPriorityQueue; | ||
|
||
use function array_values; | ||
use function iterator_to_array; | ||
|
||
final class SplPriorityQueueGenericsShouldMatchNativeSplPriorityQueue | ||
{ | ||
/** @var SplPriorityQueue<int, string> */ | ||
private SplPriorityQueue $laminas; | ||
/** @var NativeSplPriorityQueue<int, string> */ | ||
private NativeSplPriorityQueue $native; | ||
|
||
/** | ||
* @param SplPriorityQueue<int, string> $laminas | ||
* @param NativeSplPriorityQueue<int, string> $native | ||
*/ | ||
public function __construct( | ||
SplPriorityQueue $laminas, | ||
NativeSplPriorityQueue $native | ||
) { | ||
$this->laminas = $laminas; | ||
$this->native = $native; | ||
} | ||
|
||
/** @return list<string> */ | ||
public function laminasList(): array | ||
{ | ||
return array_values(iterator_to_array($this->laminas)); | ||
} | ||
|
||
/** @return list<string> */ | ||
public function nativeList(): array | ||
{ | ||
return array_values(iterator_to_array($this->native)); | ||
} | ||
} |