Skip to content

Commit

Permalink
Upgrade to PHP-Scoper 0.12 (box-project#423)
Browse files Browse the repository at this point in the history
- Upgrade to PHP-Scoper 0.12
- Remove the pinned `roave/better-reflection` dependency (no longer necessary as the new Configuration works with the 3.5.0 version)
- Upgrade to `nikic/iter` 2.0.0 which is compatible with the new PHP-Parser version and PHP 7.4.0
- Remove the Amphp related event loop extensions as it is no longer necessary to have them loaded for the scoping of their symbols to be done correctly
- Update the PHP-Scoper config
  • Loading branch information
theofidry authored Jun 5, 2019
1 parent c1a51ad commit efe97a7
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 92 deletions.
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ env:
matrix:
- COMPOSER_FLAGS='--no-interaction --no-progress --no-suggest --prefer-dist'

addons:
apt:
packages:
- libevent-dev

matrix:
include:
- php: '7.2'
Expand All @@ -41,9 +36,6 @@ before_install:
fi
- set -eo pipefail
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- .travis/install-uv.sh
- .travis/install-ev.sh
- .travis/install-event.sh
- composer validate
- |
if [ "DEPLOY" != "true" ]; then
Expand Down
14 changes: 0 additions & 14 deletions .travis/install-ev.sh

This file was deleted.

14 changes: 0 additions & 14 deletions .travis/install-event.sh

This file was deleted.

28 changes: 0 additions & 28 deletions .travis/install-uv.sh

This file was deleted.

5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@
"ext-phar": "*",
"amphp/parallel-functions": "^0.1.3",
"beberlei/assert": "^3.2",
"roave/better-reflection": "~3.5.0",
"composer/semver": "^1.5",
"composer/xdebug-handler": "^1.3.2",
"hoa/compiler": "^3.17",
"humbug/php-scoper": "~0.11",
"humbug/php-scoper": "~0.12",
"justinrainbow/json-schema": "^5.2",
"nikic/iter": "^1.6",
"nikic/iter": "^2.0",
"nikic/php-parser": "^4.2",
"ocramius/package-versions": "^1.4",
"opis/closure": "^3.2",
Expand Down
19 changes: 3 additions & 16 deletions scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ static function (string $filePath, string $prefix, string $contents): string {
return preg_replace(
'/Hoa\\\\Consistency::registerShutdownFunction\(xcallable\(\'(.*)\'\)\)/',
sprintf(
'Hoa\\Consistency::registerShutdownFunction(xcallable(\'%s$1\'))',
'Hoa\\Consistency::registerShutdownFunction(%sxcallable(\'%s$1\'))',
'\\\\'.$prefix.'\\\\',
$prefix.'\\\\\\\\'
),
$contents
Expand Down Expand Up @@ -138,6 +139,7 @@ static function (string $filePath, string $prefix, string $contents): string {

return $contents;
},
// Symfony polyfills patches
static function (string $filePath, string $prefix, string $contents): string {
if ('vendor/symfony/polyfill-php72/bootstrap.php' !== $filePath) {
return $contents;
Expand All @@ -151,8 +153,6 @@ static function (string $filePath, string $prefix, string $contents): string {
},
],
'whitelist' => [
'Composer\*',

\Composer\Autoload\ClassLoader::class,

\KevinGH\Box\Compactor\Compactor::class,
Expand All @@ -162,18 +162,6 @@ static function (string $filePath, string $prefix, string $contents): string {
\KevinGH\Box\Compactor\Php::class,
\KevinGH\Box\Compactor\PhpScoper::class,

// Symfony Polyfill for PHP 7.1 support
// https://github.com/humbug/php-scoper/issues/304
'sapi_windows_vt100_support',
'stream_isatty',
'utf8_encode',
'utf8_decode',
'spl_object_id',
'PHP_OS_FAMILY',
'mb_chr',
'mb_ord',
'mb_scrub',

// Hoa symbols
'SUCCEED',
'FAILED',
Expand Down Expand Up @@ -203,7 +191,6 @@ static function (string $filePath, string $prefix, string $contents): string {
'_concrete',
'_overridable',
'WITH_COMPOSER',
'xcallable',
],
'whitelist-global-constants' => false,
'whitelist-global-classes' => false,
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/ComposerOrchestrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static function generateAutoloadStatements(Whitelist $whitelist, string
$autoload
);

$whitelistStatements = (new ScoperAutoloadGenerator($whitelist))->dump($prefix);
$whitelistStatements = (new ScoperAutoloadGenerator($whitelist))->dump();

$whitelistStatements = preg_replace(
'/scoper\-autoload\.php \@generated by PhpScoper/',
Expand Down
9 changes: 2 additions & 7 deletions src/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use Herrera\Box\Compactor\Json as LegacyJson;
use Herrera\Box\Compactor\Php as LegacyPhp;
use Humbug\PhpScoper\Configuration as PhpScoperConfiguration;
use Humbug\PhpScoper\Console\ApplicationFactory;
use Humbug\PhpScoper\Container;
use Humbug\PhpScoper\Scoper;
use Humbug\PhpScoper\Scoper\FileWhitelistScoper;
use function implode;
Expand Down Expand Up @@ -2846,12 +2846,7 @@ static function (string $path) use ($basePath): string {

$scoper = new SerializablePhpScoper(
static function () use ($whitelistedFiles): Scoper {
$scoper = (new class() extends ApplicationFactory {
public static function createScoper(): Scoper
{
return parent::createScoper();
}
})::createScoper();
$scoper = (new Container())->getScoper();

if ([] !== $whitelistedFiles) {
return new FileWhitelistScoper($scoper, ...$whitelistedFiles);
Expand Down
2 changes: 1 addition & 1 deletion src/PhpScoper/SerializablePhpScoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use function unserialize;

/**
* Humbug PHP-Scoper scoper which leverages closures to ensure the scoper is serialiable.
* Humbug PHP-Scoper scoper which leverages closures to ensure the scoper is serializable.
*/
final class SerializablePhpScoper implements HumbugPhpScoperScoper, Serializable
{
Expand Down

0 comments on commit efe97a7

Please sign in to comment.