1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Hack around PHP 7.3 polyfill scoping

This commit is contained in:
Matthew Brown 2019-06-08 19:51:40 -04:00
parent 08d029b3c5
commit bfbe9a527a
3 changed files with 42 additions and 2 deletions

View File

@ -60,8 +60,8 @@ jobs:
- vendor/bin/phpcs
- stage: Phar build
php: 7.2
env: DEPS="low"
php: 7.3
env: DEPS="high"
script: bin/build-phar.sh
deploy:
# deploy tagged releases to github releases page

View File

@ -4,6 +4,10 @@ set -e
composer bin box install
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
php $DIR/improve_class_alias.php
vendor/bin/box compile
if [[ "$GPG_ENCRYPTION" != '' ]] ; then

View File

@ -0,0 +1,36 @@
<?php
$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);
$stmts[] = new If_(
new FuncCall(
new FullyQualified(\'class_exists\'),
[
new Node\Arg(
new Node\Expr\ClassConstFetch(
$originalName,
\'class\'
)
)
]
),
[\'stmts\' => [$aliasStmt]]
);';
$contents = file_get_contents($vendor_path);
$contents = str_replace($search, $replace, $contents);
file_put_contents($vendor_path, $contents);