Skip to content

Commit

Permalink
refactor!: Drop Laravel v9 support (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
LastDragon-ru authored Jan 2, 2024
2 parents e9ca939 + 4ff46c3 commit baeb081
Show file tree
Hide file tree
Showing 52 changed files with 162 additions and 289 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The set provides best practices to make development more fun and classes/service
| | `>=8.0.0` | `0.11.0 ⋯ 0.4.0` |
| | `>=7.4.0` | `0.3.0 ⋯ 0.1.0` |
| Laravel | `^10.0.0` | `HEAD ⋯ 2.1.0` |
| | `^9.21.0` | `HEAD ⋯ 5.0.0-beta.1` |
| | `^9.21.0` | `5.4.0 ⋯ 5.0.0-beta.1` |
| | `^9.0.0` | `5.0.0-beta.0 ⋯ 0.12.0` |
| | `^8.22.1` | `3.0.0 ⋯ 0.2.0` |
| | `^8.0` | `0.1.0` |
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"doctrine/sql-formatter": "^1.1",
"guzzlehttp/psr7": "^1.9.1|^2.4.5",
"http-interop/http-factory-guzzle": "^1.0.0",
"laravel/framework": "^9.21.0|^10.0.0",
"laravel/framework": "^10.0.0",
"league/commonmark": "^2.4",
"nuwave/lighthouse": "^6.5.0",
"opis/json-schema": "^2.3.0",
Expand All @@ -59,7 +59,6 @@
"symfony/http-foundation": "^6.3.0",
"symfony/mime": "^6.3.0",
"symfony/polyfill-php83": "^1.28",
"symfony/process": "^6.3.0",
"symfony/property-access": "^6.3.0",
"symfony/property-info": "^6.3.9",
"symfony/psr-http-message-bridge": "^2.0.0|^6.4.0",
Expand All @@ -74,12 +73,12 @@
"mockery/mockery": "^1.6.2",
"nikic/php-parser": "^4.15",
"larastan/larastan": "2.7.0",
"orchestra/testbench": "^7.0.0|^8.0.0",
"orchestra/testbench": "^8.0.0",
"phpstan/phpstan": "1.10.50",
"phpstan/phpstan-mockery": "^1.0.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpunit/phpunit": "^9.5.0|^10.1.0",
"phpunit/phpunit": "^10.1.0",
"slevomat/coding-standard": "^8.12.0",
"spaze/phpstan-disallowed-calls": "^2.16",
"squizlabs/php_codesniffer": "^3.7.1",
Expand Down
3 changes: 1 addition & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"requirements": {
"HEAD": {
"laravel/framework": [
"^10.0.0",
"^9.21.0"
"^10.0.0"
],
"php": [
"^8.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This package contains useful utilities and classes.
| | `>=8.0.0` | `0.11.0 ⋯ 0.4.0` |
| | `>=7.4.0` | `0.3.0 ⋯ 0.1.0` |
| Laravel | `^10.0.0` | `HEAD ⋯ 2.1.0` |
| | `^9.21.0` | `HEAD ⋯ 5.0.0-beta.1` |
| | `^9.21.0` | `5.4.0 ⋯ 5.0.0-beta.1` |
| | `^9.0.0` | `5.0.0-beta.0 ⋯ 0.12.0` |
| | `^8.22.1` | `3.0.0 ⋯ 0.4.0` |

Expand Down
6 changes: 3 additions & 3 deletions packages/core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"require": {
"php": "^8.1|^8.2|^8.3",
"ext-mbstring": "*",
"laravel/framework": "^9.21.0|^10.0.0",
"laravel/framework": "^10.0.0",
"symfony/polyfill-php83": "^1.28"
},
"require-dev": {
"phpunit/phpunit": "^9.5.0|^10.1.0",
"phpunit/phpunit": "^10.1.0",
"lastdragon-ru/lara-asp-testing": "self.version",
"orchestra/testbench": "^7.0.0|^8.0.0"
"orchestra/testbench": "^8.0.0"
},
"suggest": {
"ext-fileinfo": "Required for league/flysystem"
Expand Down
3 changes: 1 addition & 2 deletions packages/core/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"requirements": {
"HEAD": {
"laravel/framework": [
"^10.0.0",
"^9.21.0"
"^10.0.0"
],
"php": [
"^8.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/documentator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This package provides various utilities for documentation generation.
| | `^8.2` | `HEAD ⋯ 5.0.0-beta.1` |
| | `^8.1` | `HEAD ⋯ 5.0.0-beta.1` |
| Laravel | `^10.0.0` | `HEAD ⋯ 5.0.0-beta.1` |
| | `^9.21.0` | `HEAD ⋯ 5.0.0-beta.1` |
| | `^9.21.0` | `5.4.0 ⋯ 5.0.0-beta.1` |

[//]: # (end: 876a9177c0e8e3722ac84e8f3888245fc9070a64a87dedfe7c9d9ba2a13b374b)

Expand Down
7 changes: 3 additions & 4 deletions packages/documentator/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@
"php": "^8.1|^8.2|^8.3",
"ext-mbstring": "*",
"composer/semver": "^3.2",
"laravel/framework": "^9.21.0|^10.0.0",
"laravel/framework": "^10.0.0",
"league/commonmark": "^2.4",
"phpdocumentor/reflection-docblock": "^5.2",
"symfony/filesystem": "^6.3.0",
"symfony/finder": "^6.3.0",
"symfony/process": "^6.3.0",
"symfony/polyfill-php83": "^1.28",
"lastdragon-ru/lara-asp-core": "self.version",
"lastdragon-ru/lara-asp-serializer": "self.version"
},
"require-dev": {
"lastdragon-ru/lara-asp-testing": "self.version",
"orchestra/testbench": "^7.0.0|^8.0.0",
"phpunit/phpunit": "^9.5.0|^10.1.0"
"orchestra/testbench": "^8.0.0",
"phpunit/phpunit": "^10.1.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 1 addition & 2 deletions packages/documentator/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"requirements": {
"HEAD": {
"laravel/framework": [
"^10.0.0",
"^9.21.0"
"^10.0.0"
],
"php": [
"^8.3",
Expand Down
7 changes: 0 additions & 7 deletions packages/documentator/src/Commands/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ class CommandsTest_CommandB extends Command {
*/
protected $aliases = ['command-b-alias'];

public function __construct() {
parent::__construct();

// @phpstan-ignore-next-line Required for Laravel v9
$this->setAliases((array) $this->aliases);
}

public function __invoke(): void {
throw new Exception('Should not be called.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions;

use Exception;
use Illuminate\Support\Facades\Process;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\ProcessableInstruction;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetExecFailed;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotFile;
use LastDragon_ru\LaraASP\Documentator\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Utils\Process;
use Override;

use function dirname;
Expand All @@ -26,9 +26,7 @@ class IncludeExample implements ProcessableInstruction {
public const Limit = 50;
protected const MarkdownRegexp = '/^\<(?P<tag>markdown)\>(?P<markdown>.*?)\<\/(?P=tag)\>$/msu';

public function __construct(
protected readonly Process $process,
) {
public function __construct() {
// empty
}

Expand Down Expand Up @@ -78,7 +76,7 @@ public function process(string $path, string $target): string {
if ($command) {
// Call
try {
$output = $this->process->run($command, dirname($path));
$output = Process::path(dirname($path))->run($command)->throw()->output();
$output = trim($output);
} catch (Exception $exception) {
throw new TargetExecFailed($path, $target, $exception);
Expand Down Expand Up @@ -144,16 +142,13 @@ protected function getLanguage(string $path, string $target): string {
return pathinfo($target, PATHINFO_EXTENSION);
}

/**
* @return list<string>
*/
protected function getCommand(string $path, string $target): ?array {
protected function getCommand(string $path, string $target): ?string {
$info = pathinfo($target);
$file = isset($info['dirname'])
? Path::join($info['dirname'], "{$info['filename']}.run")
: "{$info['filename']}.run";
$command = Path::getPath(dirname($path), $file);
$command = is_file($command) ? [$command] : null;
$command = is_file($command) ? $command : null;

return $command;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions;

use Illuminate\Container\Container;
use Illuminate\Process\PendingProcess;
use Illuminate\Support\Facades\Process;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use LastDragon_ru\LaraASP\Documentator\Utils\Process;
use Mockery;
use PHPUnit\Framework\Attributes\CoversClass;

use function basename;
Expand All @@ -23,14 +23,10 @@ public function testProcessNoRun(): void {
$path = self::getTestData()->path('~example.md');
$file = basename(self::getTestData()->path('~example.md'));
$expected = trim(self::getTestData()->content('~example.md'));
$process = Mockery::mock(Process::class);
$process
->shouldReceive('run')
->never();
$instance = Container::getInstance()->make(IncludeExample::class);

$instance = Container::getInstance()->make(IncludeExample::class, [
'process' => $process,
]);
Process::preventStrayProcesses();
Process::fake();

self::assertEquals(
<<<EXPECTED
Expand All @@ -40,22 +36,21 @@ public function testProcessNoRun(): void {
EXPECTED,
$instance->process($path, $file),
);

Process::assertNothingRan();
}

public function testProcess(): void {
$path = self::getTestData()->path('~runnable.md');
$file = basename(self::getTestData()->path('~runnable.md'));
$command = self::getTestData()->path('~runnable.run');
$expected = trim(self::getTestData()->content('~runnable.md'));
$output = 'command output';
$process = Mockery::mock(Process::class);
$process
->shouldReceive('run')
->with([self::getTestData()->path('~runnable.run')], dirname($path))
->once()
->andReturn($output);

$instance = Container::getInstance()->make(IncludeExample::class, [
'process' => $process,
$instance = Container::getInstance()->make(IncludeExample::class);

Process::preventStrayProcesses();
Process::fake([
$command => Process::result($output),
]);

self::assertEquals(
Expand All @@ -72,22 +67,24 @@ public function testProcess(): void {
EXPECTED,
$instance->process($path, $file),
);

Process::assertRan(static function (PendingProcess $process) use ($path, $command): bool {
return $process->path === dirname($path)
&& $process->command === $command;
});
}

public function testProcessLongOutput(): void {
$path = self::getTestData()->path('~runnable.md');
$file = self::getTestData()->path('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim(self::getTestData()->content('~runnable.md'));
$output = implode("\n", range(0, IncludeExample::Limit + 1));
$process = Mockery::mock(Process::class);
$process
->shouldReceive('run')
->with([self::getTestData()->path('~runnable.run')], dirname($path))
->once()
->andReturn($output);

$instance = Container::getInstance()->make(IncludeExample::class, [
'process' => $process,
$instance = Container::getInstance()->make(IncludeExample::class);

Process::preventStrayProcesses();
Process::fake([
$command => Process::result($output),
]);

self::assertEquals(
Expand All @@ -106,22 +103,24 @@ public function testProcessLongOutput(): void {
EXPECTED,
$instance->process($path, $file),
);

Process::assertRan(static function (PendingProcess $process) use ($path, $command): bool {
return $process->path === dirname($path)
&& $process->command === $command;
});
}

public function testProcessMarkdown(): void {
$path = self::getTestData()->path('~runnable.md');
$file = basename(self::getTestData()->path('~runnable.md'));
$command = self::getTestData()->path('~runnable.run');
$expected = trim(self::getTestData()->content('~runnable.md'));
$output = 'command output';
$process = Mockery::mock(Process::class);
$process
->shouldReceive('run')
->with([self::getTestData()->path('~runnable.run')], dirname($path))
->once()
->andReturn("<markdown>{$output}</markdown>");

$instance = Container::getInstance()->make(IncludeExample::class, [
'process' => $process,
$instance = Container::getInstance()->make(IncludeExample::class);

Process::preventStrayProcesses();
Process::fake([
$command => Process::result("<markdown>{$output}</markdown>"),
]);

self::assertEquals(
Expand All @@ -134,22 +133,24 @@ public function testProcessMarkdown(): void {
EXPECTED,
$instance->process($path, $file),
);

Process::assertRan(static function (PendingProcess $process) use ($path, $command): bool {
return $process->path === dirname($path)
&& $process->command === $command;
});
}

public function testProcessMarkdownLongOutput(): void {
$path = self::getTestData()->path('~runnable.md');
$file = self::getTestData()->path('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim(self::getTestData()->content('~runnable.md'));
$output = implode("\n", range(0, IncludeExample::Limit + 1));
$process = Mockery::mock(Process::class);
$process
->shouldReceive('run')
->with([self::getTestData()->path('~runnable.run')], dirname($path))
->once()
->andReturn("<markdown>{$output}</markdown>");

$instance = Container::getInstance()->make(IncludeExample::class, [
'process' => $process,
$instance = Container::getInstance()->make(IncludeExample::class);

Process::preventStrayProcesses();
Process::fake([
$command => Process::result("<markdown>{$output}</markdown>"),
]);

self::assertEquals(
Expand All @@ -166,5 +167,10 @@ public function testProcessMarkdownLongOutput(): void {
EXPECTED,
$instance->process($path, $file),
);

Process::assertRan(static function (PendingProcess $process) use ($path, $command): bool {
return $process->path === dirname($path)
&& $process->command === $command;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions;

use Exception;
use Illuminate\Support\Facades\Process;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\ProcessableInstruction;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetExecFailed;
use LastDragon_ru\LaraASP\Documentator\Utils\Process;
use Override;

use function dirname;
use function trim;

class IncludeExec implements ProcessableInstruction {
public function __construct(
protected readonly Process $process,
) {
public function __construct() {
// empty
}

Expand All @@ -35,7 +34,7 @@ public static function getTargetDescription(): ?string {
#[Override]
public function process(string $path, string $target): string {
try {
return $this->process->run($target, dirname($path));
return trim(Process::path(dirname($path))->run($target)->throw()->output());
} catch (Exception $exception) {
throw new TargetExecFailed($path, $target, $exception);
}
Expand Down
Loading

0 comments on commit baeb081

Please sign in to comment.