Skip to content
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

Drop support for Composer v1.x #230

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 0 additions & 14 deletions .github/workflows/integrationtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,17 @@ jobs:
- '8.4'
- '8.5'
composer:
- 'v1'
- 'v2'
os:
- 'ubuntu-latest'
- 'windows-latest'

exclude:
# Exclude a particularly problematic build.
# @link https://github.com/PHPCSStandards/composer-installer/issues/181
- php: '5.5'
composer: 'v1'
os: 'windows-latest'
# Installing on Windows with PHP 5.4 runs into all sorts of problems (which are not ours).
# Considering PHP 5.4 is ancient, I deem it acceptable to exclude the Windows PHP 5.4 builds.
# @link https://github.com/PHPCSStandards/composer-installer/pull/213
- php: '5.4'
os: 'windows-latest'
# Composer 1.x is no longer supported and while Composer 2.2 is an LTS version, the LTS
# is only for critical bugs and security issues, not for supporting new PHP versions.
# In practice, this means that Composer 1.x and 2.2 are not compatible with PHP 8.4 and later.
# @link https://github.com/composer/composer/issues/10340
- php: '8.4'
composer: 'v1'
- php: '8.5'
composer: 'v1'

include:
# Composer 2.3 drops support for PHP < 7.2, so for PHP 5.4 to 7.1, `v2` will install
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,22 @@ jobs:
- '7.2'
- 'latest'
composer:
- 'v1'
# Note: for PHP 5.4 - 7.1, "v2" will install Composer 2.2.
# For PHP 7.2+, it will install Composer "latest".
- 'v2'
os:
- 'ubuntu-latest'
- 'windows-latest'

# Installing on Windows with PHP 5.4 runs into all sorts of problems (which are not ours).
# Exclude the Windows PHP 5.4 builds and replace them with PHP 5.5/5.6 for the same.
# Exclude the Windows PHP 5.4 builds and replace them with PHP 5.5 for the same.
# @link https://github.com/PHPCSStandards/composer-installer/issues/181
# @link https://github.com/PHPCSStandards/composer-installer/pull/213
exclude:
- php: '5.4'
os: 'windows-latest'
include:
- php: '5.5'
composer: 'v2'
os: 'windows-latest'
- php: '5.6'
composer: 'v1'
os: 'windows-latest'

name: "Quick test"
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ Even better: You could submit a pull request with a fix / new feature!
### (Code) Quality checks

Every merge-request triggers a build process which runs various checks to help
maintain a quality standard. All JSON, Markdown, PHP, and Yaml files are
maintain a quality standard. All JSON, Markdown, PHP, and Yaml files are
expected to adhere to these quality standards.

These tools fall into two categories: PHP and non-PHP.

### PHP
### PHP

The PHP specific tools used by this build are:

Expand Down Expand Up @@ -99,7 +99,7 @@ In case the test setup has trouble locating your `composer.phar` file:
</php>
```
**Note**: this setting also allows for locally testing with different versions of Composer.
You could, for instance, have multiple Composer Phar files locally, `composer1.phar`, `composer2.1.phar`, `composer2.2.phar`.
You could, for instance, have multiple Composer Phar files locally, `composer.phar`, `composer2.2.phar`, `composer2.6.phar`.
By changing the path in the value of this `env` setting, you can switch which version will be used in the tests.

### Non-PHP
Expand All @@ -112,7 +112,7 @@ The non-PHP specific tools used by this build are:

These tools are also run as [GitHub actions][].
All the checks can be run locally using [`act`][].
Alternatively they can be run using `docker run`, as all checks use Docker
Alternatively they can be run using `docker run`, as all checks use Docker
images provided by [Pipeline-Component][].

Finally, they could be run locally using NodeJS, Ruby, PHP, or whatever the tool
Expand Down
7 changes: 4 additions & 3 deletions README.md
fredden marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Installation can be done with [Composer][composer], by requiring this package as
composer require --dev dealerdirect/phpcodesniffer-composer-installer:"^1.0"
```

When using Composer 2.2 or higher, Composer will [ask for your permission](https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution) to allow this plugin to execute code. For this plugin to be functional, permission needs to be granted.
Since Composer 2.2, Composer will [ask for your permission](https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution) to allow this plugin to execute code. For this plugin to be functional, permission needs to be granted.

When permission has been granted, the following snippet will automatically be added to your `composer.json` file by Composer:
```json
Expand All @@ -36,7 +36,7 @@ When permission has been granted, the following snippet will automatically be ad
}
```

When using Composer < 2.2, you can add the permission flag ahead of the upgrade to Composer 2.2, by running:
You can safely add the permission flag (to avoid Composer needing to ask), by running:
```bash
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
```
Expand All @@ -48,7 +48,7 @@ That's it.
This plugin is compatible with:

