Skip to content

Commit 8e263f5

Browse files
committed
Remove unnecessary assertions and suppress warnings
This commit eliminates redundant assert statements to streamline the code and improve readability. Additionally, it uses `@phpstan-ignore-line` annotations to suppress specific warnings, enhancing compatibility with static analysis tools.
1 parent f7c8844 commit 8e263f5

File tree

8 files changed

+4
-8
lines changed

8 files changed

+4
-8
lines changed

src/di/Argument.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function getMeta(): string
9191
/**
9292
* {@inheritDoc}
9393
*/
94-
public function serialize(): ?string
94+
public function serialize(): ?string // @phpstan-ignore-line
9595
{
9696
return serialize($this->__serialize());
9797
}

src/di/Di/Inject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class Inject implements InjectInterface
2525
public $optional = false;
2626

2727
/**
28-
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
28+
* @SuppressWarnings(PHPMD.BooleanArgumentFlag) // @phpstan-ignore-line
2929
*/
3030
public function __construct(bool $optional = false)
3131
{

src/di/InjectionPoint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function __unserialize(array $array): void
107107
[$this->pClass, $this->pFunction, $this->pName] = $array;
108108
}
109109

110-
public function serialize(): ?string
110+
public function serialize(): ?string // @phpstan-ignore-line
111111
{
112112
return serialize($this->__serialize());
113113
}

src/di/MultiBinding/LazyProvider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public function __construct(string $class)
3131
public function __invoke(InjectorInterface $injector)
3232
{
3333
$provider = $injector->getInstance($this->class);
34-
assert($provider instanceof ProviderInterface);
3534

3635
return $provider->get();
3736
}

src/di/Name.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ private function parseName(string $name): array
150150
$exploded = explode('=', $keyValue);
151151
if (isset($exploded[1])) {
152152
[$key, $value] = $exploded;
153-
assert(is_string($key));
154153
if (isset($key[0]) && $key[0] === '$') {
155154
$key = substr($key, 1);
156155
}

tests/di/ArgumentsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function testInject(): void
2929
$this->assertInstanceOf(FakeTyre::class, $parameters[0]);
3030
$this->assertInstanceOf(FakeTyre::class, $parameters[1]);
3131
$param0 = $parameters[0];
32-
assert(is_object($param0));
3332
$this->assertNotSame(spl_object_hash($param0), $parameters[1]);
3433
}
3534

tests/di/Fake/FakePhp8Car.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function setQualiferMirrors(#[FakeRight] FakeMirrorInterface $rightMirror
6363
}
6464

6565
#[Inject]
66-
public function notQualifer(#[FakeNotQualifer] FakeMirrorInterface $rightMirror = null): void
66+
public function notQualifer(#[FakeNotQualifer] ?FakeMirrorInterface $rightMirror = null): void
6767
{
6868
}
6969

tests/di/GrapherTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public function testGetInstanceWithArgs(): void
2828
$grapher = new Grapher(new FakeUntargetModule(), __DIR__ . '/tmp');
2929
$instance = $grapher->newInstanceArgs(FakeUntargetChild::class, ['1']);
3030
$this->assertInstanceOf(FakeUntargetChild::class, $instance);
31-
assert(is_object($instance));
3231
assert(property_exists($instance, 'val'));
3332
$this->assertSame('1', $instance->val);
3433
}

0 commit comments

Comments
 (0)