Skip to content

Commit

Permalink
feat: PHP 8.4 Support (#216)
Browse files Browse the repository at this point in the history
Closes: #190
  • Loading branch information
LastDragon-ru authored Jan 13, 2025
2 parents f026fc7 + f680d1d commit 528f6d4
Show file tree
Hide file tree
Showing 87 changed files with 250 additions and 195 deletions.
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN apt install -y \
RUN <<EOF
set -eux

PHP_VERSION=8.3
PHP_VERSION=8.4
PHP_CONFIG="/etc/php/${PHP_VERSION}"

LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
Expand All @@ -35,10 +35,11 @@ DEBIAN_FRONTEND=noninteractive TZ=UTC apt install -y \
"php${PHP_VERSION}-pdo-sqlite" \
""

sed -i 's/^error_reporting = .\+$/error_reporting = E_ALL/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^display_errors = .\+$/display_errors = On/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^;opcache\.enable=.\+$/opcache.enable=1/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^;opcache\.enable_cli=.\+$/opcache.enable_cli=1/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^error_reporting = .\+$/error_reporting = E_ALL \& ~E_DEPRECATED/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^display_errors = .\+$/display_errors = On/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^;opcache\.enable=.\+$/opcache.enable=1/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^;opcache\.enable_cli=.\+$/opcache.enable_cli=1/' "${PHP_CONFIG}/cli/php.ini"
sed -i 's/^opcache\.jit=.\+$/opcache.jit=disable/' "${PHP_CONFIG}/mods-available/opcache.ini"
tee -a "${PHP_CONFIG}/mods-available/xdebug.ini" > /dev/null <<"EOT"
xdebug.output_dir = /project/.xdebug
xdebug.profiler_output_name = callgrind.out.%t.%r
Expand Down Expand Up @@ -83,4 +84,4 @@ EOF
# ==============================================================================
FROM scratch
COPY --from=build / /
CMD "/bin/bash"
CMD ["/bin/bash"]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ The set provides best practices to make development more fun and classes/service

| Requirement | Constraint | Supported by |
|--------------|---------------------|------------------|
| PHP | `^8.3` | `HEAD ⋯ 5.0.0` |
| PHP | `^8.4` | `HEAD` |
| | `^8.3` | `HEAD ⋯ 5.0.0` |
| | `^8.2` | `7.1.0 ⋯ 2.0.0` |
| | `^8.1` | `6.4.2 ⋯ 2.0.0` |
| | `^8.0` | `4.6.0 ⋯ 2.0.0` |
Expand Down
7 changes: 4 additions & 3 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// General
$config = (new Configuration())
->enableAnalysisOfUnusedDevDependencies()
->ignoreErrorsOnPackage('symfony/polyfill-php84', [ErrorType::UNUSED_DEPENDENCY])
->ignoreErrorsOnPackage('bamarni/composer-bin-plugin', [ErrorType::UNUSED_DEPENDENCY])
->ignoreErrorsOnPackage('laravel/scout', [ErrorType::DEV_DEPENDENCY_IN_PROD])
->ignoreUnknownClasses([
Expand Down Expand Up @@ -67,14 +68,14 @@
$parse = static function (string $line): string {
// Simplified parser
// https://git-scm.com/docs/gitattributes
$line = trim($line);
$line = mb_trim($line);

if (str_starts_with($line, '#')) {
$line = '';
}

if (str_ends_with($line, ' export-ignore')) {
$line = trim(explode(' ', $line, 2)[0] ?? '');
$line = mb_trim(explode(' ', $line, 2)[0] ?? '');
} else {
$line = '';
}
Expand All @@ -92,7 +93,7 @@

// Convert
if ($line) {
$line = ltrim($line, '/');
$line = mb_ltrim($line, '/');
$line = Glob::toRegex($line);
}

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"forum": "https://github.com/LastDragon-ru/lara-asp/discussions"
},
"require": {
"php": "^8.3",
"php": "^8.3|^8.4",
"ext-bcmath": "*",
"ext-dom": "*",
"ext-filter": "*",
Expand All @@ -44,7 +44,6 @@
"composer/semver": "^3.2",
"doctrine/sql-formatter": "^1.1",
"guzzlehttp/psr7": "^2.4.5",
"http-interop/http-factory-guzzle": "^1.0.0",
"illuminate/collections": "^11.0.8",
"illuminate/conditionable": "^11.0.8",
"illuminate/console": "^11.0.8",
Expand All @@ -67,6 +66,7 @@
"nette/neon": "^3.4.1",
"nikic/php-parser": "^5.4.0",
"nuwave/lighthouse": "^6.36.0",
"nyholm/psr7": "^1.8",
"opis/json-schema": "^2.3.0",
"phpdocumentor/type-resolver": "^1.7",
"phpstan/phpdoc-parser": "^2.0.0",
Expand All @@ -82,6 +82,7 @@
"symfony/http-foundation": "^7.0.0",
"symfony/http-kernel": "^7.0.0",
"symfony/mime": "^7.0.0",
"symfony/polyfill-php84": "^1.31",
"symfony/property-access": "^7.0.0",
"symfony/property-info": "^7.1.10",
"symfony/psr-http-message-bridge": "^7.0.0",
Expand Down
1 change: 1 addition & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"^11.0.8"
],
"php": [
"^8.4",
"^8.3"
]
},
Expand Down
3 changes: 2 additions & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ This package contains useful utilities and classes.

| Requirement | Constraint | Supported by |
|--------------|---------------------|------------------|
| PHP | `^8.3` | `HEAD ⋯ 5.0.0` |
| PHP | `^8.4` | `HEAD` |
| | `^8.3` | `HEAD ⋯ 5.0.0` |
| | `^8.2` | `7.1.0 ⋯ 2.0.0` |
| | `^8.1` | `6.4.2 ⋯ 2.0.0` |
| | `^8.0` | `4.6.0 ⋯ 2.0.0` |
Expand Down
6 changes: 4 additions & 2 deletions packages/core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
"forum": "https://github.com/LastDragon-ru/lara-asp/discussions"
},
"require": {
"php": "^8.3",
"php": "^8.3|^8.4",
"ext-mbstring": "*",
"illuminate/console": "^11.0.8",
"illuminate/container": "^11.0.8",
"illuminate/contracts": "^11.0.8",
"illuminate/support": "^11.0.8",
"symfony/deprecation-contracts": "^3.0.0",
"symfony/filesystem": "^7.0.0"
"symfony/filesystem": "^7.0.0",
"symfony/polyfill-php84": "^1.31"
},
"require-dev": {
"phpunit/phpunit": "^10.5.0|^11.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/core/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"^11.0.8"
],
"php": [
"^8.4",
"^8.3"
]
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Provider/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use ReflectionClass;

use function dirname;
use function ltrim;
use function mb_ltrim;

trait Helper {
/**
Expand All @@ -18,7 +18,7 @@ abstract protected function getName(): string;
*/
protected function getPath(string $path): string {
$class = new ReflectionClass(self::class);
$path = dirname((string) $class->getFileName()).'/'.ltrim($path, '/');
$path = dirname((string) $class->getFileName()).'/'.mb_ltrim($path, '/');

return $path;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Various internal tools and helpers to develop the package itself.

| Requirement | Constraint | Supported by |
|--------------|---------------------|------------------|
| PHP | `^8.3` | `HEAD ⋯ 6.2.0` |
| PHP | `^8.4` | `HEAD` |
| | `^8.3` | `HEAD ⋯ 6.2.0` |
| | `^8.2` | `7.1.0 ⋯ 6.2.0` |
| | `^8.1` | `6.4.2 ⋯ 6.2.0` |
| PHPStan | `^2.1.1` | `HEAD` |
Expand Down
4 changes: 3 additions & 1 deletion packages/dev/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"forum": "https://github.com/LastDragon-ru/lara-asp/discussions"
},
"require": {
"php": "^8.3",
"php": "^8.3|^8.4",
"ext-mbstring": "*",
"illuminate/container": "^11.0.8",
"illuminate/contracts": "^11.0.8",
"illuminate/support": "^11.0.8",
Expand All @@ -27,6 +28,7 @@
"nikic/php-parser": "^5.4.0",
"nette/neon": "^3.4.1",
"phpstan/phpstan": "^2.1.1",
"symfony/polyfill-php84": "^1.31",
"symfony/var-dumper": "^7.0.0"
},
"require-dev": {
Expand Down
1 change: 1 addition & 0 deletions packages/dev/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"requirements": {
"HEAD": {
"php": [
"^8.4",
"^8.3"
],
"phpstan/phpstan": [
Expand Down
4 changes: 2 additions & 2 deletions packages/dev/src/App/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\VarDumper\Dumper\AbstractDumper;
use Symfony\Component\VarDumper\Dumper\CliDumper;

use function trim;
use function mb_trim;

class Dumper {
private readonly VarCloner $cloner;
Expand Down Expand Up @@ -49,7 +49,7 @@ public function dump(mixed $value, ?string $expression): void {
}

public function raw(Stringable|string $value, ?string $expression, string $type): void {
$dump = trim((string) $value);
$dump = mb_trim((string) $value);
$dump = ($expression !== null ? "The `{$expression}` is:\n\n" : '')."```{$type}\n{$dump}\n```\n";
$this->dumps[] = $dump;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/documentator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ This package provides various utilities for documentation generation such as Mar

| Requirement | Constraint | Supported by |
|--------------|---------------------|------------------|
| PHP | `^8.3` | `HEAD ⋯ 5.0.0` |
| PHP | `^8.4` | `HEAD` |
| | `^8.3` | `HEAD ⋯ 5.0.0` |
| | `^8.2` | `7.1.0 ⋯ 5.0.0-beta.1` |
| | `^8.1` | `6.4.2 ⋯ 5.0.0-beta.1` |
| Laravel | `^11.0.8` | `HEAD` |
Expand Down
3 changes: 2 additions & 1 deletion packages/documentator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"forum": "https://github.com/LastDragon-ru/lara-asp/discussions"
},
"require": {
"php": "^8.3",
"php": "^8.3|^8.4",
"ext-filter": "*",
"ext-intl": "*",
"ext-mbstring": "*",
Expand All @@ -35,6 +35,7 @@
"symfony/deprecation-contracts": "^3.0.0",
"symfony/filesystem": "^7.0.0",
"symfony/finder": "^7.0.0",
"symfony/polyfill-php84": "^1.31",
"symfony/serializer": "^7.0.0",
"lastdragon-ru/lara-asp-core": "self.version",
"lastdragon-ru/lara-asp-formatter": "self.version",
Expand Down
1 change: 1 addition & 0 deletions packages/documentator/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"^11.0.8"
],
"php": [
"^8.4",
"^8.3"
]
},
Expand Down
28 changes: 14 additions & 14 deletions packages/documentator/src/Commands/Preprocess.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
use function is_scalar;
use function ksort;
use function max;
use function mb_rtrim;
use function mb_trim;
use function min;
use function rtrim;
use function str_repeat;
use function strtr;
use function strval;
use function trim;
use function var_export;

/**
Expand Down Expand Up @@ -137,7 +137,7 @@ protected function tasks(): array {
public function getProcessedHelp(): string {
try {
return strtr(parent::getProcessedHelp(), [
'%tasks%' => trim($this->getProcessedHelpTasks(3)),
'%tasks%' => mb_trim($this->getProcessedHelpTasks(3)),
]);
} finally {
$this->phpDocumentFactory = null;
Expand All @@ -151,11 +151,11 @@ protected function getProcessedHelpTasks(int $level): string {
$processor = $this->processor();

foreach ($processor->tasks() as $index => $task) {
$description = trim($this->getProcessedHelpTaskDescription($task, $level + 1));
$description = mb_trim($this->getProcessedHelpTaskDescription($task, $level + 1));
$description = $description !== '' ? $description : $default;
$extensions = '`'.implode('`, `', $task::getExtensions()).'`';
$deprecated = $this->getDeprecatedMark(new ReflectionClass($task));
$title = trim((string) $this->getProcessedHelpTaskTitle($task));
$title = mb_trim((string) $this->getProcessedHelpTaskTitle($task));
$title = $title !== '' ? $title : "Task №{$index}";
$help .= <<<MARKDOWN
{$heading} {$title} ({$extensions}){$deprecated}
Expand Down Expand Up @@ -196,15 +196,15 @@ protected function getProcessedHelpTaskPreprocessInstructions(PreprocessTask $ta
$class = new ReflectionClass($instruction);
$name = $instruction::getName();
$desc = $this->getDocBlock($class, null, $level + 1);
$target = trim(
$target = mb_trim(
(string) $this->getProcessedHelpTaskPreprocessInstructionTarget($instruction, 'target', 2),
);
$target = $target !== '' ? $target : '_No description provided_.';
$params = $this->getProcessedHelpTaskPreprocessParameters($instruction, 'target', 2);
$deprecated = $this->getDeprecatedMark($class);

if ($params !== null) {
$help[$name] = rtrim(
$help[$name] = mb_rtrim(
<<<HELP
{$heading} `[{$name}]: <target> <parameters>`{$deprecated}
Expand All @@ -216,7 +216,7 @@ protected function getProcessedHelpTaskPreprocessInstructions(PreprocessTask $ta
HELP,
);
} else {
$help[$name] = rtrim(
$help[$name] = mb_rtrim(
<<<HELP
{$heading} `[{$name}]: <target>`{$deprecated}
Expand Down Expand Up @@ -313,10 +313,10 @@ protected function getProcessedHelpTaskPreprocessParameters(
}

// Add
$definition = $this->getDeprecatedMark($property).$definition;
$description = trim($this->getDocBlock($property, $padding));
$description = $description !== '' ? $description : '_No description provided_.';
$parameters[trim($definition)] = $description;
$definition = $this->getDeprecatedMark($property).$definition;
$description = mb_trim($this->getDocBlock($property, $padding));
$description = $description !== '' ? $description : '_No description provided_.';
$parameters[mb_trim($definition)] = $description;
}

// Empty?
Expand All @@ -335,7 +335,7 @@ protected function getProcessedHelpTaskPreprocessParameters(
}

$list = Text::setPadding($list, $padding);
$list = rtrim($list);
$list = mb_rtrim($list);

// Return
return $list;
Expand Down Expand Up @@ -379,7 +379,7 @@ private function getDocBlock(
}

// Return
return trim($help);
return mb_trim($help);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/documentator/src/Commands/Requirements.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
use function getcwd;
use function mb_strlen;
use function mb_substr;
use function mb_trim;
use function preg_match;
use function preg_quote;
use function range;
use function reset;
use function str_starts_with;
use function strtr;
use function trim;
use function uksort;
use function usort;

Expand Down Expand Up @@ -188,7 +188,7 @@ public function __invoke(
'packages' => $packages,
'requirements' => $requirements,
]);
$output = trim($output);
$output = mb_trim($output);

$this->output->writeln($output);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ protected function getPackageRequirements(array $require, array $merge, Composer

// Add
$required = explode('|', Cast::toString($constraint));
$required = array_map(trim(...), $required);
$required = array_map(mb_trim(...), $required);
$required = array_filter($required, static fn ($string) => $string !== '');
$required = array_values($required);
$requirement = Cast::toString($requirement);
Expand Down
Loading

0 comments on commit 528f6d4

Please sign in to comment.