php-mock/php-mock 2.6.1
“PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed.”
Basename is uppercase README.mdPHP invokes a variable-named function
SHA-256616a6542d2c1835aded47d0efc796f9709ac9a55b043b2f1b22c56a84fe07be7
Evidence
3:63… ilt-in PHP functions like
4`time()` or `rand()`. This is achieved by [PHP's namespace fallback policy](http://php.net/manual/en/language.namespaces.fallback.php):
5
6> PHP will fall back to global functions […]
7> if a namespaced function […] does not exist.
8
9PHP-Mock uses that feature by providing the namespaced function. I.e. you have
10to be in a **non global namespace** context and call the function
11**unqualified**:
12
⋯4 lines
17```
18
19## Requirements and restrictions
20
21* Only *unqualified* function calls in a namespace context can be mocked.
22 E.g. a call for `time()` in the namespace `foo` is mockable,
23 a call for `\time()` is not.
24
25* The mock has to …
25:61… qualified function
26 in the tested class. This is documented in [Bug #68541](https://bugs.php.net/bug.php?id=68541).
27 In most cases, you can ignore this restriction but if you happen to run into
28 this issue you can call [`Mock::define()`](http://php-mock.github.io/php-mock/api/class-phpmock.Mock.html#_define)
29 before that first call. This would define a side effectless n …
⋯5 lines
6 * Implementation deactivates related mocks.
7 *
8 * @author Markus Malkusch <markus@malkusch.de>
9 * @link bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK Donations
10 * @license http://www.wtfpl.net/txt/copying/ WTFPL
11 */
12interface Deactivatable
13{
14 /**
15 * Disable related mocks.
16 */
17 public function disable();
18}
131 public function call(array $arguments)
132 {
133 return call_user_func_array($this->function, $arguments);
134 }
135
136 /**
137 * Returns the fully qualified function name.
138 *
139 * @return string The function name with its namespace.
140 * @internal
141 */
142 public function getFQFN()
143 {
144 return strt …
176:21… ed this method does nothing.
177 *
178 * @see enable()
179 * @link https://bugs.php.net/bug.php?id=68541 Bug #68541
180 */
181 public function define()
182 {
183 $fqfn = $this->getFQFN();
184 if (function_exists($fqfn)) {
185 return;
186 }
187 $functionGenerator = new MockFunctionGenerator($this);
188 $functionGenerator …
Showing the top 5 files — 7 more files (39 regions) not shown.
No evidence locations were recorded for this file. Raw result