Skip to content

Commit

Permalink
Remove Iterator/IteratorAggregate type hints
Browse files Browse the repository at this point in the history
Newer PHPStan versions use the wrong type information if multiple
type hints exists on different classes, leading to the typing
of generated repositories being ignored/overlooked. By removing
the type hints for the base classes, only one type hint exists
and PHPStan applies it correctly.
  • Loading branch information
iquito committed Feb 14, 2022
1 parent 6fd3d29 commit cfade52
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@
"squirrelphp/entities-bundle": "Automatic integration of squirrel/entities in Symfony"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"bamarni/composer-bin-plugin": true,
"captainhook/plugin-composer": true
}
},
"bin": [
"bin/squirrel_repositories_generate"
Expand Down
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ parameters:
count: 1
path: src/Builder/MultiSelectIterator.php

-
message: "#^Class Squirrel\\\\Entities\\\\Builder\\\\SelectEntries implements generic interface IteratorAggregate but does not specify its types\\: TKey, TValue$#"
count: 1
path: src/Builder/SelectEntries.php

-
message: "#^Class Squirrel\\\\Entities\\\\Builder\\\\SelectIterator implements generic interface Iterator but does not specify its types\\: TKey, TValue$#"
count: 1
path: src/Builder/SelectIterator.php

-
message: "#^Property Squirrel\\\\Entities\\\\Builder\\\\SelectIterator\\:\\:\\$selectReference is never read, only written\\.$#"
count: 1
Expand Down
4 changes: 1 addition & 3 deletions src/Builder/SelectEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
use Squirrel\Queries\Builder\BuilderInterface;
use Squirrel\Queries\Builder\FlattenedFieldsWithTypeTrait;

/**
/*
* Select query builder as a fluent object - build query and return object(s) or flattened fields
*
* Properties are only protected so we can extend it with generated repositories
*
* @implements \IteratorAggregate<int,object>
*/
class SelectEntries implements BuilderInterface, \IteratorAggregate
{
Expand Down
4 changes: 1 addition & 3 deletions src/Builder/SelectIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
use Squirrel\Queries\Builder\BuilderInterface;
use Squirrel\Queries\Builder\SelectIteratorTrait;

/**
/*
* Iterator returned by SelectEntries to be used in a foreach loop
*
* @implements \Iterator<int,object>
*/
class SelectIterator implements \Iterator, BuilderInterface
{
Expand Down
5 changes: 5 additions & 0 deletions vendor-bin/phpcs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@
"require": {
"squizlabs/php_codesniffer": "^3.5",
"slevomat/coding-standard": "^7.0"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": false
}
}
}

0 comments on commit cfade52

Please sign in to comment.