10934 Commits (9fde6ec88bc91cfbf91b5ecb66cffe16a56425c1)
 

Author SHA1 Message Date
Jordi Boggiano 6aa2d15868
Introduce ProcessExecutorMock to fix deprecations and amount of mocking pain 3 years ago
Jordi Boggiano 5062619046
Fix deprecation warnings with strpos receiving null 3 years ago
Jordi Boggiano 0b09e08f4b
Fix direct deprecations 3 years ago
Jordi Boggiano 20b7e395b4
Fail tests when deprecations are triggered in the code, refs #10038 3 years ago
Jordi Boggiano c5a02a2b58
Fix return value of ProcessExecutor::getErrorOutput, closes #10054 3 years ago
Jordi Boggiano cac4c190f1
Merge pull request #10053 from jrfnl/feature/php-8.1-null-to-non-nullable-fix-2
PHP 8.1: prevent a "null to non-nullable" deprecation notice [2] (test only fix)
3 years ago
Jordi Boggiano 052065028f
Merge pull request #10051 from jrfnl/feature/php-8.1-null-to-non-nullable-fix-1
PHP 8.1: prevent a "null to non-nullable" deprecation notice [1]
3 years ago
Jordi Boggiano 3dcc6c1514
Make return value explicit 3 years ago
Jordi Boggiano 9708f4568f
Merge pull request #10055 from jrfnl/feature/php-8.1-fix-missing-mock-expectation
PHP 8.1/LibraryInstallerTest: add missing mock expectation
3 years ago
Jordi Boggiano cfe718fa43
Fix usage of getRequiredPackage, closes #10052 3 years ago
Jordi Boggiano b232ee6663
Fix test 3 years ago
Jordi Boggiano 8ce0ea300e
Fix pear repo preventing self-update from functioning, fixes #10049 3 years ago
Jordi Boggiano a72784c4da
Merge pull request #10057 from nicholsonjf/docs-double-pipe-note
Note in docs about how single pipes are treated
3 years ago
Jordi Boggiano 5c201687e5
Fix 7zip issues on windows when mixing forward and backslashes, fixes #10058 3 years ago
Jordi Boggiano b7bb7718fb
Merge pull request #10060 from goodjack/update-plugin-api-version-2.1.0
Update the Composer plugin API version to 2.1.0
3 years ago
Jordi Boggiano 91a1a471db
Fix path repo bug causing symlinks to be left behind when uninstalling, fixes #10023 3 years ago
Jordi Boggiano d465df434c
Make sure diagnose command can run without proc_open, refs #9253 3 years ago
Jordi Boggiano 60fe67086e
Make sure proc_open is not required for basic installs, refs #9253 3 years ago
Jordi Boggiano d6f4111f35
Fix php 5.3 support 3 years ago
Jordi Boggiano 46f2d9de48
Fix php 5.3 support 3 years ago
Jordi Boggiano ddd7920d2a
Fix corrupt archives in cache from getting the installs stuck forever, and make sure it fails only once, fixes #10028 3 years ago
Jordi Boggiano e49f24e355
Switch phar signatures to sha512 3 years ago
小克 d9a94b376a
Update the Composer plugin API version to 2.1.0 3 years ago
James Nicholson 2d79f3381b Single pipe note 3 years ago
Jordi Boggiano 4da1a2d43a
Merge pull request #10050 from jrfnl/feature/10037-classmapgenerator-bug-fixes
ClassMapGenerator: fix two bugs (long heredocs + markers in text)
3 years ago
jrfnl 7004e0d031 PHP 8.1/LibraryInstallerTest: add missing mock expectation
The `LibraryInstallerTest::testUninstall()` method mocks a `Package` object, but did not set an expectation for a call to `getName()`, while that method _is_ called in the `LibraryInstaller::uninstall()` method.

Without expectation, the mock returns `null`, which was subsequently being passed on to `strpos()` leading to the below error.

Fixes:
```
Deprecation triggered by Composer\Test\Installer\LibraryInstallerTest::testUninstall:
strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated

Stack trace:
0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 202)
1 src/Composer/Installer/LibraryInstaller.php(202): strpos(NULL, '...')
2 vendor/react/promise/src/FulfilledPromise.php(28): Composer\Installer\LibraryInstaller->Composer\Installer\{closure}(NULL)
3 src/Composer/Installer/LibraryInstaller.php(208): React\Promise\FulfilledPromise->then(Object(Closure))
4 tests/Composer/Test/Installer/LibraryInstallerTest.php(221): Composer\Installer\LibraryInstaller->uninstall(Object(Mock_InstalledRepositoryInterface_e3699f95), Object(Mock_Package_e4571076))
...
```
3 years ago
jrfnl 7022ceb0a6 PHP 8.1: prevent a "null to non-nullable" deprecation notice (test only fix)
Not all tests in the `InstallerTest` class actually create a temporary directory and set the `$this->tempComposerHome` property.

