Skip to content
Permalink
Browse files

PhpStan fixes (#16)

  • Loading branch information...
janbarasek authored and dg committed Aug 11, 2019
1 parent 21c3c6a commit 9ae6fc252631d07189cf74e61a8888429855ea4b
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/RobotLoader/RobotLoader.php
@@ -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 */
@@ -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] */
@@ -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;
}
@@ -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);
}
@@ -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);
}
@@ -309,7 +309,7 @@ private function scanPhp(string $file): array
{
$code = file_get_contents($file);
$expected = false;
$namespace = '';
$namespace = $name = '';
$level = $minLevel = 0;
$classes = [];
@@ -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;
}
@@ -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'.");
}

0 comments on commit 9ae6fc2

Please sign in to comment.
You can’t perform that action at this time.