Aggrego /
FragmentedDataBoard
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * |
||
| 4 | * This file is part of the Aggrego. |
||
| 5 | * (c) Tomasz Kunicki <[email protected]> |
||
| 6 | * |
||
| 7 | * For the full copyright and license information, please view the LICENSE |
||
| 8 | * file that was distributed with this source code. |
||
| 9 | * |
||
| 10 | */ |
||
| 11 | |||
| 12 | declare(strict_types = 1); |
||
| 13 | |||
| 14 | namespace Aggrego\FragmentedDataBoard\Board; |
||
| 15 | |||
| 16 | use Aggrego\AggregateEventConsumer\Uuid; |
||
| 17 | use Aggrego\Domain\Board\Board; |
||
|
0 ignored issues
–
show
|
|||
| 18 | use Aggrego\Domain\Board\Key; |
||
| 19 | use Aggrego\Domain\Board\Metadata; |
||
|
0 ignored issues
–
show
This use statement conflicts with another class in this namespace,
Aggrego\FragmentedDataBoard\Board\Metadata. Consider defining an alias.
Let?s assume that you have a directory layout like this: .
|-- OtherDir
| |-- Bar.php
| `-- Foo.php
`-- SomeDir
`-- Foo.php
and let?s assume the following content of // Bar.php
namespace OtherDir;
use SomeDir\Foo; // This now conflicts the class OtherDir\Foo
If both files PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as // Bar.php
namespace OtherDir;
use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
|
|||
| 20 | use Aggrego\Domain\Profile\Profile; |
||
| 21 | use Aggrego\FragmentedDataBoard\Board\Prototype\Board as ProgressiveBoardPrototype; |
||
| 22 | use Aggrego\Domain\Board\Builder as FactoryInterface; |
||
| 23 | use Aggrego\Domain\Board\Prototype\Board as PrototypeBoard; |
||
| 24 | |||
| 25 | class Builder implements FactoryInterface |
||
| 26 | { |
||
| 27 | public function isSupported(PrototypeBoard $board): bool |
||
| 28 | { |
||
| 29 | return $board instanceof ProgressiveBoardPrototype; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function build(Uuid $uuid, Key $key, Profile $profile, Metadata $step, ?Uuid $parentUuid): Board |
||
| 33 | { |
||
| 34 | // TODO: Implement build() method. |
||
| 35 | } |
||
|
0 ignored issues
–
show
In this branch, the function will implicitly return
null which is incompatible with the type-hinted return Aggrego\Domain\Board\Board. Consider adding a return statement or allowing null as return value.
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: interface ReturnsInt {
public function returnsIntHinted(): int;
}
class MyClass implements ReturnsInt {
public function returnsIntHinted(): int
{
if (foo()) {
return 123;
}
// here: null is implicitly returned
}
}
Loading history...
|
|||
| 36 | } |
||
| 37 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: