Upgraded to Symfony 6.3 and PHP 8.2.

This commit is contained in:
Klaus Silveira
2023-11-16 22:20:26 -05:00
parent dd98962de9
commit ea0d763394
18 changed files with 1167 additions and 1198 deletions

View File

@@ -7,7 +7,7 @@ jobs:
strategy: strategy:
matrix: matrix:
php: [8.1] php: [8.1, 8.2]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View File

@@ -8,34 +8,11 @@ $finder = PhpCsFixer\Finder::create()
$config = new PhpCsFixer\Config(); $config = new PhpCsFixer\Config();
return $config->setRules([ return $config->setRules([
'@Symfony' => true, '@Symfony' => true,
'@PHP80Migration:risky' => true, 'global_namespace_import' => [
'@PHPUnit84Migration:risky' => true, 'import_classes' => true,
'array_indentation' => true, 'import_constants' => false,
'array_syntax' => ['syntax' => 'short'], 'import_functions' => false,
'blank_line_after_opening_tag' => true, ],
'concat_space' => ['spacing' => 'one'],
'declare_strict_types' => true,
'increment_style' => ['style' => 'post'],
'is_null' => true,
'list_syntax' => ['syntax' => 'short'],
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'method_chaining_indentation' => true,
'modernize_types_casting' => true,
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => false,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'phpdoc_align' => false,
'phpdoc_order' => true,
'php_unit_construct' => true,
'php_unit_dedicate_assert' => true,
'return_assignment' => true,
'single_blank_line_at_eof' => true,
'single_line_comment_style' => true,
'ternary_to_null_coalescing' => true,
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
'void_return' => true,
]) ])
->setRiskyAllowed(true) ->setRiskyAllowed(true)
->setFinder($finder) ->setFinder($finder)

View File

