Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve static analysis #49

Merged
merged 5 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Doctrine/Deprecations/Deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Deprecation
private const TYPE_TRIGGER_ERROR = 2;
private const TYPE_PSR_LOGGER = 4;

/** @var self::TYPE_*|null */
/** @var int-mask-of<self::TYPE_*>|null */
private static $type;

/** @var LoggerInterface|null */
Expand Down Expand Up @@ -271,7 +271,7 @@ public static function getTriggeredDeprecations(): array
}

/**
* @return self::TYPE_*
* @return int-mask-of<self::TYPE_*>
*/
private static function getTypeFromEnv(): int
{
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 3
level: 6
paths:
- lib
- tests
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
7 changes: 4 additions & 3 deletions tests/Doctrine/Deprecations/DeprecationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
use Doctrine\Foo\Baz;
use PHPUnit\Framework\Error\Deprecated;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use ReflectionProperty;
Expand Down Expand Up @@ -56,12 +55,14 @@ public function expectDeprecationMessage(string $message): void

public function expectErrorHandler(string $expectedMessage, string $identifier, int $times = 1): void
{
set_error_handler(function ($type, $message) use ($expectedMessage, $identifier, $times): void {
set_error_handler(function ($type, $message) use ($expectedMessage, $identifier, $times): bool {
$this->assertStringMatchesFormat(
$expectedMessage,
$message
);
$this->assertEquals([$identifier => $times], Deprecation::getTriggeredDeprecations());

return false;
});
}

Expand Down Expand Up @@ -152,7 +153,7 @@ public function testDeprecationResetsCounts(): void
}
}

public function expectDeprecationMock(string $message, string $identifier, string $package): MockObject
public function expectDeprecationMock(string $message, string $identifier, string $package): LoggerInterface
{
$mock = $this->createMock(LoggerInterface::class);
$mock->method('notice')->with($message, $this->callback(function ($context) use ($identifier, $package) {
Expand Down
3 changes: 2 additions & 1 deletion tests/Doctrine/Deprecations/VerifyDeprecationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class VerifyDeprecationsTest extends TestCase

public function setUp(): void
{
set_error_handler(static function (): void {
set_error_handler(static function (): bool {
return false;
});
}

Expand Down