Skip to content

Commit

Permalink
[phpstorm-stubs] Attempt to fix methods signature according to tests …
Browse files Browse the repository at this point in the history
…failures.
  • Loading branch information
LolGleb committed Aug 30, 2023
1 parent a2b4a25 commit 622a0f9
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions gd/gd.php
Original file line number Diff line number Diff line change
Expand Up @@ -1028,17 +1028,17 @@ function imagepng(GdImage $image, $file = null, int $quality = -1, int $filters
* Output a WebP image to browser or file
* @link https://php.net/manual/en/function.imagewebp.php
* @param resource|GdImage $image
* @param string $to [optional] <p>
* The path to save the file to. If not set or null, the raw image stream
* will be outputted directly.
* @param resource|string|null $file [optional] <p>
* The path or an open stream resource (which is automatically closed after this function returns)
* to save the file to. If not set or null, the raw image stream will be output directly.
* </p>
* @param int $quality [optional] <p>
* quality ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file).
* </p>
* @return bool true on success or false on failure.
* @since 5.4
*/
function imagewebp($image, $to = null, $quality = -1): bool {}
function imagewebp(GdImage $image, $file = null, int $quality = -1): bool {}

/**
* Output image to browser or file
Expand Down Expand Up @@ -1071,7 +1071,7 @@ function imagegif(GdImage $image, $file = null): bool {}
* </p>
* @return bool true on success or false on failure.
*/
function imagejpeg($image, $file = null, $quality = -1): bool {}
function imagejpeg(GdImage $image, $file = null, int $quality = -1): bool {}

/**
* Output image to browser or file
Expand Down Expand Up @@ -1569,9 +1569,10 @@ function imagedashedline(GdImage $image, int $x1, int $y1, int $x2, int $y2, int
* search for files that do not begin with a leading '/' by appending
* '.ttf' to the filename and searching along a library-defined font path.
* </p>
* @param string $text <p>
* @param string $string <p>
* The string to be measured.
* </p>
* @param array $options [optional]
* @return array|false imagettfbbox returns an array with 8
* elements representing four points making the bounding box of the
* text on success and false on error.
Expand Down Expand Up @@ -1618,7 +1619,7 @@ function imagedashedline(GdImage $image, int $x1, int $y1, int $x2, int $y2, int
* corner seeing the text horizontally.
*/
#[Pure]
function imagettfbbox($size, $angle, $font_filename, $text, array $options = []) {}
function imagettfbbox(float $size, float $angle, string $font_filename, string $string, #[PhpStormStubsElementAvailable(from: '8.0')] $options = []): array|false {}

/**
* Write text to the image using TrueType fonts
Expand Down Expand Up @@ -1703,14 +1704,15 @@ function imagettfbbox($size, $angle, $font_filename, $text, array $options = [])
* If a character is used in the string which is not supported by the
* font, a hollow rectangle will replace the character.
* </p>
* @param array $options [optional]
* @return array|false an array with 8 elements representing four points making the
* bounding box of the text. The order of the points is lower left, lower
* right, upper right, upper left. The points are relative to the text
* regardless of the angle, so "upper left" means in the top left-hand
* corner when you see the text horizontally.
* Returns false on error.
*/
function imagettftext(GdImage $image, float $size, float $angle, int $x, int $y, int $color, string $font_filename, string $text, array $options = []): array|false {}
function imagettftext(GdImage $image, float $size, float $angle, int $x, int $y, int $color, string $font_filename, string $text, #[PhpStormStubsElementAvailable(from: '8.0')] array $options = []): array|false {}

/**
* Give the bounding box of a text using fonts via freetype2
Expand Down Expand Up @@ -1790,7 +1792,7 @@ function imagettftext(GdImage $image, float $size, float $angle, int $x, int $y,
* Returns false on error.
*/
#[Pure]
function imageftbbox($size, $angle, $font_filename, $string, $options = []) {}
function imageftbbox(float $size, float $angle, string $font_filename, string $string, array $options = []): array|false {}

/**
* Write text to the image using fonts using FreeType 2
Expand Down Expand Up @@ -1855,7 +1857,7 @@ function imageftbbox($size, $angle, $font_filename, $string, $options = []) {}
* <strong>Note:</strong>
* <code>open_basedir</code> does <em>not</em> apply to font_filename.
* </p>
* @param string $string <p>
* @param string $text <p>
* Text to be inserted into image.
* </p>
* @param array $options [optional] <p>
Expand Down Expand Up @@ -1908,7 +1910,7 @@ function imageftbbox($size, $angle, $font_filename, $string, $options = []) {}
* </tr>
* Returns false on error.
*/
function imagefttext($image, $size, $angle, $x, $y, $color, $font_filename, $string, $options = []) {}
function imagefttext(GdImage $image, float $size, float $angle, int $x, int $y, int $color, string $font_filename, string $text, array $options = []): array|false {}

/**
* Load a PostScript Type 1 font from file
Expand Down

0 comments on commit 622a0f9

Please sign in to comment.