Skip to content

Commit c860f27

Browse files
authored
Add patch for PHP-Parser (#174)
1 parent 0a2097b commit c860f27

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ e2e_017: bin/php-scoper.phar fixtures/set017-symfony-di/vendor
135135

136136
e2e_018: ## Run end-to-end tests for the fixture set 018: nikic PHP-Parser
137137
e2e_018: bin/php-scoper.phar fixtures/set018-nikic-parser/vendor
138-
php -d zend.enable_gc=0 $(PHPSCOPER) add-prefix --working-dir=fixtures/set018-nikic-parser --prefix=_Prefixed --output-dir=../../build/set018-nikic-parser --force --no-config --no-interaction --stop-on-failure
138+
php -d zend.enable_gc=0 $(PHPSCOPER) add-prefix --working-dir=fixtures/set018-nikic-parser --prefix=_Prefixed --output-dir=../../build/set018-nikic-parser --force --no-interaction --stop-on-failure
139139
composer --working-dir=build/set018-nikic-parser dump-autoload
140140

141141
php build/set018-nikic-parser/main.php > build/set018-nikic-parser/output
@@ -213,14 +213,11 @@ composer.lock: composer.json
213213
@echo composer.lock is not up to date.
214214

215215
vendor-bin/box/composer.lock: composer.lock
216-
@echo fixtures/set011/composer.lock is not up to date.
216+
@echo composer.lock is not up to date.
217217

218218
fixtures/set005/composer.lock: fixtures/set005/composer.json
219219
@echo fixtures/set005/composer.lock is not up to date.
220220

221-
fixtures/set011/composer.lock: fixtures/set011/composer.json
222-
@echo fixtures/set011/composer.lock is not up to date.
223-
224221
fixtures/set015/composer.lock: fixtures/set015/composer.json
225222
@echo fixtures/set015/composer.lock is not up to date.
226223

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the humbug/php-scoper package.
7+
*
8+
* Copyright (c) 2017 Théo FIDRY <[email protected]>,
9+
* Pádraic Brady <[email protected]>
10+
*
11+
* For the full copyright and license information, please view the LICENSE
12+
* file that was distributed with this source code.
13+
*/
14+
15+
use Isolated\Symfony\Component\Finder\Finder;
16+
17+
return [
18+
'patchers' => [
19+
function (string $filePath, string $prefix, string $contents): string {
20+
//
21+
// PHP-Parser patch
22+
//
23+
if ($filePath === realpath(__DIR__.'/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php')) {
24+
$length = 15 + strlen($prefix) + 1;
25+
26+
return preg_replace(
27+
'%strpos\((.+?)\) \+ 15%',
28+
sprintf('strpos($1) + %d', $length),
29+
$contents
30+
);
31+
}
32+
33+
return $contents;
34+
},
35+
function (string $filePath, string $prefix, string $contents): string {
36+
$finderClass = sprintf('\%s\%s', $prefix, Finder::class);
37+
38+
return str_replace($finderClass, '\\'.Finder::class, $contents);
39+
},
40+
],
41+
];

0 commit comments

Comments
 (0)