-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from assertwell/feature/runkit-proxy
Introduce a Runkit support class
- Loading branch information
Showing
9 changed files
with
130 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
/** | ||
* A utility class to ensure we're calling the runkit7_* functions when available, as the runkit_* | ||
* versions are deprecated in newer versions of PHP. | ||
*/ | ||
|
||
namespace AssertWell\PHPUnitGlobalState\Support; | ||
|
||
/** | ||
* phpcs:disable Generic.Files.LineLength.TooLong | ||
* @method static bool constant_add(string $constname, mixed $value, int $newVisibility = NULL) | ||
* @method static bool constant_redefine(string $constname, mixed $value, int $newVisibility = NULL) | ||
* @method static bool constant_remove(string $constname) | ||
* @method static bool function_add(string $funcname, string $arglist, string $code, bool $return_by_reference = NULL, string $doc_comment = NULL, string $return_type, bool $is_strict = NULL) | ||
* @method static bool function_copy(string $funcname, string $targetname) | ||
* @method static bool function_redefine(string $funcname, string $arglist, string $code, bool $return_by_reference = NULL, string $doc_comment = NULL, string $return_type = NULL, bool $is_strict) | ||
* @method static bool function_remove(string $funcname) | ||
* @method static bool function_rename(string $funcname, string $newname) | ||
* @method static bool import(string $filename, int $flags = NULL) | ||
* @method static bool method_add(string $classname, string $methodname, string $args, string $code, int $flags = RUNKIT7_ACC_PUBLIC, string $doc_comment = NULL, string $return_type = NULL, bool $is_strict = NULL) | ||
* @method static bool method_copy(string $dClass, string $dMethod, string $sClass, string $sMethod = NULL) | ||
* @method static bool method_redefine(string $classname, string $methodname, string $args, string $code, int $flags = RUNKIT7_ACC_PUBLIC, string $doc_comment = NULL, string $return_type, bool $is_strict = NULL) | ||
* @method static bool method_remove(string $classname, string $methodname) | ||
* @method static bool method_rename(string $classname, string $methodname, string $newname) | ||
* @method static int object_id(object $obj) | ||
* @method static array superglobals() | ||
* @method static array zval_inspect(string $value) | ||
* phpcs:enable Generic.Files.LineLength.TooLong | ||
*/ | ||
class Runkit | ||
{ | ||
/** | ||
* Dynamically alias methods to the underlying Runkit functions. | ||
* | ||
* @throws \BadFunctionCallException if the underlying function does not exist. | ||
* | ||
* @param string $name The method name. | ||
* @param mixed[] $args Method arguments. | ||
* | ||
* @return mixed The return value of the corresponding runkit(7)_* functions. | ||
*/ | ||
public static function __callStatic($name, array $args = []) | ||
{ | ||
if (function_exists('runkit7_' . $name)) { | ||
return call_user_func_array('runkit7_' . $name, $args); | ||
} | ||
|
||
if (function_exists('runkit_' . $name)) { | ||
return call_user_func_array('runkit_' . $name, $args); | ||
} | ||
|
||
throw new \BadFunctionCallException(sprintf( | ||
'Runkit7 does not include a runkit7_%1$s() function.', | ||
$name | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters