Skip to content

Commit

Permalink
PHPStan: bump level to 7
Browse files Browse the repository at this point in the history
  • Loading branch information
mhujer committed Nov 22, 2019
1 parent da5a0ac commit 4c916dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
],
"phplint": "parallel-lint -j 10 --exclude vendor .",
"phpcs": "phpcs --standard=ruleset.xml --extensions=php --encoding=utf-8 --tab-width=4 -sp bin src tests",
"phpstan": "@php vendor/phpstan/phpstan-shim/phpstan.phar analyse bin src tests --level 5 --no-progress",
"phpstan": "@php vendor/phpstan/phpstan-shim/phpstan.phar analyse bin src tests --level 7 --no-progress",
"test": "phpunit"
},
"config": {
Expand Down
6 changes: 5 additions & 1 deletion src/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
}
$output->writeln(sprintf('Using config file "%s"', $configFilePath));

$config = Yaml::parse(file_get_contents($configFilePath));
$configFileContents = file_get_contents($configFilePath);
if ($configFileContents === false) {
throw new \Exception(sprintf('File "%s" could not be loaded', $configFilePath));
}
$config = Yaml::parse($configFileContents);

if (!array_key_exists('files', $config)) {
$output->writeln('There must be a key "files" in config');
Expand Down
10 changes: 7 additions & 3 deletions src/SortChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public function isSorted(
): SortCheckResult
{
try {
$data = Yaml::parse(file_get_contents($filename), Yaml::PARSE_CUSTOM_TAGS);
$yamlContent = file_get_contents($filename);
if ($yamlContent === false) {
throw new \Exception(sprintf('File "%s" could not be loaded', $filename));
}
$data = Yaml::parse($yamlContent, Yaml::PARSE_CUSTOM_TAGS);

$errors = $this->areDataSorted($data, $excludedKeys, $excludedSections, null, $depth);

Expand All @@ -39,8 +43,8 @@ public function isSorted(

/**
* @param mixed[] $yamlData
* @param string[]|string[][] $excludedKeys
* @param string[]|string[][] $excludedSections
* @param mixed[]|string[]|string[][] $excludedKeys
* @param mixed[]|string[]|string[][] $excludedSections
* @param string|null $parent
* @param int $depth
* @return string[] array of error messages
Expand Down

0 comments on commit 4c916dc

Please sign in to comment.