Skip to content

Commit

Permalink
Use phpstan/phpstan-strict-rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 12, 2019
1 parent 7247de4 commit 83a4e4d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"infection/infection": "^0.13",
"phpspec/phpspec": "^5",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11.1",
"scrutinizer/ocular": "^1.6"
},
"config": {
Expand Down
16 changes: 3 additions & 13 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,7 @@ public function walk(callable ...$callbacks): CollectionInterface
}

/**
* Create a new collection instance.
*
* @param null|array|callable|Closure|CollectionInterface $data
*
* @return \drupol\collection\Contract\Collection
* {@inheritdoc}
*/
public static function with($data = []): CollectionInterface
{
Expand All @@ -370,9 +366,7 @@ public static function with($data = []): CollectionInterface
}

/**
* @param array $array
*
* @return \drupol\collection\Contract\Collection
* {@inheritdoc}
*/
public static function withArray(array $array): CollectionInterface
{
Expand All @@ -386,11 +380,7 @@ public static function withArray(array $array): CollectionInterface
}

/**
* Create a new collection instance.
*
* @param callable $callback
*
* @return \drupol\collection\Contract\Collection
* {@inheritdoc}
*/
public static function withClosure(callable $callback): CollectionInterface
{
Expand Down
18 changes: 17 additions & 1 deletion src/Contract/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace drupol\collection\Contract;

use Closure;

/**
* Interface Collection.
*/
Expand Down Expand Up @@ -185,6 +187,16 @@ public function nth(int $step, int $offset = 0): self;
*/
public function only(...$keys): self;

/**
* TODO: Pad.
*
* @param int $size
* @param mixed $value
*
* @return \drupol\collection\Contract\Collection
*/
public function pad(int $size, $value): self;

/**
* Push an item onto the beginning of the collection.
*
Expand Down Expand Up @@ -238,7 +250,9 @@ public function slice(int $offset, int $length = null): self;
public function walk(callable ...$callbacks): self;

/**
* @param mixed $data
* Create a new collection instance.
*
* @param null|array|callable|Closure|Collection $data
*
* @return \drupol\collection\Contract\Collection
*/
Expand All @@ -252,6 +266,8 @@ public static function with($data = []): self;
public static function withArray(array $data): self;

/**
* Create a new collection instance.
*
* @param callable $callable
*
* @return \drupol\collection\Contract\Collection
Expand Down
4 changes: 2 additions & 2 deletions src/Operation/Flatten.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ static function () use ($depth, $collection) {
yield $i;
}
} else {
foreach ($collection::with($item)->flatten($depth - 1) as $item) {
yield $item;
foreach ($collection::with($item)->flatten($depth - 1) as $flattenItem) {
yield $flattenItem;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Operation/Limit.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function run(Collection $collection): Collection
static function () use ($limit, $collection) {
$iterator = $collection->getIterator();

for (; $iterator->valid() && $limit--; $iterator->next()) {
for (; (true === $iterator->valid()) && (0 !== $limit--); $iterator->next()) {
yield $iterator->key() => $iterator->current();
}
}
Expand Down

0 comments on commit 83a4e4d

Please sign in to comment.