Skip to content

Prefix dependencies with PHP-Scoper #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 30 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6c39d76
Prefix dependencies with PHP-Scoper
swissspidy Feb 25, 2025
391bb4b
Don't ignore folder
swissspidy Feb 25, 2025
268eb8a
Fix spell checker issue
ernilambar Feb 26, 2025
7997131
Update test steps
ernilambar Feb 26, 2025
ad55d6a
Update PHP array
ernilambar Feb 26, 2025
1bf67db
Update parser in readme check
ernilambar Feb 26, 2025
8d93738
Trying PHP above 8.2
ernilambar Feb 26, 2025
32e07e2
Revert "Trying PHP above 8.2"
swissspidy Feb 26, 2025
21579b6
Revert "Update PHP array"
swissspidy Feb 26, 2025
c804d92
Revert "Update test steps"
swissspidy Feb 26, 2025
91016cc
Switch PHP version on CI
swissspidy Feb 26, 2025
c264650
Move around
swissspidy Feb 26, 2025
60f400e
Update lock file
swissspidy Feb 26, 2025
ebab021
Update readme parser package
swissspidy Feb 26, 2025
6a00213
Fix PHPCS path
swissspidy Feb 26, 2025
3862936
PHPStan fixes
swissspidy Feb 26, 2025
e19f545
Another PHPStan fix
swissspidy Feb 26, 2025
8488feb
Prefix more dependencies
swissspidy Feb 26, 2025
b243412
Fix autoloader path
swissspidy Feb 26, 2025
7601690
Make debugging a bit easier
swissspidy Feb 26, 2025
4e1aed7
Try excluding PHPCS autoloader from classmap
swissspidy Feb 26, 2025
9142c4b
Remove file_exists check
swissspidy Feb 26, 2025
46645a2
Update scoper config
swissspidy Feb 26, 2025
143afd2
Add patchers to fix namespace issues
swissspidy Feb 26, 2025
40e8360
Set WP_DEBUG for Behat tests
swissspidy Feb 27, 2025
d48d842
Try verbose phpunit output
swissspidy Feb 27, 2025
00cb4c8
Try php-error.php drop-in for Behat
swissspidy Feb 27, 2025
912d37e
double dash
swissspidy Feb 27, 2025
cbf4ff2
Exclude vipwpcs from classmap
swissspidy Feb 27, 2025
93b777d
Remove debug flag
swissspidy Feb 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ patches
# Distributed via vendor/plugin-check/phpcs-sniffs instead
/phpcs-sniffs/
tests
/vendor

*.DS_Store
.DS_Store
Expand Down Expand Up @@ -40,3 +41,4 @@ phpunit.xml.dist
plugin-check.iml
README.md
SECURITY.md
scoper.inc.php
28 changes: 25 additions & 3 deletions .github/workflows/behat-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,8 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
extensions: mysql
tools: composer
php-version: ${{ matrix.php }}
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
ini-values: pcov.directory=.,pcov.exclude=~(vendor|tests)~

- name: Install PHP dependencies
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a
Expand All @@ -99,6 +96,31 @@ jobs:
run: |
echo "${PWD}/vendor/bin" >> $GITHUB_PATH

- name: Setup PHP for PHP-Scoper
uses: shivammathur/setup-php@v2
with:
tools: composer
php-version: latest

- name: Install PHP-Scoper
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a
with:
working-directory: 'vendor-bin/php-scoper'
composer-options: '--prefer-dist'

- name: Prefix Composer dependencies
run: |
composer prefix-dependencies

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
extensions: mysql
tools: composer
php-version: ${{ matrix.php }}
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
ini-values: pcov.directory=.,pcov.exclude=~(vendor|tests)~

- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/php-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,21 @@ jobs:
- name: Validate Composer configuration
run: composer validate

- name: Install PHP-Scoper
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a
with:
working-directory: 'vendor-bin/php-scoper'
composer-options: '--prefer-dist'

- name: Install PHP dependencies
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a
with:
composer-options: '--prefer-dist'

- name: Prefix Composer dependencies
run: |
composer prefix-dependencies

- name: PHP Lint
run: composer lint

Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/php-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@ jobs:
with:
composer-options: '--prefer-dist'

- name: Setup PHP for PHP-Scoper
uses: shivammathur/setup-php@v2
with:
tools: composer
php-version: 8.4
coverage: none

- name: Install PHP-Scoper
uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a
with:
working-directory: "vendor-bin/php-scoper"
composer-options: '--prefer-dist'

- name: Prefix Composer dependencies
run: |
composer prefix-dependencies

- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Setup Node.js (.nvmrc)
uses: actions/setup-node@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ build

node_modules/
/vendor/
/vendor-bin/**/vendor/
/vendor-prefixed/
/includes/vendor/
/includes/composer.json

############
## OSes
Expand Down
27 changes: 23 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": ">=7.4",
"ext-json": "*",
"afragen/wordpress-plugin-readme-parser": "dev-master#c3758599348148be684b3c4ad1105d09b6230d51",
"afragen/wordpress-plugin-readme-parser": "dev-master",
"automattic/vipwpcs": "^3.0.0",
"composer/installers": "^2.2",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
Expand All @@ -27,7 +27,8 @@
"wp-cli/i18n-command": "^2.6",
"wp-cli/entity-command": "^2.8",
"wp-phpunit/wp-phpunit": "^6.3",
"yoast/phpunit-polyfills": "^1.0"
"yoast/phpunit-polyfills": "^1.0",
"bamarni/composer-bin-plugin": "^1.8"
},
"repositories": [
{
Expand Down Expand Up @@ -55,12 +56,20 @@
"composer/installers": true,
"cweagans/composer-patches": false,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"bamarni/composer-bin-plugin": true
},
"platform": {
"php": "7.4"
}
},
"extra": {
"bamarni-bin": {
"bin-links": false,
"target-directory": "vendor-bin",
"forward-command": false
}
},
"scripts": {
"behat": "BEHAT_FEATURES_FOLDER=tests/behat/features run-behat-tests",
"behat-rerun": "BEHAT_FEATURES_FOLDER=tests/behat/features rerun-behat-tests",
Expand All @@ -69,7 +78,17 @@
"phpmd": "phpmd . text phpmd.xml",
"phpstan": "phpstan analyse --memory-limit=2048M",
"prepare-behat-tests": "install-package-tests",
"test": "phpunit"
"test": "phpunit",
"prefix-dependencies": [
"vendor-bin/php-scoper/vendor/bin/php-scoper add-prefix --output-dir=./vendor-prefixed --force --quiet",
"echo '{ \"autoload\": { \"classmap\": [\"\"], \"exclude-from-classmap\": [\"vendor\\/squizlabs//\", \"vendor\\/automattic//\"] } }' > ./vendor-prefixed/composer.json",
"@composer dump-autoload --working-dir ./vendor-prefixed --no-dev --classmap-authoritative",
"sed -i'.bak' -e 's/Composer\\\\Autoload/Plugin_Check_Composer\\\\Autoload/' vendor-prefixed/vendor/composer/*.php",
"rm -rf vendor-prefixed/vendor/composer/*.php.bak",
"echo '{ \"autoload\": { \"classmap\": [\"\"] } }' > ./includes/composer.json",
"@composer dump-autoload --working-dir ./includes --no-dev --classmap-authoritative",
"sed -i'.bak' -e 's/Composer\\\\Autoload/Plugin_Check_Composer\\\\Autoload/' includes/vendor/composer/*.php && rm -rf includes/vendor/composer/*.php.bak"
]
},
"scripts-descriptions": {
"behat": "Run functional tests",
Expand Down
Loading
Loading