Should the type for parameter $paths not be string|array|null? Also, consider making the array more specific, something like array<String>, or String[].
This check looks for @param annotations where the type inferred by our
type inference engine differs from the declared type.
It makes a suggestion as to what type it considers more descriptive. In addition it
looks for parameters that have the generic type array and suggests a stricter type
like array<String>.
Most often this is a case of a parameter that can be null in addition to
its declared types.
Loading history...
32
*/
33
public function __construct($paths = null)
34
{
35
if ($paths !== null && !is_array($paths)) {
36
$paths = [$paths];
37
}
38
39
if (is_array($paths)) {
40
foreach ($paths as $path) {
41
$this->addPath($path);
42
}
43
}
44
}
45
46
/**
47
* Add path.
48
*
49
* @param string $path
50
*
51
* @return $this
52
*/
53
public function addPath($path)
54
{
55
if (trim($path) !== '') {
56
$this->paths[] = trim($path);
57
}
58
59
return $this;
60
}
61
62
/**
63
* {@inheritdoc}
64
*/
65
public function isExcluded(ServerRequestInterface $request)
66
{
67
if (!count($this->paths)) {
68
throw new \RuntimeException('No paths defined in path excluder');
69
}
70
71
$currentPath = $request->getUri()->getPath();
72
73
foreach ($this->paths as $path) {
74
if ($path === $currentPath || @preg_match($path, $currentPath) === 1) {
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type
array
and suggests a stricter type likearray<String>
.Most often this is a case of a parameter that can be null in addition to its declared types.