Other Scrutinizer fixes

This commit is contained in:
Stéphane Goetz 2019-12-07 16:32:38 +01:00
parent 8215808282
commit ac60948fab
12 changed files with 19 additions and 12 deletions

View File

@ -262,7 +262,7 @@ class ConfigBuilder
*/
private function findLocation($path, $basedir, $type) {
// If Path is explicitly null, it's useless to go further
if ($path == null) {
if ($path === null) {
return null;
}

View File

@ -16,7 +16,7 @@ class ClearCache extends SymfonyCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln("Clearing cache at '" . Cache::getDirectory() ."'");
$output->writeln("Clearing cache at '" . Cache::getDirectory() . "'");
Cache::clear();
$output->writeln("<info>Cache cleared</info>");

View File

@ -44,7 +44,7 @@ class Serve extends DauxCommand
// Write the current configuration to a file to read it from the other serving side
$file = tmpfile();
if (!$file) {
if ($file === false) {
$output->writeln("<fg=red>Failed to create temporary file for configuration</fg=red>");
return 1;
}
@ -54,7 +54,7 @@ class Serve extends DauxCommand
chdir(__DIR__ . '/../../');
putenv('DAUX_CONFIG='. $path);
putenv('DAUX_CONFIG=' . $path);
putenv('DAUX_VERBOSITY=' . $output->getVerbosity());
putenv('DAUX_EXTENSION=' . DAUX_EXTENSION);

View File

@ -85,7 +85,7 @@ class Daux
$entry_page[$key] = $this->tree->getEntries()[$key]->getFirstPage();
}
} else {
$entry_page= $this->tree->getFirstPage();
$entry_page = $this->tree->getFirstPage();
}
$this->config->setEntryPage($entry_page);
$this->merged_tree = true;

View File

@ -218,6 +218,11 @@ class Api
public function showSourceCode($css, $lineNumber, $column)
{
$lines = preg_split("/\r?\n/", $css);
if ($lines === false) {
return $css;
}
$start = max($lineNumber - 3, 0);
$end = min($lineNumber + 2, count($lines));

View File

@ -45,7 +45,7 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
);
}
return parent::render($inline, $htmlRenderer);
return $this->parent->render($inline, $htmlRenderer);
}
/**

View File

@ -49,7 +49,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
throw new \RuntimeException("The following options are mandatory for confluence : '" . implode("', '", $errors) . "'");
}
if (!array_key_exists('ancestor_id', $confluence) && !array_key_exists('root_id', $confluence)) {
if (!$confluence->hasAncestorId() && !$confluence->hasRootId()) {
throw new \RuntimeException("You must specify an 'ancestor_id' or a 'root_id' for confluence.");
}
}

View File

@ -138,7 +138,7 @@ class Processor
}
}
$node->data['attributes']['id'] = $this->getUniqueId($document, 'page_'. $this->escaped($text));
$node->data['attributes']['id'] = $this->getUniqueId($document, 'page_' . $this->escaped($text));
}
/**

View File

@ -73,7 +73,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
$this->runAction(
'Generating ' . $current->getTitle(),
$width,
function () use ($book, $current, $config) {
function() use ($book, $current, $config) {
$contentType = $this->daux->getContentTypeHandler()->getType($current);
$content = ContentPage::fromFile($current, $config, $contentType);
$content->templateRenderer = $this->templateRenderer;

View File

@ -39,7 +39,7 @@ class GeneratorHelper
$dir = opendir($source);
if (!$dir) {
if ($dir === false) {
throw new RuntimeException("Cannot copy '$source' to '$destination'");
}

View File

@ -20,7 +20,7 @@ class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface
*/
public function guessMimeType(string $path): ?string
{
$extension = pathinfo($path,PATHINFO_EXTENSION);
$extension = pathinfo($path, PATHINFO_EXTENSION);
if ($extension == "css") {
return "text/css";

View File

@ -59,7 +59,9 @@ class Builder
*/
public static function build($node, $ignore)
{
if (($it = new \FilesystemIterator($node->getPath())) == false) {
try {
$it = new \FilesystemIterator($node->getPath());
} catch (\UnexpectedValueException $e) {
return;
}