Skip to content

Commit 9a4dbc5

Browse files
authored
Merge pull request #112 from j6s/feature/add-upon-failure-return-false
Add 'Upon failure' phrasing detection
2 parents 96a9210 + 8e02ad1 commit 9a4dbc5

File tree

7 files changed

+102
-9
lines changed

7 files changed

+102
-9
lines changed

generated/curl.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,9 @@ function curl_multi_init()
647647
*
648648
* CURLOPT_DNS_USE_GLOBAL_CACHE
649649
*
650-
* TRUE to use a global DNS cache. This option is
651-
* not thread-safe and is enabled by default.
650+
* TRUE to use a global DNS cache. This option is not thread-safe.
651+
* It is conditionally enabled by default if PHP is built for non-threaded use
652+
* (CLI, FCGI, Apache2-Prefork, etc.).
652653
*
653654
*
654655
*

generated/filesystem.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,66 @@ function file_put_contents(string $filename, $data, int $flags = 0, $context = n
345345
}
346346

347347

348+
/**
349+
* Reads an entire file into an array.
350+
*
351+
* @param string $filename Path to the file.
352+
* @param int $flags The optional parameter flags can be one, or
353+
* more, of the following constants:
354+
*
355+
*
356+
*
357+
* FILE_USE_INCLUDE_PATH
358+
*
359+
*
360+
*
361+
* Search for the file in the include_path.
362+
*
363+
*
364+
*
365+
*
366+
*
367+
* FILE_IGNORE_NEW_LINES
368+
*
369+
*
370+
*
371+
* Omit newline at the end of each array element
372+
*
373+
*
374+
*
375+
*
376+
*
377+
* FILE_SKIP_EMPTY_LINES
378+
*
379+
*
380+
*
381+
* Skip empty lines
382+
*
383+
*
384+
*
385+
*
386+
* @param resource $context
387+
* @return array Returns the file in an array. Each element of the array corresponds to a
388+
* line in the file, with the newline still attached. Upon failure,
389+
* file returns FALSE.
390+
* @throws FilesystemException
391+
*
392+
*/
393+
function file(string $filename, int $flags = 0, $context = null): array
394+
{
395+
error_clear_last();
396+
if ($context !== null) {
397+
$result = \file($filename, $flags, $context);
398+
} else {
399+
$result = \file($filename, $flags);
400+
}
401+
if ($result === false) {
402+
throw FilesystemException::createFromPhpError();
403+
}
404+
return $result;
405+
}
406+
407+
348408
/**
349409
*
350410
*

generated/functionsList.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
'fflush',
142142
'file_get_contents',
143143
'file_put_contents',
144+
'file',
144145
'fileatime',
145146
'filectime',
146147
'fileinode',
@@ -957,6 +958,7 @@
957958
'ssh2_sftp_rmdir',
958959
'ssh2_sftp_symlink',
959960
'ssh2_sftp_unlink',
961+
'ssh2_sftp',
960962
'stats_covariance',
961963
'stats_standard_deviation',
962964
'stats_stat_correlation',

generated/json.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,23 @@
1919
*
2020
* PHP implements a superset of JSON as specified in the original
2121
* RFC 7159.
22-
* @param int $options Bitmask consisting of JSON_HEX_QUOT,
22+
* @param int $options Bitmask consisting of
23+
* JSON_FORCE_OBJECT,
24+
* JSON_HEX_QUOT,
2325
* JSON_HEX_TAG,
2426
* JSON_HEX_AMP,
2527
* JSON_HEX_APOS,
28+
* JSON_INVALID_UTF8_IGNORE,
29+
* JSON_INVALID_UTF8_SUBSTITUTE,
2630
* JSON_NUMERIC_CHECK,
31+
* JSON_PARTIAL_OUTPUT_ON_ERROR,
32+
* JSON_PRESERVE_ZERO_FRACTION,
2733
* JSON_PRETTY_PRINT,
34+
* JSON_UNESCAPED_LINE_TERMINATORS,
2835
* JSON_UNESCAPED_SLASHES,
29-
* JSON_FORCE_OBJECT,
30-
* JSON_PRESERVE_ZERO_FRACTION,
3136
* JSON_UNESCAPED_UNICODE,
32-
* JSON_PARTIAL_OUTPUT_ON_ERROR,
33-
* JSON_UNESCAPED_LINE_TERMINATORS,
34-
* JSON_THROW_ON_ERROR. The behaviour of these
35-
* constants is described on the
37+
* JSON_THROW_ON_ERROR.
38+
* The behaviour of these constants is described on the
3639
* JSON constants page.
3740
* @param int $depth Set the maximum depth. Must be greater than zero.
3841
* @return string Returns a JSON encoded string on success.

generated/ssh2.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,25 @@ function ssh2_sftp_unlink($sftp, string $filename): void
617617
throw Ssh2Exception::createFromPhpError();
618618
}
619619
}
620+
621+
622+
/**
623+
* Request the SFTP subsystem from an already connected SSH2 server.
624+
*
625+
* @param resource $session An SSH connection link identifier, obtained from a call to
626+
* ssh2_connect.
627+
* @return resource This method returns an SSH2 SFTP resource for use with
628+
* all other ssh2_sftp_*() methods and the
629+
* ssh2.sftp:// fopen wrapper.
630+
* @throws Ssh2Exception
631+
*
632+
*/
633+
function ssh2_sftp($session)
634+
{
635+
error_clear_last();
636+
$result = \ssh2_sftp($session);
637+
if ($result === false) {
638+
throw Ssh2Exception::createFromPhpError();
639+
}
640+
return $result;
641+
}

generator/src/DocPage.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public function detectFalsyFunction(): bool
8383
if (preg_match('/If\s+the\s+call\s+fails,\s+it\s+will\s+return\s+&false;/m', $file)) {
8484
return true;
8585
}
86+
if (preg_match('/Upon\s+failure,?\s+\<function\>[\w_]{1,15}?\<\/function\>\s+returns\s+&false;/m', $file)) {
87+
return true;
88+
}
8689

8790
return false;
8891
}

rector-migrate.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ services:
142142
fflush: 'Safe\fflush'
143143
file_get_contents: 'Safe\file_get_contents'
144144
file_put_contents: 'Safe\file_put_contents'
145+
file: 'Safe\file'
145146
fileatime: 'Safe\fileatime'
146147
filectime: 'Safe\filectime'
147148
fileinode: 'Safe\fileinode'
@@ -958,6 +959,7 @@ services:
958959
ssh2_sftp_rmdir: 'Safe\ssh2_sftp_rmdir'
959960
ssh2_sftp_symlink: 'Safe\ssh2_sftp_symlink'
960961
ssh2_sftp_unlink: 'Safe\ssh2_sftp_unlink'
962+
ssh2_sftp: 'Safe\ssh2_sftp'
961963
stats_covariance: 'Safe\stats_covariance'
962964
stats_standard_deviation: 'Safe\stats_standard_deviation'
963965
stats_stat_correlation: 'Safe\stats_stat_correlation'

0 commit comments

Comments
 (0)