• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nepada / message-bus / 6499378211

12 Oct 2023 06:00PM UTC coverage: 96.474% (+0.3%) from 96.19%
6499378211

push

github

xificurk
Add missing transitive dependency symfony/deprecation-contracts

This should have been required by symfony/messenger, but it's missing.

301 of 312 relevant lines covered (96.47%)

0.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/MessageBus/StaticAnalysis/Rules/MethodParameterTypeMatchesRule.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\MessageBus\StaticAnalysis\Rules;
5

6
use Nepada\MessageBus\StaticAnalysis\StaticAnalysisFailedException;
7
use ReflectionParameter;
8

9
final class MethodParameterTypeMatchesRule
10
{
11

12
    private string $parameterType;
13

14
    public function __construct(string $parameterType)
1✔
15
    {
16
        $this->parameterType = $parameterType;
1✔
17
    }
1✔
18

19
    /**
20
     * @throws StaticAnalysisFailedException
21
     */
22
    public function validate(ReflectionParameter $parameter): void
1✔
23
    {
24
        $parameterType = $parameter->getType();
1✔
25
        if ($parameterType === null) {
1✔
26
            throw $this->createException($parameter);
×
27
        }
28

29
        $parameterTypeName = $parameterType->getName();
1✔
30
        if ($parameterTypeName !== $this->parameterType && ! is_subclass_of($parameterTypeName, $this->parameterType)) {
1✔
31
            throw $this->createException($parameter);
1✔
32
        }
33
    }
1✔
34

35
    private function createException(ReflectionParameter $parameter): StaticAnalysisFailedException
1✔
36
    {
37
        $class = $parameter->getDeclaringClass();
1✔
38
        if ($class === null) {
1✔
39
            throw new \LogicException('Class must be set in this context.');
×
40
        }
41

42
        return StaticAnalysisFailedException::with(
1✔
43
            sprintf('Method parameter "%s" must be of type "%s"', $parameter->getName(), $this->parameterType),
1✔
44
            $class->getName(),
1✔
45
        );
46
    }
47

48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc