2019-06-09 01:51:40 +02:00
|
|
|
<?php
|
|
|
|
|
2023-10-19 13:12:06 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-06-09 01:51:40 +02:00
|
|
|
$vendor_path = 'vendor-bin/box/vendor/humbug/php-scoper/src/PhpParser/NodeVisitor/ClassAliasStmtAppender.php';
|
|
|
|
|
|
|
|
if (!file_exists($vendor_path)) {
|
|
|
|
die('Vendor file does not exist' . PHP_EOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
$search = '/* @var FullyQualified $originalName */
|
|
|
|
|
|
|
|
$stmts[] = $this->createAliasStmt($originalName, $stmt);';
|
|
|
|
|
|
|
|
$replace = '/* @var FullyQualified $originalName */
|
|
|
|
$aliasStmt = $this->createAliasStmt($originalName, $stmt);
|
|
|
|
|
2019-06-09 02:27:49 +02:00
|
|
|
$stmts[] = new Node\Stmt\If_(
|
|
|
|
new Node\Expr\BooleanNot(
|
|
|
|
new Node\Expr\FuncCall(
|
|
|
|
new FullyQualified(\'class_exists\'),
|
|
|
|
[
|
|
|
|
new Node\Arg(
|
|
|
|
new Node\Expr\ClassConstFetch(
|
|
|
|
$originalName,
|
|
|
|
\'class\'
|
|
|
|
)
|
|
|
|
),
|
|
|
|
new Node\Arg(
|
|
|
|
new Node\Expr\ConstFetch(
|
|
|
|
new Node\Name(\'false\')
|
|
|
|
)
|
2019-06-09 01:51:40 +02:00
|
|
|
)
|
2019-06-09 02:27:49 +02:00
|
|
|
]
|
|
|
|
)
|
2019-06-09 01:51:40 +02:00
|
|
|
),
|
|
|
|
[\'stmts\' => [$aliasStmt]]
|
|
|
|
);';
|
|
|
|
|
|
|
|
$contents = file_get_contents($vendor_path);
|
|
|
|
|
|
|
|
$contents = str_replace($search, $replace, $contents);
|
|
|
|
|
|
|
|
file_put_contents($vendor_path, $contents);
|