@@ -5,32 +5,32 @@
"type": "project", "type": "project",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"require": { "require": {
"php": "^8.1", "php": ">=8.1",
"ext-iconv": "*", "ext-iconv": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"league/commonmark": "^2.1", "league/commonmark": "^2.4",
"nesbot/carbon": "^2.55", "nesbot/carbon": "^2.71",
"symfony/asset": "^6.0", "symfony/asset": "^6.3",
"symfony/cache": "^6.0", "symfony/cache": "^6.3",
"symfony/console": "^6.0", "symfony/console": "^6.3",
"symfony/form": "^6.0", "symfony/form": "^6.3",
"symfony/framework-bundle": "^6.0", "symfony/framework-bundle": "^6.3",
"symfony/monolog-bundle": "^3.5", "symfony/monolog-bundle": "^3.10",
"symfony/process": "^6.0", "symfony/process": "^6.3",
"symfony/string": "^6.0", "symfony/string": "^6.3",
"symfony/templating": "^6.0", "symfony/templating": "^6.3",
"symfony/translation": "^6.0", "symfony/translation": "^6.3",
"symfony/twig-bundle": "^6.0", "symfony/twig-bundle": "^6.3",
"symfony/webpack-encore-bundle": "^1.13", "symfony/webpack-encore-bundle": "^2.1",
"symfony/yaml": "^6.0" "symfony/yaml": "^6.3"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^3.4", "friendsofphp/php-cs-fixer": "^3.38",
"phpspec/prophecy-phpunit": "^2.0", "phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^1.3", "phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.6",
"symfony/debug-bundle": "^6.0", "symfony/debug-bundle": "^6.3",
"symfony/dotenv": "^6.0" "symfony/dotenv": "^6.3"
}, },
"config": { "config": {
"preferred-install": { "preferred-install": {

2167
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
FROM php:8.1-fpm-alpine FROM php:8.2-fpm-alpine
ENV PHP_EXT_DEPS \ ENV PHP_EXT_DEPS \
gettext=gettext-dev \ gettext=gettext-dev \
@@ -11,6 +11,7 @@ ENV PHP_EXT_DEPS \
RUN set -x; \ RUN set -x; \
apk add --no-cache --virtual .php-extensions-build-dependencies \ apk add --no-cache --virtual .php-extensions-build-dependencies \
$PHPIZE_DEPS \ $PHPIZE_DEPS \
linux-headers \
$(echo ${PHP_EXT_DEPS} | tr ' ' '\n' | cut -d = -f 2) \ $(echo ${PHP_EXT_DEPS} | tr ' ' '\n' | cut -d = -f 2) \
&& apk add --no-cache \ && apk add --no-cache \
$(echo ${PHP_EXT_DEPS} | tr ' ' '\n' | cut -d = -f 1) \ $(echo ${PHP_EXT_DEPS} | tr ' ' '\n' | cut -d = -f 1) \

View File

@@ -58,7 +58,7 @@ class RepositoryExtension extends AbstractExtension
{ {
$parent = dirname($path); $parent = dirname($path);
if ($parent == '.') { if ('.' == $parent) {
return ''; return '';
} }
@@ -72,7 +72,7 @@ class RepositoryExtension extends AbstractExtension
$previousPart = ''; $previousPart = '';
foreach ($parts as $index => $part) { foreach ($parts as $index => $part) {
$previousPart .= ($index == 0 ? '' : '/') . $part; $previousPart .= (0 == $index ? '' : '/').$part;
$breadcrumbs[] = [ $breadcrumbs[] = [
'name' => $part, 'name' => $part,
'commitish' => $this->getCommitish($blob->getHash(), $previousPart), 'commitish' => $this->getCommitish($blob->getHash(), $previousPart),

View File

@@ -66,7 +66,7 @@ class Kernel extends BaseKernel
$confDir = $this->getProjectDir().'/config'; $confDir = $this->getProjectDir().'/config';
$routes->import($confDir.'/routes.yml'); $routes->import($confDir.'/routes.yml');
if ($this->environment == 'dev') { if ('dev' == $this->environment) {
$routes->import($confDir.'/dev/routes.yml'); $routes->import($confDir.'/dev/routes.yml');
} }
} }

View File

@@ -47,7 +47,7 @@ class Repository
return $this->system->getTags($this->repository); return $this->system->getTags($this->repository);
} }
public function getTree(?string $commitish = null): Tree public function getTree(string $commitish = null): Tree
{ {
if (!$commitish) { if (!$commitish) {
return $this->system->getTree($this->repository); return $this->system->getTree($this->repository);
@@ -62,7 +62,7 @@ class Repository
return $this->system->getTree($this->repository, $commitish->getHash()); return $this->system->getTree($this->repository, $commitish->getHash());
} }
public function getCommit(?string $commitish = null): Commit public function getCommit(string $commitish = null): Commit
{ {
if (!$commitish) { if (!$commitish) {
return $this->system->getCommit($this->repository); return $this->system->getCommit($this->repository);
@@ -129,7 +129,7 @@ class Repository
} }
} }
public function searchCommits(Criteria $criteria, ?string $commitish = null): array public function searchCommits(Criteria $criteria, string $commitish = null): array
{ {
if (!$commitish) { if (!$commitish) {
return $this->system->searchCommits($this->repository, $criteria); return $this->system->searchCommits($this->repository, $criteria);

View File

@@ -24,7 +24,7 @@ class Commitish
$this->hash = $rev->getName(); $this->hash = $rev->getName();
$revSuffix = substr($commitish, strlen($this->hash)); $revSuffix = substr($commitish, strlen($this->hash));
if ($revSuffix && ($revSuffix[0] === '@' || $revSuffix[0] === '^' || $revSuffix[0] === '~')) { if ($revSuffix && ('@' === $revSuffix[0] || '^' === $revSuffix[0] || '~' === $revSuffix[0])) {
$this->hash .= strtok($revSuffix, '/'); $this->hash .= strtok($revSuffix, '/');
} }
} }

View File

@@ -40,7 +40,7 @@ class Blob extends Item
{ {
$fileName = strtolower($this->getFileName()); $fileName = strtolower($this->getFileName());
return $fileName == 'readme.md' || $fileName == 'readme.txt'; return 'readme.md' == $fileName || 'readme.txt' == $fileName;
} }
public function getSize(): ?int public function getSize(): ?int

View File

@@ -128,7 +128,7 @@ class Parse
$this->currentHunk->addLine(new Line($line, Line::TYPE_DELETE, $oldNumber, $newNumber)); $this->currentHunk->addLine(new Line($line, Line::TYPE_DELETE, $oldNumber, $newNumber));
$this->currentFile->increaseDeletions(); $this->currentFile->increaseDeletions();
$this->deletedLines++; ++$this->deletedLines;
} }
protected function addedLine(string $line, array $context): void protected function addedLine(string $line, array $context): void
@@ -138,7 +138,7 @@ class Parse
$this->currentHunk->addLine(new Line($line, Line::TYPE_ADD, $oldNumber, $newNumber)); $this->currentHunk->addLine(new Line($line, Line::TYPE_ADD, $oldNumber, $newNumber));
$this->currentFile->increaseAdditions(); $this->currentFile->increaseAdditions();
$this->addedLines++; ++$this->addedLines;
} }
protected function line(string $line): void protected function line(string $line): void
@@ -151,8 +151,8 @@ class Parse
$newNumber = $this->newCounter + $this->addedLines; $newNumber = $this->newCounter + $this->addedLines;
$this->currentHunk->addLine(new Line($line, Line::TYPE_NO_CHANGE, $oldNumber, $newNumber)); $this->currentHunk->addLine(new Line($line, Line::TYPE_NO_CHANGE, $oldNumber, $newNumber));
$this->oldCounter++; ++$this->oldCounter;
$this->newCounter++; ++$this->newCounter;
} }
protected function clearAccumulator(): void protected function clearAccumulator(): void

View File

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace GitList\SCM\Exception; namespace GitList\SCM\Exception;
class InvalidCommitException extends \RuntimeException use RuntimeException;
class InvalidCommitException extends RuntimeException
{ {
} }

View File

@@ -18,17 +18,17 @@ interface System
public function getTags(Repository $repository): array; public function getTags(Repository $repository): array;
public function getTree(Repository $repository, ?string $hash = null): Tree; public function getTree(Repository $repository, string $hash = null): Tree;
public function getRecursiveTree(Repository $repository, ?string $hash = null): Tree; public function getRecursiveTree(Repository $repository, string $hash = null): Tree;
public function getPathTree(Repository $repository, string $path, ?string $hash = null): Tree; public function getPathTree(Repository $repository, string $path, string $hash = null): Tree;
public function getCommit(Repository $repository, ?string $hash = null): Commit; public function getCommit(Repository $repository, string $hash = null): Commit;
public function getCommits(Repository $repository, ?string $hash = null, int $page = 1, int $perPage = 10): array; public function getCommits(Repository $repository, string $hash = null, int $page = 1, int $perPage = 10): array;
public function getCommitsFromPath(Repository $repository, string $path, ?string $hash = null, int $page = 1, int $perPage = 10): array; public function getCommitsFromPath(Repository $repository, string $path, string $hash = null, int $page = 1, int $perPage = 10): array;
public function getSpecificCommits(Repository $repository, array $hashes): array; public function getSpecificCommits(Repository $repository, array $hashes): array;
@@ -36,7 +36,7 @@ interface System
public function getBlob(Repository $repository, string $hash, string $path): Blob; public function getBlob(Repository $repository, string $hash, string $path): Blob;
public function searchCommits(Repository $repository, Criteria $criteria, ?string $hash = null): array; public function searchCommits(Repository $repository, Criteria $criteria, string $hash = null): array;
public function archive(Repository $repository, string $format, string $hash, string $path): string; public function archive(Repository $repository, string $format, string $hash, string $path): string;
} }

View File

@@ -330,12 +330,12 @@ class CommandLine implements System
$file = preg_split('/[\s]+/', $line, 5); $file = preg_split('/[\s]+/', $line, 5);
if ($file[1] == 'commit') { if ('commit' == $file[1]) {
// Don't handle submodules yet // Don't handle submodules yet
continue; continue;
} }
if ($file[0] == '120000') { if ('120000' == $file[0]) {
$symlinkTarget = $this->run(['show', $file[2]], $repository); $symlinkTarget = $this->run(['show', $file[2]], $repository);
$symlink = new Symlink($repository, $file[2]); $symlink = new Symlink($repository, $file[2]);
$symlink->setMode($file[0]); $symlink->setMode($file[0]);
@@ -347,7 +347,7 @@ class CommandLine implements System
continue; continue;
} }
if ($file[1] == 'blob') { if ('blob' == $file[1]) {
$blob = new Blob($repository, $file[2]); $blob = new Blob($repository, $file[2]);
$blob->setMode($file[0]); $blob->setMode($file[0]);
$blob->setName($file[4]); $blob->setName($file[4]);
@@ -396,7 +396,7 @@ class CommandLine implements System
{ {
$xmlStart = strpos($input, '<item>'); $xmlStart = strpos($input, '<item>');
if ($xmlStart === false) { if (false === $xmlStart) {
throw new InvalidCommitException($input); throw new InvalidCommitException($input);
} }
@@ -429,10 +429,10 @@ class CommandLine implements System
$commit->setCommitedAt(new CarbonImmutable((string) $item->commiter_date)); $commit->setCommitedAt(new CarbonImmutable((string) $item->commiter_date));
$signatureStatus = (string) $item->valid_signature; $signatureStatus = (string) $item->valid_signature;
if ($signatureStatus != 'N') { if ('N' != $signatureStatus) {
$signature = new Signature((string) $item->signer, (string) $item->signer_key); $signature = new Signature((string) $item->signer, (string) $item->signer_key);
if ($signatureStatus == 'B') { if ('B' == $signatureStatus) {
$signature->validate(); $signature->validate();
} }

View File

@@ -47,7 +47,7 @@ class CommandLine implements System
{ {
$path = $repository->getPath(); $path = $repository->getPath();
return file_exists($path) && (file_exists($path . '/.hg')); return file_exists($path) && file_exists($path.'/.hg');
} }
public function getDescription(Repository $repository): string public function getDescription(Repository $repository): string
@@ -357,11 +357,11 @@ class CommandLine implements System
$file = preg_split('/[\s]+/', $line, 4); $file = preg_split('/[\s]+/', $line, 4);
if ($file[2] == '.hgtags') { if ('.hgtags' == $file[2]) {
continue; continue;
} }
if ($file[2] == '@') { if ('@' == $file[2]) {
$symlinkTarget = $this->run(['cat', '-r', $hash, $file[3]], $repository); $symlinkTarget = $this->run(['cat', '-r', $hash, $file[3]], $repository);
$symlink = new Symlink($repository, $file[0]); $symlink = new Symlink($repository, $file[0]);
$symlink->setMode($file[1]); $symlink->setMode($file[1]);