Skip to content

Commit

Permalink
Merge pull request #345 from kowsar89/suppress-warnings
Browse files Browse the repository at this point in the history
Suppressed PHP warnings for rename and unlink operations
  • Loading branch information
rosell-dk authored Apr 6, 2024
2 parents dacf9b8 + 555974f commit f9e64ac
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Convert/Converters/AbstractConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private function doConvertImplementation()
if (!@file_exists($destination)) {
throw new ConversionFailedException('Destination file is not there: ' . $destination);
} elseif (@filesize($destination) === 0) {
unlink($destination);
@unlink($destination);
throw new ConversionFailedException('Destination file was completely empty');
} else {
if (!isset($this->options['_suppress_success_message'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private function checkDestinationWritable()
// No harm in doing that for non-Windows systems either.
if (file_put_contents($destination, 'dummy') !== false) {
// all is well, after all
unlink($destination);
@unlink($destination);
return;
}

Expand All @@ -91,7 +91,7 @@ private function removeExistingDestinationIfExists()
if (file_exists($destination)) {
// A file already exists in this folder...
// We delete it, to make way for a new webp
if (!unlink($destination)) {
if (!@unlink($destination)) {
throw new CreateDestinationFileException(
'Existing file cannot be removed: ' . basename($destination)
);
Expand Down
8 changes: 4 additions & 4 deletions src/Convert/Converters/ConverterTraits/EncodingAutoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ private function convertTwoAndSelectSmallest()

if (filesize($destinationLossless) > filesize($destinationLossy)) {
$this->logLn('Picking lossy');
unlink($destinationLossless);
rename($destinationLossy, $destination);
@unlink($destinationLossless);
@rename($destinationLossy, $destination);
} else {
$this->logLn('Picking lossless');
unlink($destinationLossy);
rename($destinationLossless, $destination);
@unlink($destinationLossy);
@rename($destinationLossless, $destination);
}
$this->setDestination($destination);
$this->setOption('encoding', 'auto');
Expand Down
2 changes: 1 addition & 1 deletion src/Convert/Converters/Gd.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ protected function destroyAndRemove($image)
{
imagedestroy($image);
if (file_exists($this->destination)) {
unlink($this->destination);
@unlink($this->destination);
}
}

Expand Down

0 comments on commit f9e64ac

Please sign in to comment.