Skip to content

Commit

Permalink
Try fixing typeError
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Dec 12, 2020
1 parent 8bdd402 commit a082da2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
13 changes: 6 additions & 7 deletions Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Command
*/
protected $version;

public function __construct(string $magickBinaryPath = null)
public function __construct(?string $magickBinaryPath = null)
{
$magickBinaryPath = self::findMagickBinaryPath($magickBinaryPath);

Expand All @@ -102,7 +102,7 @@ public function __construct(string $magickBinaryPath = null)
$this->magickBinaryPath = $magickBinaryPath;
}

public static function create(string $magickBinaryPath = null): self
public static function create(?string $magickBinaryPath = null): self
{
return new self($magickBinaryPath);
}
Expand Down Expand Up @@ -148,7 +148,7 @@ private static function cleanPath(string $path, bool $rtrim = false): string
*
* @see https://imagemagick.org/script/command-line-tools.php
*/
public function getExecutable(string $binary = null): array
public function getExecutable(?string $binary = null): array
{
if (!\in_array($binary, static::ALLOWED_EXECUTABLES, true)) {
throw new \InvalidArgumentException(\sprintf(
Expand All @@ -165,7 +165,7 @@ public function getExecutable(string $binary = null): array
/**
* Entirely reset all current command statements, and start a whole new command.
*/
public function newCommand(string $binary = null): self
public function newCommand(?string $binary = null): self
{
$this->env = [];
$this->command = $binary ? $this->getExecutable($binary) : [];
Expand All @@ -185,7 +185,7 @@ public function convert(string $sourceFile, bool $checkIfFileExists = true): sel
/**
* @see https://imagemagick.org/script/mogrify.php
*/
public function mogrify(string $sourceFile = null): self
public function mogrify(?string $sourceFile = null): self
{
$this->newCommand('mogrify');
if ($sourceFile) {
Expand Down Expand Up @@ -382,7 +382,6 @@ public function size($geometry): self
/**
* Create a colored canvas.
*
*
* @see http://www.imagemagick.org/Usage/canvas/
*/
public function xc(string $canvasColor = 'none'): self
Expand Down Expand Up @@ -432,7 +431,7 @@ public function extent($geometry): self
}

/**
* @param string $gravity
* @param string|Gravity $gravity
*
* @see https://www.imagemagick.org/script/command-line-options.php#gravity
*/
Expand Down
24 changes: 14 additions & 10 deletions ReferenceClasses/Geometry.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ class Geometry
*/
private $value;

/**
* @param string|int|null $width
*/
public static function createFromParameters(
$width = null,
int $height = null,
int $x = null,
int $y = null,
?int $height = null,
?int $x = null,
?int $y = null,
?string $aspectRatio = self::RATIO_NONE
): string {
$geometry = $width;
Expand Down Expand Up @@ -74,20 +77,21 @@ public static function createFromParameters(
$geometry .= ($y >= 0 ? '+' : '-').\abs($y);
}
} elseif (null !== $y) {
if (null !== $y) {
$geometry .= '+0'.($y >= 0 ? '+' : '-').\abs($y);
}
$geometry .= '+0'.($y >= 0 ? '+' : '-').\abs($y);
}

return $geometry;
}

/**
* @param string|int|null $width
*/
public function __construct(
$width = null,
int $height = null,
int $x = null,
int $y = null,
string $aspectRatio = self::RATIO_NONE
?int $height = null,
?int $x = null,
?int $y = null,
?string $aspectRatio = self::RATIO_NONE
) {
$args = \func_get_args();

Expand Down
6 changes: 4 additions & 2 deletions ReferenceClasses/Gravity.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ class Gravity
*/
private $value;

public static function createFromParameters(string $gravity): string {
public static function createFromParameters(string $gravity): string
{
return $gravity;
}

public function __construct(string $gravity) {
public function __construct(string $gravity)
{
$this->value = $gravity;
}

Expand Down
1 change: 0 additions & 1 deletion References.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,5 @@ public function threshold(string $threshold): string
$threshold,
'http://www.imagemagick.org/script/command-line-options.php#threshold'
));

}
}

0 comments on commit a082da2

Please sign in to comment.