Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Normalize composer.json file#226

Open
ghostwriter wants to merge 4 commits intoPHPCSStandards:stablePHPCSStandards/PHPCSDevTools:stablefrom
ghostwriter:oss/composer/normalize-composer-json-fileghostwriter/PHPCSDevTools:oss/composer/normalize-composer-json-fileCopy head branch name to clipboard
Open

Normalize composer.json file#226
ghostwriter wants to merge 4 commits intoPHPCSStandards:stablePHPCSStandards/PHPCSDevTools:stablefrom
ghostwriter:oss/composer/normalize-composer-json-fileghostwriter/PHPCSDevTools:oss/composer/normalize-composer-json-fileCopy head branch name to clipboard

Conversation

@ghostwriter
Copy link
Copy Markdown

Reformat and normalize composer.json.

Add @phpunit and @xdebug composer scripts (setting XDEBUG_MODE=coverage) and update test scripts to enable coverage in future PRs.

@jrfnl
Copy link
Copy Markdown
Member

jrfnl commented Apr 22, 2026

@ghostwriter Would you mind rebasing this PR on stable and changing the base branch of this PR ? (if you change the PR base branch before force-pushing, the CI should work correctly).

Sorry about that, but doing a file rewrite like this only in develop will make any up-merges pretty difficult.

@jrfnl jrfnl added this to the 1.x Next milestone Apr 22, 2026
@ghostwriter ghostwriter changed the base branch from develop to stable April 22, 2026 17:27
@ghostwriter ghostwriter changed the base branch from stable to develop April 22, 2026 17:30
@ghostwriter ghostwriter force-pushed the oss/composer/normalize-composer-json-file branch from 89e2008 to 3472734 Compare April 22, 2026 17:42
@ghostwriter ghostwriter changed the base branch from develop to stable April 22, 2026 17:43
Reformat and normalize `composer.json`.

Add `@phpunit` and `@xdebug` scripts (setting `XDEBUG_MODE=coverage`) and update test scripts to enable coverage in future PRs.

Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
@ghostwriter ghostwriter force-pushed the oss/composer/normalize-composer-json-file branch from 3472734 to 53ca0bb Compare April 22, 2026 17:59
Copy link
Copy Markdown
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghostwriter Thanks for this PR.

I've left a few small notes inline, but mostly looking good.

Comment thread composer.json
Comment on lines +47 to 51
"autoload": {
"psr-4": {
"PHPCSDevTools\\Scripts\\": "Scripts/"
}
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I wonder why nobody complained about that being missing before. Then again, I can see it's working in PHPCSExtra without this, so 🤷🏻‍♀️ .

In develop, the "feature complete" feature has been refactored and includes the autoload section, as well as a custom autoload file: devtools-autoload.php

I currently can't think of a good reason not to add it for stable too (though there must have been a reason I didn't before 😉 ).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I wonder why nobody complained about that being missing before. Then again, I can see it's working in PHPCSExtra without this, so 🤷🏻‍♀️ .

Because you were manually requiring the class files in bin/phpcs-check-feature-completeness.

// Presume git clone.
require_once __DIR__ . '/../Scripts/FileList.php';
require_once __DIR__ . '/../Scripts/CheckSniffCompleteness.php';

In develop, the "feature complete" feature has been refactored and includes the autoload section, as well as a custom autoload file: devtools-autoload.php

I currently can't think of a good reason not to add it for stable too (though there must have been a reason I didn't before 😉 ).

I will add the devtools-autoload.php file and let composer autoload it.

"autoload": {
    "psr-4": {
        "PHPCSDevTools\\Scripts\\": "Scripts/"
    },
    "files": [
        "devtools-autoload.php"
    ]
},

Copy link
Copy Markdown
Member

@jrfnl jrfnl Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I wonder why nobody complained about that being missing before. Then again, I can see it's working in PHPCSExtra without this, so 🤷🏻‍♀️ .

Because you were manually requiring the class files in bin/phpcs-check-feature-completeness.

But that was only supposed to happen if there was no Composer autoload.php.

I currently can't think of a good reason not to add it for stable too (though there must have been a reason I didn't before 😉 ).

I will add the devtools-autoload.php file and let composer autoload it.

