From ed4fc9fdbf858f8ddb8b04c3f4901a29d2b82f5c Mon Sep 17 00:00:00 2001 From: Kharhamel Date: Mon, 24 Jun 2019 10:59:33 +0200 Subject: [PATCH 1/2] added support for more fallsy functions: gethostname and getimagesize --- generator/src/DocPage.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/generator/src/DocPage.php b/generator/src/DocPage.php index f9568209..2b62eff7 100644 --- a/generator/src/DocPage.php +++ b/generator/src/DocPage.php @@ -93,6 +93,12 @@ public function detectFalsyFunction(): bool if (preg_match('/Upon\s+failure,?\s+\[\w_]{1,15}?\<\/function\>\s+returns\s+&false;/m', $file)) { return true; } + if (preg_match('/On\s+failure,\s+&false;\s+is\s+returned/m', $file)) { + return true; + } + if (preg_match('/on\s+success,\s+otherwise\s+&false;\s+is\s+returned/m', $file)) { + return true; + } return false; } From f904ee7510431e883fe5eb63eec34d50148c7ea6 Mon Sep 17 00:00:00 2001 From: Kharhamel Date: Tue, 25 Jun 2019 10:22:52 +0200 Subject: [PATCH 2/2] regenerated files --- generated/functionsList.php | 2 + generated/image.php | 73 +++++++++++++++++++++++++++++++++++++ generated/network.php | 20 ++++++++++ rector-migrate.yml | 2 + 4 files changed, 97 insertions(+) diff --git a/generated/functionsList.php b/generated/functionsList.php index 00a1d286..d50c629d 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -258,6 +258,7 @@ 'iconv_get_encoding', 'iconv_set_encoding', 'iconv', + 'getimagesize', 'image2wbmp', 'imageaffine', 'imageaffinematrixconcat', @@ -555,6 +556,7 @@ 'closelog', 'dns_get_record', 'fsockopen', + 'gethostname', 'getprotobyname', 'getprotobynumber', 'header_register_callback', diff --git a/generated/image.php b/generated/image.php index d389f6f5..969e18a7 100644 --- a/generated/image.php +++ b/generated/image.php @@ -4,6 +4,79 @@ use Safe\Exceptions\ImageException; +/** + * The getimagesize function will determine the + * size of any supported given image file and return the dimensions along with + * the file type and a height/width text string to be used inside a + * normal HTML IMG tag and the + * correspondent HTTP content type. + * + * getimagesize can also return some more information + * in imageinfo parameter. + * + * @param string $filename This parameter specifies the file you wish to retrieve information + * about. It can reference a local file or (configuration permitting) a + * remote file using one of the supported streams. + * @param array $imageinfo This optional parameter allows you to extract some extended + * information from the image file. Currently, this will return the + * different JPG APP markers as an associative array. + * Some programs use these APP markers to embed text information in + * images. A very common one is to embed + * IPTC information in the APP13 marker. + * You can use the iptcparse function to parse the + * binary APP13 marker into something readable. + * + * The imageinfo only supports + * JFIF files. + * @return array Returns an array with up to 7 elements. Not all image types will include + * the channels and bits elements. + * + * Index 0 and 1 contains respectively the width and the height of the image. + * + * Index 2 is one of the IMAGETYPE_XXX constants indicating + * the type of the image. + * + * Index 3 is a text string with the correct + * height="yyy" width="xxx" string that can be used + * directly in an IMG tag. + * + * mime is the correspondant MIME type of the image. + * This information can be used to deliver images with the correct HTTP + * Content-type header: + * + * getimagesize and MIME types + * + * + * ]]> + * + * + * + * channels will be 3 for RGB pictures and 4 for CMYK + * pictures. + * + * bits is the number of bits for each color. + * + * For some image types, the presence of channels and + * bits values can be a bit + * confusing. As an example, GIF always uses 3 channels + * per pixel, but the number of bits per pixel cannot be calculated for an + * animated GIF with a global color table. + * + * On failure, FALSE is returned. + * @throws ImageException + * + */ +function getimagesize(string $filename, array &$imageinfo = null): array +{ + error_clear_last(); + $result = \getimagesize($filename, $imageinfo); + if ($result === false) { + throw ImageException::createFromPhpError(); + } + return $result; +} + + /** * image2wbmp outputs or save a WBMP * version of the given image. diff --git a/generated/network.php b/generated/network.php index 37711b41..c44819bc 100644 --- a/generated/network.php +++ b/generated/network.php @@ -315,6 +315,26 @@ function fsockopen(string $hostname, int $port = -1, ?int &$errno = null, ?strin } +/** + * gethostname gets the standard host name for + * the local machine. + * + * @return string Returns a string with the hostname on success, otherwise FALSE is + * returned. + * @throws NetworkException + * + */ +function gethostname(): string +{ + error_clear_last(); + $result = \gethostname(); + if ($result === false) { + throw NetworkException::createFromPhpError(); + } + return $result; +} + + /** * getprotobyname returns the protocol number * associated with the protocol name as per diff --git a/rector-migrate.yml b/rector-migrate.yml index 702cf12c..d4af30a5 100644 --- a/rector-migrate.yml +++ b/rector-migrate.yml @@ -261,6 +261,7 @@ services: iconv_get_encoding: 'Safe\iconv_get_encoding' iconv_set_encoding: 'Safe\iconv_set_encoding' iconv: 'Safe\iconv' + getimagesize: 'Safe\getimagesize' image2wbmp: 'Safe\image2wbmp' imageaffine: 'Safe\imageaffine' imageaffinematrixconcat: 'Safe\imageaffinematrixconcat' @@ -558,6 +559,7 @@ services: closelog: 'Safe\closelog' dns_get_record: 'Safe\dns_get_record' fsockopen: 'Safe\fsockopen' + gethostname: 'Safe\gethostname' getprotobyname: 'Safe\getprotobyname' getprotobynumber: 'Safe\getprotobynumber' header_register_callback: 'Safe\header_register_callback'