7152 Commits (0761474599f2f813d805d171b16012052a7b2f7e)

Author SHA1 Message Date
Jordi Boggiano 0761474599
Add type info to many properties/methods 3 years ago
Jordi Boggiano fc04c86f82
Add type info to Autoload namespace 3 years ago
Jordi Boggiano 61fba697a0
Fix validating array loader handling of invalid target branch datatype 3 years ago
Jordi Boggiano 024f0eda53
Add a bunch of type info to Util namespace 3 years ago
Jordi Boggiano 8559279025
Merge pull request #10076 from aschempp/bugfix/package-type-update
Correctly resolve promises when package type changes
3 years ago
Jordi Boggiano b8e461ea61
Make sure /proc/version read does not fail the process ever, closes #10080 3 years ago
Jordi Boggiano 0158436fb4
Fix list command not showing plugin commands, fixes #10075 3 years ago
Jordi Boggiano 922ba01d07
Merge pull request #10072 from jrfnl/feature/10067-fix-classmap-regression
ClassMapGenerator: stabilize the heredoc/nowdoc stripping
3 years ago
Jordi Boggiano d8054d1d2f
Add more possessive quantifiers, unicode flag and support for more post-heredoc syntax, fix test file syntax being invalid 3 years ago
Andreas Schempp 0bed60e631 Correctly resolve promises when package type changes 3 years ago
Jordi Boggiano 73c109c561
Make sure that names with wildcards which are not preceded by dots are also seen as package names and not version constraints 3 years ago
Jordi Boggiano 6ab1b6a7d2
Regex simplifications 3 years ago
Jordi Boggiano f6c446bdd7
Tweak to allow matching delimiter within the string 3 years ago
Jordi Boggiano c44be998ab
Undo new stripping code and fix regex 3 years ago
powellblyth 5e75017166
Just some comments with 'it's' that should have been 'its' (#10071)
Co-authored-by: Toby Powell-Blyth <tobypowell-blyth@elasticstage.com>
3 years ago
jrfnl 40bd4b03ad
ClassMapGenerator: stabilize the heredoc/nowdoc stripping
I've looked into 10067 and have come to the conclusion that using a single regex to strip the heredoc/nowdocs is always going to run into trouble as:
* Either the matching will be too greedy (issue 10067);
* Or the matching will run into backtrace limits for large heredoc/nowdocs.

We cannot solve both within a single regex.

So, I'm proposing a slightly different solution which should support both and should also improve performance for files containing large heredoc/nowdocs.

The `stripHereNowDocs()` function will find a start marker and remember the offset of the start marker.
It will then find the end marker and strip the contents between the two (replace with `null`).
The function will then recurse onto itself until all heredocs/nowdocs in a file have been removed.
3 years ago
Jordi Boggiano d3c176ec69
PHPStan Level 5 (#10070)
* Bump PHPStan to level 5

* Update seld/phar-utils to latest

* Add phpstan-setup / phpstan scripts
3 years ago
Jordi Boggiano b583310476
Allow ircs protocol for support.irc 3 years ago
Jordi Boggiano 74b231a4bc
Fix lib-openssl detection on FreeBSD, fixes #10046 3 years ago
Jordi Boggiano 9727adf63b
Fix init performance when plugin commands are not needed, fixes #10064 3 years ago
Jordi Boggiano a586a753df
Fix all remaining php8.1 test suite deprecations 3 years ago
Jordi Boggiano b77fce8a4f
More deprecation fixes by using ProcessExecutorMock and a couple of PackageInterface type fixes 3 years ago
Jordi Boggiano 6aa2d15868
Introduce ProcessExecutorMock to fix deprecations and amount of mocking pain 3 years ago
Jordi Boggiano c5a02a2b58
Fix return value of ProcessExecutor::getErrorOutput, closes #10054 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 cfe718fa43
Fix usage of getRequiredPackage, closes #10052 3 years ago
Jordi Boggiano 8ce0ea300e
Fix pear repo preventing self-update from functioning, fixes #10049 3 years ago
Jordi Boggiano 5c201687e5
Fix 7zip issues on windows when mixing forward and backslashes, fixes #10058 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
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
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
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 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 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 2be03f0d60
More fixes for php8.1 deprecations 3 years ago