Those tests which didn't, throw a notice in PHP 8.1.

Fixes 3 notices along the lines of:
```
Deprecation triggered by Composer\Test\InstallerTest::tearDown:
is_dir(): Passing null to parameter #1 ($filename) of type string is deprecated

Stack trace:
0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 53)
1 tests/Composer/Test/InstallerTest.php(53): is_dir(NULL)
...
```
3 years ago
jrfnl 609007b072 PHP 8.1: prevent a "null to non-nullable" deprecation notice
Discovered while running the existing unit tests on PHP 8.1.

The default state of the protected `$distUrl` property is "not set" and the property may not be set when the `Package::setSourceDistReferences()` method gets called.

Fixes a total of 9 deprecation notices along the lines of:
```
Deprecation triggered by Composer\Test\DependencyResolver\PoolBuilderTest::testPoolBuilder:
preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated

Stack trace:
0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 597)
1 src/Composer/Package/Package.php(597): preg_match('...', NULL)
2 src/Composer/DependencyResolver/PoolBuilder.php(360): Composer\Package\Package->setSourceDistReferences('...')
3 src/Composer/DependencyResolver/PoolBuilder.php(338): Composer\DependencyResolver\PoolBuilder->loadPackage(Object(Composer\DependencyResolver\Request), Object(Composer\Package\CompletePackage))
4 src/Composer/DependencyResolver/PoolBuilder.php(195): Composer\DependencyResolver\PoolBuilder->loadPackagesMarkedForLoading(Object(Composer\DependencyResolver\Request), Array)
5 src/Composer/Repository/RepositorySet.php(229): Composer\DependencyResolver\PoolBuilder->buildPool(Array, Object(Composer\DependencyResolver\Request))
6 tests/Composer/Test/DependencyResolver/PoolBuilderTest.php(110): Composer\Repository\RepositorySet->createPool(Object(Composer\DependencyResolver\Request), Object(Composer\IO\NullIO))
...
```

Side-note: I'm wondering why `$this->getDistUrl()` is used instead of using the `$distUrl` property. It is a property within the same class after all. Haven't changed it, but did want to raise the question.

Refs:
* https://www.php.net/manual/en/function.preg-match.php
* https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
3 years ago
jrfnl 42c6a0d7c5 ClassMapGenerator: fix the regex
By using a look ahead assertion to match "new line - maybe whitespace - marker", the negative performance impact of the `.*` is significantly mitigated and backtracing will be severely limited.

This fixes the bug as reported in 10037.

The bug was discovered due to a PHP 8.1 "passing null to non-nullable" deprecation notice being thrown, but is not a PHP 8.1 bug.

In actual fact, this issue affected all PHP versions and could lead to incomplete classmaps when the code base contained files with huge heredocs/nowdocs.

The regex change (not completely) incidentally also fixes an issue with markers in a heredoc/nowdoc not being correctly handled. This bug could lead to "classes" being added to the class map which aren't actually classes.

Fixes 10037
3 years ago
jrfnl e729c418dd ClassMapGenerator: add test for "marker in text" bug
In PHP < 7.3, the heredoc/nowdoc marker was allowed to occur in the text, as long as it did not occur at the very start of the line.

This was also not handled correctly.

Ref: https://www.php.net/manual/en/migration73.incompatible.php#migration73.incompatible.core.heredoc-nowdoc
3 years ago
jrfnl 9588654ae3 ClassMapGenerator: add tests for "long heredoc" bug
... to proof the existence of the bug and demonstrate the effect.

