Skip to content

Commit 515c7d9

Browse files
committed
Exclude dev-only Symfony packages from the Phar when composer/composer is absent
1 parent 1d8e73a commit 515c7d9

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎features/make-phar.feature‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,13 @@ Feature: Check `utils/make-phar.php` output
7676
"""
7777
present
7878
"""
79+
80+
Scenario: Dev-only Symfony packages are excluded from the Phar
81+
Given an empty directory
82+
And a new Phar with the same version
83+
84+
When I run `php -r '$phar = new Phar( "{PHAR_PATH}" ); $found = 0; foreach ( new RecursiveIteratorIterator( $phar ) as $file ) { if ( false !== strpos( $file->getPathname(), "/vendor/symfony/" ) ) { ++$found; } } echo $found;'`
85+
Then STDOUT should be:
86+
"""
87+
0
88+
"""

‎utils/make-phar.php‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function add_file( $phar, $path ) {
7878
'\/nb\/oxymel\/',
7979
'-command\/src\/',
8080
'\/wp-cli\/[^\n]+?-command\/',
81-
'\/symfony\/(?:config|console|debug|dependency-injection|event-dispatcher|filesystem|translation|yaml)',
81+
is_dir( WP_CLI_VENDOR_DIR . '/composer/composer' ) ? '\/symfony\/(?:config|console|debug|dependency-injection|event-dispatcher|filesystem|translation|yaml)' : '\/symfony\/',
8282
'\/(?:dealerdirect|myclabs|squizlabs|wimg)\/',
8383
'\/yoast\/',
8484
];
@@ -91,7 +91,7 @@ function add_file( $phar, $path ) {
9191
'\/phpspec\/',
9292
'\/sebastian\/',
9393
'\/php-parallel-lint\/',
94-
'\/symfony\/(?:config|debug|dependency-injection|event-dispatcher|translation|yaml)',
94+
is_dir( WP_CLI_VENDOR_DIR . '/composer/composer' ) ? '\/symfony\/(?:config|debug|dependency-injection|event-dispatcher|translation|yaml)' : '\/symfony\/',
9595
'\/composer\/spdx-licenses\/',
9696
'\/Composer\/(?:Command\/|Compiler\.php|Console\/|Downloader\/Pear|Installer\/Pear|Question\/|Repository\/Pear|SelfUpdate\/)',
9797
'\/(?:dealerdirect|myclabs|squizlabs|wimg)\/',
@@ -201,7 +201,6 @@ function get_composer_versions( $current_version ) {
201201
->in( WP_CLI_VENDOR_DIR . '/eftec/bladeone' )
202202
->in( WP_CLI_ROOT . '/bundle/rmccue/requests' )
203203
->in( WP_CLI_VENDOR_DIR . '/composer' )
204-
->in( WP_CLI_VENDOR_DIR . '/symfony' )
205204
->notName( 'behat-tags.php' )
206205
->notPath( '#(?:[^/]+-command|php-cli-tools)/vendor/#' ) // For running locally, in case have composer installed or symlinked them.
207206
->exclude( 'config' )
@@ -216,6 +215,10 @@ function get_composer_versions( $current_version ) {
216215
->exclude( 'tests' )
217216
->exclude( 'Test' )
218217
->exclude( 'Tests' );
218+
if ( is_dir( WP_CLI_VENDOR_DIR . '/composer/composer' ) && is_dir( WP_CLI_VENDOR_DIR . '/symfony' ) ) {
219+
$finder
220+
->in( WP_CLI_VENDOR_DIR . '/symfony' );
221+
}
219222
if ( is_dir( WP_CLI_VENDOR_DIR . '/react' ) ) {
220223
$finder
221224
->in( WP_CLI_VENDOR_DIR . '/react' );

0 commit comments

Comments
 (0)