1 | <?php |
||||||||
2 | |||||||||
3 | declare(strict_types=1); |
||||||||
4 | |||||||||
5 | namespace spec\Loevgaard\SyliusBarcodePlugin\BarcodeChecker; |
||||||||
6 | |||||||||
7 | use Loevgaard\SyliusBarcodePlugin\BarcodeChecker\BarcodeChecker; |
||||||||
8 | use Loevgaard\SyliusBarcodePlugin\Event\PostBarcodeCheckEvent; |
||||||||
9 | use Loevgaard\SyliusBarcodePlugin\Event\PreBarcodeCheckEvent; |
||||||||
10 | use Loevgaard\SyliusBarcodePlugin\Model\BarcodeAwareInterface; |
||||||||
11 | use PhpSpec\ObjectBehavior; |
||||||||
12 | use Prophecy\Argument; |
||||||||
13 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
||||||||
14 | |||||||||
15 | class BarcodeCheckerSpec extends ObjectBehavior |
||||||||
16 | { |
||||||||
17 | public function it_is_initializable(): void |
||||||||
18 | { |
||||||||
19 | $this->shouldHaveType(BarcodeChecker::class); |
||||||||
20 | } |
||||||||
21 | |||||||||
22 | public function let(EventDispatcherInterface $eventDispatcher): void |
||||||||
23 | { |
||||||||
24 | $this->beConstructedWith($eventDispatcher); |
||||||||
25 | } |
||||||||
26 | |||||||||
27 | public function it_invalidates(BarcodeAwareInterface $barcodeAware): void |
||||||||
28 | { |
||||||||
29 | $barcodeAware->getBarcode()->willReturn('invalid'); |
||||||||
30 | $barcodeAware->markBarcodeAsChecked(false)->shouldBeCalled(); |
||||||||
0 ignored issues
–
show
|
|||||||||
31 | |||||||||
32 | $this->check($barcodeAware); |
||||||||
0 ignored issues
–
show
The method
check() does not exist on spec\Loevgaard\SyliusBar...cker\BarcodeCheckerSpec . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||||
33 | } |
||||||||
34 | |||||||||
35 | public function it_validates(BarcodeAwareInterface $barcodeAware): void |
||||||||
36 | { |
||||||||
37 | $barcodeAware->getBarcode()->willReturn('4006381333931'); |
||||||||
38 | $barcodeAware->markBarcodeAsChecked(true)->shouldBeCalled(); |
||||||||
0 ignored issues
–
show
Are you sure the usage of
$barcodeAware->markBarcodeAsChecked(true) targeting Loevgaard\SyliusBarcodeP...:markBarcodeAsChecked() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||||||||
39 | |||||||||
40 | $this->check($barcodeAware); |
||||||||
41 | } |
||||||||
42 | |||||||||
43 | public function it_dispatches_events(EventDispatcherInterface $eventDispatcher, BarcodeAwareInterface $barcodeAware): void |
||||||||
44 | { |
||||||||
45 | $eventDispatcher->dispatch(Argument::type(PreBarcodeCheckEvent::class), PreBarcodeCheckEvent::NAME)->shouldBeCalledOnce(); |
||||||||
0 ignored issues
–
show
The constant
Loevgaard\SyliusBarcodeP...BarcodeCheckEvent::NAME has been deprecated: will be removed in v2
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() The call to
Symfony\Contracts\EventD...erInterface::dispatch() has too many arguments starting with Loevgaard\SyliusBarcodeP...BarcodeCheckEvent::NAME .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||||
46 | $eventDispatcher->dispatch(Argument::type(PostBarcodeCheckEvent::class), PostBarcodeCheckEvent::NAME)->shouldBeCalledOnce(); |
||||||||
0 ignored issues
–
show
The constant
Loevgaard\SyliusBarcodeP...BarcodeCheckEvent::NAME has been deprecated: will be removed in v2
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||||||||
47 | |||||||||
48 | $this->check($barcodeAware); |
||||||||
49 | } |
||||||||
50 | } |
||||||||
51 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.