Skip to content

Commit

Permalink
Fix phpstan errors (#3472)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 authored Dec 21, 2023
1 parent 0d1547c commit 32da8cc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
9 changes: 2 additions & 7 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ parameters:
path: src/MediaCollections/Models/Media.php

-
message: "#^Call to an undefined method Spatie\\\\Image\\\\Manipulations\\:\\:save\\(\\)\\.$#"
message: "#^Call to an undefined method Illuminate\\\\Database\\\\Eloquent\\\\Builder\\:\\:withTrashed\\(\\)\\.$#"
count: 1
path: src/ResponsiveImages/ResponsiveImageGenerator.php

-
message: "#^Call to an undefined method Spatie\\\\Image\\\\Manipulations\\:\\:save\\(\\)\\.$#"
count: 1
path: src/ResponsiveImages/TinyPlaceholderGenerator/Blurred.php
path: src/MediaCollections/MediaRepository.php
5 changes: 2 additions & 3 deletions src/Conversions/Conversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public function __construct(
) {
$optimizerChain = OptimizerChainFactory::create(config('media-library.image_optimizers'));

$this->manipulations = (new Manipulations())
->optimize($optimizerChain)
->format('jpg');
$this->manipulations = new Manipulations();
$this->manipulations->optimize($optimizerChain)->format('jpg');

$this->fileNamer = app(config('media-library.file_namer'));

Expand Down
9 changes: 9 additions & 0 deletions src/Conversions/Manipulations.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ public function apply(ImageDriver $image): void
}
}

public function mergeManipulations(self $manipulations): self
{
foreach ($manipulations->toArray() as $name => $parameters) {
$this->manipulations[$name] = array_merge($this->manipulations[$name] ?? [], $parameters ?: []);
}

return $this;
}

public function removeManipulation(string $name): self
{
unset($this->manipulations[$name]);
Expand Down
2 changes: 1 addition & 1 deletion src/MediaCollections/Exceptions/InvalidFileRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static function doesntExist(string $class): self
return new static("File remover class `{$class}` doesn't exist");
}

public static function doesNotImplementPathGenerator(string $class): self
public static function doesNotImplementFileRemover(string $class): self
{
$fileRemoverClass = FileRemover::class;

Expand Down

0 comments on commit 32da8cc

Please sign in to comment.