Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/Reflection/SignatureMap/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4536,7 +4536,8 @@
'imagealphablending' => ['bool', 'im'=>'resource', 'on'=>'bool'],
'imageantialias' => ['bool', 'im'=>'resource', 'on'=>'bool'],
'imagearc' => ['bool', 'im'=>'resource', 'cx'=>'int', 'cy'=>'int', 'w'=>'int', 'h'=>'int', 's'=>'int', 'e'=>'int', 'col'=>'int'],
'imagebmp' => ['bool', 'image'=>'resource', 'to='=>'mixed', 'compressed='=>'bool'],
'imagebmp' => ['bool', 'image'=>'resource', 'to='=>'string|resource', 'compressed='=>'bool'],
'imagebmp\'1' => ['string|false', 'image'=>'resource', 'to='=>'null', 'compressed='=>'bool'],
'imagechar' => ['bool', 'im'=>'resource', 'font'=>'int', 'x'=>'int', 'y'=>'int', 'c'=>'string', 'col'=>'int'],
'imagecharup' => ['bool', 'im'=>'resource', 'font'=>'int', 'x'=>'int', 'y'=>'int', 'c'=>'string', 'col'=>'int'],
'imagecolorallocate' => ['int', 'im'=>'resource', 'red'=>'int', 'green'=>'int', 'blue'=>'int'],
Expand Down Expand Up @@ -4593,15 +4594,19 @@
'imageftbbox' => ['array', 'size'=>'float', 'angle'=>'float', 'font_file'=>'string', 'text'=>'string', 'extrainfo='=>'array'],
'imagefttext' => ['array', 'im'=>'resource', 'size'=>'float', 'angle'=>'float', 'x'=>'int', 'y'=>'int', 'col'=>'int', 'font_file'=>'string', 'text'=>'string', 'extrainfo='=>'array'],
'imagegammacorrect' => ['bool', 'im'=>'resource', 'inputgamma'=>'float', 'outputgamma'=>'float'],
'imagegd' => ['bool', 'im'=>'resource', 'filename='=>'string|resource|null'],
'imagegd2' => ['bool', 'im'=>'resource', 'filename='=>'string|resource|null', 'chunk_size='=>'int', 'type='=>'int'],
'imagegd' => ['bool', 'im'=>'resource', 'filename='=>'string|resource'],
'imagegd\'1' => ['string|false', 'im'=>'resource', 'filename='=>'null'],
'imagegd2' => ['bool', 'im'=>'resource', 'filename='=>'string|resource', 'chunk_size='=>'int', 'type='=>'int'],
'imagegd2\'1' => ['string|false', 'im'=>'resource', 'filename='=>'null', 'chunk_size='=>'int', 'type='=>'int'],
'imagegetclip' => ['array', 'im'=>'resource'],
'imagegif' => ['bool', 'im'=>'resource', 'filename='=>'string|resource|null'],
'imagegif' => ['bool', 'im'=>'resource', 'filename='=>'string|resource'],
'imagegif\'1' => ['string|false', 'im'=>'resource', 'filename='=>'null'],
'imagegrabscreen' => ['resource'],
'imagegrabwindow' => ['resource', 'window_handle'=>'int', 'client_area='=>'int'],
'imageinterlace' => ['int', 'im'=>'resource', 'interlace='=>'int'],
'imageistruecolor' => ['bool', 'im'=>'resource'],
'imagejpeg' => ['bool', 'im'=>'resource', 'filename='=>'string|resource|null', 'quality='=>'int'],
'imagejpeg' => ['bool', 'im'=>'resource', 'filename='=>'string|resource', 'quality='=>'int'],
'imagejpeg\'1' => ['string|false', 'im'=>'resource', 'filename='=>'null', 'quality='=>'int'],
'imagelayereffect' => ['bool', 'im'=>'resource', 'effect'=>'int'],
'imageline' => ['bool', 'im'=>'resource', 'x1'=>'int', 'y1'=>'int', 'x2'=>'int', 'y2'=>'int', 'col'=>'int'],
'imageloadfont' => ['int', 'filename'=>'string'],
Expand All @@ -4611,7 +4616,8 @@
'imageopenpolygon' => ['bool', 'image'=>'resource', 'points'=>'array', 'num_points'=>'int', 'color'=>'int'],
'imagepalettecopy' => ['void', 'dst'=>'resource', 'src'=>'resource'],
'imagepalettetotruecolor' => ['bool', 'src'=>'resource'],
'imagepng' => ['bool', 'im'=>'resource', 'filename='=>'string|resource|null', 'quality='=>'int', 'filters='=>'int'],
'imagepng' => ['bool', 'im'=>'resource', 'filename='=>'string|resource', 'quality='=>'int', 'filters='=>'int'],
'imagepng\'1' => ['string|false', 'im'=>'resource', 'filename='=>'null', 'quality='=>'int', 'filters='=>'int'],
'imagepolygon' => ['bool', 'im'=>'resource', 'point'=>'array', 'num_points'=>'int', 'col'=>'int'],
'imagepsbbox' => ['array', 'text'=>'string', 'font'=>'', 'size'=>'int', 'space'=>'int', 'tightness'=>'int', 'angle'=>'float'],
'imagepsencodefont' => ['bool', 'font_index'=>'resource', 'encodingfile'=>'string'],
Expand Down Expand Up @@ -4640,9 +4646,12 @@
'imagettfbbox' => ['array', 'size'=>'float', 'angle'=>'float', 'font_file'=>'string', 'text'=>'string'],
'imagettftext' => ['array', 'im'=>'resource', 'size'=>'float', 'angle'=>'float', 'x'=>'int', 'y'=>'int', 'col'=>'int', 'font_file'=>'string', 'text'=>'string'],
'imagetypes' => ['int'],
'imagewbmp' => ['bool', 'im'=>'resource', 'filename='=>'string|resource|null', 'foreground='=>'int'],
'imagewebp' => ['bool', 'im'=>'resource', 'filename='=>'string|resource|null', 'quality='=>'int'],
'imagexbm' => ['bool', 'im'=>'resource', 'filename'=>'string|resource|null', 'foreground='=>'int'],
'imagewbmp' => ['bool', 'im'=>'resource', 'filename='=>'string|resource', 'foreground='=>'int'],
'imagewbmp\'1' => ['string|false', 'im'=>'resource', 'filename='=>'null', 'foreground='=>'int'],
'imagewebp' => ['bool', 'im'=>'resource', 'filename='=>'string|resource', 'quality='=>'int'],
'imagewebp\'1' => ['string|false', 'im'=>'resource', 'filename='=>'null', 'quality='=>'int'],
'imagexbm' => ['bool', 'im'=>'resource', 'filename'=>'string|resource', 'foreground='=>'int'],
'imagexbm\'1' => ['string|false', 'im'=>'resource', 'filename'=>'null', 'foreground='=>'int'],
'Imagick::__construct' => ['void', 'files='=>''],
'Imagick::__toString' => ['string'],
'Imagick::adaptiveBlurImage' => ['bool', 'radius'=>'float', 'sigma'=>'float', 'channel='=>'int'],
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9980,6 +9980,15 @@ public function dataBitwiseNot(): array
return $this->gatherAssertTypes(__DIR__ . '/data/bitwise-not.php');
}

public function dataGraphicsDrawReturnTypes(): array
{
if (!extension_loaded('gd')) {
return [];
}

return $this->gatherAssertTypes(__DIR__ . '/data/graphics-draw-return-types.php');
}

/**
* @dataProvider dataBug2574
* @dataProvider dataBug2577
Expand Down Expand Up @@ -10039,6 +10048,7 @@ public function dataBitwiseNot(): array
* @dataProvider dataArrayTypehintWithoutNullInPhpDoc
* @dataProvider dataOverrideVariableCertaintyInRootScope
* @dataProvider dataBitwiseNot
* @dataProvider dataGraphicsDrawReturnTypes
* @param string $assertType
* @param string $file
* @param mixed ...$args
Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Analyser/data/graphics-draw-return-types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

use function PHPStan\Analyser\assertType;

$image = imagecreatetruecolor(1, 1);
$memoryHandle = fopen('php://memory', 'w');

assertType('bool', imagegd($image, 'php://memory'));
assertType('bool', imagegd($image, $memoryHandle));
assertType('string|false', imagegd($image, null));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify imagegd($image); too, thanks.