Skip to content

Commit fd0476c

Browse files
Merge pull request #17 from assertwell/feature/functions-trait
Define the Functions trait
2 parents e8a9571 + 510b10e commit fd0476c

20 files changed

+868
-160
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class MyTestClass extends TestCase
3030

3131
### Introduction to Runkit
3232

33-
Some of the traits will rely on [Runkit7](https://www.php.net/runkit7), a port of PHP's runkit designed to work in PHP 7.x, to rewrite code at runtime (a.k.a. "monkey-patching").
33+
Some of the traits will rely on [Runkit7], a port of PHP's runkit designed to work in PHP 7.x, to rewrite code at runtime (a.k.a. "monkey-patching").
3434

3535
For example, once a PHP constant is defined, it will normally have that value until the PHP process ends. Under normal circumstances, that's great: it prevents the value from being accidentally overwritten and/or tampered with.
3636

@@ -46,7 +46,7 @@ var_dump(SOME_CONSTANT)
4646
#=> string(10) "some value"
4747

4848
// Now, re-define the constant.
49-
runkit_constant_redefine('SOME_CONSTANT', 'some other value');
49+
runkit7_constant_redefine('SOME_CONSTANT', 'some other value');
5050
var_dump(SOME_CONSTANT)
5151
#=> string(16) "some other value"
5252
```
@@ -57,11 +57,14 @@ Of course, we might want a constant's original value to be restored after our te
5757

5858
The library offers a number of traits, based on the type of global state that might need to be manipulated.
5959

60-
* [Constants](docs/Constants.md) (requires Runkit7)
60+
* [Constants](docs/Constants.md) (requires [Runkit7])
6161
* [Environment Variables](docs/EnvironmentVariables.md)
62+
* [Functions](docs/Functions.md) (requires [Runkit7])
6263
* [Global Variables](docs/GlobalVariables.md)
6364

6465

6566
## Contributing
6667

6768
If you're interested in contributing to the library, [please review our contributing guidelines](.github/CONTRIBUTING.md).
69+
70+
[Runkit7]: docs/Runkit.md

composer.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"phpcompatibility/php-compatibility": "^9.3",
2929
"phpstan/phpstan": "^0.12",
3030
"squizlabs/php_codesniffer": "^3.5",
31-
"stevegrunwell/runkit7-installer": "^1.1",
31+
"stevegrunwell/runkit7-installer": "^1.2",
3232
"symfony/phpunit-bridge": "^5.1"
3333
},
3434
"suggest": {
@@ -42,7 +42,10 @@
4242
"autoload-dev": {
4343
"psr-4": {
4444
"Tests\\": "tests/"
45-
}
45+
},
46+
"files": [
47+
"tests/stubs/functions.php"
48+
]
4649
},
4750
"config": {
4851
"preferred-install": "dist",

composer.lock

+42-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Constants.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,8 @@
22

33
Some applications — especially WordPress — will use [PHP constants](https://www.php.net/manual/en/language.constants.php) for configuration that should not be edited directly through the <abbr title="User Interface">UI</abbr>.
44

5-
Normally, a constant cannot be redefined or removed once defined; however, [the runkit7 extension](https://www.php.net/manual/en/book.runkit7) exposes functions to modify normally immutable constructs.
5+
Normally, a constant cannot be redefined or removed once defined; however, [the runkit7 extension](Runkit.md) exposes functions to modify normally immutable constructs.
66

7-
If runkit functions are unavailable, the `Constants` trait will automatically skip tests that rely on this functionality.
8-
9-
In order to install runkit7 in your development and CI environments, you may use [the installer bundled with this repo](https://github.com/stevegrunwell/runkit7-installer):
10-
11-
```sh
12-
$ sudo ./vendor/bin/install-runkit.sh
13-
```
147

158
## Methods
169

0 commit comments

Comments
 (0)