Skip to content

Commit

Permalink
Merge branch 'update'
Browse files Browse the repository at this point in the history
  • Loading branch information
lkrms committed Jan 27, 2025
2 parents 38bded1 + 4395ff1 commit 627ba8d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 47 deletions.
84 changes: 42 additions & 42 deletions composer.lock

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

2 changes: 1 addition & 1 deletion scripts/update-fixture-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$indexPath = FormatterTest::getIndexFixturePath();
/** @var array<int,string[]> */
$index = file_exists($indexPath)
? Json::parseObjectAsArray(File::getContents($indexPath))
? Json::objectAsArray(File::getContents($indexPath))
: [];

// Do nothing if a PHP version is missing from the index, otherwise remove any
Expand Down
2 changes: 1 addition & 1 deletion scripts/update-out-fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
$indexPath = FormatterTest::getIndexFixturePath();
/** @var array<int,string[]> */
$index = file_exists($indexPath)
? Json::parseObjectAsArray(File::getContents($indexPath))
? Json::objectAsArray(File::getContents($indexPath))
: [];

$invalid = array_keys($invalid);
Expand Down
11 changes: 10 additions & 1 deletion src/App/PrettyPHPCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ public function getDescription(): string
return 'Format a PHP file';
}

/**
* @inheritDoc
*/
protected function canRunAsRoot(): bool
{
// Allow the command to run in containers that elevate privileges
return true;
}

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -1342,7 +1351,7 @@ private function getConfigValues(string $filename, bool $pristine = false): arra
}

try {
$config = Json::parseObjectAsArray($json);
$config = Json::objectAsArray($json);
} catch (JsonException $ex) {
throw new InvalidConfigurationException(sprintf(
'Invalid JSON in configuration file: %s (%s)',
Expand Down
2 changes: 1 addition & 1 deletion src/Rule/NormaliseStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function processTokens(array $tokens): void
$double = addcslashes($string, "\0..\t\v\f\x0e..\x1f\$\\{$escape}");

// Convert ignorable code points to "\u{xxxx}" unless they belong to
// an extended grapheme cluster, i.e. a recognised Unicode sequence
// an extended grapheme cluster
$utf8Escapes = 0;
if ($utf8) {
$double = Regex::replaceCallback(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ private static function doGetFiles(string $format, bool $all = false): Generator
$index = [];
if (!$all && is_file($indexPath = self::getIndexFixturePath())) {
/** @var array<int,string[]> */
$index = Json::parseObjectAsArray(File::getContents($indexPath));
$index = Json::objectAsArray(File::getContents($indexPath));
$index = $index[\PHP_VERSION_ID - \PHP_VERSION_ID % 100] ?? [];
$index = array_fill_keys($index, true);
}
Expand Down

0 comments on commit 627ba8d

Please sign in to comment.