Skip to content

Commit

Permalink
PhpStan fixes (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored and dg committed Aug 11, 2019
1 parent 21c3c6a commit 8940d9b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/RobotLoader/RobotLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class RobotLoader

private const RETRY_LIMIT = 3;

/** @var array */
/** @var string[] */
public $ignoreDirs = ['.*', '*.old', '*.bak', '*.tmp', 'temp'];

/** @var array */
/** @var string[] */
public $acceptFiles = ['*.php'];

/** @var bool */
Expand All @@ -42,10 +42,10 @@ class RobotLoader
/** @var bool */
private $reportParseErrors = true;

/** @var array */
/** @var string[] */
private $scanPaths = [];

/** @var array */
/** @var string[] */
private $excludeDirs = [];

/** @var array of class => [file, time] */
Expand Down Expand Up @@ -133,7 +133,7 @@ public function addDirectory(...$paths): self

public function reportParseErrors(bool $on = true): self
{
$this->reportParseErrors = (bool) $on;
$this->reportParseErrors = $on;
return $this;
}

Expand Down Expand Up @@ -239,7 +239,7 @@ private function createFileIterator(string $dir): Nette\Utils\Finder
throw new Nette\IOException("File or directory '$dir' not found.");
}

if (!is_array($ignoreDirs = $this->ignoreDirs)) {
if (is_string($ignoreDirs = $this->ignoreDirs)) {
trigger_error(__CLASS__ . ': $ignoreDirs must be an array.', E_USER_WARNING);
$ignoreDirs = preg_split('#[,\s]+#', $ignoreDirs);
}
Expand All @@ -250,7 +250,7 @@ private function createFileIterator(string $dir): Nette\Utils\Finder
}
}

if (!is_array($acceptFiles = $this->acceptFiles)) {
if (is_string($acceptFiles = $this->acceptFiles)) {
trigger_error(__CLASS__ . ': $acceptFiles must be an array.', E_USER_WARNING);
$acceptFiles = preg_split('#[,\s]+#', $acceptFiles);
}
Expand Down Expand Up @@ -389,7 +389,7 @@ private function scanPhp(string $file): array
*/
public function setAutoRefresh(bool $on = true): self
{
$this->autoRebuild = (bool) $on;
$this->autoRebuild = $on;
return $this;
}

Expand All @@ -416,7 +416,7 @@ private function loadCache(): void
return;
}

$handle = fopen("$file.lock", 'c+');
$handle = fopen("$file.lock", 'cb+');
if (!$handle || !flock($handle, LOCK_EX)) {
throw new \RuntimeException("Unable to create or acquire exclusive lock on file '$file.lock'.");
}
Expand Down

0 comments on commit 8940d9b

Please sign in to comment.