Should the type for parameter $files 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...
30
*/
31
public function __construct($files = null)
32
{
33
if ($files !== null && !is_array($files)) {
34
$files = [$files];
35
}
36
37
if (is_array($files)) {
38
foreach ($files as $file) {
39
$this->addFile($file);
40
}
41
}
42
}
43
44
/**
45
* Add file path.
46
*
47
* @param string $file
48
*
49
* @return $this
50
*/
51
public function addFile($file)
52
{
53
if (trim($file) !== '') {
54
$this->files[] = trim($file);
55
}
56
57
return $this;
58
}
59
60
/**
61
* {@inheritdoc}
62
*
63
* @throws \RuntimeException
64
*/
65
public function isActive()
66
{
67
if (!count($this->files)) {
68
throw new \RuntimeException('At least one file path must be defined');
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.