diff --git a/Dockerfile b/Dockerfile index 798246908..70a8c2c1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN apt install -y \ RUN < /dev/null <<"EOT" xdebug.output_dir = /project/.xdebug xdebug.profiler_output_name = callgrind.out.%t.%r @@ -83,4 +84,4 @@ EOF # ============================================================================== FROM scratch COPY --from=build / / -CMD "/bin/bash" +CMD ["/bin/bash"] diff --git a/README.md b/README.md index 502f38879..39d723753 100644 --- a/README.md +++ b/README.md @@ -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` | diff --git a/composer-dependency-analyser.php b/composer-dependency-analyser.php index 7855eaaea..76f366caf 100644 --- a/composer-dependency-analyser.php +++ b/composer-dependency-analyser.php @@ -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([ @@ -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 = ''; } @@ -92,7 +93,7 @@ // Convert if ($line) { - $line = ltrim($line, '/'); + $line = mb_ltrim($line, '/'); $line = Glob::toRegex($line); } diff --git a/composer.json b/composer.json index 949a3188a..2f24558d1 100644 --- a/composer.json +++ b/composer.json @@ -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": "*", @@ -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", @@ -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", @@ -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", diff --git a/metadata.json b/metadata.json index 47364d896..df5adfae0 100644 --- a/metadata.json +++ b/metadata.json @@ -8,6 +8,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ] }, diff --git a/packages/core/README.md b/packages/core/README.md index f540a50d5..7338452bc 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -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` | diff --git a/packages/core/composer.json b/packages/core/composer.json index ac7e738a4..3a9f92264 100644 --- a/packages/core/composer.json +++ b/packages/core/composer.json @@ -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", diff --git a/packages/core/metadata.json b/packages/core/metadata.json index cd9fbc478..d38516b76 100644 --- a/packages/core/metadata.json +++ b/packages/core/metadata.json @@ -8,6 +8,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ] }, diff --git a/packages/core/src/Provider/Helper.php b/packages/core/src/Provider/Helper.php index c9baa4a54..e8118a8ef 100644 --- a/packages/core/src/Provider/Helper.php +++ b/packages/core/src/Provider/Helper.php @@ -5,7 +5,7 @@ use ReflectionClass; use function dirname; -use function ltrim; +use function mb_ltrim; trait Helper { /** @@ -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; } diff --git a/packages/dev/README.md b/packages/dev/README.md index 4c1d4d0a1..5905daa3f 100644 --- a/packages/dev/README.md +++ b/packages/dev/README.md @@ -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` | diff --git a/packages/dev/composer.json b/packages/dev/composer.json index 9a61b06d9..af8c7a909 100644 --- a/packages/dev/composer.json +++ b/packages/dev/composer.json @@ -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", @@ -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": { diff --git a/packages/dev/metadata.json b/packages/dev/metadata.json index 6fd54d485..104901cd8 100644 --- a/packages/dev/metadata.json +++ b/packages/dev/metadata.json @@ -8,6 +8,7 @@ "requirements": { "HEAD": { "php": [ + "^8.4", "^8.3" ], "phpstan/phpstan": [ diff --git a/packages/dev/src/App/Dumper.php b/packages/dev/src/App/Dumper.php index 288172ca8..e31551522 100644 --- a/packages/dev/src/App/Dumper.php +++ b/packages/dev/src/App/Dumper.php @@ -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; @@ -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; } diff --git a/packages/documentator/README.md b/packages/documentator/README.md index e39b10cf6..06e3afd76 100644 --- a/packages/documentator/README.md +++ b/packages/documentator/README.md @@ -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` | diff --git a/packages/documentator/composer.json b/packages/documentator/composer.json index c70505e6d..e3d463076 100644 --- a/packages/documentator/composer.json +++ b/packages/documentator/composer.json @@ -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": "*", @@ -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", diff --git a/packages/documentator/metadata.json b/packages/documentator/metadata.json index cbb88d08d..bdf4de0d1 100644 --- a/packages/documentator/metadata.json +++ b/packages/documentator/metadata.json @@ -8,6 +8,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ] }, diff --git a/packages/documentator/src/Commands/Preprocess.php b/packages/documentator/src/Commands/Preprocess.php index 3fb2700c3..190f78802 100644 --- a/packages/documentator/src/Commands/Preprocess.php +++ b/packages/documentator/src/Commands/Preprocess.php @@ -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; /** @@ -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; @@ -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 .= <<getDocBlock($class, null, $level + 1); - $target = trim( + $target = mb_trim( (string) $this->getProcessedHelpTaskPreprocessInstructionTarget($instruction, 'target', 2), ); $target = $target !== '' ? $target : '_No description provided_.'; @@ -204,7 +204,7 @@ protected function getProcessedHelpTaskPreprocessInstructions(PreprocessTask $ta $deprecated = $this->getDeprecatedMark($class); if ($params !== null) { - $help[$name] = rtrim( + $help[$name] = mb_rtrim( << `{$deprecated} @@ -216,7 +216,7 @@ protected function getProcessedHelpTaskPreprocessInstructions(PreprocessTask $ta HELP, ); } else { - $help[$name] = rtrim( + $help[$name] = mb_rtrim( <<`{$deprecated} @@ -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? @@ -335,7 +335,7 @@ protected function getProcessedHelpTaskPreprocessParameters( } $list = Text::setPadding($list, $padding); - $list = rtrim($list); + $list = mb_rtrim($list); // Return return $list; @@ -379,7 +379,7 @@ private function getDocBlock( } // Return - return trim($help); + return mb_trim($help); } /** diff --git a/packages/documentator/src/Commands/Requirements.php b/packages/documentator/src/Commands/Requirements.php index 69cb08ddd..760854ecc 100644 --- a/packages/documentator/src/Commands/Requirements.php +++ b/packages/documentator/src/Commands/Requirements.php @@ -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; @@ -188,7 +188,7 @@ public function __invoke( 'packages' => $packages, 'requirements' => $requirements, ]); - $output = trim($output); + $output = mb_trim($output); $this->output->writeln($output); } @@ -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); diff --git a/packages/documentator/src/Composer/Package.php b/packages/documentator/src/Composer/Package.php index 8b0929c02..cc37af862 100644 --- a/packages/documentator/src/Composer/Package.php +++ b/packages/documentator/src/Composer/Package.php @@ -8,7 +8,7 @@ use function array_key_exists; use function array_unique; use function array_values; -use function ltrim; +use function mb_ltrim; use function mb_strlen; use function mb_substr; use function str_starts_with; @@ -59,7 +59,7 @@ public function resolve(string $class): ?array { } public function normalize(string $class): string { - return '\\'.ltrim($class, '\\'); + return '\\'.mb_ltrim($class, '\\'); } /** diff --git a/packages/documentator/src/Editor/Editor.php b/packages/documentator/src/Editor/Editor.php index f6a86cb67..e411f052d 100644 --- a/packages/documentator/src/Editor/Editor.php +++ b/packages/documentator/src/Editor/Editor.php @@ -15,8 +15,8 @@ use function count; use function implode; use function is_string; +use function mb_rtrim; use function mb_substr; -use function rtrim; use function usort; use const PHP_INT_MAX; @@ -103,17 +103,17 @@ public function mutate(iterable $changes): static { for ($t = 0; $t < $count; $t++) { $insert[] = match (true) { - $t === 0 => rtrim($prefix.$text[$t]), - $t === $count - 1 => rtrim($padding.$text[$t].$suffix), - default => rtrim($padding.$text[$t]), + $t === 0 => mb_rtrim($prefix.$text[$t]), + $t === $count - 1 => mb_rtrim($padding.$text[$t].$suffix), + default => mb_rtrim($padding.$text[$t]), }; } array_splice($lines, $number, 1, $insert); } elseif ($count === 1) { - $lines[$number] = rtrim($prefix.$text[0].$suffix); + $lines[$number] = mb_rtrim($prefix.$text[0].$suffix); } elseif (($prefix !== '' && $prefix !== $padding) || $suffix !== '') { - $lines[$number] = rtrim($prefix.$suffix); + $lines[$number] = mb_rtrim($prefix.$suffix); } else { unset($lines[$number]); } diff --git a/packages/documentator/src/Markdown/Document.php b/packages/documentator/src/Markdown/Document.php index ecb90e9cc..487f2be6f 100644 --- a/packages/documentator/src/Markdown/Document.php +++ b/packages/documentator/src/Markdown/Document.php @@ -25,10 +25,10 @@ use function count; use function implode; use function is_int; -use function ltrim; +use function mb_ltrim; +use function mb_trim; use function str_ends_with; use function str_starts_with; -use function trim; // todo(documentator): There is no way to convert AST back to Markdown yet // https://github.com/thephpleague/commonmark/issues/419 @@ -57,7 +57,7 @@ public function getTitle(): ?string { if ($this->title === null) { $title = $this->getFirstNode(Heading::class, static fn ($n) => $n->getLevel() === 1); $title = $this->getBlockText($title) ?? ''; - $title = trim(ltrim("{$title}", '#')); + $title = mb_trim(mb_ltrim("{$title}", '#')); $this->title = $title; } @@ -71,7 +71,7 @@ public function getSummary(): ?string { if ($this->summary === null) { $summary = $this->getSummaryNode(); $summary = $this->getBlockText($summary); - $summary = trim("{$summary}"); + $summary = mb_trim("{$summary}"); $this->summary = $summary; } @@ -88,7 +88,7 @@ public function getBody(): ?string { $body = $start !== null && is_int($end) ? $this->getText(new Location($start + 1, $end)) : null; - $body = trim((string) $body); + $body = mb_trim((string) $body); $body = $body !== '' ? $body : null; return $body; @@ -106,7 +106,7 @@ public function mutate(Mutation ...$mutations): self { foreach ($mutations as $mutation) { $changes = $mutation($document); - $content = trim((string) $document->getEditor()->mutate($changes))."\n"; + $content = mb_trim((string) $document->getEditor()->mutate($changes))."\n"; $document = $this->markdown->parse($content, $document->path); } diff --git a/packages/documentator/src/Markdown/Extensions/Generated/Node.php b/packages/documentator/src/Markdown/Extensions/Generated/Node.php index 93cdc750c..1ab9ad57c 100644 --- a/packages/documentator/src/Markdown/Extensions/Generated/Node.php +++ b/packages/documentator/src/Markdown/Extensions/Generated/Node.php @@ -4,7 +4,7 @@ use League\CommonMark\Node\Block\AbstractBlock; -use function trim; +use function mb_trim; /** * Represents the generated text inside document. @@ -35,7 +35,7 @@ public static function get(string $id, string $content): string { $suffix = << <<setStartLine($line); $cell->setEndLine($line); @@ -191,7 +191,7 @@ private function fixFootnote(Document $document, Footnote $footnote): void { do { $line = (string) Utils::getLine($document, $index++); $line = mb_substr($line, $initial); - $trimmed = ltrim($line); + $trimmed = mb_ltrim($line); $padding = mb_strlen($line) - mb_strlen($trimmed); } while ($index < $end && $trimmed === ''); diff --git a/packages/documentator/src/Markdown/Mutations/Document/Move.php b/packages/documentator/src/Markdown/Mutations/Document/Move.php index 81704bbe3..5058eb334 100644 --- a/packages/documentator/src/Markdown/Mutations/Document/Move.php +++ b/packages/documentator/src/Markdown/Mutations/Document/Move.php @@ -18,15 +18,15 @@ use League\CommonMark\Node\Node; use Override; -use function ltrim; +use function mb_ltrim; +use function mb_rtrim; use function mb_strlen; use function mb_substr; +use function mb_trim; use function parse_url; use function preg_match; use function preg_quote; use function rawurldecode; -use function rtrim; -use function trim; use const PHP_URL_PATH; @@ -76,16 +76,16 @@ public function __invoke(Document $document): iterable { if ($node instanceof Link || $node instanceof Image) { $offset = Offset::get($node); $location = $location->withOffset($offset); - $origin = trim((string) $document->getText($location)); + $origin = mb_trim((string) $document->getText($location)); $titleValue = (string) $node->getTitle(); - $titleWrapper = mb_substr(rtrim(mb_substr($origin, 0, -1)), -1, 1); + $titleWrapper = mb_substr(mb_rtrim(mb_substr($origin, 0, -1)), -1, 1); $title = Utils::getLinkTitle($node, $titleValue, $titleWrapper); $targetValue = $this->target($document, $docPath, $newPath, $node->getUrl()); - $targetWrap = mb_substr(ltrim(ltrim($origin, '(')), 0, 1) === '<'; + $targetWrap = mb_substr(mb_ltrim(mb_ltrim($origin, '(')), 0, 1) === '<'; $target = Utils::getLinkTarget($node, $targetValue, $targetWrap); $text = $title !== '' ? "({$target} {$title})" : "({$target})"; } elseif ($node instanceof ReferenceNode) { - $origin = trim((string) $document->getText($location)); + $origin = mb_trim((string) $document->getText($location)); $label = $node->getLabel(); $titleValue = $node->getTitle(); $titleWrapper = mb_substr($origin, -1, 1); @@ -93,7 +93,7 @@ public function __invoke(Document $document): iterable { $targetValue = $this->target($document, $docPath, $newPath, $node->getDestination()); $targetWrap = (bool) preg_match('/^\['.preg_quote($node->getLabel(), '/').']:\s+startLine !== $location->endLine) { $padding = $location->internalPadding ?? $location->startLinePadding; diff --git a/packages/documentator/src/Markdown/Mutations/Heading/Renumber.php b/packages/documentator/src/Markdown/Mutations/Heading/Renumber.php index 1445a88af..9f14f6ed9 100644 --- a/packages/documentator/src/Markdown/Mutations/Heading/Renumber.php +++ b/packages/documentator/src/Markdown/Mutations/Heading/Renumber.php @@ -12,10 +12,10 @@ use function mb_strlen; use function mb_strpos; use function mb_substr; +use function mb_trim; use function min; use function str_repeat; use function str_starts_with; -use function trim; /** * Updates all ATX headings levels. @@ -50,9 +50,9 @@ public function __invoke(Document $document): iterable { foreach ($headings as [$heading, $location, $text]) { $level = min(6, $heading->getLevel() + $diff); $prefix = mb_substr($text, 0, (int) mb_strpos($text, '#')); - $eols = mb_strlen($text) - mb_strlen(trim($text, "\n")); + $eols = mb_strlen($text) - mb_strlen(mb_trim($text, "\n")); $text = mb_substr($text, mb_strlen($prefix)); - $text = $prefix.str_repeat('#', $level).' '.trim(trim($text, '#')).str_repeat("\n", $eols); + $text = $prefix.str_repeat('#', $level).' '.mb_trim(mb_trim($text, '#')).str_repeat("\n", $eols); yield [$location, $text]; } @@ -74,7 +74,7 @@ private function getHeadings(Document $document, int &$highest): array { $location = LocationData::get($node); $line = $document->getText($location); - if ($line === null || !str_starts_with(trim($line), '#')) { + if ($line === null || !str_starts_with(mb_trim($line), '#')) { continue; } diff --git a/packages/documentator/src/Metadata/Storage.php b/packages/documentator/src/Metadata/Storage.php index fc85e5979..15e6ed5af 100644 --- a/packages/documentator/src/Metadata/Storage.php +++ b/packages/documentator/src/Metadata/Storage.php @@ -11,7 +11,7 @@ use function file_get_contents; use function file_put_contents; use function is_file; -use function trim; +use function mb_trim; use function uksort; use function usort; @@ -61,7 +61,7 @@ public function save(Metadata $metadata): bool { $metadata = $this->normalize($metadata); $context = (new JsonEncoderContextBuilder())->withEncodeOptions(self::Options)->toArray(); $content = $this->serializer->serialize($metadata, self::Format, $context); - $result = file_put_contents($this->getPath(), trim($content)."\n") !== false; + $result = file_put_contents($this->getPath(), mb_trim($content)."\n") !== false; return $result; } diff --git a/packages/documentator/src/Processor/Metadata/PhpDocBlock.php b/packages/documentator/src/Processor/Metadata/PhpDocBlock.php index d6497d717..5ce6835c5 100644 --- a/packages/documentator/src/Processor/Metadata/PhpDocBlock.php +++ b/packages/documentator/src/Processor/Metadata/PhpDocBlock.php @@ -13,9 +13,9 @@ use PhpParser\NameContext; use PhpParser\Node\Name; +use function mb_trim; use function preg_replace_callback; use function trigger_deprecation; -use function trim; use const PREG_UNMATCHED_AS_NULL; @@ -51,7 +51,7 @@ public function __invoke(File $file): mixed { // Prepare $content = (new PhpDoc($class->class->getDocComment()?->getText()))->getText(); $content = $this->preprocess($class->context, $content); - $content = trim($content); + $content = mb_trim($content); // Create return $this->markdown->parse($content, $file->getPath()); diff --git a/packages/documentator/src/Processor/Tasks/CodeLinks/Links/Base.php b/packages/documentator/src/Processor/Tasks/CodeLinks/Links/Base.php index 0160c5616..7d778c3c0 100644 --- a/packages/documentator/src/Processor/Tasks/CodeLinks/Links/Base.php +++ b/packages/documentator/src/Processor/Tasks/CodeLinks/Links/Base.php @@ -13,7 +13,7 @@ use PhpParser\Node; use PhpParser\Node\Stmt\ClassLike; -use function ltrim; +use function mb_ltrim; use function mb_strrpos; use function mb_substr; @@ -76,7 +76,7 @@ public function getTarget(File $file, File $source): ?LinkTarget { return null; } - if ((string) $comment->class->namespacedName !== ltrim($this->class, '\\')) { + if ((string) $comment->class->namespacedName !== mb_ltrim($this->class, '\\')) { return null; } @@ -113,7 +113,7 @@ private function target(FilePath $path, ?Node $node, bool $deprecated): ?LinkTar } private function un(string $class): string { - $class = ltrim($class, '\\'); + $class = mb_ltrim($class, '\\'); $position = mb_strrpos($class, '\\'); if ($position !== false) { diff --git a/packages/documentator/src/Processor/Tasks/CodeLinks/Links/Factory.php b/packages/documentator/src/Processor/Tasks/CodeLinks/Links/Factory.php index d25b91a9b..62b0cf012 100644 --- a/packages/documentator/src/Processor/Tasks/CodeLinks/Links/Factory.php +++ b/packages/documentator/src/Processor/Tasks/CodeLinks/Links/Factory.php @@ -7,9 +7,9 @@ use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\CodeLinks\Contracts\LinkFactory; use Override; -use function ltrim; +use function mb_ltrim; +use function mb_trim; use function preg_match; -use function trim; use const PREG_UNMATCHED_AS_NULL; @@ -37,7 +37,7 @@ public function create(string $string, ?Closure $resolver = null): ?Link { /imx REGEXP; $matches = []; - $string = trim($string); + $string = mb_trim($string); if (preg_match($regexp, $string, $matches, PREG_UNMATCHED_AS_NULL) > 0) { $class = $matches['class']; @@ -46,7 +46,7 @@ public function create(string $string, ?Closure $resolver = null): ?Link { : $class; if ($class !== null) { - $class = '\\'.ltrim($class, '\\'); + $class = '\\'.mb_ltrim($class, '\\'); $reference = match (true) { isset($matches['property']) => new ClassPropertyLink($class, $matches['property']), isset($matches['method']) => new ClassMethodLink($class, $matches['method']), diff --git a/packages/documentator/src/Processor/Tasks/CodeLinks/Task.php b/packages/documentator/src/Processor/Tasks/CodeLinks/Task.php index bb7d4fbe0..76aeb9128 100644 --- a/packages/documentator/src/Processor/Tasks/CodeLinks/Task.php +++ b/packages/documentator/src/Processor/Tasks/CodeLinks/Task.php @@ -34,9 +34,9 @@ use function implode; use function is_array; use function ksort; +use function mb_trim; use function sort; use function str_starts_with; -use function trim; /** * Searches class/method/property/etc names in `inline code` and wrap it into a @@ -286,7 +286,7 @@ protected function parse(Document $document): array { } elseif ($node instanceof CodeNode) { $parent = $node->parent(); $target = $node; - $link = $this->factory->create(trim($node->getLiteral(), "`{$mark}")); + $link = $this->factory->create(mb_trim($node->getLiteral(), "`{$mark}")); if ($parent instanceof LinkNode) { $target = $parent; @@ -298,7 +298,7 @@ protected function parse(Document $document): array { } $key = (string) $link; - $deprecated = str_starts_with(trim($node->getLiteral(), '`'), $mark); + $deprecated = str_starts_with(mb_trim($node->getLiteral(), '`'), $mark); if (isset($links[$key])) { $links[$key]->deprecated = $links[$key]->deprecated || $deprecated; diff --git a/packages/documentator/src/Processor/Tasks/CodeLinks/TaskTest.php b/packages/documentator/src/Processor/Tasks/CodeLinks/TaskTest.php index 25d50082d..afc7fb534 100644 --- a/packages/documentator/src/Processor/Tasks/CodeLinks/TaskTest.php +++ b/packages/documentator/src/Processor/Tasks/CodeLinks/TaskTest.php @@ -27,7 +27,7 @@ use function array_map; use function array_walk_recursive; -use function trim; +use function mb_trim; /** * @internal @@ -68,7 +68,7 @@ public function getEnvironment(): EnvironmentInterface { }; $renderer = $this->app()->make(DocumentRenderer::class); $render = static function (Node $node) use ($markdown, $renderer): string { - return trim( + return mb_trim( $renderer->render( new class ($markdown, $node) extends Document { public function __construct(MarkdownContract $markdown, Node $node) { diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Instruction.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Instruction.php index b86763fed..334d07295 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Instruction.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Instruction.php @@ -16,9 +16,9 @@ use Symfony\Component\Console\Output\BufferedOutput; use function getenv; +use function mb_trim; use function putenv; use function strtr; -use function trim; /** * Executes the `` as Artisan command and returns result. @@ -71,7 +71,7 @@ public function __invoke(Context $context, InstructionParameters $parameters): s throw new ArtisanCommandFailed($context, $parameters, $result); } - return trim($output->fetch()); + return mb_trim($output->fetch()); } catch (ArtisanCommandFailed $exception) { throw $exception; } catch (Exception $exception) { diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/InstructionTest.php index 2f1edfd40..88d3b9154 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/InstructionTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; -use function trim; +use function mb_trim; /** * @internal @@ -41,7 +41,7 @@ public function testInvoke(Closure|string $expected, string $file, Parameters $p if ($expected instanceof Closure) { self::expectExceptionObject($expected($this, $context, $params)); } else { - $expected = trim(self::getTestData()->content($expected)); + $expected = mb_trim(self::getTestData()->content($expected)); } $actual = $this->getProcessorResult($fs, ($instance)($context, $params)); @@ -52,7 +52,7 @@ public function testInvoke(Closure|string $expected, string $file, Parameters $p self::assertIsString($actual); } - self::assertSame($expected, trim((string) $actual)); + self::assertSame($expected, mb_trim((string) $actual)); } // diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/Instruction.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/Instruction.php index a12290aec..983a028b3 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/Instruction.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/Instruction.php @@ -17,10 +17,10 @@ use Override; use Throwable; +use function mb_trim; use function preg_match; use function preg_match_all; use function preg_replace_callback; -use function trim; use const PREG_UNMATCHED_AS_NULL; @@ -70,7 +70,7 @@ public function __invoke(Context $context, InstructionParameters $parameters): G $target = $context->file->getFilePath($parameters->target); $target = Cast::to(File::class, yield new FileReference($target)); $language = $this->getLanguage($context, $target, $parameters); - $content = trim($target->getMetadata(Content::class)); + $content = mb_trim($target->getMetadata(Content::class)); $content = <<runner !== null) { // Run try { - $output = trim((string) ($this->runner)($target)); + $output = mb_trim((string) ($this->runner)($target)); } catch (Throwable $exception) { throw new ExampleFailed($context, $parameters, $exception); } @@ -100,7 +100,7 @@ public function __invoke(Context $context, InstructionParameters $parameters): G ); $output = $this->markdown->parse($output, $target->getPath()); $output = $context->toInlinable($output); - $output = trim((string) $output); + $output = mb_trim((string) $output); } // Format @@ -142,7 +142,7 @@ public function __invoke(Context $context, InstructionParameters $parameters): G } // Return - return trim($content); + return mb_trim($content); } protected function getLanguage(Context $context, File $target, Parameters $parameters): ?string { diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/InstructionTest.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/InstructionTest.php index 05ccf28c8..966fae467 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/InstructionTest.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExample/InstructionTest.php @@ -18,8 +18,8 @@ use function file_get_contents; use function implode; +use function mb_trim; use function range; -use function trim; /** * @internal @@ -63,7 +63,7 @@ public function testInvokeNoRun(): void { $file = $fs->getFile($path); $params = new Parameters($file->getName()); $context = new Context($file, Mockery::mock(Document::class), new Node(), new Nop()); - $expected = trim((string) file_get_contents((string) $path)); + $expected = mb_trim((string) file_get_contents((string) $path)); $instance = $this->app()->make(Instruction::class); $actual = $this->getProcessorResult($fs, ($instance)($context, $params)); diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/Instruction.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/Instruction.php index adae6bc0d..76afc06d0 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/Instruction.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeExec/Instruction.php @@ -10,7 +10,7 @@ use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeExec\Exceptions\TargetExecFailed; use Override; -use function trim; +use function mb_trim; /** * Executes the `` and returns result. @@ -45,7 +45,7 @@ public static function getParameters(): string { #[Override] public function __invoke(Context $context, InstructionParameters $parameters): string { try { - return trim( + return mb_trim( $this->factory->newPendingProcess() ->path((string) $context->file->getDirectoryPath()) ->run($parameters->target) diff --git a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/Instruction.php b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/Instruction.php index bead7f6ea..3c0951c78 100644 --- a/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/Instruction.php +++ b/packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeGraphqlDirective/Instruction.php @@ -12,7 +12,7 @@ use Override; use function mb_substr; -use function trim; +use function mb_trim; /** * Includes the definition of the directive as a Markdown code block. @@ -61,7 +61,7 @@ public function __invoke(Context $context, InstructionParameters $parameters): s try { $settings = ImmutableSettings::createFrom($origin)->setPrintDirectives(false); - $exported = trim((string) $this->printer->setSettings($settings)->export($definition)); + $exported = mb_trim((string) $this->printer->setSettings($settings)->export($definition)); $markdown = <<getText($location)); + $instruction = mb_trim((string) $document->getText($location)); $text = "{$instruction}\n{$text}"; } diff --git a/packages/documentator/src/Utils/Git.php b/packages/documentator/src/Utils/Git.php index 8f6371b8b..78bd973b3 100644 --- a/packages/documentator/src/Utils/Git.php +++ b/packages/documentator/src/Utils/Git.php @@ -8,7 +8,7 @@ use function array_filter; use function array_values; use function explode; -use function trim; +use function mb_trim; readonly class Git { public function __construct( @@ -50,7 +50,7 @@ private function run(array|string $command, ?DirectoryPath $root = null): string $process = $this->factory->newPendingProcess(); $process = $root !== null ? $process->path((string) $root) : $process->command(''); $output = $process->run($command)->throw()->output(); - $output = trim($output); + $output = mb_trim($output); return $output; } diff --git a/packages/documentator/src/Utils/Markdown.php b/packages/documentator/src/Utils/Markdown.php index ae44952d7..598278fd3 100644 --- a/packages/documentator/src/Utils/Markdown.php +++ b/packages/documentator/src/Utils/Markdown.php @@ -15,16 +15,16 @@ use function array_slice; use function implode; -use function ltrim; +use function mb_ltrim; use function mb_strlen; use function mb_substr; +use function mb_trim; use function min; use function preg_split; use function str_ends_with; use function str_repeat; use function str_starts_with; use function trigger_deprecation; -use function trim; use const PHP_INT_MAX; @@ -41,7 +41,7 @@ class Markdown { */ public static function getTitle(string $string): ?string { $title = static::getText($string, static::getTitleNode($string)); - $title = $title !== null ? ltrim($title, '# ') : null; + $title = $title !== null ? mb_ltrim($title, '# ') : null; $title = $title !== '' ? $title : null; return $title; @@ -70,7 +70,7 @@ public static function setPadding(string $string, int $spaces): string { $cut = PHP_INT_MAX; foreach ($lines as $line) { - $trimmed = ltrim($line); + $trimmed = mb_ltrim($line); $padding = mb_strlen($line) - mb_strlen($trimmed); $cut = min($cut, $padding); } @@ -112,7 +112,7 @@ protected static function getText(string $string, ?AbstractBlock $node): ?string $lines = preg_split('/\R/u', $string); $lines = $lines !== false ? $lines : []; $lines = array_slice($lines, $start - 1, $end - $start + 1); - $text = trim(implode("\n", $lines)); + $text = mb_trim(implode("\n", $lines)); return $text; } diff --git a/packages/documentator/src/Utils/PhpDoc.php b/packages/documentator/src/Utils/PhpDoc.php index 4139ea8e5..a88ec3e34 100644 --- a/packages/documentator/src/Utils/PhpDoc.php +++ b/packages/documentator/src/Utils/PhpDoc.php @@ -13,7 +13,7 @@ use function array_slice; use function implode; -use function trim; +use function mb_trim; /** * @see https://github.com/mockery/mockery/issues/1317 @@ -60,7 +60,7 @@ private function join(array $strings): string { private function parse(?string $comment): ?PhpDocNode { // Empty? - if ($comment === null || trim($comment) === '') { + if ($comment === null || mb_trim($comment) === '') { return null; } @@ -84,7 +84,7 @@ private function getTextNodes(?PhpDocNode $node): array { foreach (($node->children ?? []) as $child) { if ($child instanceof PhpDocTextNode) { - if (trim($child->text) !== '') { + if (mb_trim($child->text) !== '') { $nodes[] = $child->text; } } else { diff --git a/packages/documentator/src/Utils/PhpDocumentFactory.php b/packages/documentator/src/Utils/PhpDocumentFactory.php index 0a34017ba..8f0cfbb4b 100644 --- a/packages/documentator/src/Utils/PhpDocumentFactory.php +++ b/packages/documentator/src/Utils/PhpDocumentFactory.php @@ -13,8 +13,8 @@ use PhpParser\ParserFactory; use function file_get_contents; +use function mb_trim; use function preg_replace_callback; -use function trim; use const PREG_UNMATCHED_AS_NULL; @@ -39,7 +39,7 @@ public function __invoke(PhpDoc $phpdoc, ?FilePath $path, ?NameContext $context if ($path !== null) { $context ??= $this->getContext((string) $path); - $text = trim( + $text = mb_trim( (string) preg_replace_callback( pattern : '/\{@(?:see|link)\s+(?P[^}\s]+)\s?}/imu', callback: function (array $matches) use ($context): string { diff --git a/packages/documentator/src/Utils/Text.php b/packages/documentator/src/Utils/Text.php index 3333f03b7..4615a76ed 100644 --- a/packages/documentator/src/Utils/Text.php +++ b/packages/documentator/src/Utils/Text.php @@ -4,17 +4,17 @@ use function hash; use function implode; +use function mb_rtrim; use function mb_strlen; use function mb_substr; +use function mb_trim; use function min; use function pathinfo; use function preg_replace; use function preg_split; -use function rtrim; use function str_repeat; use function str_replace; use function str_starts_with; -use function trim; use const PATHINFO_FILENAME; use const PHP_INT_MAX; @@ -32,7 +32,7 @@ public static function setEol(string $text, ?string $eol = null): string { * @param int<0, max> $level */ public static function setPadding(string $text, int $level, string $padding = ' ', int &$cuts = 0): string { - $trimmed = rtrim($padding); + $trimmed = mb_rtrim($padding); $prefix = str_repeat($padding, $level); $length = mb_strlen($padding); $lines = static::getLines($text); @@ -58,7 +58,7 @@ public static function setPadding(string $text, int $level, string $padding = ' } foreach ($lines as $i => $line) { - $lines[$i] = rtrim($prefix.mb_substr($line, $cut)); + $lines[$i] = mb_rtrim($prefix.mb_substr($line, $cut)); } $text = implode("\n", $lines); @@ -82,7 +82,7 @@ public static function getPathTitle(string $path): string { $title = str_replace(['_', '.'], ' ', $title); $title = (string) preg_replace('/(\p{Ll})(\p{Lu})/u', '$1 $2', $title); $title = (string) preg_replace('/\s+/u', ' ', $title); - $title = trim($title); + $title = mb_trim($title); return $title; } diff --git a/packages/eloquent/README.md b/packages/eloquent/README.md index d15d91985..2011acc52 100644 --- a/packages/eloquent/README.md +++ b/packages/eloquent/README.md @@ -10,7 +10,8 @@ This package contains useful extensions and mixins for [Eloquent](https://larave | 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` | diff --git a/packages/eloquent/composer.json b/packages/eloquent/composer.json index f74a471d0..d58e95edc 100644 --- a/packages/eloquent/composer.json +++ b/packages/eloquent/composer.json @@ -17,11 +17,13 @@ "forum": "https://github.com/LastDragon-ru/lara-asp/discussions" }, "require": { - "php": "^8.3", + "php": "^8.3|^8.4", + "ext-mbstring": "*", "illuminate/collections": "^11.0.8", "illuminate/database": "^11.0.8", "illuminate/support": "^11.0.8", - "lastdragon-ru/lara-asp-core": "self.version" + "lastdragon-ru/lara-asp-core": "self.version", + "symfony/polyfill-php84": "^1.31" }, "require-dev": { "illuminate/contracts": "^11.0.8", diff --git a/packages/eloquent/metadata.json b/packages/eloquent/metadata.json index 47364d896..df5adfae0 100644 --- a/packages/eloquent/metadata.json +++ b/packages/eloquent/metadata.json @@ -8,6 +8,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ] }, diff --git a/packages/eloquent/src/Iterators/ChunkedChangeSafeIterator.php b/packages/eloquent/src/Iterators/ChunkedChangeSafeIterator.php index 92371c664..d62d4a4ad 100644 --- a/packages/eloquent/src/Iterators/ChunkedChangeSafeIterator.php +++ b/packages/eloquent/src/Iterators/ChunkedChangeSafeIterator.php @@ -10,7 +10,7 @@ use function end; use function explode; -use function trim; +use function mb_trim; /** * The iterator that grabs rows by chunk and safe for changing/deleting rows @@ -90,7 +90,7 @@ protected function chunkProcessed(Collection $items): bool { protected function column(Model|null $item): mixed { $value = null; $column = explode('.', $this->getColumn()); - $column = trim(end($column), '`"[]'); + $column = mb_trim(end($column), '`"[]'); if ($item !== null) { $value = $item->getAttribute($column); diff --git a/packages/formatter/README.md b/packages/formatter/README.md index eb360cea8..6caf940fe 100644 --- a/packages/formatter/README.md +++ b/packages/formatter/README.md @@ -10,7 +10,8 @@ This package provides a customizable wrapper around [Intl](https://www.php.net/m | 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` | diff --git a/packages/formatter/composer.json b/packages/formatter/composer.json index bcbf811af..13707e001 100644 --- a/packages/formatter/composer.json +++ b/packages/formatter/composer.json @@ -18,13 +18,14 @@ "forum": "https://github.com/LastDragon-ru/lara-asp/discussions" }, "require": { - "php": "^8.3", + "php": "^8.3|^8.4", "ext-bcmath": "*", "ext-intl": "*", "ext-mbstring": "*", "illuminate/macroable": "^11.0.8", "illuminate/support": "^11.0.8", - "lastdragon-ru/lara-asp-core": "self.version" + "lastdragon-ru/lara-asp-core": "self.version", + "symfony/polyfill-php84": "^1.31" }, "require-dev": { "illuminate/contracts": "^11.0.8", diff --git a/packages/formatter/metadata.json b/packages/formatter/metadata.json index 47364d896..df5adfae0 100644 --- a/packages/formatter/metadata.json +++ b/packages/formatter/metadata.json @@ -8,6 +8,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ] }, diff --git a/packages/formatter/src/Formats/Duration/DurationFormat.php b/packages/formatter/src/Formats/Duration/DurationFormat.php index 9fdc29c1f..678e87d33 100644 --- a/packages/formatter/src/Formats/Duration/DurationFormat.php +++ b/packages/formatter/src/Formats/Duration/DurationFormat.php @@ -16,10 +16,10 @@ use function floor; use function is_float; use function iterator_to_array; +use function mb_str_pad; use function mb_strlen; use function pow; use function round; -use function str_pad; use const STR_PAD_LEFT; @@ -144,7 +144,7 @@ private function value(float|int $value, int $length): string { } // Width? - $value = str_pad((string) $value, $length, '0', STR_PAD_LEFT); + $value = mb_str_pad((string) $value, $length, '0', STR_PAD_LEFT); // Return return $value; diff --git a/packages/formatter/src/Formats/String/StringFormat.php b/packages/formatter/src/Formats/String/StringFormat.php index 7ea1c2ef4..4e1d3b0cd 100644 --- a/packages/formatter/src/Formats/String/StringFormat.php +++ b/packages/formatter/src/Formats/String/StringFormat.php @@ -6,7 +6,7 @@ use Override; use Stringable; -use function trim; +use function mb_trim; /** * @implements Format @@ -18,6 +18,6 @@ public function __construct() { #[Override] public function __invoke(mixed $value): string { - return trim((string) $value); + return mb_trim((string) $value); } } diff --git a/packages/formatter/src/FormatterTest.php b/packages/formatter/src/FormatterTest.php index 14951662f..0f9655303 100644 --- a/packages/formatter/src/FormatterTest.php +++ b/packages/formatter/src/FormatterTest.php @@ -20,8 +20,8 @@ use Override; use PHPUnit\Framework\Attributes\CoversClass; +use function mb_rtrim; use function pow; -use function rtrim; use function str_replace; use const PHP_INT_MAX; @@ -114,7 +114,7 @@ public function testDecimalConfig(): void { public function testOrdinal(): void { self::assertSame('1st', $this->formatter->ordinal(1)); - self::assertSame('10', rtrim($this->formatter->forLocale('ru_RU')->ordinal(10), '.')); + self::assertSame('10', mb_rtrim($this->formatter->forLocale('ru_RU')->ordinal(10), '.')); } public function testString(): void { diff --git a/packages/graphql-printer/composer.json b/packages/graphql-printer/composer.json index 0d0a09bdd..33b230807 100644 --- a/packages/graphql-printer/composer.json +++ b/packages/graphql-printer/composer.json @@ -17,8 +17,9 @@ "forum": "https://github.com/LastDragon-ru/lara-asp/discussions" }, "require": { - "php": "^8.3", + "php": "^8.3|^8.4", "ext-mbstring": "*", + "symfony/polyfill-php84": "^1.31", "webonyx/graphql-php": "^15.4.0" }, "require-dev": { diff --git a/packages/graphql-printer/src/Blocks/Types/DescriptionBlock.php b/packages/graphql-printer/src/Blocks/Types/DescriptionBlock.php index 3f7b0cdbf..bf94ff8ac 100644 --- a/packages/graphql-printer/src/Blocks/Types/DescriptionBlock.php +++ b/packages/graphql-printer/src/Blocks/Types/DescriptionBlock.php @@ -7,10 +7,10 @@ use LastDragon_ru\LaraASP\GraphQLPrinter\Misc\Context; use Override; +use function mb_rtrim; +use function mb_trim; use function preg_replace; -use function rtrim; use function str_replace; -use function trim; /** * @internal @@ -40,7 +40,7 @@ protected function getString(): string { if ($this->isNormalized()) { $eol = $this->eol(); $string = str_replace(["\r\n", "\n\r", "\n", "\r"], $eol, $string); - $string = rtrim(trim($string, $eol)); + $string = mb_rtrim(mb_trim($string, $eol)); $string = (string) preg_replace('/\R{2,}/u', "{$eol}{$eol}", $string); $string = (string) preg_replace('/^(.*?)\h+$/mu', '$1', $string); } diff --git a/packages/graphql/composer.json b/packages/graphql/composer.json index f9766487f..9a0fe646a 100644 --- a/packages/graphql/composer.json +++ b/packages/graphql/composer.json @@ -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-mbstring": "*", "composer/semver": "^3.2", @@ -31,6 +31,7 @@ "lastdragon-ru/lara-asp-eloquent": "self.version", "lastdragon-ru/lara-asp-graphql-printer": "self.version", "lastdragon-ru/lara-asp-serializer": "self.version", + "symfony/polyfill-php84": "^1.31", "webonyx/graphql-php": "^15.4.0" }, "require-dev": { diff --git a/packages/graphql/src/Builder/Types/InputObject.php b/packages/graphql/src/Builder/Types/InputObject.php index e392caa6e..95fec9a4f 100644 --- a/packages/graphql/src/Builder/Types/InputObject.php +++ b/packages/graphql/src/Builder/Types/InputObject.php @@ -37,7 +37,7 @@ use function count; use function is_a; -use function trim; +use function mb_trim; abstract class InputObject implements TypeDefinition { public function __construct( @@ -388,7 +388,7 @@ protected function getFieldDescription( } if ($description !== null) { - $description = trim($description); + $description = mb_trim($description); $description = $description !== '' ? $description : null; } diff --git a/packages/graphql/src/Testing/GraphQLAssertions.php b/packages/graphql/src/Testing/GraphQLAssertions.php index 0debb7cbd..cfd753949 100644 --- a/packages/graphql/src/Testing/GraphQLAssertions.php +++ b/packages/graphql/src/Testing/GraphQLAssertions.php @@ -36,7 +36,7 @@ use function assert; use function implode; use function ksort; -use function trim; +use function mb_trim; /** * @phpstan-import-type Change from BreakingChangesFinder @@ -267,7 +267,7 @@ private function getGraphQLChanges(array $changes): string { $message .= "{$type}:\n\n* ".implode('* ', $descriptions)."\n\n"; } - return trim($message); + return mb_trim($message); } // } diff --git a/packages/graphql/src/Utils/AstManipulator.php b/packages/graphql/src/Utils/AstManipulator.php index 8ed86803c..1325a906c 100644 --- a/packages/graphql/src/Utils/AstManipulator.php +++ b/packages/graphql/src/Utils/AstManipulator.php @@ -68,8 +68,8 @@ use function json_encode; use function mb_strlen; use function mb_substr; +use function mb_trim; use function sprintf; -use function trim; use const JSON_THROW_ON_ERROR; @@ -520,7 +520,7 @@ public function getTypeFullName( // empty } - return trim("{$prefix} {$name}"); + return mb_trim("{$prefix} {$name}"); } /** diff --git a/packages/migrator/README.md b/packages/migrator/README.md index 87a5e8239..f9f7a20ec 100644 --- a/packages/migrator/README.md +++ b/packages/migrator/README.md @@ -14,7 +14,8 @@ This package improves standard Laravel migrations to add support for raw SQL fil | 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` | diff --git a/packages/migrator/composer.json b/packages/migrator/composer.json index 9636316ce..c9ea4ddc7 100644 --- a/packages/migrator/composer.json +++ b/packages/migrator/composer.json @@ -20,7 +20,7 @@ "forum": "https://github.com/LastDragon-ru/lara-asp/discussions" }, "require": { - "php": "^8.3", + "php": "^8.3|^8.4", "ext-json": "*", "ext-mbstring": "*", "illuminate/conditionable": "^11.0.8", @@ -32,7 +32,8 @@ "illuminate/support": "^11.0.8", "lastdragon-ru/lara-asp-core": "self.version", "symfony/console": "^7.0.0", - "symfony/finder": "^7.0.0" + "symfony/finder": "^7.0.0", + "symfony/polyfill-php84": "^1.31" }, "require-dev": { "illuminate/config": "^11.0.8", diff --git a/packages/migrator/metadata.json b/packages/migrator/metadata.json index 47364d896..df5adfae0 100644 --- a/packages/migrator/metadata.json +++ b/packages/migrator/metadata.json @@ -8,6 +8,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ] }, diff --git a/packages/migrator/src/Commands/SqlMigration.php b/packages/migrator/src/Commands/SqlMigration.php index ce6008f0f..78fbe555f 100644 --- a/packages/migrator/src/Commands/SqlMigration.php +++ b/packages/migrator/src/Commands/SqlMigration.php @@ -14,8 +14,8 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +use function mb_trim; use function sprintf; -use function trim; #[AsCommand( name : Package::Name.':sql-migration', @@ -35,7 +35,7 @@ protected function configure(): void { } public function __invoke(SqlMigrationCreator $creator): int { - $name = Str::snake(trim(Cast::toString($this->input->getArgument('name')))); + $name = Str::snake(mb_trim(Cast::toString($this->input->getArgument('name')))); $path = Cast::toStringNullable($this->input->getOption('path')) ?? $this->getMigrationPath(); $path = (new DirectoryPath($this->laravel->basePath()))->getFilePath($path); $path = (string) $path; diff --git a/packages/migrator/src/Commands/SqlSeeder.php b/packages/migrator/src/Commands/SqlSeeder.php index 3c7ebea7d..701af9832 100644 --- a/packages/migrator/src/Commands/SqlSeeder.php +++ b/packages/migrator/src/Commands/SqlSeeder.php @@ -9,7 +9,7 @@ use function basename; use function dirname; -use function trim; +use function mb_trim; #[AsCommand( name : Package::Name.':sql-seeder', @@ -33,7 +33,7 @@ protected function getStub(): string { } protected function resolveStubPath(string $stub): string { - $custom = $this->laravel->basePath(trim($stub, '/')); + $custom = $this->laravel->basePath(mb_trim($stub, '/')); $path = !$this->files->exists($custom) ? __DIR__.'/../../'.$stub : $custom; diff --git a/packages/migrator/src/Migrations/MigratorTest.php b/packages/migrator/src/Migrations/MigratorTest.php index 427db3d01..b825186b0 100644 --- a/packages/migrator/src/Migrations/MigratorTest.php +++ b/packages/migrator/src/Migrations/MigratorTest.php @@ -18,9 +18,9 @@ use function implode; use function json_decode; use function json_encode; -use function rtrim; +use function mb_rtrim; +use function mb_trim; use function str_replace; -use function trim; /** * @internal @@ -162,6 +162,6 @@ public function testMigrateRaw(): void { } private function prepare(string $content): string { - return trim(implode("\n", array_map(rtrim(...), explode("\n", str_replace("\r\n", "\n", $content))))); + return mb_trim(implode("\n", array_map(mb_rtrim(...), explode("\n", str_replace("\r\n", "\n", $content))))); } } diff --git a/packages/serializer/README.md b/packages/serializer/README.md index abaf3c96f..5caa0cf78 100644 --- a/packages/serializer/README.md +++ b/packages/serializer/README.md @@ -10,7 +10,8 @@ This package provides a customizable wrapper around the [Symfony Serializer Comp | 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.0` | | | `^8.1` | `6.4.2 ⋯ 5.0.0-beta.0` | | Laravel | `^11.0.8` | `HEAD` | diff --git a/packages/serializer/composer.json b/packages/serializer/composer.json index 1c9250240..5acfd9185 100644 --- a/packages/serializer/composer.json +++ b/packages/serializer/composer.json @@ -17,7 +17,7 @@ "forum": "https://github.com/LastDragon-ru/lara-asp/discussions" }, "require": { - "php": "^8.3", + "php": "^8.3|^8.4", "illuminate/contracts": "^11.0.8", "illuminate/database": "^11.0.8", "illuminate/support": "^11.0.8", diff --git a/packages/serializer/metadata.json b/packages/serializer/metadata.json index 399e49754..b4ed35ff7 100644 --- a/packages/serializer/metadata.json +++ b/packages/serializer/metadata.json @@ -8,6 +8,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ] }, diff --git a/packages/spa/README.md b/packages/spa/README.md index 4c56a95f2..59fb1579a 100644 --- a/packages/spa/README.md +++ b/packages/spa/README.md @@ -8,7 +8,8 @@ | 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` | diff --git a/packages/spa/composer.json b/packages/spa/composer.json index 1b588fa85..e55170d17 100644 --- a/packages/spa/composer.json +++ b/packages/spa/composer.json @@ -18,7 +18,7 @@ "forum": "https://github.com/LastDragon-ru/lara-asp/discussions" }, "require": { - "php": "^8.3", + "php": "^8.3|^8.4", "ext-mbstring": "*", "illuminate/collections": "^11.0.8", "illuminate/contracts": "^11.0.8", diff --git a/packages/spa/metadata.json b/packages/spa/metadata.json index 4a900e4f5..f62b31e14 100644 --- a/packages/spa/metadata.json +++ b/packages/spa/metadata.json @@ -8,6 +8,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ] }, diff --git a/packages/testing/README.md b/packages/testing/README.md index 863759b27..373bec69a 100644 --- a/packages/testing/README.md +++ b/packages/testing/README.md @@ -10,7 +10,8 @@ This package provides various useful asserts for [PHPUnit](https://phpunit.de/) | 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` | diff --git a/packages/testing/composer.json b/packages/testing/composer.json index 97d4e22b5..3a96b6f80 100644 --- a/packages/testing/composer.json +++ b/packages/testing/composer.json @@ -19,7 +19,7 @@ "forum": "https://github.com/LastDragon-ru/lara-asp/discussions" }, "require": { - "php": "^8.3", + "php": "^8.3|^8.4", "ext-json": "*", "ext-libxml": "*", "ext-dom": "*", @@ -27,13 +27,13 @@ "ext-mbstring": "*", "composer/semver": "^3.2", "doctrine/sql-formatter": "^1.1", - "http-interop/http-factory-guzzle": "^1.0.0", "illuminate/collections": "^11.0.8", "illuminate/console": "^11.0.8", "illuminate/contracts": "^11.0.8", "illuminate/database": "^11.0.8", "illuminate/testing": "^11.0.8", "illuminate/translation": "^11.0.8", + "nyholm/psr7": "^1.8", "mockery/mockery": "^1.6.5", "opis/json-schema": "^2.3.0", "phpunit/phpunit": "^10.5.0|^11.0.0", @@ -43,11 +43,11 @@ "symfony/filesystem": "^7.0.0", "symfony/http-foundation": "^7.0.0", "symfony/mime": "^7.0.0", + "symfony/polyfill-php84": "^1.31", "symfony/psr-http-message-bridge": "^7.0.0" }, "require-dev": { "fakerphp/faker": "^1.21.0", - "guzzlehttp/psr7": "^2.4.5", "illuminate/http": "^11.0.8", "laravel/scout": "^10.8.0", "orchestra/testbench": "^9.0.0", diff --git a/packages/testing/metadata.json b/packages/testing/metadata.json index 61785f790..b5fedf014 100644 --- a/packages/testing/metadata.json +++ b/packages/testing/metadata.json @@ -12,6 +12,7 @@ "^11.0.8" ], "php": [ + "^8.4", "^8.3" ], "phpunit/phpunit": [ diff --git a/packages/testing/src/Comparators/DatabaseQueryComparator.php b/packages/testing/src/Comparators/DatabaseQueryComparator.php index 15da23462..a74e0194b 100644 --- a/packages/testing/src/Comparators/DatabaseQueryComparator.php +++ b/packages/testing/src/Comparators/DatabaseQueryComparator.php @@ -13,10 +13,10 @@ use function array_flip; use function array_unique; use function array_values; +use function mb_strlen; use function natsort; use function preg_match_all; use function str_replace; -use function strlen; use function uksort; use const PREG_SET_ORDER; @@ -94,7 +94,7 @@ protected function normalize(Query $query): Query { $matches = array_flip($matches); uksort($matches, static function (string|int $a, string|int $b): int { - return strlen("{$b}") <=> strlen("{$a}"); + return mb_strlen("{$b}") <=> mb_strlen("{$a}"); }); foreach ($matches as $match => $index) { diff --git a/packages/testing/src/Constraints/Json/JsonMatchesSchema.php b/packages/testing/src/Constraints/Json/JsonMatchesSchema.php index 26a570707..936597c4a 100644 --- a/packages/testing/src/Constraints/Json/JsonMatchesSchema.php +++ b/packages/testing/src/Constraints/Json/JsonMatchesSchema.php @@ -10,7 +10,7 @@ use Override; use PHPUnit\Framework\Constraint\Constraint; -use function ltrim; +use function mb_ltrim; use function preg_replace; use const PHP_EOL; @@ -66,7 +66,7 @@ protected function additionalFailureDescription(mixed $other): string { $formatted = (new ErrorFormatter())->format($error); $padding = ' '; $description .= PHP_EOL.$padding.'Errors: '; - $description .= ltrim((string) preg_replace('/^/m', $padding, $this->prettify($formatted))); + $description .= mb_ltrim((string) preg_replace('/^/m', $padding, $this->prettify($formatted))); $description .= PHP_EOL; } } diff --git a/packages/testing/src/Constraints/Json/Protocol.php b/packages/testing/src/Constraints/Json/Protocol.php index 198356835..c7d35a11b 100644 --- a/packages/testing/src/Constraints/Json/Protocol.php +++ b/packages/testing/src/Constraints/Json/Protocol.php @@ -13,7 +13,7 @@ use function explode; use function http_build_query; use function implode; -use function ltrim; +use function mb_ltrim; use function parse_url; use function preg_match; use function rawurldecode; @@ -48,7 +48,7 @@ public static function getUri(SplFileInfo $file, array $parameters = []): Uri { // Build $scheme = static::Scheme; $query = http_build_query($parameters, '', '&', PHP_QUERY_RFC3986); - $path = implode('/', array_map(rawurlencode(...), explode('/', ltrim($path, '/')))); + $path = implode('/', array_map(rawurlencode(...), explode('/', mb_ltrim($path, '/')))); $uri = new Uri((array) parse_url("{$scheme}://{$host}/{$path}?{$query}")); // Return @@ -70,8 +70,8 @@ public function __invoke(Uri $uri): ?string { if ($uri->host() === self::HostWindows) { // For Windows it can be `/C:/path`, so we need to remove the slash - if (preg_match('/^\/[a-z]\:/i', $path) > 0) { - $path = ltrim($path, '/'); + if (preg_match('/^\/[a-z]\:/iu', $path) > 0) { + $path = mb_ltrim($path, '/'); } } diff --git a/packages/testing/src/Constraints/Json/ProtocolTest.php b/packages/testing/src/Constraints/Json/ProtocolTest.php index 0b7373aa8..f5081591f 100644 --- a/packages/testing/src/Constraints/Json/ProtocolTest.php +++ b/packages/testing/src/Constraints/Json/ProtocolTest.php @@ -14,7 +14,7 @@ use function http_build_query; use function implode; use function json_decode; -use function ltrim; +use function mb_ltrim; use function rawurlencode; use function str_replace; @@ -49,7 +49,7 @@ public function testGetUri(): void { $file = new SplFileInfo(__FILE__); $host = PHP_OS_FAMILY === 'Windows' ? 'windows.path' : 'unix.path'; $path = str_replace('\\', '/', $file->getPathname()); - $path = implode('/', array_map(rawurlencode(...), explode('/', '/'.ltrim($path, '/')))); + $path = implode('/', array_map(rawurlencode(...), explode('/', '/'.mb_ltrim($path, '/')))); $params = ['a' => 'a', 'b' => 'b']; $actual = Protocol::getUri($file, $params); diff --git a/packages/testing/src/Constraints/Response/ContentTypeTest.php b/packages/testing/src/Constraints/Response/ContentTypeTest.php index 7b4510cfb..54fc55113 100644 --- a/packages/testing/src/Constraints/Response/ContentTypeTest.php +++ b/packages/testing/src/Constraints/Response/ContentTypeTest.php @@ -2,9 +2,9 @@ namespace LastDragon_ru\LaraASP\Testing\Constraints\Response; -use GuzzleHttp\Psr7\Response; use LastDragon_ru\LaraASP\Testing\Exceptions\InvalidArgumentResponse; use LastDragon_ru\LaraASP\Testing\Testing\TestCase; +use Nyholm\Psr7\Response; use PHPUnit\Framework\Attributes\CoversClass; use stdClass; diff --git a/packages/testing/src/Constraints/Response/Factory.php b/packages/testing/src/Constraints/Response/Factory.php index 1d9774cf1..1bdc57271 100644 --- a/packages/testing/src/Constraints/Response/Factory.php +++ b/packages/testing/src/Constraints/Response/Factory.php @@ -2,11 +2,8 @@ namespace LastDragon_ru\LaraASP\Testing\Constraints\Response; -use Http\Factory\Guzzle\ResponseFactory; -use Http\Factory\Guzzle\ServerRequestFactory; -use Http\Factory\Guzzle\StreamFactory; -use Http\Factory\Guzzle\UploadedFileFactory; use Illuminate\Testing\TestResponse; +use Nyholm\Psr7\Factory\Psr17Factory; use Psr\Http\Message\ResponseInterface; use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; use Symfony\Component\HttpFoundation\Response; @@ -53,11 +50,10 @@ protected static function create(Response $response): ResponseInterface { // one time, so we should use a cloned response and cache the // created PSR response (to avoid double code execution). - return (new PsrHttpFactory( - new ServerRequestFactory(), - new StreamFactory(), - new UploadedFileFactory(), - new ResponseFactory(), - ))->createResponse(clone $response); + $psr17Factory = new Psr17Factory(); + $psrFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory); + $psrResponse = $psrFactory->createResponse(clone $response); + + return $psrResponse; } } diff --git a/packages/testing/src/Constraints/Response/HeaderTest.php b/packages/testing/src/Constraints/Response/HeaderTest.php index f58fda3d9..50c0daec0 100644 --- a/packages/testing/src/Constraints/Response/HeaderTest.php +++ b/packages/testing/src/Constraints/Response/HeaderTest.php @@ -2,9 +2,9 @@ namespace LastDragon_ru\LaraASP\Testing\Constraints\Response; -use GuzzleHttp\Psr7\Response; use LastDragon_ru\LaraASP\Testing\Exceptions\InvalidArgumentResponse; use LastDragon_ru\LaraASP\Testing\Testing\TestCase; +use Nyholm\Psr7\Response; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Constraint\IsEqual; use stdClass; diff --git a/packages/testing/src/Constraints/Response/MimeTypeTest.php b/packages/testing/src/Constraints/Response/MimeTypeTest.php index 4c9bdd181..36a695f23 100644 --- a/packages/testing/src/Constraints/Response/MimeTypeTest.php +++ b/packages/testing/src/Constraints/Response/MimeTypeTest.php @@ -2,9 +2,9 @@ namespace LastDragon_ru\LaraASP\Testing\Constraints\Response; -use GuzzleHttp\Psr7\Response; use LastDragon_ru\LaraASP\Testing\Exceptions\InvalidArgumentResponse; use LastDragon_ru\LaraASP\Testing\Testing\TestCase; +use Nyholm\Psr7\Response; use PHPUnit\Framework\Attributes\CoversClass; use stdClass; diff --git a/packages/testing/src/Constraints/Response/Response.php b/packages/testing/src/Constraints/Response/Response.php index c3e3e09cb..52d5693ea 100644 --- a/packages/testing/src/Constraints/Response/Response.php +++ b/packages/testing/src/Constraints/Response/Response.php @@ -18,9 +18,9 @@ use function in_array; use function is_null; use function mb_strtolower; +use function mb_trim; use function str_ends_with; use function str_starts_with; -use function trim; use const PHP_EOL; @@ -110,7 +110,7 @@ protected function additionalFailureDescription(mixed $other, bool $root = true) } $description = array_map(static function (string $text): string { - return trim($text, PHP_EOL); + return mb_trim($text, PHP_EOL); }, $description); $description = array_unique($description); $description = array_filter($description, static fn ($line) => $line !== ''); diff --git a/packages/testing/src/Constraints/Response/StatusCodeTest.php b/packages/testing/src/Constraints/Response/StatusCodeTest.php index 1a2316e9e..52c4ebe0e 100644 --- a/packages/testing/src/Constraints/Response/StatusCodeTest.php +++ b/packages/testing/src/Constraints/Response/StatusCodeTest.php @@ -2,9 +2,9 @@ namespace LastDragon_ru\LaraASP\Testing\Constraints\Response; -use GuzzleHttp\Psr7\Response; use LastDragon_ru\LaraASP\Testing\Exceptions\InvalidArgumentResponse; use LastDragon_ru\LaraASP\Testing\Testing\TestCase; +use Nyholm\Psr7\Response; use PHPUnit\Framework\Attributes\CoversClass; use stdClass; diff --git a/packages/testing/src/Constraints/Xml/XmlMatchesSchema.php b/packages/testing/src/Constraints/Xml/XmlMatchesSchema.php index ae6ea9516..da2f10505 100644 --- a/packages/testing/src/Constraints/Xml/XmlMatchesSchema.php +++ b/packages/testing/src/Constraints/Xml/XmlMatchesSchema.php @@ -16,8 +16,8 @@ use function libxml_clear_errors; use function libxml_get_errors; use function libxml_use_internal_errors; +use function mb_trim; use function strtolower; -use function trim; use const LIBXML_ERR_ERROR; use const LIBXML_ERR_FATAL; @@ -93,7 +93,7 @@ protected function additionalFailureDescription(mixed $other): string { foreach ($this->errors as $error) { $padding = ' '; - $description .= PHP_EOL.$padding.trim("{$levels[$error->level]} #{$error->code}: {$error->message}"); + $description .= PHP_EOL.$padding.mb_trim("{$levels[$error->level]} #{$error->code}: {$error->message}"); $description .= PHP_EOL."{$padding}{$error->file}:{$error->line}"; $description .= PHP_EOL; } diff --git a/packages/testing/src/Utils/TestData.php b/packages/testing/src/Utils/TestData.php index e99f241d8..d0e603a31 100644 --- a/packages/testing/src/Utils/TestData.php +++ b/packages/testing/src/Utils/TestData.php @@ -10,7 +10,7 @@ use function basename; use function dirname; -use function ltrim; +use function mb_ltrim; use function sprintf; use function str_replace; use function str_starts_with; @@ -40,7 +40,7 @@ public function path(string $path): string { $path = str_replace('\\', '/', $path); $path = (str_starts_with($path, '.') && !str_starts_with($path, './') && !str_starts_with($path, '../')) || str_starts_with($path, '~') ? $path - : '/'.ltrim($path, '/'); + : '/'.mb_ltrim($path, '/'); $path = "{$dir}/{$name}{$path}"; return $path; diff --git a/phpstan.neon b/phpstan.neon index d9ab23784..417653191 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -42,6 +42,31 @@ parameters: allowIn: - packages/dev/src/App/* - packages/*/docs/* + disallowedFunctionCalls: + - + function: 'strlen()' + message: 'use mb_strlen() instead' + - + function: 'substr()' + message: 'use mb_substr() instead' + - + function: 'trim()' + message: 'use mb_trim() instead' + - + function: 'ltrim()' + message: 'use mb_ltrim() instead' + - + function: 'rtrim()' + message: 'use mb_rtrim() instead' + - + function: 'str_pad()' + message: 'use mb_str_pad() instead' + - + function: 'lcfirst()' + message: 'use mb_lcfirst() instead' + - + function: 'ucfirst()' + message: 'use mb_ucfirst() instead' includes: # Vendor