No, please don't. I'm okay with adding the autoload section. It shouldn't do any harm. Any further autoloading changes are for the develop branch. I don't want us to miss anything and break stable.

Copy link
Copy Markdown
Author

@ghostwriter ghostwriter Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I wonder why nobody complained about that being missing before. Then again, I can see it's working in PHPCSExtra without this, so 🤷🏻‍♀️ .

Because you were manually requiring the class files in bin/phpcs-check-feature-completeness.

But that was only supposed to happen if there was no Composer autoload.php.

yes, which is always the case here.

The is_file(__DIR__ . '/../autoload.php') check always returns false.

if (is_file(__DIR__ . '/../autoload.php') === true) {
// Installed via Composer.
require_once __DIR__ . '/../autoload.php';
} else {
// Presume git clone.
require_once __DIR__ . '/../Scripts/FileList.php';
require_once __DIR__ . '/../Scripts/CheckSniffCompleteness.php';
}

This:

__DIR__ . '/../autoload.php'

resolves to:

/Volumes/workspace/OSS/PHPCSStandards/PHPCSDevTools/autoload.php

not:

/Volumes/workspace/OSS/PHPCSStandards/PHPCSDevTools/vendor/autoload.php


Globally: ~/.composer/vendor/autoload.php
Current Project: ./../vendor/autoload.php
Relative path to another project: ./../../vendor/autoload.php

When Composer autoloads bins, it sets $_composer_autoload_path.

image

I usually fall back to:

$_composer_autoload_path ?? implode(DIRECTORY_SEPARATOR, [dirname(__DIR__), 'vendor', 'autoload.php'])

it works cross-platform.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread composer.json Outdated
Comment on lines +67 to +105
"@php ./vendor/phpunit/phpunit/phpunit"
"@phpunit"
],
"test-sniff": [
"@php ./vendor/phpunit/phpunit/phpunit --testsuite DebugSniff"
"@phpunit --testsuite DebugSniff"
],
"test-tools": [
"@php ./vendor/phpunit/phpunit/phpunit --testsuite DevTools"
"@phpunit --testsuite DevTools"
],
"test-lte9": [
"@php ./vendor/phpunit/phpunit/phpunit -c phpunitlte9.xml.dist"
"@phpunit -c phpunitlte9.xml.dist"
],
"test-sniff-lte9": [
"@php ./vendor/phpunit/phpunit/phpunit -c phpunitlte9.xml.dist --testsuite DebugSniff"
"@phpunit -c phpunitlte9.xml.dist --testsuite DebugSniff"
],
"test-tools-lte9": [
"@php ./vendor/phpunit/phpunit/phpunit -c phpunitlte9.xml.dist --testsuite DevTools"
"@phpunit -c phpunitlte9.xml.dist --testsuite DevTools"
],
"check-complete": [
"@php ./bin/phpcs-check-feature-completeness ./PHPCSDebug"
],
"phpunit": [
"@xdebug",
"@php ./vendor/phpunit/phpunit/phpunit"
],
"xdebug": [
"@putenv XDEBUG_MODE=coverage"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you are making this change at this time ?

As things are, there is no code coverage set up in the PHPUnit config files, so code coverage isn't (and shouldn't be) run at this time. It feels like this doesn't belong in this PR ?


For when code coverage does get set up and enabled in CI:
I tend to default to the test* scripts being the ones running without code-coverage (and with the --no-coverage flag) and having separate coverage* scripts (with the same suffixes) for running the same commands with code coverage.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record - I did test the script changes on Windows and see no blockers for adding this change at a later point when it becomes relevant.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why you are making this change at this time ?

As things are, there is no code coverage set up in the PHPUnit config files, so code coverage isn't (and shouldn't be) run at this time. It feels like this doesn't belong in this PR ?

Agreed, this doesn't belong in this PR.

For when code coverage does get set up and enabled in CI: I tend to default to the test* scripts being the ones running without code-coverage (and with the --no-coverage flag) and having separate coverage* scripts (with the same suffixes) for running the same commands with code coverage.

I'll make a note of this, thanks.

ghostwriter and others added 3 commits April 22, 2026 20:40
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
Co-Authored-By: Juliette <663378+jrfnl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.