diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 9250928..50f0a34 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -2,6 +2,7 @@ use PhpCsFixer\Config; use PhpCsFixer\Finder; +use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; $finder = Finder::create() ->in(__DIR__) @@ -24,4 +25,5 @@ 'import_functions' => true, ] ]) + ->setParallelConfig(ParallelConfigFactory::detect()) ->setFinder($finder); diff --git a/phpstan.neon b/phpstan.neon index 9263e67..24adda2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,7 +5,7 @@ parameters: type_coverage: return: 100 - param: 90 + param: 100 property: 100 declare: 100 constant: 0 diff --git a/src/Models/Error.php b/src/Models/Error.php index fa36cf7..0d6ccca 100644 --- a/src/Models/Error.php +++ b/src/Models/Error.php @@ -90,7 +90,7 @@ public function stackTraceToArray(Throwable $throwable): array // Exception object `getTrace` does not return file and line number for the first line // http://php.net/manual/en/exception.gettrace.php#107563 - $inApp = function ($file): bool { + $inApp = function (string $file): bool { return !str_contains($file, 'vendor') && !str_contains($file, 'index.php') && !str_contains($file, 'web/core'); // Drupal diff --git a/src/Models/Model.php b/src/Models/Model.php index 531d17a..87a3c4a 100644 --- a/src/Models/Model.php +++ b/src/Models/Model.php @@ -34,7 +34,7 @@ public function only(array $keys): array public function jsonSerialize(): array { - return array_filter($this->getProperties(), fn ($value): bool|int => + return array_filter($this->getProperties(), fn (mixed $value): bool|int => // remove NULL, FALSE, empty strings and empty arrays, but keep values of 0 (zero) is_array($value) || is_object($value) ? !empty($value) : strlen((string) ($value ?? ''))); } diff --git a/src/Models/Transaction.php b/src/Models/Transaction.php index 0697be5..2837a8e 100644 --- a/src/Models/Transaction.php +++ b/src/Models/Transaction.php @@ -63,7 +63,7 @@ public function setType(string $type): Transaction * * @param integer|string $id */ - public function withUser($id, ?string $name = null, ?string $email = null): Transaction + public function withUser(int|string $id, ?string $name = null, ?string $email = null): Transaction { $this->user = new User($id, $name, $email); return $this; diff --git a/tests/AgentTest.php b/tests/AgentTest.php index ce23a86..f401d1b 100644 --- a/tests/AgentTest.php +++ b/tests/AgentTest.php @@ -60,14 +60,15 @@ public function testCallbackReturn(): void public function testAddSegmentWithInput(): void { - $this->inspector->addSegment(function ($segment): void { + $this->inspector->addSegment(function (Segment $segment): void { $this->assertInstanceOf(Segment::class, $segment); }, 'callback', 'test callback', true); } public function testAddSegmentWithInputContext(): void { - $segment = $this->inspector->addSegment(fn ($segment) => $segment->setContext(['foo' => 'bar']), 'callback', 'test callback', true); + $segment = $this->inspector + ->addSegment(fn (Segment $segment) => $segment->setContext(['foo' => 'bar']), 'callback', 'test callback', true); $this->assertEquals(['foo' => 'bar'], $segment->getContext()); } diff --git a/tests/NestedSegmentsTest.php b/tests/NestedSegmentsTest.php index 4e67839..235212b 100644 --- a/tests/NestedSegmentsTest.php +++ b/tests/NestedSegmentsTest.php @@ -185,7 +185,7 @@ public function testMixedStartAndAddSegment(): void $this->inspector->startSegment('parent', 'parent-operation'); - $result = $this->inspector->addSegment(function ($segment): string { + $result = $this->inspector->addSegment(function (Segment $segment): string { $this->assertEquals($this->inspector->getOpenSegments()[0]['hash'], $segment->parent_hash); // Start another segment inside the callback @@ -273,7 +273,7 @@ public function testAddSegmentWithExceptionHandling(): void $this->inspector->startSegment('parent', 'parent-operation'); // Test with throw = false - $result = $this->inspector->addSegment(function ($segment): void { + $result = $this->inspector->addSegment(function (): void { throw new Exception('Test exception'); }, 'child', 'child-operation', false);