Skip to content

Commit

Permalink
Merge pull request #387 from thecodingmachine/sleep
Browse files Browse the repository at this point in the history
deprecated sleep()
  • Loading branch information
Kharhamel authored Sep 8, 2022
2 parents 14fe494 + cf37257 commit be78f5b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
1 change: 1 addition & 0 deletions deprecated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
'stats_stat_correlation',
'stats_stat_innerproduct',
'stats_variance',
'sleep',
'substr',
'usort',
'vsprintf',
Expand Down
29 changes: 29 additions & 0 deletions deprecated/misc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Safe;

use Safe\Exceptions\MiscException;

/**
*
* @param int $seconds Halt time in seconds.
* @return int Returns zero on success.
*
* If the call was interrupted by a signal, sleep returns
* a non-zero value. On Windows, this value will always be
* 192 (the value of the
* WAIT_IO_COMPLETION constant within the Windows API).
* On other platforms, the return value will be the number of seconds left to
* sleep.
* @throws MiscException
* @deprecated The Safe version of this function is no longer needed in PHP 8.0+
*/
function sleep(int $seconds): int
{
error_clear_last();
$safeResult = \sleep($seconds);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}
1 change: 0 additions & 1 deletion generated/functionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@
'simplexml_import_dom',
'simplexml_load_file',
'simplexml_load_string',
'sleep',
'socket_accept',
'socket_addrinfo_bind',
'socket_addrinfo_connect',
Expand Down
26 changes: 0 additions & 26 deletions generated/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,32 +418,6 @@ function sapi_windows_vt100_support($stream, bool $enable = null): void
}


/**
*
*
* @param int $seconds Halt time in seconds.
* @return int Returns zero on success.
*
* If the call was interrupted by a signal, sleep returns
* a non-zero value. On Windows, this value will always be
* 192 (the value of the
* WAIT_IO_COMPLETION constant within the Windows API).
* On other platforms, the return value will be the number of seconds left to
* sleep.
* @throws MiscException
*
*/
function sleep(int $seconds): int
{
error_clear_last();
$safeResult = \sleep($seconds);
if ($safeResult === false) {
throw MiscException::createFromPhpError();
}
return $safeResult;
}


/**
* Delays program execution for the given number of
* seconds and nanoseconds.
Expand Down
1 change: 0 additions & 1 deletion rector-migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,6 @@
'simplexml_import_dom' => 'Safe\simplexml_import_dom',
'simplexml_load_file' => 'Safe\simplexml_load_file',
'simplexml_load_string' => 'Safe\simplexml_load_string',
'sleep' => 'Safe\sleep',
'socket_accept' => 'Safe\socket_accept',
'socket_addrinfo_bind' => 'Safe\socket_addrinfo_bind',
'socket_addrinfo_connect' => 'Safe\socket_addrinfo_connect',
Expand Down

0 comments on commit be78f5b

Please sign in to comment.