Skip to content

Commit

Permalink
General: Update to phpstan level 10
Browse files Browse the repository at this point in the history
  • Loading branch information
pprkut committed Feb 8, 2025
1 parent b7d8673 commit 3a794ab
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
php-tests:
uses: lunr-php/actions-templates/.github/workflows/php-composer.yml@master
with:
phpstan-level: 6
phpstan-level: 10
allow-style-failures: false
allow-phpstan-failures: false
codestyle-branch: '0.10.2'
Expand Down
2 changes: 1 addition & 1 deletion src/Lunr/Halo/FluidInterfaceMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FluidInterfaceMock

/**
* Array of mocked return values
* @var array<string, mixed>
* @var array<string, mixed[]>
*/
protected array $return;

Expand Down
22 changes: 12 additions & 10 deletions src/Lunr/Halo/LegacyBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
* This class contains helper code for the Lunr unit tests.
*
* @deprecated Use `LunrBaseTestCase` instead
*
* @phpstan-type CallableMethod array{0:object|string,1:string}
*/
abstract class LegacyBaseTest extends TestCase
{

/**
* Instance of the tested class.
* @var mixed
* @var object
*/
protected $class;

Expand Down Expand Up @@ -251,10 +253,10 @@ private function uopz_unmock_function(string $name): void
*
* Replace the code of a function of a specific class
*
* @param array<int,object|string> $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $visibility Visibility of the redefined method
* @param string $args Comma-delimited list of arguments for the redefined method
* @param CallableMethod $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $visibility Visibility of the redefined method
* @param string $args Comma-delimited list of arguments for the redefined method
*
* @return void
*/
Expand All @@ -269,9 +271,9 @@ protected function mock_method(array $method, Closure $mock, string $visibility
*
* Replace the code of a function of a specific class
*
* @param array<int,object|string> $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $args Comma-delimited list of arguments for the redefined method
* @param CallableMethod $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $args Comma-delimited list of arguments for the redefined method
*
* @return void
*/
Expand Down Expand Up @@ -309,7 +311,7 @@ private function uopz_mock_method(array $method, Closure $mock, string $args = '
/**
* Unmock a method.
*
* @param array<int,object|string> $method Method defined in an array form
* @param CallableMethod $method Method defined in an array form
*
* @return void
*/
Expand All @@ -321,7 +323,7 @@ protected function unmock_method(array $method): void
/**
* Unmock a method with uopz.
*
* @param array<int,object|string> $method Method defined in an array form
* @param CallableMethod $method Method defined in an array form
*
* @return void
*/
Expand Down
38 changes: 23 additions & 15 deletions src/Lunr/Halo/LunrBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

/**
* This class contains helper code for the Lunr unit tests.
*
* @phpstan-type CallableMethod array{0:object|string,1:string}
*/
abstract class LunrBaseTestCase extends TestCase
{
Expand Down Expand Up @@ -97,7 +99,13 @@ public function baseSetUp(object $class): void

if ($class instanceof MockObject)
{
$this->reflection = new ReflectionClass(get_parent_class($class));
/**
* MockObject *must* have a parent, so this can't return FALSE.
* @var class-string<object> $instance
*/
$instance = get_parent_class($class);

Check warning on line 106 in src/Lunr/Halo/LunrBaseTestCase.php

View check run for this annotation

Codecov / codecov/patch

src/Lunr/Halo/LunrBaseTestCase.php#L106

Added line #L106 was not covered by tests

$this->reflection = new ReflectionClass($instance);

Check warning on line 108 in src/Lunr/Halo/LunrBaseTestCase.php

View check run for this annotation

Codecov / codecov/patch

src/Lunr/Halo/LunrBaseTestCase.php#L108

Added line #L108 was not covered by tests
}
else
{
Expand Down Expand Up @@ -353,10 +361,10 @@ private function uopzUnmockFunction(string $name): void
*
* Replace the code of a function of a specific class
*
* @param array<int,object|string> $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $visibility Visibility of the redefined method
* @param string $args Comma-delimited list of arguments for the redefined method
* @param CallableMethod $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $visibility Visibility of the redefined method
* @param string $args Comma-delimited list of arguments for the redefined method
*
* @deprecated Use mockMethod() instead
*
Expand All @@ -372,10 +380,10 @@ protected function mock_method(array $method, Closure $mock, string $visibility
*
* Replace the code of a function of a specific class
*
* @param array<int,object|string> $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $visibility Visibility of the redefined method
* @param string $args Comma-delimited list of arguments for the redefined method
* @param CallableMethod $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $visibility Visibility of the redefined method
* @param string $args Comma-delimited list of arguments for the redefined method
*
* @return void
*/
Expand All @@ -390,9 +398,9 @@ protected function mockMethod(array $method, Closure $mock, string $visibility =
*
* Replace the code of a function of a specific class
*
* @param array<int,object|string> $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $args Comma-delimited list of arguments for the redefined method
* @param CallableMethod $method Method defined in an array form
* @param Closure $mock Replacement code for the method
* @param string $args Comma-delimited list of arguments for the redefined method
*
* @return void
*/
Expand Down Expand Up @@ -430,7 +438,7 @@ private function uopzMockMethod(array $method, Closure $mock, string $args = '')
/**
* Unmock a method.
*
* @param array<int,object|string> $method Method defined in an array form
* @param CallableMethod $method Method defined in an array form
*
* @deprecated Use unmockMethod() instead
*
Expand All @@ -444,7 +452,7 @@ protected function unmock_method(array $method): void
/**
* Unmock a method.
*
* @param array<int,object|string> $method Method defined in an array form
* @param CallableMethod $method Method defined in an array form
*
* @return void
*/
Expand All @@ -456,7 +464,7 @@ protected function unmockMethod(array $method): void
/**
* Unmock a method with uopz.
*
* @param array<int,object|string> $method Method defined in an array form
* @param CallableMethod $method Method defined in an array form
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: CC0-1.0

parameters:
level: 6
level: 10
paths:
- ../src
bootstrapFiles:
Expand Down

0 comments on commit 3a794ab

Please sign in to comment.