Skip to content

Commit

Permalink
Drop support for Composer v1.x
Browse files Browse the repository at this point in the history
Composer themselves will no longer support version 1.x beyond 1st August 2025.
Composer version 2.0 was released in October 2020, which is more than four
years ago. Anyone wanting to use this plug-in with Composer v1.x can use any
existing version.

https://blog.packagist.com/composer-2-0-is-now-available/
https://blog.packagist.com/deprecating-composer-1-support/
https://blog.packagist.com/shutting-down-packagist-org-support-for-composer-1-x/
  • Loading branch information
fredden committed Jan 14, 2025
1 parent 9711529 commit 0df962b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 66 deletions.
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.x**
- [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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"require": {
"php": ">=5.4",
"composer-plugin-api": "^1.0 || ^2.0",
"composer-plugin-api": "^2.0",
"squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0"
},
"require-dev": {
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
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

0 comments on commit 0df962b

Please sign in to comment.