You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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
.github Update PHPStan and remove ignore 3 years ago
bin Register ErrorHandler early to catch deprecation notices while the Application is being initialized 3 years ago
doc Highlight the proprietary license trick 3 years ago
phpstan DiagnoseCommand - fix PHPDoc (#9991) 3 years ago
res Add "symlink" option for "bin-compat" config (#9959) 3 years ago
src PHP 8.1: prevent a "null to non-nullable" deprecation notice 3 years ago
tests Url: fix sanitize for new github tokens (#10048) 3 years ago
.editorconfig Enhancement: Add .editorconfig 6 years ago
.gitattributes Update HTTP URLs to their HTTPS if they already redirect automatically 4 years ago
.gitignore Fix EOL of text files (#9877) 3 years ago
.php_cs Uses config data from Composer object whenever possible on ArchiveCommand 4 years ago
CHANGELOG.md Update changelog 3 years ago
CODE_OF_CONDUCT.md Add coc file to appease the github UI 4 years ago
LICENSE lets avoid silly commits in the future 8 years ago
PORTING_INFO Import initial partial port of the libzypp satsolver. 13 years ago
README.md Update community section of readme 3 years ago
UPGRADE-2.0.md Escape special characters in Markdown files 4 years ago
composer.json More fixes for php8.1 deprecations 3 years ago
composer.lock Update to xdebug-handler 2.0.2 (#10047) 3 years ago
phpunit.xml.dist Prevent cache gc from happening during test suite runs, and add output so it is clear why it is blocking for a bit 3 years ago

README.md

Composer - Dependency Management for PHP

Composer helps you declare, manage, and install dependencies of PHP projects.

See https://getcomposer.org/ for more information and documentation.

Continuous Integration

Installation / Usage

Download and install Composer by following the official instructions.

For usage, see the documentation.

Packages

Find packages on Packagist.

Community

Follow @packagist or @seldaek on Twitter for announcements, or check the #composerphp hashtag.

For support, Stack Overflow offers a good collection of Composer related questions, or you can use the GitHub discussions.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project and its community you agree to abide by those terms.

Requirements

PHP 5.3.2 or above (at least 5.3.4 recommended to avoid potential bugs)

Authors

See also the list of contributors who participated in this project.

Security Reports

Please send any sensitive issue to security@packagist.org. Thanks!

License

Composer is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments