From f844c762bdc4ddeb5a516e06bb53a46ccd961f5e Mon Sep 17 00:00:00 2001 From: DonCallisto Date: Sun, 4 Oct 2020 22:02:18 +0200 Subject: [PATCH] Raised PHPStan to level 5 --- phpstan.neon | 7 +++++-- src/Process/ProcessorCounter.php | 1 + src/Process/Report.php | 4 ++-- src/Queue/CreateTestsQueueFromPhpUnitXML.php | 2 +- src/UI/VerboseRenderer.php | 4 ++-- tests/Process/ProcessesManagerTest.php | 6 +++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index fef0edc..8165cfb 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,7 +2,10 @@ includes: - vendor/phpstan/phpstan-phpunit/extension.neon parameters: - level: 3 + level: 5 paths: - src - - tests \ No newline at end of file + - tests + reportUnmatchedIgnoredErrors: false + ignoreErrors: #see https://github.com/phpstan/phpstan/issues/1267#issuecomment-552874947 -> @todo remove when sf 3.4 support ends + - "#^Call to an undefined static method #" \ No newline at end of file diff --git a/src/Process/ProcessorCounter.php b/src/Process/ProcessorCounter.php index 22bf2f5..f385207 100644 --- a/src/Process/ProcessorCounter.php +++ b/src/Process/ProcessorCounter.php @@ -55,6 +55,7 @@ private function readFromProcCPUInfo() $process = Process::fromShellCommandline($executeCommand); } else { // Drop when sf 3.4 supports ends + /** @phpstan-ignore-next-line */ // @todo remove when sf 3.4 support ends $process = new Process($executeCommand); } $process->run(); diff --git a/src/Process/Report.php b/src/Process/Report.php index cf60c8a..ce0497a 100644 --- a/src/Process/Report.php +++ b/src/Process/Report.php @@ -14,7 +14,7 @@ class Report /** * @param string $suite * @param bool $isSuccess - * @param int $time + * @param float $time * @param int $processorNumber * @param string|null $errorBuffer * @param bool $isFirstOnThread @@ -68,7 +68,7 @@ public function getSuite() } /** - * @return int Time in microseconds + * @return float Time in microseconds */ public function getTime() { diff --git a/src/Queue/CreateTestsQueueFromPhpUnitXML.php b/src/Queue/CreateTestsQueueFromPhpUnitXML.php index c570262..3313f5a 100644 --- a/src/Queue/CreateTestsQueueFromPhpUnitXML.php +++ b/src/Queue/CreateTestsQueueFromPhpUnitXML.php @@ -41,7 +41,7 @@ public static function execute($xmlFile) private static function processTestSuite( TestsQueue $testSuites, - \PHPUnit\Framework\TestSuiteIterator $testSuiteIterator + \Iterator $testSuiteIterator ) { foreach ($testSuiteIterator as $testSuite) { self::addTestFile($testSuites, $testSuite); diff --git a/src/UI/VerboseRenderer.php b/src/UI/VerboseRenderer.php index 04ec3ee..cba3bfe 100644 --- a/src/UI/VerboseRenderer.php +++ b/src/UI/VerboseRenderer.php @@ -52,7 +52,7 @@ public function renderBody(QueueInterface $queue, Processes $processes) $log = $processes->getReport(); $count = count($log); - $tests = array_slice($log, $this->lastIndex, $count, 1); + $tests = array_slice($log, $this->lastIndex, $count, true); foreach ($tests as $report) { ++$this->lastIndex; @@ -90,7 +90,7 @@ public function renderBody(QueueInterface $queue, Processes $processes) /** * Method to format duration to human readable format. * - * @param int $milliseconds + * @param float $milliseconds * * @return string */ diff --git a/tests/Process/ProcessesManagerTest.php b/tests/Process/ProcessesManagerTest.php index cba8ade..a9636e8 100644 --- a/tests/Process/ProcessesManagerTest.php +++ b/tests/Process/ProcessesManagerTest.php @@ -30,7 +30,7 @@ public function shouldCreateBeforeProcessesExecutingFactoryWithTheCorrectArgumen $this->assertTrue($manager->assertNProcessRunning($queue, $processes)); } - /** + /**src/UI/VerboseRenderer.php * @test */ public function shouldCreateProcessesWithoutBeforeProcessExecutingFactoryWithTheCorrectArguments() @@ -57,7 +57,7 @@ public function shouldCreateProcessesWithoutBeforeProcessExecutingFactoryWithThe $factory->expects($this->exactly(1)) ->method('createAProcess') ->with($this->anything(), $this->equalTo(1), $this->equalTo(1), $this->equalTo(true)) - ->willReturn(new Process(['echo '], rand())); + ->willReturn(new Process(['echo '], (string) rand())); $manager = new ProcessesManager($factory, 1); @@ -107,7 +107,7 @@ public function shouldCreate6ProcessesGivingThemTheCorrectEnvParameters() $factory->expects($this->at($at)) ->method('createAProcess') ->with($this->anything(), $this->equalTo($expectation[0]), $this->equalTo($expectation[1]), $this->equalTo($expectation[2])) - ->willReturn(new Process(['echo '], rand())); + ->willReturn(new Process(['echo '], (string) rand())); } $manager = new ProcessesManager($factory, 1);