1 | <?php declare(strict_types=1); |
||
2 | /** |
||
3 | * This file is part of the daikon-cqrs/value-object project. |
||
4 | * |
||
5 | * For the full copyright and license information, please view the LICENSE |
||
6 | * file that was distributed with this source code. |
||
7 | */ |
||
8 | |||
9 | namespace Daikon\Tests\ValueObject; |
||
10 | |||
11 | use Daikon\Interop\InvalidArgumentException; |
||
12 | use Daikon\ValueObject\NullValue; |
||
13 | use PHPUnit\Framework\TestCase; |
||
14 | |||
15 | final class NullValueTest extends TestCase |
||
16 | { |
||
17 | private NullValue $nullValue; |
||
18 | |||
19 | 1 | public function testToNative(): void |
|
20 | { |
||
21 | 1 | $this->assertNull($this->nullValue->toNative()); |
|
0 ignored issues
–
show
|
|||
22 | 1 | $this->assertNull(NullValue::fromNative(null)->toNative()); |
|
0 ignored issues
–
show
Are you sure the usage of
Daikon\ValueObject\NullV...ative(null)->toNative() targeting Daikon\ValueObject\NullValue::toNative() 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. ![]() |
|||
23 | 1 | $this->assertNull(NullValue::fromNative('')->toNative()); |
|
0 ignored issues
–
show
Are you sure the usage of
Daikon\ValueObject\NullV...mNative('')->toNative() targeting Daikon\ValueObject\NullValue::toNative() 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. ![]() |
|||
24 | |||
25 | 1 | $this->expectException(InvalidArgumentException::class); |
|
26 | 1 | NullValue::fromNative('xyz'); |
|
27 | } |
||
28 | |||
29 | 1 | public function testEquals(): void |
|
30 | { |
||
31 | 1 | $this->assertTrue($this->nullValue->equals(NullValue::fromNative(''))); |
|
32 | 1 | } |
|
33 | |||
34 | 1 | public function testToString(): void |
|
35 | { |
||
36 | 1 | $this->assertEquals('', (string)$this->nullValue); |
|
37 | 1 | } |
|
38 | |||
39 | 3 | protected function setUp(): void |
|
40 | { |
||
41 | 3 | $this->nullValue = NullValue::makeEmpty(); |
|
42 | 3 | } |
|
43 | } |
||
44 |
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.