Note: in the test the backtrack limit is being lowered (and restored back to the default afterwards) to prevent the tests needing ridiculously huge test fixture files.
3 years ago
Stephan c65bd832d6
Url: fix sanitize for new github tokens (#10048) 3 years ago
Juliette c7d11f361c
PHP 8.1: fix more return type deprecation warnings (#10039)
Follow up on 10008 and the various commits made for that.

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
3 years ago
Juliette f5a0dfeb50
PHP 8.1: fix deprecation warnings about incorrect default values (#10036)
* PHP 8.1/Tests: fix some deprecation warnings

The default value for the `preg_split()` `$limit` parameter is `-1`, not `null`.

Fixes numerous `preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated` notices when running the test suite.

Ref: https://www.php.net/manual/en/function.preg-split.php

* PHP 8.1/NoProxyPattern: fix deprecation warning

The default value for the `preg_split()` `$limit` parameter is `-1`, not `null`.

Fixes some `preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated` notices when running the test suite.

```
Deprecation triggered by Composer\Test\Util\Http\ProxyManagerTest::testGetProxyForRequest:
preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated

Stack trace:
0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 42)
1 src/Composer/Util/NoProxyPattern.php(42): preg_split('...', '...', NULL, 1)
2 src/Composer/Util/Http/ProxyManager.php(148): Composer\Util\NoProxyPattern->__construct('...')
3 src/Composer/Util/Http/ProxyManager.php(50): Composer\Util\Http\ProxyManager->initProxyData()
4 src/Composer/Util/Http/ProxyManager.php(59): Composer\Util\Http\ProxyManager->__construct()
5 tests/Composer/Test/Util/Http/ProxyManagerTest.php(75): Composer\Util\Http\ProxyManager::getInstance()
...
```

Ref: https://www.php.net/manual/en/function.preg-split.php

* PHP 8.1: fix deprecation warnings / http_build_query()

This fixes all relevant calls to the PHP native `http_build_query()` function.
The second parameter of which is the _optional_ `$numeric_prefix` parameter which expects a `string`.

A parameter being optional, however, does not automatically make it nullable.

As of PHP 8.1, passing `null` to a non-nullable PHP native function will generate a deprecation notice.
In this case, these function calls yielded a `http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated` notice.

Changing the `null` to an empty string fixes this without BC-break.

Fixes a few deprecation warnings found when running the tests.

Refs:
* https://www.php.net/manual/en/function.http-build-query.php
* https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

* PHP 8.1: fix deprecation notices / PharData::__construct()

This fixes all relevant calls to the PHP native `PharData::__construct()` method.

The second parameter of this method is the _optional_ `$flags` parameter which expects an `int` of flags to be passed to the `Phar` parent class `RecursiveDirectoryIterator`.
Fixed by passing the default value for the `$flags` parameter as per the `RecursiveDirectoryIterator::__construct()` method.

The third parameter of the method is the _optional_ `$alias` parameter which expects an `string`.
Fixed by passing an empty string.

Fixes various notices along the lines of:
```
Deprecation triggered by Composer\Test\Package\Archiver\ArchiveManagerTest::testArchiveTar:
PharData::__construct(): Passing null to parameter #2 ($flags) of type int is deprecated

Stack trace:
0 [internal function]: Symfony\Bridge\PhpUnit\DeprecationErrorHandler->handleError(8192, '...', '...', 55)
1 src/Composer/Package/Archiver/PharArchiver.php(55): PharData->__construct('...', NULL, NULL, 2)
2 src/Composer/Package/Archiver/ArchiveManager.php(193): Composer\Package\Archiver\PharArchiver->archive('...', '...', '...', Array, false)
3 tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php(65): Composer\Package\Archiver\ArchiveManager->archive(Object(Composer\Package\CompletePackage), '...', '...')
...
```

Refs:
* https://www.php.net/manual/en/phardata.construct.php
* https://www.php.net/manual/en/recursivedirectoryiterator.construct.php

Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
3 years ago
John Stevenson 93f2e5f8fc
Update to xdebug-handler 2.0.2 (#10047) 3 years ago
Jordi Boggiano df99150db6
Pin versions to avoid new dependencies breaking tests 3 years ago
Jordi Boggiano 2665f1b282
Fix private property access, fixes #10022 3 years ago
Jordi Boggiano 2fb53232d1
Fix usage on symfony 2.x, fixes #10022 3 years ago
Jordi Boggiano bbe3769bcd
Update changelog 3 years ago
Jordi Boggiano deb4c48bbc
Avoid using an invalid path for InstalledFilesystemRepo in create-project and use an array repo instead, fixes #10020, fixes #10021 3 years ago
Jordi Boggiano 1f4401005c
Allow default_socket_timeout to extend the curl timeout if it is longer than 300s, fixes #10018 3 years ago
GeoSot e07d2a7bef
Respect parent setting, handling exceptions (#10017) 3 years ago
Jordi Boggiano a5ee2269ef
Update changelog 3 years ago
Jordi Boggiano 2f83338d2f
Fix hopefully last php 8.1 deprecation warnings 3 years ago
Jordi Boggiano 24f5e54fbe
Fix only/exclude to avoid matching names as sub-strings of full package names, fixes #10001 3 years ago
Jordi Boggiano 29a52ff463
Register ErrorHandler early to catch deprecation notices while the Application is being initialized 3 years ago
Jordi Boggiano 5413faec49
Merge pull request #10016 from tdutrion/patch-1
Highlight the proprietary license trick
3 years ago
Jordi Boggiano 2be03f0d60
More fixes for php8.1 deprecations 3 years ago
Thomas Dutrion 82a7c527f9
Highlight the proprietary license trick
From the Symfony Dev #french slack channel (symfony-devs.slack.com), people look confused regarding the value to use as license for proprietary projects, even though it's written in the documentation.

Because proprietary software is still a massive part of composer's usage, I think it can be interesting to have it as a note, more readable to people.

Extract from the conversation:
> J’étais sur la bonne page, il me manquait deux lignes de scroll pour voir ça -.- On a tous nos petits moments de faiblesse

Which roughly translates to:
> I was looking at the right page, just about two lines above... We all have our weak moments
3 years ago
Jordi Boggiano a7efb27338
More php8.1 deprecation fixes, refs #10008 3 years ago