diff --git a/src/Psl/Asio/IResultOrExceptionWrapper.php b/src/Psl/Asio/IResultOrExceptionWrapper.php index 4ee7223..54c010a 100644 --- a/src/Psl/Asio/IResultOrExceptionWrapper.php +++ b/src/Psl/Asio/IResultOrExceptionWrapper.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Psl\Asio; -use Psl; use Exception; +use Psl; /** * Represents a result of operation that either has a successful result or the exception object if that operation failed. diff --git a/src/Psl/Asio/WrappedException.php b/src/Psl/Asio/WrappedException.php index 1b9559c..ca12af5 100644 --- a/src/Psl/Asio/WrappedException.php +++ b/src/Psl/Asio/WrappedException.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace Psl\Asio; +use Exception; use Psl; use Psl\Str; -use Exception; /** * Represents the result of failed operation. diff --git a/src/Psl/Asio/WrappedResult.php b/src/Psl/Asio/WrappedResult.php index cca41e8..f5dfff1 100644 --- a/src/Psl/Asio/WrappedResult.php +++ b/src/Psl/Asio/WrappedResult.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace Psl\Asio; +use Exception; use Psl; use Psl\Str; -use Exception; /** * Represents the result of successful operation. diff --git a/src/Psl/Collection/IMutableMap.php b/src/Psl/Collection/IMutableMap.php index f95ef2b..afe34db 100644 --- a/src/Psl/Collection/IMutableMap.php +++ b/src/Psl/Collection/IMutableMap.php @@ -11,7 +11,8 @@ namespace Psl\Collection; * @extends IMap * @extends IMutableAccessibleCollection */ -interface IMutableMap extends IMap, IMutableAccessibleCollection { +interface IMutableMap extends IMap, IMutableAccessibleCollection +{ /** * Returns a `IMutableVector` containing the values of the current * `IMutableMap`. diff --git a/src/Psl/Gen/RewindableGenerator.php b/src/Psl/Gen/RewindableGenerator.php index d36acb0..a518e5e 100644 --- a/src/Psl/Gen/RewindableGenerator.php +++ b/src/Psl/Gen/RewindableGenerator.php @@ -4,10 +4,10 @@ declare(strict_types=1); namespace Psl\Gen; +use Generator; +use Iterator; use Psl; use Psl\Iter; -use Iterator; -use Generator; /** * @template Tk @@ -91,7 +91,7 @@ final class RewindableGenerator implements Iterator $valid = $this->iterator->valid(); if (!$valid && $this->iterator instanceof Generator) { /** @psalm-var (Closure(): Generator) $generator */ - $generator = function(): Generator { + $generator = function (): Generator { foreach ($this->cache as [$k, $v]) { yield $k => $v; } diff --git a/src/Psl/Gen/product.php b/src/Psl/Gen/product.php index 76e2808..8d58681 100644 --- a/src/Psl/Gen/product.php +++ b/src/Psl/Gen/product.php @@ -35,7 +35,7 @@ function product(iterable ...$iterables): iterable /** @psalm-var array> $iterators */ $iterators = Iter\to_array(Iter\map( $iterables, - fn(iterable $iterable) => new Iter\Iterator($iterable) + fn (iterable $iterable) => new Iter\Iterator($iterable) )); $numIterators = count($iterators); diff --git a/src/Psl/Gen/reverse.php b/src/Psl/Gen/reverse.php index 3e7cf76..6d50854 100644 --- a/src/Psl/Gen/reverse.php +++ b/src/Psl/Gen/reverse.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Psl\Gen; -use Psl\Iter; use Generator; +use Psl\Iter; /** * Reverse the given iterable. diff --git a/src/Psl/Gen/zip.php b/src/Psl/Gen/zip.php index bf4261f..788d28b 100644 --- a/src/Psl/Gen/zip.php +++ b/src/Psl/Gen/zip.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Psl\Gen; -use Psl\Iter; use Generator; +use Psl\Iter; /** * Zips the iterables that were passed as arguments. diff --git a/src/Psl/Internal/Loader.php b/src/Psl/Internal/Loader.php index 2876fd5..369f7e6 100644 --- a/src/Psl/Internal/Loader.php +++ b/src/Psl/Internal/Loader.php @@ -13,14 +13,6 @@ namespace Psl\Internal; */ final class Loader { - private const TypeConstant = 1; - private const TypeFunction = 2; - private const TypeInterface = 4; - private const TypeTrait = 8; - private const TypeClass = 16; - - private const TypeClassish = self::TypeInterface | self::TypeTrait | self::TypeClass; - public const Constants = [ 'Psl\Internal\ALPHABET_BASE64', 'Psl\Internal\ALPHABET_BASE64_URL', @@ -315,6 +307,13 @@ final class Loader 'Psl\Asio\WrappedException', 'Psl\Asio\WrappedResult', ]; + private const TypeConstant = 1; + private const TypeFunction = 2; + private const TypeInterface = 4; + private const TypeTrait = 8; + private const TypeClass = 16; + + private const TypeClassish = self::TypeInterface | self::TypeTrait | self::TypeClass; private function __construct() { @@ -324,7 +323,7 @@ final class Loader { if (!\function_exists(self::Functions[0])) { self::preload(); - } else if (!\defined(self::Constants[0])) { + } elseif (!\defined(self::Constants[0])) { self::loadConstants(); } } @@ -332,7 +331,7 @@ final class Loader public static function preload(): void { static::loadConstants(); - static::autoload(static function(): void { + static::autoload(static function (): void { static::loadFunctions(); static::loadInterfaces(); static::loadTraits(); @@ -342,7 +341,7 @@ final class Loader private static function autoload(callable $callback): void { - $loader = static function(string $classname): ?bool { + $loader = static function (string $classname): ?bool { if ('P' === $classname[0] && 0 === \strpos($classname, 'Psl\\')) { require_once static::getFile($classname, self::TypeClassish); @@ -424,7 +423,7 @@ final class Loader $lastSeparatorPosition = \strrpos($typename, '\\'); $namespace = substr($typename, 0, $lastSeparatorPosition); - if ($type === ($type & self::TypeClassish) || ($type === ($type & self::TypeFunction))) { + if (($type & self::TypeClassish) === $type || (($type & self::TypeFunction) === $type)) { $file = \substr($typename, $lastSeparatorPosition + 1) . '.php'; } else { $file = 'constants.php'; diff --git a/tests/Psl/Asio/WrapTest.php b/tests/Psl/Asio/WrapTest.php index 3f46ab9..f6ebd4b 100644 --- a/tests/Psl/Asio/WrapTest.php +++ b/tests/Psl/Asio/WrapTest.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Psl\Tests\Asio; -use Psl\Asio; use PHPUnit\Framework\TestCase; +use Psl\Asio; use Psl\Exception\InvariantViolationException; class WrapTest extends TestCase @@ -13,7 +13,7 @@ class WrapTest extends TestCase public function testWrapException(): void { $exception = new \Exception('foo'); - $wrapper = Asio\wrap(static function() use ($exception): void { + $wrapper = Asio\wrap(static function () use ($exception): void { throw $exception; }); $this->assertFalse($wrapper->isSucceeded()); @@ -27,7 +27,7 @@ class WrapTest extends TestCase public function testWrapResult(): void { - $wrapper = Asio\wrap(static function(): string { + $wrapper = Asio\wrap(static function (): string { return 'foo'; }); $this->assertTrue($wrapper->isSucceeded()); diff --git a/tests/Psl/Asio/WrappedExceptionTest.php b/tests/Psl/Asio/WrappedExceptionTest.php index 1220afb..907aed7 100644 --- a/tests/Psl/Asio/WrappedExceptionTest.php +++ b/tests/Psl/Asio/WrappedExceptionTest.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Psl\Tests\Asio; -use Psl\Asio\WrappedException; use PHPUnit\Framework\TestCase; +use Psl\Asio\WrappedException; class WrappedExceptionTest extends TestCase { diff --git a/tests/Psl/Asio/WrappedResultTest.php b/tests/Psl/Asio/WrappedResultTest.php index 7f007d9..e8b6165 100644 --- a/tests/Psl/Asio/WrappedResultTest.php +++ b/tests/Psl/Asio/WrappedResultTest.php @@ -1,10 +1,11 @@ $items - * - * @psalm-return IMap - */ - abstract protected function create(iterable $items): IMap; - public function testIsEmpty(): void { $this->assertTrue($this->create([])->isEmpty()); @@ -116,7 +106,7 @@ abstract class AbstractMapTest extends TestCase 3 => 'qux', ]); - $filtered = $map->filter(fn(string $item) => Str\contains($item, 'b')); + $filtered = $map->filter(fn (string $item) => Str\contains($item, 'b')); $this->assertInstanceOf($this->mapClass, $filtered); $this->assertNotSame($map, $filtered); @@ -133,7 +123,7 @@ abstract class AbstractMapTest extends TestCase 3 => 'qux', ]); - $filtered = $map->filter(fn(string $item) => Str\contains($item, 'hello')); + $filtered = $map->filter(fn (string $item) => Str\contains($item, 'hello')); $this->assertInstanceOf($this->mapClass, $filtered); $this->assertNotContains('bar', $filtered); @@ -152,7 +142,7 @@ abstract class AbstractMapTest extends TestCase 3 => 'qux', ]); - $filtered = $map->filterWithKey(fn(int $k, string $v) => $v === 'foo' || $k === 3); + $filtered = $map->filterWithKey(fn (int $k, string $v) => 'foo' === $v || 3 === $k); $this->assertInstanceOf($this->mapClass, $filtered); $this->assertNotSame($map, $filtered); @@ -169,7 +159,7 @@ abstract class AbstractMapTest extends TestCase 3 => 'qux', ]); - $filtered = $map->filterWithKey(fn(int $k, string $v) => $k === 4); + $filtered = $map->filterWithKey(fn (int $k, string $v) => 4 === $k); $this->assertInstanceOf($this->mapClass, $filtered); $this->assertNotContains('bar', $filtered); @@ -188,7 +178,7 @@ abstract class AbstractMapTest extends TestCase 3 => 'qux', ]); - $mapped = $map->map(fn(string $item) => Str\uppercase($item)); + $mapped = $map->map(fn (string $item) => Str\uppercase($item)); $this->assertInstanceOf($this->mapClass, $mapped); $this->assertSame([ @@ -207,7 +197,7 @@ abstract class AbstractMapTest extends TestCase 3 => 'qux', ]); - $mapped = $map->map(fn(string $item) => $item); + $mapped = $map->map(fn (string $item) => $item); $this->assertInstanceOf($this->mapClass, $mapped); $this->assertNotSame($map, $mapped); @@ -224,7 +214,7 @@ abstract class AbstractMapTest extends TestCase 3 => 'qux', ]); - $mapped = $map->mapWithKey(fn(int $k, string $v) => Str\format('%s ( %d )', $v, $k)); + $mapped = $map->mapWithKey(fn (int $k, string $v) => Str\format('%s ( %d )', $v, $k)); $this->assertInstanceOf($this->mapClass, $mapped); $this->assertSame([ @@ -243,14 +233,14 @@ abstract class AbstractMapTest extends TestCase 3 => 'qux', ]); - $mapped = $map->mapWithKey(fn(int $k, string $v) => $k); + $mapped = $map->mapWithKey(fn (int $k, string $v) => $k); $this->assertInstanceOf($this->mapClass, $mapped); $this->assertNotSame($map, $mapped); $this->assertSame($map->keys()->toArray(), $mapped->toArray()); $this->assertCount(4, $mapped); - $mapped = $map->mapWithKey(fn(int $k, string $v) => $v); + $mapped = $map->mapWithKey(fn (int $k, string $v) => $v); $this->assertInstanceOf($this->mapClass, $mapped); $this->assertNotSame($map, $mapped); @@ -398,26 +388,26 @@ abstract class AbstractMapTest extends TestCase public function testTakeWhile(): void { $map = $this->create([]); - $rest = $map->takeWhile(fn($v) => false); + $rest = $map->takeWhile(fn ($v) => false); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(0, $rest); $map = $this->create([]); - $rest = $map->takeWhile(fn($v) => true); + $rest = $map->takeWhile(fn ($v) => true); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->takeWhile(fn($v) => true); + $rest = $map->takeWhile(fn ($v) => true); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(2, $rest); $this->assertSame($map->toArray(), $rest->toArray()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->takeWhile(fn($v) => $v === 'bar'); + $rest = $map->takeWhile(fn ($v) => 'bar' === $v); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(1, $rest); @@ -456,32 +446,32 @@ abstract class AbstractMapTest extends TestCase public function testDropWhile(): void { $map = $this->create([]); - $rest = $map->dropWhile(fn($v) => true); + $rest = $map->dropWhile(fn ($v) => true); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(0, $rest); $map = $this->create([]); - $rest = $map->dropWhile(fn($v) => false); + $rest = $map->dropWhile(fn ($v) => false); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->dropWhile(fn($v) => true); + $rest = $map->dropWhile(fn ($v) => true); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(0, $rest); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->dropWhile(fn($v) => false); + $rest = $map->dropWhile(fn ($v) => false); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(2, $rest); $this->assertSame($map->toArray(), $rest->toArray()); $map = $this->create(['foo' => 'bar', 'baz' => 'qux']); - $rest = $map->dropWhile(fn($v) => $v === 'bar'); + $rest = $map->dropWhile(fn ($v) => 'bar' === $v); $this->assertInstanceOf($this->mapClass, $rest); $this->assertNotSame($map, $rest); $this->assertCount(1, $rest); @@ -558,4 +548,14 @@ abstract class AbstractMapTest extends TestCase $this->assertSame('world', $map->get('bar')); $this->assertNull($map->get('baz')); } + + /** + * @template Tk of array-key + * @template Tv + * + * @psalm-param iterable $items + * + * @psalm-return IMap + */ + abstract protected function create(iterable $items): IMap; } diff --git a/tests/Psl/Collection/AbstractVectorTest.php b/tests/Psl/Collection/AbstractVectorTest.php index 3e70ce0..f41c838 100644 --- a/tests/Psl/Collection/AbstractVectorTest.php +++ b/tests/Psl/Collection/AbstractVectorTest.php @@ -4,10 +4,10 @@ declare(strict_types=1); namespace Psl\Tests\Collection; -use Psl\Str; -use Psl\Collection\IVector; use PHPUnit\Framework\TestCase; +use Psl\Collection\IVector; use Psl\Exception\InvariantViolationException; +use Psl\Str; /** * @covers \Psl\Collection\AbstractVector @@ -22,15 +22,6 @@ abstract class AbstractVectorTest extends TestCase */ protected string $vectorClass = IVector::class; - /** - * @template T - * - * @psalm-param iterable $items - * - * @psalm-return IVector - */ - abstract protected function create(iterable $items): IVector; - public function testIsEmpty(): void { $this->assertTrue($this->create([])->isEmpty()); @@ -103,7 +94,7 @@ abstract class AbstractVectorTest extends TestCase 'qux', ]); - $filtered = $vector->filter(fn(string $item) => Str\contains($item, 'b')); + $filtered = $vector->filter(fn (string $item) => Str\contains($item, 'b')); $this->assertInstanceOf($this->vectorClass, $filtered); $this->assertNotSame($vector, $filtered); @@ -120,7 +111,7 @@ abstract class AbstractVectorTest extends TestCase 'qux', ]); - $filtered = $vector->filter(fn(string $item) => Str\contains($item, 'hello')); + $filtered = $vector->filter(fn (string $item) => Str\contains($item, 'hello')); $this->assertInstanceOf($this->vectorClass, $filtered); $this->assertNotContains('bar', $filtered); @@ -139,7 +130,7 @@ abstract class AbstractVectorTest extends TestCase 'qux', ]); - $filtered = $vector->filterWithKey(fn(int $k, string $v) => $v === 'foo' || $k === 3); + $filtered = $vector->filterWithKey(fn (int $k, string $v) => 'foo' === $v || 3 === $k); $this->assertInstanceOf($this->vectorClass, $filtered); $this->assertNotSame($vector, $filtered); @@ -156,7 +147,7 @@ abstract class AbstractVectorTest extends TestCase 'qux', ]); - $filtered = $vector->filterWithKey(fn(int $k, string $v) => $k === 4); + $filtered = $vector->filterWithKey(fn (int $k, string $v) => 4 === $k); $this->assertInstanceOf($this->vectorClass, $filtered); $this->assertNotContains('bar', $filtered); @@ -175,7 +166,7 @@ abstract class AbstractVectorTest extends TestCase 'qux', ]); - $mapped = $vector->map(fn(string $item) => Str\uppercase($item)); + $mapped = $vector->map(fn (string $item) => Str\uppercase($item)); $this->assertInstanceOf($this->vectorClass, $mapped); $this->assertSame([ @@ -194,7 +185,7 @@ abstract class AbstractVectorTest extends TestCase 'qux', ]); - $mapped = $vector->map(fn(string $item) => $item); + $mapped = $vector->map(fn (string $item) => $item); $this->assertInstanceOf($this->vectorClass, $mapped); $this->assertNotSame($vector, $mapped); @@ -211,7 +202,7 @@ abstract class AbstractVectorTest extends TestCase 3 => 'qux', ]); - $mapped = $vector->mapWithKey(fn(int $k, string $v) => Str\format('%s ( %d )', $v, $k)); + $mapped = $vector->mapWithKey(fn (int $k, string $v) => Str\format('%s ( %d )', $v, $k)); $this->assertInstanceOf($this->vectorClass, $mapped); $this->assertSame([ @@ -230,14 +221,14 @@ abstract class AbstractVectorTest extends TestCase 'qux', ]); - $mapped = $vector->mapWithKey(fn(int $k, string $v) => $k); + $mapped = $vector->mapWithKey(fn (int $k, string $v) => $k); $this->assertInstanceOf($this->vectorClass, $mapped); $this->assertNotSame($vector, $mapped); $this->assertSame($vector->keys()->toArray(), $mapped->toArray()); $this->assertCount(4, $mapped); - $mapped = $vector->mapWithKey(fn(int $k, string $v) => $v); + $mapped = $vector->mapWithKey(fn (int $k, string $v) => $v); $this->assertInstanceOf($this->vectorClass, $mapped); $this->assertNotSame($vector, $mapped); @@ -385,26 +376,26 @@ abstract class AbstractVectorTest extends TestCase public function testTakeWhile(): void { $vector = $this->create([]); - $rest = $vector->takeWhile(fn($v) => false); + $rest = $vector->takeWhile(fn ($v) => false); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(0, $rest); $vector = $this->create([]); - $rest = $vector->takeWhile(fn($v) => true); + $rest = $vector->takeWhile(fn ($v) => true); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); - $rest = $vector->takeWhile(fn($v) => true); + $rest = $vector->takeWhile(fn ($v) => true); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(2, $rest); $this->assertSame($vector->toArray(), $rest->toArray()); $vector = $this->create(['bar', 'qux']); - $rest = $vector->takeWhile(fn($v) => $v === 'bar'); + $rest = $vector->takeWhile(fn ($v) => 'bar' === $v); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(1, $rest); @@ -443,32 +434,32 @@ abstract class AbstractVectorTest extends TestCase public function testDropWhile(): void { $vector = $this->create([]); - $rest = $vector->dropWhile(fn($v) => true); + $rest = $vector->dropWhile(fn ($v) => true); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(0, $rest); $vector = $this->create([]); - $rest = $vector->dropWhile(fn($v) => false); + $rest = $vector->dropWhile(fn ($v) => false); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); - $rest = $vector->dropWhile(fn($v) => true); + $rest = $vector->dropWhile(fn ($v) => true); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(0, $rest); $vector = $this->create(['bar', 'qux']); - $rest = $vector->dropWhile(fn($v) => false); + $rest = $vector->dropWhile(fn ($v) => false); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(2, $rest); $this->assertSame($vector->toArray(), $rest->toArray()); $vector = $this->create(['bar', 'qux']); - $rest = $vector->dropWhile(fn($v) => $v === 'bar'); + $rest = $vector->dropWhile(fn ($v) => 'bar' === $v); $this->assertInstanceOf($this->vectorClass, $rest); $this->assertNotSame($vector, $rest); $this->assertCount(1, $rest); @@ -545,4 +536,13 @@ abstract class AbstractVectorTest extends TestCase $this->assertSame('world', $vector->get(1)); $this->assertNull($vector->get(2)); } + + /** + * @template T + * + * @psalm-param iterable $items + * + * @psalm-return IVector + */ + abstract protected function create(iterable $items): IVector; } diff --git a/tests/Psl/Collection/MutableMapTest.php b/tests/Psl/Collection/MutableMapTest.php index f015638..4067aa9 100644 --- a/tests/Psl/Collection/MutableMapTest.php +++ b/tests/Psl/Collection/MutableMapTest.php @@ -24,19 +24,6 @@ final class MutableMapTest extends AbstractMapTest */ protected string $vectorClass = MutableVector::class; - /** - * @template Tk of array-key - * @template Tv - * - * @psalm-param iterable $items - * - * @psalm-return MutableMap - */ - protected function create(iterable $items): MutableMap - { - return new MutableMap($items); - } - public function testClear(): void { $map = $this->create(['foo' => 'bar']); @@ -158,4 +145,17 @@ final class MutableMapTest extends AbstractMapTest $this->assertNull($map->get('foo')); $this->assertNull($map->get('bar')); } + + /** + * @template Tk of array-key + * @template Tv + * + * @psalm-param iterable $items + * + * @psalm-return MutableMap + */ + protected function create(iterable $items): MutableMap + { + return new MutableMap($items); + } } diff --git a/tests/Psl/Collection/MutableVectorTest.php b/tests/Psl/Collection/MutableVectorTest.php index 8916e56..30622e5 100644 --- a/tests/Psl/Collection/MutableVectorTest.php +++ b/tests/Psl/Collection/MutableVectorTest.php @@ -5,8 +5,8 @@ declare(strict_types=1); namespace Psl\Tests\Collection; use Psl\Collection\Map; -use Psl\Collection\Vector; use Psl\Collection\MutableVector; +use Psl\Collection\Vector; use Psl\Exception\InvariantViolationException; final class MutableVectorTest extends AbstractVectorTest @@ -18,18 +18,6 @@ final class MutableVectorTest extends AbstractVectorTest */ protected string $vectorClass = MutableVector::class; - /** - * @template T - * - * @psalm-param iterable $items - * - * @psalm-return MutableVector - */ - protected function create(iterable $items): MutableVector - { - return new MutableVector($items); - } - public function testClear(): void { $vector = $this->create(['foo', 'bar']); @@ -150,5 +138,16 @@ final class MutableVectorTest extends AbstractVectorTest $this->assertCount(1, $vector); $this->assertSame('baz', $vector->get(0)); } -} + /** + * @template T + * + * @psalm-param iterable $items + * + * @psalm-return MutableVector + */ + protected function create(iterable $items): MutableVector + { + return new MutableVector($items); + } +} diff --git a/tests/Psl/Gen/RewindableGeneratorTest.php b/tests/Psl/Gen/RewindableGeneratorTest.php index 0a7fb66..c61c406 100644 --- a/tests/Psl/Gen/RewindableGeneratorTest.php +++ b/tests/Psl/Gen/RewindableGeneratorTest.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace Psl\Tests\Gen; -use Psl\Gen; use PHPUnit\Framework\TestCase; use Psl\Collection\MutableVector; +use Psl\Gen; class RewindableGeneratorTest extends TestCase { @@ -14,7 +14,7 @@ class RewindableGeneratorTest extends TestCase { $spy = new MutableVector([]); - $generator = (static function() use ($spy): iterable { + $generator = (static function () use ($spy): iterable { for ($i = 0; $i < 3; $i++) { $spy->add('generator (' . $i . ')'); @@ -69,7 +69,7 @@ class RewindableGeneratorTest extends TestCase { $spy = new MutableVector([]); - $generator = (static function() use ($spy): iterable { + $generator = (static function () use ($spy): iterable { for ($i = 0; $i < 3; $i++) { $spy->add($e = 'generator (' . $i . ')'); yield $i;