GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#106)
by Ross
18:39 queued 15:49
created

TemplateEntityRepository::find()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 3
1
<?php declare(strict_types=1);
2
3
namespace TemplateNamespace\Entity\Repositories;
4
5
use FQNFor\AbstractEntityRepository;
0 ignored issues
show
Bug introduced by
The type FQNFor\AbstractEntityRepository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
This use statement conflicts with another class in this namespace, TemplateNamespace\Entity...bstractEntityRepository. 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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are 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.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
6
use TemplateNamespace\Entity\Interfaces\TemplateEntityInterface;
7
8
// phpcs:disable -- line length
9
class TemplateEntityRepository extends AbstractEntityRepository
10
{
11
// phpcs: enable
12
13
    public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?TemplateEntityInterface
14
    {
15
        $result = parent::find($id, $lockMode, $lockVersion);
16
        if ($result === null || $result instanceof TemplateEntityInterface) {
17
            return $result;
18
        }
19
20
        throw new \RuntimeException('Unknown entity type of ' . get_class($result) . ' returned');
21
    }
22
23
    public function findOneBy(array $criteria, ?array $orderBy = null): ?TemplateEntityInterface
24
    {
25
        $result = parent::findOneBy($criteria, $orderBy);
26
        if ($result === null || $result instanceof TemplateEntityInterface) {
27
            return $result;
28
        }
29
30
        throw new \RuntimeException('Unknown entity type of ' . get_class($result) . ' returned');
31
    }
32
33
    public function get($id, ?int $lockMode = null, ?int $lockVersion = null): TemplateEntityInterface
34
    {
35
        $result = $this->find($id, $lockMode, $lockVersion);
36
        if ($result === null) {
37
            throw new \RuntimeException('Could not find the entity');
38
        }
39
40
        return $result;
41
    }
42
43
    public function getOneBy(array $criteria, ?array $orderBy = null): TemplateEntityInterface
44
    {
45
        $result = $this->findOneBy($criteria, $orderBy);
46
        if ($result === null) {
47
            throw new \RuntimeException('Could not find the entity');
48
        }
49
50
        return $result;
51
    }
52
}
53