- PHP **5.4+**, **7.x**, and **8.x** (Support for PHP v8 is available since [`v0.7.0`][v0.7])
- [Composer][composer] **1.x** and **2.x** (Support for Composer v2 is available since [`v0.7.0`][v0.7])
- [Composer][composer] **2.2+** (Support for Composer v2 is available since [`v0.7.0`][v0.7]; support for Composer < 2.2 was dropped in [`v1.1.0`][v1.1])
- [PHP_CodeSniffer][codesniffer] **2.x** and **3.x** (Support for PHP_CodeSniffer v3 is available since [`v0.4.0`][v0.4])

### How it works
Expand Down Expand Up @@ -283,3 +283,4 @@ THE SOFTWARE.
[using-composer-plugins]: https://getcomposer.org/doc/articles/plugins.md#using-plugins
[v0.4]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v0.4.0
[v0.7]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v0.7.0
[v1.1]: https://github.com/PHPCSStandards/composer-installer/releases/tag/v1.1.0
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
},
fredden marked this conversation as resolved.
Show resolved Hide resolved
"require": {
"php": ">=5.4",
"composer-plugin-api": "^1.0 || ^2.0",
"composer-plugin-api": "^2.2",
Copy link
Member

@jrfnl jrfnl Jan 15, 2025

Choose a reason for hiding this comment

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

For the record - as I had to double-check this myself:

The plugin API does follow the same major version as Composer has, but does NOT necessarily align to the same minors.

The current version of the composer-plugin-api is 2.6.0 while the Composer package itself is at 2.8.4. See:
https://github.com/composer/composer/blob/f5e7a8390d700d09c87ae2ed79d5aea1e4153cd3/src/Composer/Plugin/PluginInterface.php#L35

However, in this specific case, the versions happen to line up for the 2.2.0 version of Composer (so all good ✔️ ):
https://github.com/composer/composer/blob/e174a4c4324f50a6f2de472aa1055c24a2fe2b2a/src/Composer/Plugin/PluginInterface.php#L35

"squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
},
"require-dev": {
"ext-json": "*",
"ext-zip": "*",
"composer/composer": "*",
"composer/composer": "^2.2",
"phpcompatibility/php-compatibility": "^9.0",
"php-parallel-lint/php-parallel-lint": "^1.3.1",
"yoast/phpunit-polyfills": "^1.0"
Expand Down
12 changes: 0 additions & 12 deletions tests/IntegrationTest/BaseLineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ public function testBaseLineGlobal($phpcsVersion, $expectedStnds)
*/
public function testBaseLineLocal($phpcsVersion, $expectedStnds)
{
if (
$phpcsVersion === PHPCSVersions::MASTER
&& \CLI_PHP_MINOR === '5.5'
&& $this->onWindows() === true
&& substr(\COMPOSER_VERSION, 0, 1) === '1'
) {
$this->markTestSkipped(
'Composer 1.x on Windows with PHP 5.5 does run the plugin when there are no external standards,'
. ' but doesn\'t consistently show this in the logs'
);
}

$config = $this->composerConfig;
$config['require-dev']['squizlabs/php_codesniffer'] = $phpcsVersion;

Expand Down
21 changes: 6 additions & 15 deletions tests/IntegrationTest/InstallUpdateEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function testPluginRunsOnReinstall()
}

/**
* Test that the plugin runs (or doesn't run) when Composer is invoked with the --no-scripts argument.
* Test that the plugin runs when Composer is invoked with the --no-scripts argument.
*
* Note: the behaviour of Composer changed in 2.1.2. Prior to that, `--no-scripts` would
Copy link
Member

Choose a reason for hiding this comment

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

I think this "Note" can now be removed as well (as it's no longer relevant).

Copy link
Member Author

Choose a reason for hiding this comment

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

I kept this because it explains why the test exists. Should we instead drop the whole test?

Copy link
Member

Choose a reason for hiding this comment

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

Understood and no, let's keep the test as it has value either way.

* also stop plugins from running. As of Composer 2.1.2, `--no-scripts` and `--no-plugins`
Expand All @@ -198,20 +198,11 @@ public function testPluginRunsOnInstallWithNoScripts()

$this->assertSame(0, $result['exitcode'], 'Exitcode for composer install did not match 0');

if (version_compare(\COMPOSER_VERSION, '2.1.2', '>=') === true) {
$this->assertStringContainsString(
Plugin::MESSAGE_RUNNING_INSTALLER,
$result['stdout'],
'Output from running Composer install missing expected contents.'
);
} else {
// Composer 1.x.
$this->assertStringNotContainsString(
Plugin::MESSAGE_RUNNING_INSTALLER,
$result['stdout'],
'Output from running Composer install contains unexpected contents.'
);
}
$this->assertStringContainsString(
Plugin::MESSAGE_RUNNING_INSTALLER,
$result['stdout'],
'Output from running Composer install missing expected contents.'
);
}

/**
Expand Down
30 changes: 6 additions & 24 deletions tests/IntegrationTest/RemovePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,24 +56,6 @@ protected function tear_down()
$this->removeTestEnvironment();
}

/**
* Helper method to get the stdout expectation for when the plugin is uninstalled.
*
* As of Composer 2.0.0, plugins which have been uninstalled will not run anymore
* after the uninstall (which is good).
* It is unclear which particular change this can be attributed to.
*
* @return string
*/
private function getUninstallStdOutExpectation()
{
if (strpos(\COMPOSER_VERSION, '1') === 0) {
return Plugin::MESSAGE_PLUGIN_UNINSTALLED;
}

return '';
}

/**
* Test the plugin doesn't exit with a non-0 exit code and doesn't throw errors when PHPCS and the plugin
* were installed via --dev and a no-dev install is run, which removes the plugin and PHPCS.
Expand Down Expand Up @@ -101,7 +83,7 @@ public function testRemovePHPCSViaNoDevGlobal()
$this->assertExecute(
'composer global install --no-dev -v --no-ansi',
0, // Expected exit code.
$this->getUninstallStdOutExpectation(), // Expected stdout.
null, // No stdout expectation.
null, // No stderr expectation.
'Uninstall by switching to no-dev did not meet expectations.'
);
Expand Down Expand Up @@ -133,7 +115,7 @@ public function testRemovePHPCSViaNoDevLocal()
$this->assertExecute(
sprintf('composer install --no-dev -v --no-ansi --working-dir=%s', escapeshellarg(static::$tempLocalPath)),
0, // Expected exit code.
$this->getUninstallStdOutExpectation(), // Expected stdout.
null, // No stdout expectation.
null, // No stderr expectation.
'Uninstall by switching to no-dev did not meet expectations.'
);
Expand Down Expand Up @@ -166,7 +148,7 @@ public function testRemovePHPCSViaDevUninstallGlobal()
$this->assertExecute(
'composer global remove --dev phpcs-composer-installer/multistandard -v --no-ansi',
0, // Expected exit code.
$this->getUninstallStdOutExpectation(), // Expected stdout.
null, // No stdout expectation.
null, // No stderr expectation.
'Uninstall of dev dependency did not meet expectations.'
);
Expand Down Expand Up @@ -203,7 +185,7 @@ public function testRemovePHPCSViaDevUninstallLocal()
$this->assertExecute(
$command,
0, // Expected exit code.
$this->getUninstallStdOutExpectation(), // Expected stdout.
null, // No stdout expectation.
null, // No stderr expectation.
'Uninstall of dev dependency did not meet expectations.'
);
Expand Down Expand Up @@ -236,7 +218,7 @@ public function testRemovePHPCSViaNoDevUninstallGlobal()
$this->assertExecute(
'composer global remove phpcs-composer-installer/multistandard -v --no-ansi',
0, // Expected exit code.
$this->getUninstallStdOutExpectation(), // Expected stdout.
null, // No stdout expectation.
null, // No stderr expectation.
'Uninstall of no-dev dependency did not meet expectations.'
);
Expand Down Expand Up @@ -273,7 +255,7 @@ public function testRemovePHPCSViaNoDevUninstallLocal()
$this->assertExecute(
$command,
0, // Expected exit code.
$this->getUninstallStdOutExpectation(), // Expected stdout.
null, // No stdout expectation.
null, // No stderr expectation.
'Uninstall of no-dev dependency did not meet expectations.'
);
Expand Down
8 changes: 0 additions & 8 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,6 @@ protected static function writeComposerJsonFile($config, $directory)
$config['config']['allow-plugins']['dealerdirect/phpcodesniffer-composer-installer'] = true;
}

/*
* Disable TLS when on Windows with Composer 1.x and PHP 5.4.
* @link https://github.com/composer/composer/issues/10495
*/
if (static::onWindows() === true && \CLI_PHP_MINOR === '5.4' && strpos(\COMPOSER_VERSION, '1') === 0) {
$config['config']['disable-tls'] = true;
}

$encoded = json_encode($config, \JSON_UNESCAPED_SLASHES | \JSON_PRETTY_PRINT);
if (json_last_error() !== \JSON_ERROR_NONE || $encoded === false) {
throw new RuntimeException('Provided configuration can not be encoded to valid JSON');
Expand Down
Loading