Skip to content

Commit

Permalink
Merge pull request #112 from j6s/feature/add-upon-failure-return-false
Browse files Browse the repository at this point in the history
Add 'Upon failure' phrasing detection
  • Loading branch information
moufmouf authored Apr 17, 2019
2 parents 96a9210 + 8e02ad1 commit 9a4dbc5
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 9 deletions.
5 changes: 3 additions & 2 deletions generated/curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.).
*
*
*
Expand Down
60 changes: 60 additions & 0 deletions generated/filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


/**
*
*
Expand Down
2 changes: 2 additions & 0 deletions generated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
'fflush',
'file_get_contents',
'file_put_contents',
'file',
'fileatime',
'filectime',
'fileinode',
Expand Down Expand Up @@ -957,6 +958,7 @@
'ssh2_sftp_rmdir',
'ssh2_sftp_symlink',
'ssh2_sftp_unlink',
'ssh2_sftp',
'stats_covariance',
'stats_standard_deviation',
'stats_stat_correlation',
Expand Down
17 changes: 10 additions & 7 deletions generated/json.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions generated/ssh2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions generator/src/DocPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+\<function\>[\w_]{1,15}?\<\/function\>\s+returns\s+&false;/m', $file)) {
return true;
}

return false;
}
Expand Down
2 changes: 2 additions & 0 deletions rector-migrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 9a4dbc5

Please sign in to comment.