Skip to content

Commit

Permalink
Merge branch 'update-3rdparty-fixtures'
Browse files Browse the repository at this point in the history
  • Loading branch information
lkrms committed Jan 20, 2025
2 parents 298b772 + eb5a710 commit 7b1f97a
Show file tree
Hide file tree
Showing 1,863 changed files with 19,951 additions and 2,219 deletions.
34 changes: 17 additions & 17 deletions scripts/update-3rdparty-fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ public function updatePhpDocFixtures(): void
}

$dir = "{$this->TargetRoot}/php-doc";
Console::log('Populating:', $dir);
File::createDir($dir);
File::pruneDir($dir);

foreach ($listings as $source => $sourceListings) {
$dir = "{$this->TargetRoot}/php-doc/$source";
Console::log('Updating:', $dir);
File::createDir($dir);
foreach ($sourceListings as $i => $output) {
$outFile = sprintf('%s/%03d.php', $dir, $i);
Console::logProgress('Creating', substr($outFile, $this->TargetLength));
File::writeContents($outFile, $output);
File::writeContents($outFile, Str::setEol($output, \PHP_EOL));
$this->Replaced++;
}
}
Expand Down Expand Up @@ -181,17 +181,17 @@ public function updatePhpParserFixtures(): void
}

$dir = "{$this->TargetRoot}/php-parser";
Console::log('Populating:', $dir);
File::createDir($dir);
File::pruneDir($dir);

foreach ($listings as $source => $sourceListings) {
$dir = "{$this->TargetRoot}/php-parser/$source";
Console::log('Updating:', $dir);
File::createDir($dir);
foreach ($sourceListings as $i => $output) {
$outFile = sprintf('%s/%03d.php', $dir, $i);
Console::logProgress('Creating', substr($outFile, $this->TargetLength));
File::writeContents($outFile, $output);
File::writeContents($outFile, Str::setEol($output, \PHP_EOL));
$this->Replaced++;
}
}
Expand All @@ -204,7 +204,7 @@ public function updatePhpfmtFixtures(): void
Console::info('Updating phpfmt fixtures');

$dir = "{$this->TargetRoot}/phpfmt";
Console::log('Updating:', $dir);
Console::log('Populating:', $dir);
File::createDir($dir);
File::pruneDir($dir);

Expand Down Expand Up @@ -240,9 +240,10 @@ public function updatePhpfmtFixtures(): void

$count = 0;
foreach ($files as $file => $outFile) {
$code = File::getContents((string) $file);
$outFile = "$dir/" . $outFile;
Console::logProgress('Creating', substr($outFile, $this->TargetLength));
File::copy($file, $outFile);
File::writeContents($outFile, Str::setEol($code, \PHP_EOL));
$count++;
$this->Fixtures++;
$this->Replaced++;
Expand Down Expand Up @@ -299,7 +300,7 @@ public function updatePhpFigFixtures(): void
}

$dir = "{$this->TargetRoot}/php-fig/per";
Console::log('Updating:', $dir);
Console::log('Populating:', $dir);
File::createDir($dir);
File::pruneDir($dir);

Expand Down Expand Up @@ -329,7 +330,7 @@ public function updatePhpFigFixtures(): void
$index++;
$outFile = sprintf('%s/%02d-%s.php', $dir, $index, $heading);
Console::logProgress('Creating', substr($outFile, $this->TargetLength));
File::writeContents($outFile, $listing);
File::writeContents($outFile, Str::setEol($listing, \PHP_EOL));
$this->Replaced++;
}
}
Expand All @@ -341,15 +342,14 @@ public function updateUtf8Fixture(): void
{
Console::info('Updating utf-8 fixture');

$output = <<<'PHP'
<?php
$ascii = "\0\x01\x02\x03\x04\x05\x06\x07\x08\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\e\x1c\x1d\x1e\x1f";
$blank = "\u{00a0}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200a}\u{202f}\u{205f}\u{3000}";
$bom = "\u{feff}";
$ignorable = "\u{00ad}\u{202a}\u{202b}\u{202c}\u{202d}\u{202e}\u{2066}\u{2067}\u{2068}\u{2069}";
$visible = "\u{FE19}";

PHP;
$output = implode(\PHP_EOL, [
'<?php',
'$ascii = "\0\x01\x02\x03\x04\x05\x06\x07\x08\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\e\x1c\x1d\x1e\x1f";',
'$blank = "\u{00a0}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200a}\u{202f}\u{205f}\u{3000}";',
'$bom = "\u{feff}";',
'$ignorable = "\u{00ad}\u{202a}\u{202b}\u{202c}\u{202d}\u{202e}\u{2066}\u{2067}\u{2068}\u{2069}";',
'$visible = "\u{FE19}";',
]) . \PHP_EOL;

Regex::matchAll(
"/\"[^\"]*(?:[\0-\x08\x0e-\x1f\x7f-\xff][^\"]*)+\"/",
Expand Down
10 changes: 8 additions & 2 deletions scripts/update-fixture-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Salient\Cli\CliApplication;
use Salient\Core\Facade\Console;
use Salient\Utility\File;
use Salient\Utility\Inflect;
use Salient\Utility\Json;
use Salient\Utility\Test;

Expand Down Expand Up @@ -36,7 +37,7 @@
foreach ($invalid as $file) {
$file = "$dir/$file";
if (file_exists($file)) {
Console::log('Suppressing', $file);
Console::logProgress('Suppressing', $file);
rename($file, $file . '.invalid');
}
}
Expand All @@ -45,9 +46,14 @@
$index[$version] = array_values(array_diff($files, $invalid));
}

Console::log('Replacing', $indexPath);
Console::logProgress('Replacing', $indexPath);
$json = Json::prettyPrint($index);
File::writeContents($indexPath, $json . \PHP_EOL);

Console::summary(Inflect::format(
$invalid,
'{{#}} {{#:fixture}} removed from testing and fixture index',
), 'successfully', true);
} else {
Console::log('Nothing to do:', $indexPath);
}
4 changes: 2 additions & 2 deletions scripts/update-out-fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
} else {
File::createDir(dirname($outFile));
}
Console::log($message, $outPath);
Console::logProgress($message, $outPath);
File::writeContents($outFile, $output);
$replaced++;
}
Expand All @@ -83,7 +83,7 @@
$index[\PHP_VERSION_ID - \PHP_VERSION_ID % 100] = $invalid;
ksort($index);

Console::log(file_exists($indexPath) ? 'Replacing' : 'Creating', $indexPath);
Console::logProgress(file_exists($indexPath) ? 'Replacing' : 'Creating', $indexPath);
$json = Json::prettyPrint($index);
File::writeContents($indexPath, $json . \PHP_EOL);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/Formatter/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ in/3rdparty/** linguist-generated
out/** linguist-generated
versions.json linguist-generated

in/** text diff
out/** text diff
out/*-psr12/** text eol=lf

**/3rdparty/utf-8.php text diff

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7b1f97a

Please sign in to comment.