From 8e02ad13ee54074f06437f781c4afb9f250c5665 Mon Sep 17 00:00:00 2001 From: Johannes Hertenstein Date: Tue, 16 Apr 2019 22:11:27 +0200 Subject: [PATCH] Add 'Upon failure' phrasing detection --- generated/curl.php | 5 ++-- generated/filesystem.php | 60 +++++++++++++++++++++++++++++++++++++ generated/functionsList.php | 2 ++ generated/json.php | 17 ++++++----- generated/ssh2.php | 22 ++++++++++++++ generator/src/DocPage.php | 3 ++ rector-migrate.yml | 2 ++ 7 files changed, 102 insertions(+), 9 deletions(-) diff --git a/generated/curl.php b/generated/curl.php index 8b865c59..e1147f37 100644 --- a/generated/curl.php +++ b/generated/curl.php @@ -647,8 +647,9 @@ function curl_multi_init() * * CURLOPT_DNS_USE_GLOBAL_CACHE * - * TRUE to use a global DNS cache. This option is - * not thread-safe and is enabled by default. + * TRUE to use a global DNS cache. This option is not thread-safe. + * It is conditionally enabled by default if PHP is built for non-threaded use + * (CLI, FCGI, Apache2-Prefork, etc.). * * * diff --git a/generated/filesystem.php b/generated/filesystem.php index 690bf645..e5af49a3 100644 --- a/generated/filesystem.php +++ b/generated/filesystem.php @@ -345,6 +345,66 @@ function file_put_contents(string $filename, $data, int $flags = 0, $context = n } +/** + * Reads an entire file into an array. + * + * @param string $filename Path to the file. + * @param int $flags The optional parameter flags can be one, or + * more, of the following constants: + * + * + * + * FILE_USE_INCLUDE_PATH + * + * + * + * Search for the file in the include_path. + * + * + * + * + * + * FILE_IGNORE_NEW_LINES + * + * + * + * Omit newline at the end of each array element + * + * + * + * + * + * FILE_SKIP_EMPTY_LINES + * + * + * + * Skip empty lines + * + * + * + * + * @param resource $context + * @return array Returns the file in an array. Each element of the array corresponds to a + * line in the file, with the newline still attached. Upon failure, + * file returns FALSE. + * @throws FilesystemException + * + */ +function file(string $filename, int $flags = 0, $context = null): array +{ + error_clear_last(); + if ($context !== null) { + $result = \file($filename, $flags, $context); + } else { + $result = \file($filename, $flags); + } + if ($result === false) { + throw FilesystemException::createFromPhpError(); + } + return $result; +} + + /** * * diff --git a/generated/functionsList.php b/generated/functionsList.php index fe9d044d..dbca346f 100644 --- a/generated/functionsList.php +++ b/generated/functionsList.php @@ -141,6 +141,7 @@ 'fflush', 'file_get_contents', 'file_put_contents', + 'file', 'fileatime', 'filectime', 'fileinode', @@ -957,6 +958,7 @@ 'ssh2_sftp_rmdir', 'ssh2_sftp_symlink', 'ssh2_sftp_unlink', + 'ssh2_sftp', 'stats_covariance', 'stats_standard_deviation', 'stats_stat_correlation', diff --git a/generated/json.php b/generated/json.php index 1de66b80..efaf7797 100644 --- a/generated/json.php +++ b/generated/json.php @@ -19,20 +19,23 @@ * * PHP implements a superset of JSON as specified in the original * RFC 7159. - * @param int $options Bitmask consisting of JSON_HEX_QUOT, + * @param int $options Bitmask consisting of + * JSON_FORCE_OBJECT, + * JSON_HEX_QUOT, * JSON_HEX_TAG, * JSON_HEX_AMP, * JSON_HEX_APOS, + * JSON_INVALID_UTF8_IGNORE, + * JSON_INVALID_UTF8_SUBSTITUTE, * JSON_NUMERIC_CHECK, + * JSON_PARTIAL_OUTPUT_ON_ERROR, + * JSON_PRESERVE_ZERO_FRACTION, * JSON_PRETTY_PRINT, + * JSON_UNESCAPED_LINE_TERMINATORS, * JSON_UNESCAPED_SLASHES, - * JSON_FORCE_OBJECT, - * JSON_PRESERVE_ZERO_FRACTION, * JSON_UNESCAPED_UNICODE, - * JSON_PARTIAL_OUTPUT_ON_ERROR, - * JSON_UNESCAPED_LINE_TERMINATORS, - * JSON_THROW_ON_ERROR. The behaviour of these - * constants is described on the + * JSON_THROW_ON_ERROR. + * The behaviour of these constants is described on the * JSON constants page. * @param int $depth Set the maximum depth. Must be greater than zero. * @return string Returns a JSON encoded string on success. diff --git a/generated/ssh2.php b/generated/ssh2.php index 0d5609a5..96af9df3 100644 --- a/generated/ssh2.php +++ b/generated/ssh2.php @@ -617,3 +617,25 @@ function ssh2_sftp_unlink($sftp, string $filename): void throw Ssh2Exception::createFromPhpError(); } } + + +/** + * Request the SFTP subsystem from an already connected SSH2 server. + * + * @param resource $session An SSH connection link identifier, obtained from a call to + * ssh2_connect. + * @return resource This method returns an SSH2 SFTP resource for use with + * all other ssh2_sftp_*() methods and the + * ssh2.sftp:// fopen wrapper. + * @throws Ssh2Exception + * + */ +function ssh2_sftp($session) +{ + error_clear_last(); + $result = \ssh2_sftp($session); + if ($result === false) { + throw Ssh2Exception::createFromPhpError(); + } + return $result; +} diff --git a/generator/src/DocPage.php b/generator/src/DocPage.php index 1c859c52..0c34f28f 100644 --- a/generator/src/DocPage.php +++ b/generator/src/DocPage.php @@ -83,6 +83,9 @@ public function detectFalsyFunction(): bool if (preg_match('/If\s+the\s+call\s+fails,\s+it\s+will\s+return\s+&false;/m', $file)) { return true; } + if (preg_match('/Upon\s+failure,?\s+\[\w_]{1,15}?\<\/function\>\s+returns\s+&false;/m', $file)) { + return true; + } return false; } diff --git a/rector-migrate.yml b/rector-migrate.yml index de3dab4d..a05a43e0 100644 --- a/rector-migrate.yml +++ b/rector-migrate.yml @@ -142,6 +142,7 @@ services: fflush: 'Safe\fflush' file_get_contents: 'Safe\file_get_contents' file_put_contents: 'Safe\file_put_contents' + file: 'Safe\file' fileatime: 'Safe\fileatime' filectime: 'Safe\filectime' fileinode: 'Safe\fileinode' @@ -958,6 +959,7 @@ services: ssh2_sftp_rmdir: 'Safe\ssh2_sftp_rmdir' ssh2_sftp_symlink: 'Safe\ssh2_sftp_symlink' ssh2_sftp_unlink: 'Safe\ssh2_sftp_unlink' + ssh2_sftp: 'Safe\ssh2_sftp' stats_covariance: 'Safe\stats_covariance' stats_standard_deviation: 'Safe\stats_standard_deviation' stats_stat_correlation: 'Safe\stats_stat_correlation'