Skip to content

Commit c788fd2

Browse files
committed
Strip auto_prepend_file from temporary ini file
We don't need to be executed for all subsequent processes as they will use temporary ini anyway (because of PHPRC)
1 parent c48a709 commit c788fd2

File tree

3 files changed

+61
-31
lines changed

3 files changed

+61
-31
lines changed

composer.json

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
11
{
2-
"name": "weirdan/run-without-xdebug",
3-
"description": "Runs a php script with XDebug disabled",
4-
"keywords" : ["Xdebug", "xdebug", "performance"],
5-
"require": {
6-
"composer/xdebug-handler": "^1.3",
7-
"php": "~5.3 || ~7.0"
8-
},
9-
"require-dev": {
10-
"phpunit/phpunit": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
11-
"ext-xdebug": "*",
12-
"php": "~5.6 || ~7.0",
13-
"squizlabs/php_codesniffer": "^3.3"
14-
},
15-
"autoload-dev": {
16-
"psr-4": {
17-
"Weirdan\\RunWithoutXdebug\\Tests\\Integration\\" : "tests/integration"
18-
}
19-
},
20-
"license": "MIT",
21-
"authors": [
22-
{
23-
"name": "Bruce Weirdan",
24-
"email": "[email protected]"
25-
}
26-
],
27-
"bin": ["bin/php-noxdebug"],
28-
"scripts": {
29-
"test": "bin/php-noxdebug vendor/bin/phpunit --color=always",
30-
"cs-check": "phpcs",
31-
"cs-fix": "phpcbf"
2+
"name": "weirdan/run-without-xdebug",
3+
"description": "Runs a php script with XDebug disabled",
4+
"keywords": [
5+
"Xdebug",
6+
"xdebug",
7+
"performance"
8+
],
9+
"require": {
10+
"composer/xdebug-handler": "^1.3",
11+
"php": "~5.3 || ~7.0"
12+
},
13+
"require-dev": {
14+
"phpunit/phpunit": "^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
15+
"ext-xdebug": "*",
16+
"php": "~5.6 || ~7.0",
17+
"squizlabs/php_codesniffer": "^3.3"
18+
},
19+
"autoload-dev": {
20+
"psr-4": {
21+
"Weirdan\\RunWithoutXdebug\\Tests\\Integration\\": "tests/integration"
3222
}
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"Weirdan\\RunWithoutXdebug\\": "src/"
27+
}
28+
},
29+
"license": "MIT",
30+
"authors": [
31+
{
32+
"name": "Bruce Weirdan",
33+
"email": "[email protected]"
34+
}
35+
],
36+
"bin": [
37+
"bin/php-noxdebug"
38+
],
39+
"scripts": {
40+
"test": "bin/php-noxdebug vendor/bin/phpunit --color=always",
41+
"cs-check": "phpcs",
42+
"cs-fix": "phpcbf"
43+
}
3344
}

src/Restarter.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Weirdan\RunWithoutXdebug;
4+
5+
use Composer\XdebugHandler\XdebugHandler;
6+
7+
class Restarter extends XdebugHandler
8+
{
9+
/** @param string $command */
10+
protected function restart($command)
11+
{
12+
assert(null !== $this->tmpIni);
13+
$contents = file_get_contents($this->tmpIni);
14+
$contents = preg_replace('/^auto_prepend_file="' . preg_quote(__DIR__ . '/prepend.php', '/') . '"/m', '', $contents, -1, $count);
15+
var_dump($count);
16+
file_put_contents($this->tmpIni, $contents);
17+
parent::restart($command);
18+
}
19+
}

src/prepend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212

1313
call_user_func(function () {
14-
$x = new \Composer\XdebugHandler\XdebugHandler('RWX');
14+
$x = new Restarter('RWX');
1515
if ($logFile = getenv('RWX_DEBUG_LOG')) {
1616
if (!class_exists(Logger::class, false)) {
1717
class Logger extends \Psr\Log\AbstractLogger

0 commit comments

Comments
 (0)