Skip to content

Commit

Permalink
PHP 8.1/Tests: fix bugs in test code
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jrfnl committed Aug 5, 2021
1 parent df99150 commit e3c633f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/Composer/Test/AllFunctionalTest.php
Expand Up @@ -181,7 +181,7 @@ public function getTestFiles()

private function parseTestFile($file)
{
$tokens = preg_split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file), null, PREG_SPLIT_DELIM_CAPTURE);
$tokens = preg_split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file), -1, PREG_SPLIT_DELIM_CAPTURE);
$data = array();
$section = null;

Expand Down
2 changes: 1 addition & 1 deletion tests/Composer/Test/DependencyResolver/PoolBuilderTest.php
Expand Up @@ -175,7 +175,7 @@ public function getIntegrationTests()

protected function readTestFile(\SplFileInfo $file, $fixturesDir)
{
$tokens = preg_split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file->getRealPath()), null, PREG_SPLIT_DELIM_CAPTURE);
$tokens = preg_split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file->getRealPath()), -1, PREG_SPLIT_DELIM_CAPTURE);

$sectionInfo = array(
'TEST' => true,
Expand Down
2 changes: 1 addition & 1 deletion tests/Composer/Test/InstallerTest.php
Expand Up @@ -484,7 +484,7 @@ public function loadIntegrationTests($path)

protected function readTestFile(\SplFileInfo $file, $fixturesDir)
{
$tokens = preg_split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file->getRealPath()), null, PREG_SPLIT_DELIM_CAPTURE);
$tokens = preg_split('#(?:^|\n*)--([A-Z-]+)--\n#', file_get_contents($file->getRealPath()), -1, PREG_SPLIT_DELIM_CAPTURE);

$sectionInfo = array(
'TEST' => true,
Expand Down

0 comments on commit e3c633f

Please sign in to comment.