Skip to content

Commit

Permalink
This one also goes out for Scrutinizer
Browse files Browse the repository at this point in the history
  • Loading branch information
rosell-dk committed Jun 17, 2019
1 parent 583657e commit 3a2c6ab
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
11 changes: 6 additions & 5 deletions src-build/webp-convert.inc
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ abstract class AbstractConverter
public function getMimeTypeOfSource()
{
if (!isset($this->sourceMimeType)) {
// PS: Scrutinizer complains that ImageMimeTypeGuesser::lenientGuess could also return a boolean
// but this is not true! - it returns string|false|null, just as this method does.
$this->sourceMimeType = ImageMimeTypeGuesser::lenientGuess($this->source);
}
return $this->sourceMimeType;
Expand Down Expand Up @@ -2161,7 +2163,9 @@ trait EncodingAutoTrait
abstract public function getOptions();
abstract protected function setOption($optionName, $optionValue);
abstract protected function logLn($msg, $style = '');
abstract protected function log($msg, $style = '');
abstract protected function ln();
abstract protected function logReduction($source, $destination);

public function supportsLossless()
{
Expand Down Expand Up @@ -4612,11 +4616,11 @@ class Stack extends AbstractConverter
$this->ln();
$this->logLn('Stack failed in ' . round((microtime(true) - $beginTimeStack) * 1000) . ' ms');

// Hm, Scrutinizer complains that $anyRuntimeErrors is always false. But that is not true!
if ($anyRuntimeErrors) {
// At least one converter failed
throw new ConversionFailedException(
'None of the converters in the stack could convert the image. ' .
'At least one failed, even though its requirements seemed to be met.'
'None of the converters in the stack could convert the image.'
);
} else {
// All converters threw a SystemRequirementsNotMetException
Expand Down Expand Up @@ -5928,10 +5932,7 @@ class Report
$options['log-call-arguments'] = true;
WebPConvert::convert($source, $destination, $options, $echoLogger);
} catch (\Exception $e) {
$success = false;

$msg = $e->getMessage();

echo '<b>' . $msg . '</b>';

//echo '<p>Rethrowing exception for your convenience</p>';
Expand Down
11 changes: 6 additions & 5 deletions src-build/webp-on-demand-2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ abstract class AbstractConverter
public function getMimeTypeOfSource()
{
if (!isset($this->sourceMimeType)) {
// PS: Scrutinizer complains that ImageMimeTypeGuesser::lenientGuess could also return a boolean
// but this is not true! - it returns string|false|null, just as this method does.
$this->sourceMimeType = ImageMimeTypeGuesser::lenientGuess($this->source);
}
return $this->sourceMimeType;
Expand Down Expand Up @@ -2083,7 +2085,9 @@ trait EncodingAutoTrait
abstract public function getOptions();
abstract protected function setOption($optionName, $optionValue);
abstract protected function logLn($msg, $style = '');
abstract protected function log($msg, $style = '');
abstract protected function ln();
abstract protected function logReduction($source, $destination);

public function supportsLossless()
{
Expand Down Expand Up @@ -4534,11 +4538,11 @@ class Stack extends AbstractConverter
$this->ln();
$this->logLn('Stack failed in ' . round((microtime(true) - $beginTimeStack) * 1000) . ' ms');

// Hm, Scrutinizer complains that $anyRuntimeErrors is always false. But that is not true!
if ($anyRuntimeErrors) {
// At least one converter failed
throw new ConversionFailedException(
'None of the converters in the stack could convert the image. ' .
'At least one failed, even though its requirements seemed to be met.'
'None of the converters in the stack could convert the image.'
);
} else {
// All converters threw a SystemRequirementsNotMetException
Expand Down Expand Up @@ -5798,10 +5802,7 @@ class Report
$options['log-call-arguments'] = true;
WebPConvert::convert($source, $destination, $options, $echoLogger);
} catch (\Exception $e) {
$success = false;

$msg = $e->getMessage();

echo '<b>' . $msg . '</b>';

//echo '<p>Rethrowing exception for your convenience</p>';
Expand Down
2 changes: 2 additions & 0 deletions src/Convert/Converters/AbstractConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ public static function convert($source, $destination, $options = [], $logger = n
public function getMimeTypeOfSource()
{
if (!isset($this->sourceMimeType)) {
// PS: Scrutinizer complains that ImageMimeTypeGuesser::lenientGuess could also return a boolean
// but this is not true! - it returns string|false|null, just as this method does.
$this->sourceMimeType = ImageMimeTypeGuesser::lenientGuess($this->source);
}
return $this->sourceMimeType;
Expand Down
2 changes: 2 additions & 0 deletions src/Convert/Converters/ConverterTraits/EncodingAutoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ abstract public function setDestination($destination);
abstract public function getOptions();
abstract protected function setOption($optionName, $optionValue);
abstract protected function logLn($msg, $style = '');
abstract protected function log($msg, $style = '');
abstract protected function ln();
abstract protected function logReduction($source, $destination);

public function supportsLossless()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Convert/Converters/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ protected function doActualConvert()
$this->ln();
$this->logLn('Stack failed in ' . round((microtime(true) - $beginTimeStack) * 1000) . ' ms');

// Hm, Scrutinizer complains that $anyRuntimeErrors is always false. But that is not true!
if ($anyRuntimeErrors) {
// At least one converter failed
throw new ConversionFailedException(
'None of the converters in the stack could convert the image. ' .
'At least one failed, even though its requirements seemed to be met.'
'None of the converters in the stack could convert the image.'
);
} else {
// All converters threw a SystemRequirementsNotMetException
Expand Down

0 comments on commit 3a2c6ab

Please sign in to comment.