From 12f79f9f20655044e7c828062a24b1e1c33f39fa Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Mon, 20 May 2024 09:39:40 +0400
Subject: [PATCH 01/30] Added root, directory and file to `Context`.
---
.../documentator/src/Preprocessor/Context.php | 7 +++-
.../Exceptions/DependencyIsMissing.php | 2 +-
.../Exceptions/DocumentTitleIsMissing.php | 2 +-
.../PackageComposerJsonIsMissing.php | 2 +-
.../Exceptions/PackageReadmeIsMissing.php | 2 +-
.../Exceptions/TargetExecFailed.php | 2 +-
.../Exceptions/TargetIsNotDirective.php | 2 +-
.../Exceptions/TargetIsNotDirectory.php | 2 +-
.../Exceptions/TargetIsNotFile.php | 2 +-
.../Exceptions/TargetIsNotValidPhpFile.php | 2 +-
.../Exceptions/TemplateDataMissed.php | 2 +-
.../Exceptions/TemplateVariablesMissed.php | 2 +-
.../Exceptions/TemplateVariablesUnused.php | 2 +-
.../IncludeDocBlock/InstructionTest.php | 39 ++++++++++---------
.../IncludeDocumentList/Instruction.php | 6 +--
.../IncludeDocumentList/InstructionTest.php | 36 +++++++++--------
.../IncludeExample/Instruction.php | 2 +-
.../IncludeExample/InstructionTest.php | 28 +++++++------
.../Instructions/IncludeExec/Instruction.php | 7 +++-
.../IncludeExec/InstructionTest.php | 14 ++++---
.../IncludeFile/InstructionTest.php | 10 ++++-
.../InstructionTest.php | 22 +++++++----
.../IncludePackageList/InstructionTest.php | 28 +++++++++----
.../IncludeTemplate/InstructionTest.php | 30 +++++++++-----
.../src/Preprocessor/Preprocessor.php | 11 +++++-
.../src/Preprocessor/PreprocessorTest.php | 2 +-
.../Preprocessor/Targets/DirectoryPath.php | 10 ++---
.../Targets/DirectoryPathTest.php | 35 +++++++++++------
.../src/Preprocessor/Targets/FilePath.php | 11 ++----
.../src/Preprocessor/Targets/FilePathTest.php | 34 ++++++++++------
30 files changed, 218 insertions(+), 138 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Context.php b/packages/documentator/src/Preprocessor/Context.php
index e4a143729..e187a87a4 100644
--- a/packages/documentator/src/Preprocessor/Context.php
+++ b/packages/documentator/src/Preprocessor/Context.php
@@ -2,9 +2,14 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+
class Context {
public function __construct(
- public readonly string $path,
+ public readonly Directory $root,
+ public readonly Directory $directory,
+ public readonly File $file,
public readonly string $target,
public readonly ?string $parameters,
) {
diff --git a/packages/documentator/src/Preprocessor/Exceptions/DependencyIsMissing.php b/packages/documentator/src/Preprocessor/Exceptions/DependencyIsMissing.php
index 54182ede0..59e1fc668 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/DependencyIsMissing.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/DependencyIsMissing.php
@@ -21,7 +21,7 @@ public function __construct(
sprintf(
'The dependency `%s` is missed (in `%s`).',
$this->class,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/DocumentTitleIsMissing.php b/packages/documentator/src/Preprocessor/Exceptions/DocumentTitleIsMissing.php
index b114141ac..27ab07111 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/DocumentTitleIsMissing.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/DocumentTitleIsMissing.php
@@ -18,7 +18,7 @@ public function __construct(
sprintf(
"The `%s` doesn't contain `# Header` (in `%s`).",
$this->document,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/PackageComposerJsonIsMissing.php b/packages/documentator/src/Preprocessor/Exceptions/PackageComposerJsonIsMissing.php
index ae0e9319c..1b1870b6f 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/PackageComposerJsonIsMissing.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/PackageComposerJsonIsMissing.php
@@ -18,7 +18,7 @@ public function __construct(
sprintf(
"The package `%s` doesn't contain `composer.json` (in `%s`).",
$this->package,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php b/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php
index 83fdcef2a..69c421a7a 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php
@@ -18,7 +18,7 @@ public function __construct(
sprintf(
"The package `%s` doesn't contain readme (in `%s`).",
$this->package,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TargetExecFailed.php b/packages/documentator/src/Preprocessor/Exceptions/TargetExecFailed.php
index 77938ceb0..d05f2bafd 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TargetExecFailed.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/TargetExecFailed.php
@@ -14,7 +14,7 @@ public function __construct(Context $context, Throwable $previous = null) {
sprintf(
'Failed to execute the `%s` command (in `%s`).',
$context->target,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirective.php b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirective.php
index f36a0e53e..2bfa36026 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirective.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirective.php
@@ -14,7 +14,7 @@ public function __construct(Context $context, Throwable $previous = null) {
sprintf(
'The `%s` is not a directive (in `%s`).',
$context->target,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirectory.php b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirectory.php
index fb39be30d..d637d69e3 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirectory.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirectory.php
@@ -14,7 +14,7 @@ public function __construct(Context $context, Throwable $previous = null) {
sprintf(
'The `%s` is not a directory (in `%s`).',
$context->target,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotFile.php b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotFile.php
index e279c0ba1..f633721b1 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotFile.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotFile.php
@@ -14,7 +14,7 @@ public function __construct(Context $context, Throwable $previous = null) {
sprintf(
'The `%s` is not a file (in `%s`).',
$context->target,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotValidPhpFile.php b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotValidPhpFile.php
index 43e807ea5..c25f6c4a6 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotValidPhpFile.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotValidPhpFile.php
@@ -14,7 +14,7 @@ public function __construct(Context $context, Throwable $previous = null) {
sprintf(
'The `%s` is not a valid PHP file (in `%s`).',
$context->target,
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TemplateDataMissed.php b/packages/documentator/src/Preprocessor/Exceptions/TemplateDataMissed.php
index 332f58b9f..53ce49a37 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TemplateDataMissed.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/TemplateDataMissed.php
@@ -13,7 +13,7 @@ public function __construct(Context $context, Throwable $previous = null) {
$context,
sprintf(
'The `data` is required for `%s`.',
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TemplateVariablesMissed.php b/packages/documentator/src/Preprocessor/Exceptions/TemplateVariablesMissed.php
index 319c79df3..c97ada2f1 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TemplateVariablesMissed.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/TemplateVariablesMissed.php
@@ -22,7 +22,7 @@ public function __construct(
sprintf(
'Variables `%s` required in `%s`, but missed.',
'`'.implode('`, `', $this->variables).'`',
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TemplateVariablesUnused.php b/packages/documentator/src/Preprocessor/Exceptions/TemplateVariablesUnused.php
index b816b8b09..3d7d92272 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TemplateVariablesUnused.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/TemplateVariablesUnused.php
@@ -22,7 +22,7 @@ public function __construct(
sprintf(
'Variables `%s` are not used in `%s`.',
'`'.implode('`, `', $this->variables).'`',
- $context->path,
+ $context->file->getRelativePath($context->root),
),
$previous,
);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
index 5db24d251..72bf6a9f3 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
@@ -2,15 +2,17 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeDocBlock;
+use Closure;
use Exception;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotValidPhpFile;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
-use function file_get_contents;
-use function str_replace;
+use function dirname;
/**
* @internal
@@ -19,19 +21,24 @@
final class InstructionTest extends TestCase {
//
// =========================================================================
+ /**
+ * @param Closure(self, Context): Exception|string $expected
+ */
#[DataProvider('dataProviderProcess')]
- public function testProcess(Exception|string $expected, string $file, Parameters $params): void {
- if ($expected instanceof Exception) {
- self::expectExceptionObject($expected);
+ public function testProcess(Closure|string $expected, string $file, Parameters $params): void {
+ $path = self::getTestData()->path($file);
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
+ $target = $file->getContent();
+ $context = new Context($root, $root, $file, $file->getName(), null);
+ $instance = $this->app()->make(Instruction::class);
+
+ if ($expected instanceof Closure) {
+ self::expectExceptionObject($expected($this, $context));
} else {
$expected = self::getTestData()->content($expected);
}
- $file = self::getTestData()->file($file);
- $target = (string) file_get_contents($file->getPathname());
- $context = new Context($file->getPathname(), $file->getFilename(), null);
- $instance = $this->app()->make(Instruction::class);
-
self::assertEquals($expected, $instance->process($context, $target, $params));
}
//
@@ -39,7 +46,7 @@ public function testProcess(Exception|string $expected, string $file, Parameters
//
// =========================================================================
/**
- * @return array
+ * @return array
*/
public static function dataProviderProcess(): array {
return [
@@ -64,13 +71,9 @@ public static function dataProviderProcess(): array {
new Parameters(),
],
'invalid' => [
- new TargetIsNotValidPhpFile(
- new Context(
- str_replace('\\', '/', __DIR__.'/InstructionTest/Invalid.txt'),
- 'Invalid.txt',
- null,
- ),
- ),
+ static function (self $test, Context $context): Exception {
+ return new TargetIsNotValidPhpFile($context);
+ },
'Invalid.txt',
new Parameters(),
],
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
index 48402c0d1..1f88afe0f 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
@@ -12,8 +12,6 @@
use Override;
use Symfony\Component\Finder\Finder;
-use function basename;
-use function dirname;
use function file_get_contents;
use function strcmp;
use function usort;
@@ -51,8 +49,8 @@ public static function getParameters(): ?string {
public function process(Context $context, mixed $target, mixed $parameters): string {
/** @var list $documents */
$documents = [];
- $path = basename($context->path);
- $base = dirname($context->path);
+ $path = $context->file->getName();
+ $base = $context->directory->getPath();
$root = $target;
$target = Path::normalize($context->target);
$finder = Finder::create()->in($root)->name('*.md');
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
index f10fc64bd..e2b89ea4b 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
@@ -5,10 +5,13 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\DirectoryPath;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use function basename;
+use function dirname;
/**
* @internal
@@ -16,9 +19,11 @@
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
public function testProcessSameDirectory(): void {
- $path = self::getTestData()->file('Document.md');
+ $path = self::getTestData()->path('Document.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = new Parameters();
- $context = new Context($path->getPathname(), './', '');
+ $context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
$target = (new DirectoryPath())->resolve($context, null);
$actual = $instance->process($context, $target, $params);
@@ -34,9 +39,11 @@ public function testProcessSameDirectory(): void {
}
public function testProcessAnotherDirectory(): void {
- $path = self::getTestData()->file('~AnotherDirectory.md');
+ $path = self::getTestData()->path('~AnotherDirectory.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = new Parameters();
- $context = new Context($path->getPathname(), basename(self::getTestData()->path('/')), '');
+ $context = new Context($root, $root, $file, basename(self::getTestData()->path('/')), '');
$instance = $this->app()->make(Instruction::class);
$target = (new DirectoryPath())->resolve($context, null);
$actual = $instance->process($context, $target, $params);
@@ -52,9 +59,11 @@ public function testProcessAnotherDirectory(): void {
}
public function testProcessNestedDirectories(): void {
- $path = self::getTestData()->file('nested/Document.md');
+ $path = self::getTestData()->path('nested/Document.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = new Parameters(null);
- $context = new Context($path->getPathname(), './', '');
+ $context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
$target = (new DirectoryPath())->resolve($context, null);
$actual = $instance->process($context, $target, $params);
@@ -70,21 +79,16 @@ public function testProcessNestedDirectories(): void {
}
public function testProcessWithoutTitle(): void {
- $path = self::getTestData()->file('invalid/Document.md');
+ $path = self::getTestData()->path('invalid/Document.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = new Parameters();
- $context = new Context($path->getPathname(), './', '');
+ $context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
$target = (new DirectoryPath())->resolve($context, null);
self::expectExceptionObject(
- new DocumentTitleIsMissing(
- new Context(
- $path->getPathname(),
- $target,
- null,
- ),
- 'WithoutTitle.md',
- ),
+ new DocumentTitleIsMissing($context, 'WithoutTitle.md'),
);
$instance->process($context, $target, $params);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
index 32724271d..635c6ad72 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
@@ -63,7 +63,7 @@ public function process(Context $context, mixed $target, mixed $parameters): str
// Prepare
$content = $target;
$target = $context->target;
- $path = $context->path;
+ $path = $context->file->getPath();
// Process
$language = $this->getLanguage($path, $target);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
index 55eaffeb2..e60f02ec7 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
@@ -5,10 +5,11 @@
use Illuminate\Process\Factory;
use Illuminate\Process\PendingProcess;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
-use function basename;
use function dirname;
use function implode;
use function range;
@@ -21,9 +22,10 @@
final class InstructionTest extends TestCase {
public function testProcessNoRun(): void {
$path = self::getTestData()->path('~example.md');
- $file = basename(self::getTestData()->path('~example.md'));
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = null;
- $context = new Context($path, $file, $params);
+ $context = new Context($root, $root, $file, $file->getName(), $params);
$content = self::getTestData()->content('~example.md');
$expected = trim($content);
$factory = $this->override(Factory::class, function (): Factory {
@@ -48,9 +50,10 @@ public function testProcessNoRun(): void {
public function testProcess(): void {
$path = self::getTestData()->path('~runnable.md');
- $file = basename(self::getTestData()->path('~runnable.md'));
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = null;
- $context = new Context($path, $file, $params);
+ $context = new Context($root, $root, $file, $file->getName(), $params);
$content = self::getTestData()->content('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim($content);
@@ -90,9 +93,10 @@ public function testProcess(): void {
public function testProcessLongOutput(): void {
$path = self::getTestData()->path('~runnable.md');
- $file = self::getTestData()->path('~runnable.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = null;
- $context = new Context($path, $file, $params);
+ $context = new Context($root, $root, $file, $file->getPath(), $params);
$content = self::getTestData()->content('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim($content);
@@ -134,9 +138,10 @@ public function testProcessLongOutput(): void {
public function testProcessMarkdown(): void {
$path = self::getTestData()->path('~runnable.md');
- $file = basename(self::getTestData()->path('~runnable.md'));
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = null;
- $context = new Context($path, $file, $params);
+ $context = new Context($root, $root, $file, $file->getName(), $params);
$content = self::getTestData()->content('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim($content);
@@ -172,9 +177,10 @@ public function testProcessMarkdown(): void {
public function testProcessMarkdownLongOutput(): void {
$path = self::getTestData()->path('~runnable.md');
- $file = self::getTestData()->path('~runnable.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = null;
- $context = new Context($path, $file, $params);
+ $context = new Context($root, $root, $file, $file->getPath(), $params);
$content = self::getTestData()->content('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim($content);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Instruction.php
index 72b623b72..13bf05287 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Instruction.php
@@ -9,7 +9,6 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetExecFailed;
use Override;
-use function dirname;
use function trim;
/**
@@ -43,7 +42,11 @@ public static function getParameters(): ?string {
public function process(Context $context, mixed $target, mixed $parameters): string {
try {
return trim(
- $this->factory->newPendingProcess()->path(dirname($context->path))->run($target)->throw()->output(),
+ $this->factory->newPendingProcess()
+ ->path($context->directory->getPath())
+ ->run($target)
+ ->throw()
+ ->output(),
);
} catch (Exception $exception) {
throw new TargetExecFailed($context, $exception);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
index c5a4066d2..5194b93a6 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
@@ -4,23 +4,25 @@
use Illuminate\Process\Factory;
use Illuminate\Process\PendingProcess;
+use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
-use function dirname;
-
/**
* @internal
*/
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
public function testProcess(): void {
- $path = 'current/working/directory/file.md';
+ $root = new Directory(Path::normalize(__DIR__), false);
+ $file = new File(Path::normalize(__FILE__), false);
$params = null;
$expected = 'result';
$command = 'command to execute';
- $context = new Context($path, $command, $params);
+ $context = new Context($root, $root, $file, $command, $params);
$factory = $this->override(Factory::class, function () use ($command, $expected): Factory {
$factory = $this->app()->make(Factory::class);
$factory->preventStrayProcesses();
@@ -34,8 +36,8 @@ public function testProcess(): void {
self::assertEquals($expected, $instance->process($context, $command, $params));
- $factory->assertRan(static function (PendingProcess $process) use ($path, $command): bool {
- return $process->path === dirname($path)
+ $factory->assertRan(static function (PendingProcess $process) use ($root, $command): bool {
+ return $process->path === $root->getPath()
&& $process->command === $command;
});
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
index d71462be5..1b83441e6 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
@@ -3,18 +3,24 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeFile;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
+use function dirname;
+
/**
* @internal
*/
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
public function testProcess(): void {
- $file = self::getTestData()->path('.md');
+ $path = self::getTestData()->path('.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = null;
- $context = new Context($file, $file, $params);
+ $context = new Context($root, $root, $file, $file->getPath(), $params);
$instance = $this->app()->make(Instruction::class);
$expected = self::getTestData()->content('.md');
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
index 994c17895..f5b1df363 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
@@ -3,9 +3,12 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeGraphqlDirective;
use GraphQL\Language\Parser;
+use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DependencyIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotDirective;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use LastDragon_ru\LaraASP\GraphQLPrinter\Contracts\DirectiveResolver;
use LastDragon_ru\LaraASP\GraphQLPrinter\Contracts\Printer as PrinterContract;
@@ -41,8 +44,10 @@ public function testProcess(): void {
return (new Printer())->setDirectiveResolver($resolver);
});
+ $root = Mockery::mock(Directory::class);
+ $file = Mockery::mock(File::class);
+ $context = new Context($root, $root, $file, '@test', null);
$instance = $this->app()->make(Instruction::class);
- $context = new Context('path/to/file.md', '@test', null);
$actual = $instance->process($context, $context->target, null);
self::assertEquals(
@@ -58,9 +63,10 @@ public function testProcess(): void {
public function testProcessNoPrinter(): void {
unset($this->app()[PrinterContract::class]);
- $path = 'path/to/file.md';
+ $root = new Directory(Path::normalize(__DIR__), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = '@test';
- $context = new Context($path, $target, null);
+ $context = new Context($root, $root, $file, $target, null);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -84,9 +90,10 @@ public function testProcessNoDirective(): void {
return (new Printer())->setDirectiveResolver($resolver);
});
- $path = 'path/to/file.md';
+ $root = new Directory(Path::normalize(__DIR__), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = '@test';
- $context = new Context($path, $target, null);
+ $context = new Context($root, $root, $file, $target, null);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -101,9 +108,10 @@ public function testProcessNoDirectiveResolver(): void {
return (new Printer())->setDirectiveResolver(null);
});
- $path = 'path/to/file.md';
+ $root = new Directory(Path::normalize(__DIR__), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = '@test';
- $context = new Context($path, $target, null);
+ $context = new Context($root, $root, $file, $target, null);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index f75bc4cf2..aa8eb2171 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -2,16 +2,20 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList;
+use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageComposerJsonIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\DirectoryPath;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use function basename;
+use function dirname;
/**
* @internal
@@ -22,10 +26,12 @@ final class InstructionTest extends TestCase {
// =========================================================================
#[DataProvider('dataProviderProcess')]
public function testProcess(string $expected, string $template): void {
- $path = self::getTestData()->file('Document.md')->getPathname();
+ $path = self::getTestData()->path('Document.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = basename(self::getTestData()->path('/packages'));
$params = new Parameters(template: $template);
- $context = new Context($path, $target, '');
+ $context = new Context($root, $root, $file, $target, '');
$resolved = (new DirectoryPath())->resolve($context, null);
$instance = $this->app()->make(Instruction::class);
$actual = $instance->process($context, $resolved, $params);
@@ -41,10 +47,12 @@ public function testProcess(string $expected, string $template): void {
}
public function testProcessNotAPackage(): void {
- $path = self::getTestData()->file('Document.md')->getPathname();
+ $path = self::getTestData()->path('Document.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = basename(self::getTestData()->path('/invalid'));
$params = new Parameters();
- $context = new Context($path, $target, '');
+ $context = new Context($root, $root, $file, $target, '');
$resolved = (new DirectoryPath())->resolve($context, null);
$instance = $this->app()->make(Instruction::class);
@@ -56,10 +64,12 @@ public function testProcessNotAPackage(): void {
}
public function testProcessNoReadme(): void {
- $path = self::getTestData()->file('Document.md')->getPathname();
+ $path = self::getTestData()->path('Document.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = basename(self::getTestData()->path('/no readme'));
$params = new Parameters();
- $context = new Context($path, $target, '');
+ $context = new Context($root, $root, $file, $target, '');
$resolved = (new DirectoryPath())->resolve($context, null);
$instance = $this->app()->make(Instruction::class);
@@ -71,10 +81,12 @@ public function testProcessNoReadme(): void {
}
public function testProcessNoTitle(): void {
- $path = self::getTestData()->file('Document.md')->getPathname();
+ $path = self::getTestData()->path('Document.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = basename(self::getTestData()->path('/no title'));
$params = new Parameters();
- $context = new Context($path, $target, '');
+ $context = new Context($root, $root, $file, $target, '');
$resolved = (new DirectoryPath())->resolve($context, null);
$instance = $this->app()->make(Instruction::class);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
index f8b06109a..2a3d07e81 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
@@ -2,25 +2,32 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeTemplate;
+use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TemplateDataMissed;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TemplateVariablesMissed;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TemplateVariablesUnused;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
+use function dirname;
+
/**
* @internal
*/
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
public function testProcess(): void {
+ $root = new Directory(Path::normalize(__DIR__), false);
+ $file = new File(Path::normalize(__FILE__), false);
$params = new Parameters([
'a' => 'Relative',
'b' => 'Inner reference ${a}',
]);
$content = self::getTestData()->content('.md');
- $context = new Context('/path/to/file.md', '/path/to/file.md', '');
+ $context = new Context($root, $root, $file, '/path/to/file.md', '');
$instance = $this->app()->make(Instruction::class);
self::assertEquals(
@@ -36,10 +43,11 @@ public function testProcess(): void {
}
public function testProcessNoData(): void {
- $file = 'path/to/file.md';
+ $root = new Directory(Path::normalize(__DIR__), false);
+ $file = new File(Path::normalize(__FILE__), false);
$params = new Parameters([]);
$content = 'content';
- $context = new Context($file, $file, '');
+ $context = new Context($root, $root, $file, $file->getPath(), '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -50,15 +58,17 @@ public function testProcessNoData(): void {
}
public function testProcessVariablesUnused(): void {
- $file = self::getTestData()->file('.md');
+ $path = self::getTestData()->path('.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = new Parameters([
'a' => 'A',
'b' => 'B',
'c' => 'C',
'd' => 'D',
]);
- $content = self::getTestData()->content('.md');
- $context = new Context($file->getPathname(), $file->getFilename(), '');
+ $content = $file->getContent();
+ $context = new Context($root, $root, $file, $file->getName(), '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -69,12 +79,14 @@ public function testProcessVariablesUnused(): void {
}
public function testProcessVariablesMissed(): void {
- $file = self::getTestData()->file('.md');
+ $path = self::getTestData()->path('.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
$params = new Parameters([
'a' => 'A',
]);
- $content = self::getTestData()->content('.md');
- $context = new Context($file->getPathname(), $file->getFilename(), '');
+ $content = $file->getContent();
+ $context = new Context($root, $root, $file, $file->getName(), '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index e7e31f2f2..80181983b 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -19,9 +19,12 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeGraphqlDirective\Instruction as IncludeGraphqlDirective;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList\Instruction as IncludePackageList;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeTemplate\Instruction as IncludeTemplate;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializer;
use function array_column;
+use function assert;
+use function dirname;
use function hash;
use function is_array;
use function json_decode;
@@ -141,13 +144,17 @@ protected function getInstruction(string $name): ?Instruction {
public function process(string $path, string $string): string {
$path = Path::normalize($path);
+ $root = new Directory(dirname($path), true);
+ $file = $root->getFile($path);
$cache = [];
$result = null;
+ assert($file !== null);
+
try {
$result = preg_replace_callback(
pattern : static::Regexp,
- callback: function (array $matches) use (&$cache, $path): string {
+ callback: function (array $matches) use (&$cache, $root, $file): string {
// Instruction?
$instruction = $this->getInstruction($matches['instruction']);
@@ -169,7 +176,7 @@ public function process(string $path, string $string): string {
if ($content === null) {
$params = $instruction::getParameters();
$params = $params ? $this->serializer->deserialize($params, $json, 'json') : null;
- $context = new Context($path, $target, $matches['parameters']);
+ $context = new Context($root, $root, $file, $target, $matches['parameters']);
$resolver = $this->container->getInstance()->make($instruction::getResolver());
$resolved = $resolver->resolve($context, $params);
$content = $instruction->process($context, $resolved, $params);
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index 28837c629..f5934eb45 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -114,7 +114,7 @@ public function testProcess(): void {
[//]: # (end: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
MARKDOWN,
- $preprocessor->process('path', $content),
+ $preprocessor->process(__FILE__, $content),
);
}
}
diff --git a/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php b/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
index 2b5a2d391..baaa28330 100644
--- a/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
+++ b/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
@@ -2,15 +2,11 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets;
-use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Resolver;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotDirectory;
use Override;
-use function dirname;
-use function is_dir;
-
/**
* Directory path.
*
@@ -23,12 +19,12 @@ public function __construct() {
#[Override]
public function resolve(Context $context, mixed $parameters): string {
- $path = Path::getPath(dirname($context->path), $context->target);
+ $directory = $context->directory->getDirectory($context->target);
- if (!is_dir($path)) {
+ if (!$directory) {
throw new TargetIsNotDirectory($context);
}
- return $path;
+ return $directory->getPath();
}
}
diff --git a/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php b/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
index 224666197..7a82dda6e 100644
--- a/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
+++ b/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
@@ -5,10 +5,13 @@
use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotDirectory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use function basename;
+use function sprintf;
/**
* @internal
@@ -16,40 +19,50 @@
#[CoversClass(DirectoryPath::class)]
final class DirectoryPathTest extends TestCase {
public function testResolveRelative(): void {
- $dir = __DIR__;
- $target = basename($dir);
+ $dir = new Directory(Path::join(__DIR__, '..'), false);
+ $root = new Directory(Path::join(__DIR__, '../..'), false);
+ $file = new File(Path::normalize(__FILE__), false);
$params = null;
- $context = new Context($dir, $target, null);
+ $context = new Context($root, $dir, $file, basename(__DIR__), null);
$resolver = new DirectoryPath();
self::assertSame(
- Path::normalize($dir),
+ $dir->getDirectory(__DIR__)?->getPath(),
$resolver->resolve($context, $params),
);
}
public function testResolveAbsolute(): void {
- $dir = __DIR__;
- $target = $dir;
+ $dir = new Directory(Path::join(__DIR__, '..'), false);
+ $root = new Directory(Path::join(__DIR__, '../..'), false);
+ $file = new File(Path::normalize(__FILE__), false);
$params = null;
- $context = new Context($dir, $target, null);
+ $context = new Context($root, $dir, $file, $dir->getPath(), null);
$resolver = new DirectoryPath();
self::assertSame(
- Path::normalize($dir),
+ $dir->getPath(),
$resolver->resolve($context, $params),
);
}
public function testResolveNotADirectory(): void {
- $dir = __DIR__;
+ $dir = new Directory(Path::join(__DIR__, '..'), false);
+ $root = new Directory(Path::join(__DIR__, '../..'), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = 'not/a/directory';
$params = null;
- $context = new Context($dir, $target, null);
+ $context = new Context($root, $dir, $file, $target, null);
$resolver = new DirectoryPath();
self::expectException(TargetIsNotDirectory::class);
- self::expectExceptionMessage("The `{$target}` is not a directory (in `{$dir}`).");
+ self::expectExceptionMessage(
+ sprintf(
+ 'The `%s` is not a directory (in `%s`).',
+ $target,
+ $context->file->getRelativePath($context->root),
+ ),
+ );
$resolver->resolve($context, $params);
}
diff --git a/packages/documentator/src/Preprocessor/Targets/FilePath.php b/packages/documentator/src/Preprocessor/Targets/FilePath.php
index 068e5748f..6989b68b3 100644
--- a/packages/documentator/src/Preprocessor/Targets/FilePath.php
+++ b/packages/documentator/src/Preprocessor/Targets/FilePath.php
@@ -2,16 +2,11 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets;
-use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Resolver;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotFile;
use Override;
-use function dirname;
-use function is_file;
-use function is_readable;
-
/**
* File path.
*
@@ -24,12 +19,12 @@ public function __construct() {
#[Override]
public function resolve(Context $context, mixed $parameters): string {
- $path = Path::getPath(dirname($context->path), $context->target);
+ $file = $context->directory->getFile($context->target);
- if (!is_file($path) || !is_readable($path)) {
+ if (!$file) {
throw new TargetIsNotFile($context);
}
- return $path;
+ return $file->getPath();
}
}
diff --git a/packages/documentator/src/Preprocessor/Targets/FilePathTest.php b/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
index 79d5d8390..d3bc8e6c5 100644
--- a/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
+++ b/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
@@ -5,10 +5,12 @@
use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotFile;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
-use function basename;
+use function sprintf;
/**
* @internal
@@ -16,40 +18,48 @@
#[CoversClass(FilePath::class)]
final class FilePathTest extends TestCase {
public function testResolveRelative(): void {
- $file = __FILE__;
- $target = basename($file);
+ $dir = new Directory(Path::join(__DIR__), false);
+ $root = new Directory(Path::join(__DIR__, '../..'), false);
+ $file = new File(Path::normalize(__FILE__), false);
$params = null;
- $context = new Context($file, $target, null);
+ $context = new Context($root, $dir, $file, $file->getName(), null);
$resolver = new FilePath();
self::assertSame(
- Path::normalize($file),
+ $file->getPath(),
$resolver->resolve($context, $params),
);
}
public function testResolveAbsolute(): void {
- $file = __FILE__;
- $target = $file;
+ $dir = new Directory(Path::join(__DIR__), false);
+ $root = new Directory(Path::join(__DIR__, '../..'), false);
+ $file = new File(Path::normalize(__FILE__), false);
$params = null;
- $context = new Context($file, $target, null);
+ $context = new Context($root, $dir, $file, $file->getPath(), null);
$resolver = new FilePath();
self::assertSame(
- Path::normalize($file),
+ $file->getPath(),
$resolver->resolve($context, $params),
);
}
public function testResolveNotAFile(): void {
- $file = __FILE__;
+ $dir = new Directory(Path::join(__DIR__), false);
+ $root = new Directory(Path::join(__DIR__, '../..'), false);
+ $file = new File(Path::normalize(__FILE__), false);
$target = 'not/a/file';
$params = null;
- $context = new Context($file, $target, null);
+ $context = new Context($root, $dir, $file, $target, null);
$resolver = new FilePath();
self::expectException(TargetIsNotFile::class);
- self::expectExceptionMessage("The `{$target}` is not a file (in `{$file}`).");
+ self::expectExceptionMessage(sprintf(
+ 'The `%s` is not a file (in `%s`).',
+ $target,
+ $context->file->getRelativePath($context->root),
+ ));
$resolver->resolve($context, $params);
}
From 060fcb72a8ba01f12fcac327d7c66ae51aae7a21 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Mon, 20 May 2024 10:25:23 +0400
Subject: [PATCH 02/30] Implementation of `Preprocessor::parse()` (extracts
instructions from the file).
---
.../src/Preprocessor/Preprocessor.php | 96 +++++++++++-
.../src/Preprocessor/PreprocessorTest.php | 138 +++++++++++++++---
.../documentator/src/Preprocessor/Token.php | 35 +++++
.../src/Preprocessor/TokenList.php | 17 +++
4 files changed, 267 insertions(+), 19 deletions(-)
create mode 100644 packages/documentator/src/Preprocessor/Token.php
create mode 100644 packages/documentator/src/Preprocessor/TokenList.php
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index 80181983b..60a31895a 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -19,8 +19,11 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeGraphqlDirective\Instruction as IncludeGraphqlDirective;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList\Instruction as IncludePackageList;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeTemplate\Instruction as IncludeTemplate;
+use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Task;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializer;
+use Override;
use function array_column;
use function assert;
@@ -31,6 +34,7 @@
use function json_encode;
use function ksort;
use function mb_substr;
+use function preg_match_all;
use function preg_replace_callback;
use function rawurldecode;
use function str_ends_with;
@@ -38,6 +42,7 @@
use function trim;
use const JSON_THROW_ON_ERROR;
+use const PREG_SET_ORDER;
use const PREG_UNMATCHED_AS_NULL;
/**
@@ -69,7 +74,7 @@
*
* @see Preprocess
*/
-class Preprocessor {
+class Preprocessor implements Task {
protected const Warning = 'Generated automatically. Do not edit.';
protected const Regexp = <<<'REGEXP'
/^
@@ -142,6 +147,95 @@ protected function getInstruction(string $name): ?Instruction {
return $this->instructions[$name][1];
}
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function getExtensions(): array {
+ return ['md'];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function getDependencies(Directory $root, Directory $directory, File $file): array {
+ // TODO: Implement getDependencies() method.
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function run(Directory $root, Directory $directory, File $file, array $dependencies): bool {
+ // TODO: Implement run() method.
+ return false;
+ }
+
+ protected function parse(Directory $root, Directory $directory, File $file): TokenList {
+ // Extract all possible instructions
+ $tokens = [];
+ $matches = [];
+
+ if (!preg_match_all(static::Regexp, $file->getContent(), $matches, PREG_SET_ORDER | PREG_UNMATCHED_AS_NULL)) {
+ return new TokenList($tokens);
+ }
+
+ // Parse each of them
+ foreach ($matches as $match) {
+ // Instruction?
+ $name = (string) $match['instruction'];
+ $instruction = $this->getInstruction($name);
+
+ if (!$instruction) {
+ continue;
+ }
+
+ // Hash
+ $parameters = $instruction::getParameters();
+ $target = (string) $match['target'];
+ $target = str_starts_with($target, '<') && str_ends_with($target, '>')
+ ? mb_substr($target, 1, -1)
+ : rawurldecode($target);
+ $params = $parameters && $match['parameters']
+ ? $this->getParametersJson($match['parameters'])
+ : '{}';
+ $hash = $this->getHash("{$name}({$target}, {$params})");
+
+ // Parsed?
+ if (isset($tokens[$hash])) {
+ $tokens[$hash]->matches[$match[0]] = (string) $match['expression'];
+
+ continue;
+ }
+
+ // Parse
+ $context = new Context($root, $directory, $file, $target, $match['parameters']);
+ $parameters = $parameters
+ ? $this->serializer->deserialize($parameters, $params, 'json')
+ : null;
+ $resolver = $this->container->getInstance()->make($instruction::getResolver());
+ $resolved = $resolver->resolve($context, $parameters);
+
+ $tokens[$hash] = new Token(
+ $instruction,
+ $context,
+ $resolved,
+ $parameters,
+ [
+ $match[0] => (string) $match['expression'],
+ ],
+ );
+ }
+
+ // Return
+ return new TokenList($tokens);
+ }
+
+ /**
+ * @deprecated ! remove
+ */
public function process(string $path, string $string): string {
$path = Path::normalize($path);
$root = new Directory(dirname($path), true);
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index f5934eb45..e31f07570 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -2,10 +2,16 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor;
+use LastDragon_ru\LaraASP\Core\Application\ContainerResolver;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Resolver;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializable;
+use LastDragon_ru\LaraASP\Serializer\Contracts\Serializer;
+use LastDragon_ru\LaraASP\Testing\Mockery\MockProperties;
+use Mockery;
use Override;
use PHPUnit\Framework\Attributes\CoversClass;
@@ -19,36 +25,132 @@
*/
#[CoversClass(Preprocessor::class)]
final class PreprocessorTest extends TestCase {
- public function testProcess(): void {
- $content = <<<'MARKDOWN'
- Bla bla bla [processable]: ./path/to/file should be ignored.
+ private const MARKDOWN = <<<'MARKDOWN'
+ Bla bla bla [processable]: ./path/to/file should be ignored.
- [unknown]: ./path/to/file (should not be parsed)
+ [unknown]: ./path/to/file (should not be parsed)
- [test:empty]: ./path/to/file
+ [test:empty]: ./path/to/file
- [test:instruction]: ./path/to/file
+ [test:instruction]: ./path/to/file
- [test:instruction]: <./path/to/file>
- [//]: # (start: hash)
+ [test:instruction]: <./path/to/file>
+ [//]: # (start: hash)
- [test:instruction]: ./path/to/file
- [//]: # (start: nested-hash)
+ [test:instruction]: ./path/to/file
+ [//]: # (start: nested-hash)
- outdated
+ outdated
- [//]: # (end: nested-hash)
+ [//]: # (end: nested-hash)
- [//]: # (end: hash)
+ [//]: # (end: hash)
- [test:instruction]: ./path/to/file
+ [test:instruction]: ./path/to/file
- [test:instruction]: ./path/to/file
+ [test:instruction]: ./path/to/file
- [test:instruction]: ./path/to/file/parametrized ({"a": "aa", "b": {"a": "a", "b": "b"}})
+ [test:instruction]: ./path/to/file/parametrized ({"a": "aa", "b": {"a": "a", "b": "b"}})
- [test:instruction]: ./path/to/file/parametrized ({"b":{ "b": "b","a": "a"},"a":"aa"})
- MARKDOWN;
+ [test:instruction]: ./path/to/file/parametrized ({"b":{ "b": "b","a": "a"},"a":"aa"})
+ MARKDOWN;
+
+ public function testParse(): void {
+ $a = new PreprocessorTest__EmptyInstruction();
+ $b = new PreprocessorTest__TestInstruction();
+ $root = Mockery::mock(Directory::class);
+ $directory = Mockery::mock(Directory::class);
+ $preprocessor = Mockery::mock(Preprocessor::class, MockProperties::class);
+ $preprocessor->shouldAllowMockingProtectedMethods();
+ $preprocessor->makePartial();
+ $preprocessor->addInstruction($a);
+ $preprocessor->addInstruction($b);
+ $preprocessor
+ ->shouldUseProperty('container')
+ ->value(
+ $this->app()->make(ContainerResolver::class),
+ );
+ $preprocessor
+ ->shouldUseProperty('serializer')
+ ->value(
+ $this->app()->make(Serializer::class),
+ );
+
+ $file = Mockery::mock(File::class);
+ $file
+ ->shouldReceive('getContent')
+ ->once()
+ ->andReturn(self::MARKDOWN);
+
+ $tokens = $preprocessor->parse($root, $directory, $file);
+
+ self::assertEquals(
+ new TokenList([
+ '88d510d98112f651df2ae08444a402cd8b6516cf4c27ad6115dbb2c03fe9ec62' => new Token(
+ $a,
+ new Context($root, $directory, $file, './path/to/file', null),
+ './path/to/file',
+ null,
+ [
+ '[test:empty]: ./path/to/file' => '[test:empty]: ./path/to/file',
+ ],
+ ),
+ '4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095' => new Token(
+ $b,
+ new Context($root, $directory, $file, './path/to/file', null),
+ new PreprocessorTest__Value('./path/to/file/a'),
+ new PreprocessorTest__Parameters(),
+ [
+ // phpcs:disable Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned
+ '[test:instruction]: ./path/to/file' => '[test:instruction]: ./path/to/file',
+ <<<'TXT'
+ [test:instruction]: <./path/to/file>
+ [//]: # (start: hash)
+
+ [test:instruction]: ./path/to/file
+ [//]: # (start: nested-hash)
+
+ outdated
+
+ [//]: # (end: nested-hash)
+
+ [//]: # (end: hash)
+ TXT
+ => '[test:instruction]: <./path/to/file>',
+ // phpcs:enable
+ ],
+ ),
+ 'ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3' => new Token(
+ $b,
+ new Context(
+ $root,
+ $directory,
+ $file,
+ './path/to/file/parametrized',
+ '{"a": "aa", "b": {"a": "a", "b": "b"}}',
+ ),
+ new PreprocessorTest__Value('./path/to/file/parametrized/aa'),
+ new PreprocessorTest__Parameters(
+ 'aa',
+ [
+ 'a' => 'a',
+ 'b' => 'b',
+ ],
+ ),
+ [
+ '[test:instruction]: ./path/to/file/parametrized ({"a": "aa", "b": {"a": "a", "b": "b"}})' => ''
+ .'[test:instruction]: ./path/to/file/parametrized ({"a": "aa", "b": {"a": "a", "b": "b"}})',
+ '[test:instruction]: ./path/to/file/parametrized ({"b":{ "b": "b","a": "a"},"a":"aa"})' => ''
+ .'[test:instruction]: ./path/to/file/parametrized ({"b":{ "b": "b","a": "a"},"a":"aa"})',
+ ],
+ ),
+ ]),
+ $tokens,
+ );
+ }
+
+ public function testProcess(): void {
+ $content = static::MARKDOWN;
$preprocessor = $this->app()->make(Preprocessor::class)
->addInstruction(new PreprocessorTest__EmptyInstruction())
diff --git a/packages/documentator/src/Preprocessor/Token.php b/packages/documentator/src/Preprocessor/Token.php
new file mode 100644
index 000000000..038ab13e3
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/Token.php
@@ -0,0 +1,35 @@
+
+ */
+ public readonly Instruction $instance,
+ public readonly Context $context,
+ /**
+ * @var TTarget
+ */
+ public readonly mixed $target,
+ /**
+ * @var TParameters
+ */
+ public readonly mixed $parameters,
+ /**
+ * @var array
+ */
+ public array $matches,
+ ) {
+ // empty
+ }
+}
diff --git a/packages/documentator/src/Preprocessor/TokenList.php b/packages/documentator/src/Preprocessor/TokenList.php
new file mode 100644
index 000000000..3b59a2619
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/TokenList.php
@@ -0,0 +1,17 @@
+>
+ */
+ public readonly array $tokens,
+ ) {
+ // empty
+ }
+}
From 34200f8f8b4b603ef9800474aacc6bc0537a39ce Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Mon, 20 May 2024 13:03:42 +0400
Subject: [PATCH 03/30] `Preprocessor::run()` implementation.
---
.../src/Preprocessor/Preprocessor.php | 58 +++++++++++-
.../src/Preprocessor/PreprocessorTest.php | 89 +++++++++++++++++++
.../documentator/src/Preprocessor/Token.php | 2 +-
3 files changed, 146 insertions(+), 3 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index 60a31895a..bdc3f3fed 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -33,13 +33,16 @@
use function json_decode;
use function json_encode;
use function ksort;
+use function mb_strlen;
use function mb_substr;
use function preg_match_all;
use function preg_replace_callback;
use function rawurldecode;
use function str_ends_with;
use function str_starts_with;
+use function strtr;
use function trim;
+use function uksort;
use const JSON_THROW_ON_ERROR;
use const PREG_SET_ORDER;
@@ -169,8 +172,59 @@ public function getDependencies(Directory $root, Directory $directory, File $fil
*/
#[Override]
public function run(Directory $root, Directory $directory, File $file, array $dependencies): bool {
- // TODO: Implement run() method.
- return false;
+ // Parse
+ // TODO: Check if Context contains tokens
+ $parsed = $this->parse($root, $directory, $file);
+
+ // Prepare
+ $replace = [];
+ $warning = static::Warning;
+
+ foreach ($parsed->tokens as $hash => $token) {
+ try {
+ $content = $token->instruction->process($token->context, $token->target, $token->parameters);
+ $content = trim($content);
+ } catch (PreprocessorError $exception) {
+ throw $exception;
+ } catch (Exception $exception) {
+ throw new PreprocessingFailed($exception);
+ }
+
+ foreach ($token->matches as $match => $expression) {
+ $prefix = << << << mb_strlen($a);
+ });
+
+ // Replace
+ $file->setContent(strtr($file->getContent(), $replace));
+
+ return true;
}
protected function parse(Directory $root, Directory $directory, File $file): TokenList {
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index e31f07570..ce02dc611 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -149,6 +149,95 @@ public function testParse(): void {
);
}
+ public function testRun(): void {
+ $actual = null;
+ $root = Mockery::mock(Directory::class);
+ $file = Mockery::mock(File::class);
+ $file
+ ->shouldReceive('getContent')
+ ->atLeast()
+ ->once()
+ ->andReturn(static::MARKDOWN);
+ $file
+ ->shouldReceive('setContent')
+ ->once()
+ ->andReturnUsing(
+ static function (string $content) use ($file, &$actual): File {
+ $actual = $content;
+
+ return $file;
+ },
+ );
+
+ $preprocessor = $this->app()->make(Preprocessor::class)
+ ->addInstruction(new PreprocessorTest__EmptyInstruction())
+ ->addInstruction(new PreprocessorTest__TestInstruction());
+
+ self::assertTrue($preprocessor->run($root, $root, $file, []));
+ self::assertEquals(
+ <<<'MARKDOWN'
+ Bla bla bla [processable]: ./path/to/file should be ignored.
+
+ [unknown]: ./path/to/file (should not be parsed)
+
+ [test:empty]: ./path/to/file
+ [//]: # (start: 88d510d98112f651df2ae08444a402cd8b6516cf4c27ad6115dbb2c03fe9ec62)
+ [//]: # (warning: Generated automatically. Do not edit.)
+ [//]: # (empty)
+ [//]: # (end: 88d510d98112f651df2ae08444a402cd8b6516cf4c27ad6115dbb2c03fe9ec62)
+
+ [test:instruction]: ./path/to/file
+ [//]: # (start: 4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095)
+ [//]: # (warning: Generated automatically. Do not edit.)
+
+ result(./path/to/file/a, {"a":"a","b":[]})
+
+ [//]: # (end: 4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095)
+
+ [test:instruction]: <./path/to/file>
+ [//]: # (start: 4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095)
+ [//]: # (warning: Generated automatically. Do not edit.)
+
+ result(./path/to/file/a, {"a":"a","b":[]})
+
+ [//]: # (end: 4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095)
+
+ [test:instruction]: ./path/to/file
+ [//]: # (start: 4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095)
+ [//]: # (warning: Generated automatically. Do not edit.)
+
+ result(./path/to/file/a, {"a":"a","b":[]})
+
+ [//]: # (end: 4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095)
+
+ [test:instruction]: ./path/to/file
+ [//]: # (start: 4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095)
+ [//]: # (warning: Generated automatically. Do not edit.)
+
+ result(./path/to/file/a, {"a":"a","b":[]})
+
+ [//]: # (end: 4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095)
+
+ [test:instruction]: ./path/to/file/parametrized ({"a": "aa", "b": {"a": "a", "b": "b"}})
+ [//]: # (start: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
+ [//]: # (warning: Generated automatically. Do not edit.)
+
+ result(./path/to/file/parametrized/aa, {"a":"aa","b":{"a":"a","b":"b"}})
+
+ [//]: # (end: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
+
+ [test:instruction]: ./path/to/file/parametrized ({"b":{ "b": "b","a": "a"},"a":"aa"})
+ [//]: # (start: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
+ [//]: # (warning: Generated automatically. Do not edit.)
+
+ result(./path/to/file/parametrized/aa, {"a":"aa","b":{"a":"a","b":"b"}})
+
+ [//]: # (end: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
+ MARKDOWN,
+ $actual,
+ );
+ }
+
public function testProcess(): void {
$content = static::MARKDOWN;
diff --git a/packages/documentator/src/Preprocessor/Token.php b/packages/documentator/src/Preprocessor/Token.php
index 038ab13e3..7fbec11d9 100644
--- a/packages/documentator/src/Preprocessor/Token.php
+++ b/packages/documentator/src/Preprocessor/Token.php
@@ -15,7 +15,7 @@ public function __construct(
/**
* @var Instruction
*/
- public readonly Instruction $instance,
+ public readonly Instruction $instruction,
public readonly Context $context,
/**
* @var TTarget
From ee2896acabae7f325f921e1ff8ae57b9ffd9f575 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Mon, 20 May 2024 14:11:35 +0400
Subject: [PATCH 04/30] `lara-asp-documentator:preprocess` switched to new
`Processor`.
---
packages/documentator/composer.json | 1 +
.../documentator/src/Commands/Preprocess.php | 58 ++++++------
.../src/Preprocessor/Preprocessor.php | 94 -------------------
.../src/Preprocessor/PreprocessorTest.php | 71 --------------
4 files changed, 32 insertions(+), 192 deletions(-)
diff --git a/packages/documentator/composer.json b/packages/documentator/composer.json
index d8349e216..6a3749604 100644
--- a/packages/documentator/composer.json
+++ b/packages/documentator/composer.json
@@ -34,6 +34,7 @@
"symfony/polyfill-php83": "^1.28",
"symfony/serializer": "^6.3.3|^7.0.0",
"lastdragon-ru/lara-asp-core": "self.version",
+ "lastdragon-ru/lara-asp-formatter": "self.version",
"lastdragon-ru/lara-asp-graphql-printer": "self.version",
"lastdragon-ru/lara-asp-serializer": "self.version"
},
diff --git a/packages/documentator/src/Commands/Preprocess.php b/packages/documentator/src/Commands/Preprocess.php
index dc3bf4b16..2d24c0862 100644
--- a/packages/documentator/src/Commands/Preprocess.php
+++ b/packages/documentator/src/Commands/Preprocess.php
@@ -4,18 +4,20 @@
use Illuminate\Console\Command;
use LastDragon_ru\LaraASP\Core\Utils\Cast;
+use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Package;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Preprocessor;
+use LastDragon_ru\LaraASP\Documentator\Processor\Processor;
use LastDragon_ru\LaraASP\Documentator\Utils\Markdown;
use LastDragon_ru\LaraASP\Documentator\Utils\PhpDoc;
+use LastDragon_ru\LaraASP\Formatter\Formatter;
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializable;
use Override;
use ReflectionClass;
use ReflectionProperty;
use Symfony\Component\Console\Attribute\AsCommand;
-use Symfony\Component\Filesystem\Filesystem;
-use Symfony\Component\Finder\Finder;
+use Symfony\Component\Console\Terminal;
use function getcwd;
use function gettype;
@@ -23,7 +25,11 @@
use function is_a;
use function is_scalar;
use function ksort;
+use function mb_strlen;
+use function microtime;
+use function min;
use function rtrim;
+use function str_repeat;
use function strtr;
use function trim;
use function var_export;
@@ -64,31 +70,29 @@ public function __construct(
parent::__construct();
}
- public function __invoke(Filesystem $filesystem): void {
- $cwd = getcwd();
- $path = Cast::toString($this->argument('path') ?? $cwd);
- $finder = Finder::create()
- ->ignoreVCSIgnored(true)
- ->in($path)
- ->exclude('vendor')
- ->exclude('node_modules')
- ->files()
- ->name('*.md');
-
- foreach ($finder as $file) {
- $this->components->task(
- $file->getPathname(),
- function () use ($filesystem, $file): void {
- $path = $file->getPathname();
- $content = $file->getContents();
- $result = $this->preprocessor->process($path, $content);
-
- if ($content !== $result) {
- $filesystem->dumpFile($path, $result);
- }
- },
- );
- }
+ public function __invoke(Formatter $formatter): void {
+ $cwd = getcwd();
+ $path = Cast::toString($this->argument('path') ?? $cwd);
+ $path = Path::normalize($path);
+ $width = min((new Terminal())->getWidth(), 150);
+ $start = microtime(true);
+
+ (new Processor())
+ ->task($this->preprocessor)
+ ->run($path, function (string $path, bool $success, float $duration) use ($formatter, $width): void {
+ $duration = $formatter->duration($duration);
+ $result = $success ? 'DONE' : 'FAIL';
+ $length = $width - (mb_strlen($path) + mb_strlen($duration) + mb_strlen($result) + 5);
+ $line = $path
+ .' '.($length > 0 ? ''.str_repeat('.', $length).'>' : '')
+ .' '."{$duration}>"
+ .' '.($success ? "{$result}>" : "{$result}>");
+
+ $this->output->writeln($line);
+ });
+
+ $this->output->newLine();
+ $this->output->writeln("OK ({$formatter->duration(microtime(true) - $start)})>");
}
#[Override]
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index bdc3f3fed..c0d597633 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -6,7 +6,6 @@
use Exception;
use LastDragon_ru\LaraASP\Core\Application\ContainerResolver;
-use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Commands\Preprocess;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PreprocessingFailed;
@@ -26,8 +25,6 @@
use Override;
use function array_column;
-use function assert;
-use function dirname;
use function hash;
use function is_array;
use function json_decode;
@@ -36,7 +33,6 @@
use function mb_strlen;
use function mb_substr;
use function preg_match_all;
-use function preg_replace_callback;
use function rawurldecode;
use function str_ends_with;
use function str_starts_with;
@@ -287,96 +283,6 @@ protected function parse(Directory $root, Directory $directory, File $file): Tok
return new TokenList($tokens);
}
- /**
- * @deprecated ! remove
- */
- public function process(string $path, string $string): string {
- $path = Path::normalize($path);
- $root = new Directory(dirname($path), true);
- $file = $root->getFile($path);
- $cache = [];
- $result = null;
-
- assert($file !== null);
-
- try {
- $result = preg_replace_callback(
- pattern : static::Regexp,
- callback: function (array $matches) use (&$cache, $root, $file): string {
- // Instruction?
- $instruction = $this->getInstruction($matches['instruction']);
-
- if (!$instruction) {
- return $matches['expression'];
- }
-
- // Hash
- $target = $matches['target'];
- $target = str_starts_with($target, '<') && str_ends_with($target, '>')
- ? mb_substr($target, 1, -1)
- : rawurldecode($target);
- $json = $this->getParametersJson($matches['parameters'] ?: '{}');
- $hash = $this->getHash("{$matches['instruction']}({$target}, {$json})");
-
- // Content
- $content = $cache[$hash] ?? null;
-
- if ($content === null) {
- $params = $instruction::getParameters();
- $params = $params ? $this->serializer->deserialize($params, $json, 'json') : null;
- $context = new Context($root, $root, $file, $target, $matches['parameters']);
- $resolver = $this->container->getInstance()->make($instruction::getResolver());
- $resolved = $resolver->resolve($context, $params);
- $content = $instruction->process($context, $resolved, $params);
- $content = trim($content);
- $cache[$hash] = $content;
- }
-
- // Return
- $warning = static::Warning;
- $prefix = <<app()->make(Preprocessor::class)
- ->addInstruction(new PreprocessorTest__EmptyInstruction())
- ->addInstruction(new PreprocessorTest__TestInstruction());
-
- self::assertEquals(
- <<<'MARKDOWN'
- Bla bla bla [processable]: ./path/to/file should be ignored.
-
- [unknown]: ./path/to/file (should not be parsed)
-
- [test:empty]: ./path/to/file
- [//]: # (start: caf14319a44edf638bf2ba4b4c76caab5a3d85ee06d5c86387fbdb703c8b5c84)
- [//]: # (warning: Generated automatically. Do not edit.)
- [//]: # (empty)
- [//]: # (end: caf14319a44edf638bf2ba4b4c76caab5a3d85ee06d5c86387fbdb703c8b5c84)
-
- [test:instruction]: ./path/to/file
- [//]: # (start: 15a77bf03e0261f0d7d2af698861fc23733fb4f09e0570e3b2570f4fe7b2694c)
- [//]: # (warning: Generated automatically. Do not edit.)
-
- result(./path/to/file/a, {"a":"a","b":[]})
-
- [//]: # (end: 15a77bf03e0261f0d7d2af698861fc23733fb4f09e0570e3b2570f4fe7b2694c)
-
- [test:instruction]: <./path/to/file>
- [//]: # (start: 15a77bf03e0261f0d7d2af698861fc23733fb4f09e0570e3b2570f4fe7b2694c)
- [//]: # (warning: Generated automatically. Do not edit.)
-
- result(./path/to/file/a, {"a":"a","b":[]})
-
- [//]: # (end: 15a77bf03e0261f0d7d2af698861fc23733fb4f09e0570e3b2570f4fe7b2694c)
-
- [test:instruction]: ./path/to/file
- [//]: # (start: 15a77bf03e0261f0d7d2af698861fc23733fb4f09e0570e3b2570f4fe7b2694c)
- [//]: # (warning: Generated automatically. Do not edit.)
-
- result(./path/to/file/a, {"a":"a","b":[]})
-
- [//]: # (end: 15a77bf03e0261f0d7d2af698861fc23733fb4f09e0570e3b2570f4fe7b2694c)
-
- [test:instruction]: ./path/to/file
- [//]: # (start: 15a77bf03e0261f0d7d2af698861fc23733fb4f09e0570e3b2570f4fe7b2694c)
- [//]: # (warning: Generated automatically. Do not edit.)
-
- result(./path/to/file/a, {"a":"a","b":[]})
-
- [//]: # (end: 15a77bf03e0261f0d7d2af698861fc23733fb4f09e0570e3b2570f4fe7b2694c)
-
- [test:instruction]: ./path/to/file/parametrized ({"a": "aa", "b": {"a": "a", "b": "b"}})
- [//]: # (start: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
- [//]: # (warning: Generated automatically. Do not edit.)
-
- result(./path/to/file/parametrized/aa, {"a":"aa","b":{"a":"a","b":"b"}})
-
- [//]: # (end: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
-
- [test:instruction]: ./path/to/file/parametrized ({"b":{ "b": "b","a": "a"},"a":"aa"})
- [//]: # (start: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
- [//]: # (warning: Generated automatically. Do not edit.)
-
- result(./path/to/file/parametrized/aa, {"a":"aa","b":{"a":"a","b":"b"}})
-
- [//]: # (end: ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3)
- MARKDOWN,
- $preprocessor->process(__FILE__, $content),
- );
- }
}
// @phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
From 5843445893c2a9d0c2d373dd2b4a69d2e57373a5 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Mon, 20 May 2024 14:16:34 +0400
Subject: [PATCH 05/30] docs: rebuild.
---
README.md | 16 ++---
UPGRADE.md | 4 +-
packages/core/README.md | 12 ++--
packages/core/UPGRADE.md | 12 ++--
packages/dev/README.md | 12 ++--
packages/dev/UPGRADE.md | 4 +-
packages/documentator/README.md | 16 ++---
packages/documentator/UPGRADE.md | 12 ++--
packages/eloquent/README.md | 12 ++--
packages/eloquent/UPGRADE.md | 12 ++--
packages/formatter/README.md | 24 +++----
packages/formatter/UPGRADE.md | 12 ++--
packages/graphql-printer/README.md | 28 ++++----
packages/graphql-printer/UPGRADE.md | 4 +-
.../AssertGraphQLExportableEquals.md | 4 +-
.../AssertGraphQLPrintableEquals.md | 4 +-
packages/graphql/README.md | 36 +++++-----
packages/graphql/UPGRADE.md | 12 ++--
.../AssertGraphQLIntrospectionEquals.md | 4 +-
.../Assertions/AssertGraphQLSchemaEquals.md | 4 +-
.../AssertGraphQLSchemaNoBreakingChanges.md | 4 +-
.../AssertGraphQLSchemaNoDangerousChanges.md | 4 +-
.../Assertions/AssertGraphQLSchemaValid.md | 4 +-
packages/graphql/docs/Directives/@searchBy.md | 16 ++---
packages/graphql/docs/Directives/@sortBy.md | 12 ++--
packages/graphql/docs/Directives/@stream.md | 8 +--
packages/graphql/docs/Directives/@type.md | 4 +-
packages/graphql/docs/Scalars/JsonString.md | 4 +-
packages/migrator/README.md | 12 ++--
packages/migrator/UPGRADE.md | 12 ++--
packages/serializer/README.md | 16 ++---
packages/serializer/UPGRADE.md | 12 ++--
packages/spa/README.md | 12 ++--
packages/spa/UPGRADE.md | 12 ++--
packages/testing/README.md | 68 +++++++++----------
packages/testing/UPGRADE.md | 12 ++--
.../Assertions/AssertDatabaseQueryEquals.md | 4 +-
.../Assertions/AssertJsonMatchesSchema.md | 4 +-
.../docs/Assertions/AssertPsrResponse.md | 4 +-
.../docs/Assertions/AssertQueryLogEquals.md | 4 +-
.../docs/Assertions/AssertScheduled.md | 4 +-
.../docs/Assertions/AssertScoutQueryEquals.md | 4 +-
.../docs/Assertions/AssertThatResponse.md | 4 +-
.../docs/Assertions/AssertXmlMatchesSchema.md | 4 +-
44 files changed, 244 insertions(+), 244 deletions(-)
diff --git a/README.md b/README.md
index d70aa4b91..f054ce5f2 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
The set provides best practices to make development more fun and classes/services that I found very useful while working on big extensible applications.
[include:exec]: <./dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 5a6479e01ca04242d936b5543af76210a1af5db5468e2f480f167a2a046b62db)
+[//]: # (start: cf085248b2284f354e6966f146d7c1c32821f3031a0316e73df3a80e038e704f)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -25,7 +25,7 @@ The set provides best practices to make development more fun and classes/service
| | `^8.22.1` | `3.0.0 ⋯ 0.2.0` |
| | `^8.0` | `0.1.0` |
-[//]: # (end: 5a6479e01ca04242d936b5543af76210a1af5db5468e2f480f167a2a046b62db)
+[//]: # (end: cf085248b2284f354e6966f146d7c1c32821f3031a0316e73df3a80e038e704f)
# Installation
@@ -42,7 +42,7 @@ composer require lastdragon-ru/lara-asp-
|:--:|---------------------------------|
[include:package-list]: ./packages
-[//]: # (start: df3ee6374fabefbdeb79b26164b3f2ef88f6ed94646bb5d44751ea6da758de19)
+[//]: # (start: 2d5a58effc8f1949a8d20851019e2cefc9eeb2ea45725bf2b8147fee917f0b0c)
[//]: # (warning: Generated automatically. Do not edit.)
## (Laravel) Core
@@ -109,17 +109,17 @@ Independent (from Laravel and Lighthouse) package that allow you to print GraphQ
[Read more]().
-[//]: # (end: df3ee6374fabefbdeb79b26164b3f2ef88f6ed94646bb5d44751ea6da758de19)
+[//]: # (end: 2d5a58effc8f1949a8d20851019e2cefc9eeb2ea45725bf2b8147fee917f0b0c)
[include:file]: ./docs/Shared/Upgrading.md
-[//]: # (start: cdb14a15bab8920d27c60204790e96bf814a9d780f6a55d5e93422db9bf56f64)
+[//]: # (start: cbfccea895cb6cddbed8d1e403e510b43171341972c83ab9373a1bc25f6c2e65)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: cdb14a15bab8920d27c60204790e96bf814a9d780f6a55d5e93422db9bf56f64)
+[//]: # (end: cbfccea895cb6cddbed8d1e403e510b43171341972c83ab9373a1bc25f6c2e65)
# Development
@@ -129,7 +129,7 @@ Please follow [Upgrade Guide](UPGRADE.md).
4. Enjoy
[include:file]: ./docs/Legend.md
-[//]: # (start: 68b5a2c9955bc3698c6033103ab34e32d67edfcff7b726f187662b5ce2e15a67)
+[//]: # (start: 9a1322b3ab69b4443131311847c0af0cf6f86c6024c1436b67733d42ba3e2e4a)
[//]: # (warning: Generated automatically. Do not edit.)
# Legend
@@ -148,4 +148,4 @@ Please follow [Upgrade Guide](UPGRADE.md).
| 🆆 | CI | Running on Windows |
| 🅼 | CI | Running on Mac OS X |
-[//]: # (end: 68b5a2c9955bc3698c6033103ab34e32d67edfcff7b726f187662b5ce2e15a67)
+[//]: # (end: 9a1322b3ab69b4443131311847c0af0cf6f86c6024c1436b67733d42ba3e2e4a)
diff --git a/UPGRADE.md b/UPGRADE.md
index a9ecad721..c59b3f4d5 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ./docs/Shared/Upgrade.md
-[//]: # (start: 556e36b93ca9f82e94056295c197aa9a4c8c042054927a9bf08dd9140ad872b8)
+[//]: # (start: c437867d96b216fb0f421c0c5b19b29eea42439b286bc4bc8f0f551f1fe2d9c2)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,7 +25,7 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 556e36b93ca9f82e94056295c197aa9a4c8c042054927a9bf08dd9140ad872b8)
+[//]: # (end: c437867d96b216fb0f421c0c5b19b29eea42439b286bc4bc8f0f551f1fe2d9c2)
# Packages
diff --git a/packages/core/README.md b/packages/core/README.md
index 8bfcd959a..06c32ed09 100644
--- a/packages/core/README.md
+++ b/packages/core/README.md
@@ -3,7 +3,7 @@
This package contains useful utilities and classes.
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -24,7 +24,7 @@ This package contains useful utilities and classes.
| | `^9.0.0` | `5.0.0-beta.0 ⋯ 0.12.0` |
| | `^8.22.1` | `3.0.0 ⋯ 0.4.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "core"}})
[//]: # (start: 701034cd4b15ff1d0ee9742e3d839f3a0c70ba66d75ff6c56f712d2f69e254ae)
@@ -43,21 +43,21 @@ composer require lastdragon-ru/lara-asp-core
Please see the [source code](./src) to find something interesting 😅
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
diff --git a/packages/core/UPGRADE.md b/packages/core/UPGRADE.md
index 0ba72f4c4..474be67cf 100644
--- a/packages/core/UPGRADE.md
+++ b/packages/core/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,26 +25,26 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
# Upgrade from v6
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
* [ ] `\LastDragon_ru\LaraASP\Core\Provider\WithRoutes::bootRoutes()` requires settings.
# Upgrade from v5
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
diff --git a/packages/dev/README.md b/packages/dev/README.md
index 703f67d20..9207f9264 100644
--- a/packages/dev/README.md
+++ b/packages/dev/README.md
@@ -3,7 +3,7 @@
Various internal tools and helpers to develop the package itself.
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -15,7 +15,7 @@ Various internal tools and helpers to develop the package itself.
| | `^8.1` | `HEAD ⋯ 6.2.0` |
| PHPStan | `^1.10` | `HEAD ⋯ 6.2.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/InstallationDev.md ({"data": {"package": "dev"}})
[//]: # (start: e7fd13bb6d43bcc48d9fe51411b607bee0e47ccbcb1b788889f59b733865e0f1)
@@ -38,21 +38,21 @@ composer require --dev lastdragon-ru/lara-asp-dev
_In progress_.
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
diff --git a/packages/dev/UPGRADE.md b/packages/dev/UPGRADE.md
index 9da8be17d..61a12a295 100644
--- a/packages/dev/UPGRADE.md
+++ b/packages/dev/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,4 +25,4 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
diff --git a/packages/documentator/README.md b/packages/documentator/README.md
index bf2382ae3..4df6f6346 100644
--- a/packages/documentator/README.md
+++ b/packages/documentator/README.md
@@ -3,7 +3,7 @@
This package provides various utilities for documentation generation such as Markdown Preprocessor, Requirements Dumper and more.
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -18,7 +18,7 @@ This package provides various utilities for documentation generation such as Mar
| | `^10.0.0` | `6.1.0 ⋯ 5.0.0-beta.1` |
| | `^9.21.0` | `5.6.0 ⋯ 5.0.0-beta.1` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "documentator"}})
[//]: # (start: d830b5dad8950e88a29e14aa443ca509cfa19889b5c3792b00691760fb8618bb)
@@ -35,7 +35,7 @@ composer require lastdragon-ru/lara-asp-documentator
# Commands
[include:document-list]: ./docs/Commands
-[//]: # (start: 3183e17484393f086cbec523de70a97446749151d781d55ef8f480075e5c75b9)
+[//]: # (start: bf4572c5a716c01f9df13bb1bfb0e1a6d9c62b3f19f5467f152a12da3f5d92ad)
[//]: # (warning: Generated automatically. Do not edit.)
## `lara-asp-documentator:commands`
@@ -56,24 +56,24 @@ Generates a table with the required versions of PHP/Laravel/etc in Markdown form
[Read more]().
-[//]: # (end: 3183e17484393f086cbec523de70a97446749151d781d55ef8f480075e5c75b9)
+[//]: # (end: bf4572c5a716c01f9df13bb1bfb0e1a6d9c62b3f19f5467f152a12da3f5d92ad)
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
diff --git a/packages/documentator/UPGRADE.md b/packages/documentator/UPGRADE.md
index d3069bd60..944fd9070 100644
--- a/packages/documentator/UPGRADE.md
+++ b/packages/documentator/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,29 +25,29 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
# Upgrade from v6
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
* [ ] Migrate to the new contract `\LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction`.
# Upgrade from v5
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
* [ ] Replace `LastDragon_ru\LaraASP\Documentator\Preprocessor\InstructionContract` by `LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\ProcessableInstruction` or `LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\ParameterizableInstruction`.
diff --git a/packages/eloquent/README.md b/packages/eloquent/README.md
index 97e44f976..eabad5262 100644
--- a/packages/eloquent/README.md
+++ b/packages/eloquent/README.md
@@ -3,7 +3,7 @@
This package contains useful extensions and mixins for [Eloquent](https://laravel.com/docs/eloquent).
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -25,7 +25,7 @@ This package contains useful extensions and mixins for [Eloquent](https://larave
| | `^8.22.1` | `3.0.0 ⋯ 0.2.0` |
| | `^8.0` | `0.1.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "eloquent"}})
[//]: # (start: 1c6aa4607fbf4f4c0efb2249a42271075a45316e15a4fe7f914d8bb883f71ea2)
@@ -101,21 +101,21 @@ foreach ($query->getChangeSafeIterator() as $user) {
| `getChangeSafeIteratorIterator()` | Return [`ChunkedChangeSafeIterator`](./src/Iterators/ChunkedChangeSafeIterator.php) instance. |
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
diff --git a/packages/eloquent/UPGRADE.md b/packages/eloquent/UPGRADE.md
index 4db3e25b6..d844e9738 100644
--- a/packages/eloquent/UPGRADE.md
+++ b/packages/eloquent/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,24 +25,24 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
# Upgrade from v6
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
# Upgrade from v5
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
diff --git a/packages/formatter/README.md b/packages/formatter/README.md
index eec043db9..bf28c6dd7 100644
--- a/packages/formatter/README.md
+++ b/packages/formatter/README.md
@@ -3,7 +3,7 @@
This package provides a customizable wrapper around [Intl](https://www.php.net/manual/en/book.intl) formatters to use it inside Laravel application.
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -25,7 +25,7 @@ This package provides a customizable wrapper around [Intl](https://www.php.net/m
| | `^8.22.1` | `3.0.0 ⋯ 0.2.0` |
| | `^8.0` | `0.1.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "formatter"}})
[//]: # (start: ca18ec42d5b2c99e52f3a550acc6e29f65958871ab3405d38e82ef8eab2ad415)
@@ -44,7 +44,7 @@ composer require lastdragon-ru/lara-asp-formatter
Formatter is very simple to use:
[include:example]: ./docs/Examples/Usage.php
-[//]: # (start: c709a4b715d1bde109a5d27982a2a5d6f481b5c72338e162e394ccbb6fc9208a)
+[//]: # (start: adef85def212f87b8f157b40eaa0695da87e1a6f63e1e1ebc9fff474ecad3fee)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -79,7 +79,7 @@ The `$locale->decimal(123.454321)` is:
"123,45"
```
-[//]: # (end: c709a4b715d1bde109a5d27982a2a5d6f481b5c72338e162e394ccbb6fc9208a)
+[//]: # (end: adef85def212f87b8f157b40eaa0695da87e1a6f63e1e1ebc9fff474ecad3fee)
Please check [source code](./src/Formatter.php) to see available methods and [config example](defaults/config.php) to available settings 🤗
@@ -92,7 +92,7 @@ php artisan vendor:publish --provider=LastDragon_ru\\LaraASP\\Formatter\\Provide
```
[include:example]: ./docs/Examples/Config.php
-[//]: # (start: 5a587883c875573a9d3678bc736730f7a394c6f0ed287bfe4ccd2d2b9009a42e)
+[//]: # (start: 79abdc1016ae295c77f37d2c430cec8b2de87be7096c32913e441a5d5057ec31)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -156,7 +156,7 @@ The `$locale->date($datetime, 'custom')` is:
"30.12.2023"
```
-[//]: # (end: 5a587883c875573a9d3678bc736730f7a394c6f0ed287bfe4ccd2d2b9009a42e)
+[//]: # (end: 79abdc1016ae295c77f37d2c430cec8b2de87be7096c32913e441a5d5057ec31)
# Duration
@@ -184,7 +184,7 @@ The syntax is the same as [ICU Date/Time format syntax](https://unicode-org.gith
[//]: # (end: 363cfceaffb54119c82e514732db74b5265a5fc6724699580b2d3c677c1258f7)
[include:example]: ./docs/Examples/Duration.php
-[//]: # (start: faff341985cd0ca05372c01461e1e4c151f5131fc7a76722fd00aac905a68ff9)
+[//]: # (start: 4601baed9dde5929ecc10d49ca83c24f5f9b1394fefd9f200fbc3085d5469cf1)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -219,24 +219,24 @@ The `$locale->duration(1234543)` is:
"342:55:43.000"
```
-[//]: # (end: faff341985cd0ca05372c01461e1e4c151f5131fc7a76722fd00aac905a68ff9)
+[//]: # (end: 4601baed9dde5929ecc10d49ca83c24f5f9b1394fefd9f200fbc3085d5469cf1)
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
diff --git a/packages/formatter/UPGRADE.md b/packages/formatter/UPGRADE.md
index bdfeb0e03..87c2b6cd8 100644
--- a/packages/formatter/UPGRADE.md
+++ b/packages/formatter/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,26 +25,26 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
# Upgrade from v6
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
# Upgrade from v5
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
* [ ] If you are passing `\IntlDateFormatter::*` constants as `$format` argument for `Formatter::time()`/`Formatter::date()`/`Formatter::datetime()`, add a new custom format(s) which will refer to `\IntlDateFormatter::*` constant(s).
diff --git a/packages/graphql-printer/README.md b/packages/graphql-printer/README.md
index c9fdeb5ce..a0dd0ddaf 100644
--- a/packages/graphql-printer/README.md
+++ b/packages/graphql-printer/README.md
@@ -3,7 +3,7 @@
Independent (from Laravel and Lighthouse) package that allow you to print GraphQL Schema and Queries in highly customized way eg you can choose indent size, print only used/wanted/all types, print only one type, print used/wanted/all directives ([it is not possible with standard printer](https://github.com/webonyx/graphql-php/issues/552)) and even check which types/directives are used in the Schema/Query.
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -18,7 +18,7 @@ Independent (from Laravel and Lighthouse) package that allow you to print GraphQ
| | `^15.2.4` | `4.2.0 ⋯ 4.0.0` |
| | `^14.11.9` | `3.0.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "graphql-printer"}})
[//]: # (start: dcf3043aff3a50970117872a9bba432cb3ef84a034a0fc88bcdc6d9dcae2ec06)
@@ -37,7 +37,7 @@ composer require lastdragon-ru/lara-asp-graphql-printer
There are two primary methods: `Printer::print()` and `Printer::export()`. The `print()` will print the current type only, meanwhile `export()` will print the current type and all used types/directives:
[include:example]: ./docs/Examples/Usage.php
-[//]: # (start: c709a4b715d1bde109a5d27982a2a5d6f481b5c72338e162e394ccbb6fc9208a)
+[//]: # (start: adef85def212f87b8f157b40eaa0695da87e1a6f63e1e1ebc9fff474ecad3fee)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -113,7 +113,7 @@ type B
}
```
-[//]: # (end: c709a4b715d1bde109a5d27982a2a5d6f481b5c72338e162e394ccbb6fc9208a)
+[//]: # (end: adef85def212f87b8f157b40eaa0695da87e1a6f63e1e1ebc9fff474ecad3fee)
# Customization
@@ -132,7 +132,7 @@ Please see:
The Printer allows filter out types and directives. This may be useful to exclude them from the schema completely. Filtering also works for queries. Please note that types filtering will work only if the schema is known (the schema is required to determine the type of argument nodes). For some AST node types, their type may also be required.
[include:example]: ./docs/Examples/Filtering.php
-[//]: # (start: 963f066509a17e2999eaa0fa940bd0f608ad2fc212eb6511f11b69eae9f7478e)
+[//]: # (start: f2eda67ec1e0063562eb72a70bc2fe190de9eb9d4e0fefd01dbf3ca1bbfc48ab)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -215,7 +215,7 @@ query {
}
```
-[//]: # (end: 963f066509a17e2999eaa0fa940bd0f608ad2fc212eb6511f11b69eae9f7478e)
+[//]: # (end: f2eda67ec1e0063562eb72a70bc2fe190de9eb9d4e0fefd01dbf3ca1bbfc48ab)
# Laravel/Lighthouse
@@ -224,7 +224,7 @@ It is highly recommended to use [`lara-asp-graphql`][pkg:graphql#Printer] packag
# Testing Assertions
[include:document-list]: ./docs/Assertions
-[//]: # (start: 86d73ad55f2c494dfe35350837400088c82dfa7457eafd0d30392ba96bbbdc9a)
+[//]: # (start: faab128ff134f31373650be0e1d23f4adffa84372a29292f956b844fb6baae6d)
[//]: # (warning: Generated automatically. Do not edit.)
## `assertGraphQLExportableEquals`
@@ -239,32 +239,32 @@ Prints and compares two GraphQL schemas/types/nodes/etc.
[Read more]().
-[//]: # (end: 86d73ad55f2c494dfe35350837400088c82dfa7457eafd0d30392ba96bbbdc9a)
+[//]: # (end: faab128ff134f31373650be0e1d23f4adffa84372a29292f956b844fb6baae6d)
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[include:file]: ../../docs/Shared/Links.md
-[//]: # (start: 9ac5c57eb03fcabb221c8db950c2dc20215f17f6e4ab17fd3a5def405da61f91)
+[//]: # (start: e3121fcf0782621da11db7a735b38993c2b6560b7b7014aa164a809a3e515040)
[//]: # (warning: Generated automatically. Do not edit.)
[pkg:graphql#Printer]: https://github.com/LastDragon-ru/lara-asp/tree/main/packages/graphql#Printer
-[//]: # (end: 9ac5c57eb03fcabb221c8db950c2dc20215f17f6e4ab17fd3a5def405da61f91)
+[//]: # (end: e3121fcf0782621da11db7a735b38993c2b6560b7b7014aa164a809a3e515040)
diff --git a/packages/graphql-printer/UPGRADE.md b/packages/graphql-printer/UPGRADE.md
index 9da8be17d..61a12a295 100644
--- a/packages/graphql-printer/UPGRADE.md
+++ b/packages/graphql-printer/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,4 +25,4 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
diff --git a/packages/graphql-printer/docs/Assertions/AssertGraphQLExportableEquals.md b/packages/graphql-printer/docs/Assertions/AssertGraphQLExportableEquals.md
index 0de5dafe1..cb2bdde0f 100644
--- a/packages/graphql-printer/docs/Assertions/AssertGraphQLExportableEquals.md
+++ b/packages/graphql-printer/docs/Assertions/AssertGraphQLExportableEquals.md
@@ -3,7 +3,7 @@
Exports and compares two GraphQL schemas/types/nodes/etc.
[include:example]: ./AssertGraphQLExportableEqualsTest.php
-[//]: # (start: f79b9dacbf93b9659f2c2a8a84646ad6b8603e38651064954060c16eac2f3fc0)
+[//]: # (start: 2852b7456553efa57ca27c58f94107dd1a13536fc09ad9878c4f8ff405c53045)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -81,4 +81,4 @@ final class AssertGraphQLExportableEqualsTest extends TestCase {
}
```
-[//]: # (end: f79b9dacbf93b9659f2c2a8a84646ad6b8603e38651064954060c16eac2f3fc0)
+[//]: # (end: 2852b7456553efa57ca27c58f94107dd1a13536fc09ad9878c4f8ff405c53045)
diff --git a/packages/graphql-printer/docs/Assertions/AssertGraphQLPrintableEquals.md b/packages/graphql-printer/docs/Assertions/AssertGraphQLPrintableEquals.md
index c01451484..506610e91 100644
--- a/packages/graphql-printer/docs/Assertions/AssertGraphQLPrintableEquals.md
+++ b/packages/graphql-printer/docs/Assertions/AssertGraphQLPrintableEquals.md
@@ -3,7 +3,7 @@
Prints and compares two GraphQL schemas/types/nodes/etc.
[include:example]: ./AssertGraphQLPrintableEqualsTest.php
-[//]: # (start: 50e51325f68526f816540bf59f9479e5a12f5183dcf5feacf1ed62c2a5bcadb7)
+[//]: # (start: d6417605333d8076842d697742023cd15a6e5c9eac1d02bfd605315b3ea401ed)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -63,4 +63,4 @@ final class AssertGraphQLPrintableEqualsTest extends TestCase {
}
```
-[//]: # (end: 50e51325f68526f816540bf59f9479e5a12f5183dcf5feacf1ed62c2a5bcadb7)
+[//]: # (end: d6417605333d8076842d697742023cd15a6e5c9eac1d02bfd605315b3ea401ed)
diff --git a/packages/graphql/README.md b/packages/graphql/README.md
index 2e1c6b159..237436b46 100644
--- a/packages/graphql/README.md
+++ b/packages/graphql/README.md
@@ -3,7 +3,7 @@
This package provides highly powerful `@searchBy`, `@sortBy`, `@stream` directives for [lighthouse-php](https://lighthouse-php.com/). The `@searchBy` directive provides basic conditions like `=`, `>`, `<`, etc, relations, `not ()`, enums, and custom operators support. All are strictly typed so you no need to use `Mixed` type anymore. The `@sortBy` is not only about standard sorting by columns but also allows use relations. 😎
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -29,7 +29,7 @@ This package provides highly powerful `@searchBy`, `@sortBy`, `@stream` directiv
| | `^5.6.1` | `0.12.0` , `0.11.0` |
| | `^5.4` | `0.10.0 ⋯ 0.5.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "graphql"}})
[//]: # (start: 3672f37b7c4365391f12ad7a15e2e629126d25f774c584c29e7930695f44040a)
@@ -54,7 +54,7 @@ php artisan vendor:publish --provider=LastDragon_ru\\LaraASP\\GraphQL\\Provider
# Directives
[include:document-list]: ./docs/Directives
-[//]: # (start: 73f7f4a1d86b7731354837c827f1b9f9aa729879639aeab4fe63985913469f48)
+[//]: # (start: 5c1942eeb33ecb83f532572514cc32d67c83ab539a597f895822259278fcb8c2)
[//]: # (warning: Generated automatically. Do not edit.)
## `@searchBy`
@@ -81,7 +81,7 @@ Converts scalar into GraphQL Type. Similar to Lighthouse's `@scalar` directive,
[Read more]().
-[//]: # (end: 73f7f4a1d86b7731354837c827f1b9f9aa729879639aeab4fe63985913469f48)
+[//]: # (end: 5c1942eeb33ecb83f532572514cc32d67c83ab539a597f895822259278fcb8c2)
# Scalars
@@ -97,7 +97,7 @@ Converts scalar into GraphQL Type. Similar to Lighthouse's `@scalar` directive,
> ```
[include:document-list]: ./docs/Scalars
-[//]: # (start: 12e162fc2ab7e9e247529882b53731fb8f8aacc4c5532610d40d36e90977b8f2)
+[//]: # (start: d7fa880330d41b72ca3aff09300ebc180dd416ac96df6dcc3e5846e780656ad3)
[//]: # (warning: Generated automatically. Do not edit.)
## `JsonString`
@@ -106,7 +106,7 @@ Represents [JSON](https://json.org) string.
[Read more]().
-[//]: # (end: 12e162fc2ab7e9e247529882b53731fb8f8aacc4c5532610d40d36e90977b8f2)
+[//]: # (end: d7fa880330d41b72ca3aff09300ebc180dd416ac96df6dcc3e5846e780656ad3)
# Scout
@@ -182,7 +182,7 @@ class Comment extends Model {
If you implement custom directives which internally enhance the Builder (like standard directives do), you may get `BuilderUnknown` error because the proper/expected builder type was not detected. In this case, your directive should implement [`BuilderInfoProvider`](./src/Builder/Contracts/BuilderInfoProvider.php) interface and to specify the builder type explicitly.
[include:example]: docs/Examples/BuilderInfoProvider.php
-[//]: # (start: b68f7337a010486bff0e1669240841cc48572f37ac74466da4fc0364db6a1067)
+[//]: # (start: 5a03ff4c8b599bd4b2a0373e04f1cbd343a5f9113c5776dd43935731c251b552)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -214,14 +214,14 @@ class CustomDirective implements Directive, BuilderInfoProvider {
}
```
-[//]: # (end: b68f7337a010486bff0e1669240841cc48572f37ac74466da4fc0364db6a1067)
+[//]: # (end: 5a03ff4c8b599bd4b2a0373e04f1cbd343a5f9113c5776dd43935731c251b552)
# Printer
The package provides bindings for [`Printer`][pkg:graphql-printer] so you can simply use:
[include:example]: ./docs/Examples/Printer.php
-[//]: # (start: 7a581dc1c9875e776a31524d2dd484da37a2b4dd60025986e9ef348c06d29a3d)
+[//]: # (start: fdd23dac1ad08b05f6acbf1e76428ec36838c96e07f84f5bb303a8b2d6981582)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -552,12 +552,12 @@ type User {
-[//]: # (end: 7a581dc1c9875e776a31524d2dd484da37a2b4dd60025986e9ef348c06d29a3d)
+[//]: # (end: fdd23dac1ad08b05f6acbf1e76428ec36838c96e07f84f5bb303a8b2d6981582)
# Testing Assertions
[include:document-list]: ./docs/Assertions
-[//]: # (start: 86d73ad55f2c494dfe35350837400088c82dfa7457eafd0d30392ba96bbbdc9a)
+[//]: # (start: faab128ff134f31373650be0e1d23f4adffa84372a29292f956b844fb6baae6d)
[//]: # (warning: Generated automatically. Do not edit.)
## `assertGraphQLIntrospectionEquals`
@@ -590,30 +590,30 @@ Validates default internal schema (with all directives). Faster than `lighthouse
[Read more]().
-[//]: # (end: 86d73ad55f2c494dfe35350837400088c82dfa7457eafd0d30392ba96bbbdc9a)
+[//]: # (end: faab128ff134f31373650be0e1d23f4adffa84372a29292f956b844fb6baae6d)
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[include:file]: ../../docs/Shared/Links.md
-[//]: # (start: 9ac5c57eb03fcabb221c8db950c2dc20215f17f6e4ab17fd3a5def405da61f91)
+[//]: # (start: e3121fcf0782621da11db7a735b38993c2b6560b7b7014aa164a809a3e515040)
[//]: # (warning: Generated automatically. Do not edit.)
[pkg:graphql#@searchBy]: https://github.com/LastDragon-ru/lara-asp/tree/main/packages/graphql/docs/Directives/@searchBy.md
@@ -622,4 +622,4 @@ This package is the part of Awesome Set of Packages for Laravel. Please use the
[pkg:graphql-printer]: https://github.com/LastDragon-ru/lara-asp/tree/main/packages/graphql-printer
-[//]: # (end: 9ac5c57eb03fcabb221c8db950c2dc20215f17f6e4ab17fd3a5def405da61f91)
+[//]: # (end: e3121fcf0782621da11db7a735b38993c2b6560b7b7014aa164a809a3e515040)
diff --git a/packages/graphql/UPGRADE.md b/packages/graphql/UPGRADE.md
index 39fb7e5cd..6b8f41312 100644
--- a/packages/graphql/UPGRADE.md
+++ b/packages/graphql/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,7 +25,7 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
## Tips
@@ -38,12 +38,12 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
## General
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
* [ ] The `\LastDragon_ru\LaraASP\GraphQL\Scalars\JsonStringType` is not implement `\LastDragon_ru\LaraASP\GraphQL\Builder\Contracts\TypeDefinition` anymore. To add the scalar into the Schema, you can use `@type`/`@scalar` directive, or create a custom implementation of `TypeDefinition` contract to use with `Builder`/`Manipulator`.
@@ -71,12 +71,12 @@ This section is actual only if you are extending the package. Please review and
## General
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
* [ ] [Input type auto-generation](README.md#input-type-auto-generation) reworked and may include more/fewer fields. Please check the documentation and update the schema if needed.
diff --git a/packages/graphql/docs/Assertions/AssertGraphQLIntrospectionEquals.md b/packages/graphql/docs/Assertions/AssertGraphQLIntrospectionEquals.md
index 852a5ede1..b53bf0db4 100644
--- a/packages/graphql/docs/Assertions/AssertGraphQLIntrospectionEquals.md
+++ b/packages/graphql/docs/Assertions/AssertGraphQLIntrospectionEquals.md
@@ -6,7 +6,7 @@ Compares default public schema (as the client sees it through introspection).
[include:example]: ./AssertGraphQLIntrospectionEqualsTest.php
-[//]: # (start: 1e34791857e79d61db977fbe4be017b38ffb53811f06d451e227c376c5c218c6)
+[//]: # (start: bd67a06e7e90174d00b11ce5b2284329d25b85cbb3bad6f39926f4ecdf685748)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -436,6 +436,6 @@ final class AssertGraphQLIntrospectionEqualsTest extends TestCase {
}
```
-[//]: # (end: 1e34791857e79d61db977fbe4be017b38ffb53811f06d451e227c376c5c218c6)
+[//]: # (end: bd67a06e7e90174d00b11ce5b2284329d25b85cbb3bad6f39926f4ecdf685748)
diff --git a/packages/graphql/docs/Assertions/AssertGraphQLSchemaEquals.md b/packages/graphql/docs/Assertions/AssertGraphQLSchemaEquals.md
index f4022f661..61c364857 100644
--- a/packages/graphql/docs/Assertions/AssertGraphQLSchemaEquals.md
+++ b/packages/graphql/docs/Assertions/AssertGraphQLSchemaEquals.md
@@ -3,7 +3,7 @@
Compares default internal schema (with all directives).
[include:example]: ./AssertGraphQLSchemaEqualsTest.php
-[//]: # (start: 1bcc4bdce373bad283736df3c40bf88ff6b8faa72cbd12e3a5750ae22ac6f439)
+[//]: # (start: 3a4b27b9fd58b85e3dbfd8da1b72182bd4b0311bb285febb3f68e4a33b325c92)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -110,4 +110,4 @@ final class AssertGraphQLSchemaEqualsTest extends TestCase {
}
```
-[//]: # (end: 1bcc4bdce373bad283736df3c40bf88ff6b8faa72cbd12e3a5750ae22ac6f439)
+[//]: # (end: 3a4b27b9fd58b85e3dbfd8da1b72182bd4b0311bb285febb3f68e4a33b325c92)
diff --git a/packages/graphql/docs/Assertions/AssertGraphQLSchemaNoBreakingChanges.md b/packages/graphql/docs/Assertions/AssertGraphQLSchemaNoBreakingChanges.md
index 7f89baaba..e52c7f8ea 100644
--- a/packages/graphql/docs/Assertions/AssertGraphQLSchemaNoBreakingChanges.md
+++ b/packages/graphql/docs/Assertions/AssertGraphQLSchemaNoBreakingChanges.md
@@ -3,7 +3,7 @@
Checks that no breaking changes in the default internal schema (with all directives).
[include:example]: ./AssertGraphQLSchemaNoBreakingChangesTest.php
-[//]: # (start: e9f72298446f8034d254998ac3b4396702a8981a7c00f14eb9ccebdadf73ea3f)
+[//]: # (start: 6f681afa633484fa9258e31bdef2ef42c8abf7b40943980fa23c6416cdb5587b)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -80,4 +80,4 @@ final class AssertGraphQLSchemaNoBreakingChangesTest extends TestCase {
}
```
-[//]: # (end: e9f72298446f8034d254998ac3b4396702a8981a7c00f14eb9ccebdadf73ea3f)
+[//]: # (end: 6f681afa633484fa9258e31bdef2ef42c8abf7b40943980fa23c6416cdb5587b)
diff --git a/packages/graphql/docs/Assertions/AssertGraphQLSchemaNoDangerousChanges.md b/packages/graphql/docs/Assertions/AssertGraphQLSchemaNoDangerousChanges.md
index 39abea36e..105c4f0d7 100644
--- a/packages/graphql/docs/Assertions/AssertGraphQLSchemaNoDangerousChanges.md
+++ b/packages/graphql/docs/Assertions/AssertGraphQLSchemaNoDangerousChanges.md
@@ -3,7 +3,7 @@
Checks that no dangerous changes in the default internal schema (with all directives).
[include:example]: ./AssertGraphQLSchemaNoDangerousChangesTest.php
-[//]: # (start: b1e5a522b2299596e819ef4f028b17963100062611b89a1ee97699e6e847dc6c)
+[//]: # (start: ebd9d48ce66dae20bfd7353a16e43121f61834ed58637913860e4e3cbfd57aa0)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -79,4 +79,4 @@ final class AssertGraphQLSchemaNoDangerousChangesTest extends TestCase {
}
```
-[//]: # (end: b1e5a522b2299596e819ef4f028b17963100062611b89a1ee97699e6e847dc6c)
+[//]: # (end: ebd9d48ce66dae20bfd7353a16e43121f61834ed58637913860e4e3cbfd57aa0)
diff --git a/packages/graphql/docs/Assertions/AssertGraphQLSchemaValid.md b/packages/graphql/docs/Assertions/AssertGraphQLSchemaValid.md
index bed96dbb9..a793eb911 100644
--- a/packages/graphql/docs/Assertions/AssertGraphQLSchemaValid.md
+++ b/packages/graphql/docs/Assertions/AssertGraphQLSchemaValid.md
@@ -3,7 +3,7 @@
Validates default internal schema (with all directives). Faster than `lighthouse:validate-schema` command because loads only used directives.
[include:example]: ./AssertGraphQLSchemaValidTest.php
-[//]: # (start: dd5e2cd2a0dfa08e0c41fb2cebb63acf79841b33dcf16658c765936ca150b73e)
+[//]: # (start: e0356d8f3cfdce8a23ff4abee80bad3af51080e957de2a787df0cf7334429c47)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -74,4 +74,4 @@ final class AssertGraphQLSchemaValidTest extends TestCase {
}
```
-[//]: # (end: dd5e2cd2a0dfa08e0c41fb2cebb63acf79841b33dcf16658c765936ca150b73e)
+[//]: # (end: e0356d8f3cfdce8a23ff4abee80bad3af51080e957de2a787df0cf7334429c47)
diff --git a/packages/graphql/docs/Directives/@searchBy.md b/packages/graphql/docs/Directives/@searchBy.md
index c3c3393ae..23259ed46 100644
--- a/packages/graphql/docs/Directives/@searchBy.md
+++ b/packages/graphql/docs/Directives/@searchBy.md
@@ -3,7 +3,7 @@
Probably the most powerful directive to provide search (`where` conditions) for your GraphQL queries.
[include:graphql-directive]: @searchBy
-[//]: # (start: 6fc59903c0b30f293d154a4e848626ee52d76fad258360243058c413339a0ba4)
+[//]: # (start: 3d8928e2d49d225b63f3b0f44358262d285ebbba9319e92cad8629a897b6f2f3)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -15,7 +15,7 @@ on
| ARGUMENT_DEFINITION
```
-[//]: # (end: 6fc59903c0b30f293d154a4e848626ee52d76fad258360243058c413339a0ba4)
+[//]: # (end: 3d8928e2d49d225b63f3b0f44358262d285ebbba9319e92cad8629a897b6f2f3)
## Basic usage
@@ -33,7 +33,7 @@ Out of the box directives provides following features:
Let's start:
[include:example]: ../../src/SearchBy/Directives/DirectiveTest/Example.schema.graphql
-[//]: # (start: cc0325309f64ed94ef1e996dc2a624162a7ebb35fb0e02191bf74e20a17cb2f3)
+[//]: # (start: 029b65fdc24245537949ce83045a9468e0eb80cc433c62fc97287c84a523c5d4)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -67,7 +67,7 @@ type Comment {
}
```
-[//]: # (end: cc0325309f64ed94ef1e996dc2a624162a7ebb35fb0e02191bf74e20a17cb2f3)
+[//]: # (end: 029b65fdc24245537949ce83045a9468e0eb80cc433c62fc97287c84a523c5d4)
That's all, just search 😃 (or look at [generated GraphQL schema](../../src/SearchBy/Directives/DirectiveTest/Example.expected.graphql))
@@ -158,7 +158,7 @@ As you can see in the example above you can use the special placeholder `_` inst
The `@searchByIgnored` can be used as Ignored marker.
[include:graphql-directive]: @searchByIgnored
-[//]: # (start: a9b2c25f23dff4186502cc93cc34a25e406edce92710315aecdfae2bbe0d1d1a)
+[//]: # (start: 19241090248b7789ee3b6de5b3922352e534a08c330be9c8ec139eaedffefabb)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -175,7 +175,7 @@ on
| SCALAR
```
-[//]: # (end: a9b2c25f23dff4186502cc93cc34a25e406edce92710315aecdfae2bbe0d1d1a)
+[//]: # (end: 19241090248b7789ee3b6de5b3922352e534a08c330be9c8ec139eaedffefabb)
## Operators
@@ -234,7 +234,7 @@ scalar MyScalar
Keep in mind, when you define/extend the scalar/enum, it will override all existing operators, so if you just want to add new operators, the `@searchByExtendOperators` directive should be used.
[include:graphql-directive]: @searchByExtendOperators
-[//]: # (start: df58b83a1ba68755665e0657a0ec9e4040fa2887c91de730680491d84e9e3251)
+[//]: # (start: 2eba3af220a941ff3782355618d583640e7f1983e3c37d062c7e2bafb805a3d2)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -250,7 +250,7 @@ on
| SCALAR
```
-[//]: # (end: df58b83a1ba68755665e0657a0ec9e4040fa2887c91de730680491d84e9e3251)
+[//]: # (end: 2eba3af220a941ff3782355618d583640e7f1983e3c37d062c7e2bafb805a3d2)
### Schema
diff --git a/packages/graphql/docs/Directives/@sortBy.md b/packages/graphql/docs/Directives/@sortBy.md
index 2147c3ca2..9df731f80 100644
--- a/packages/graphql/docs/Directives/@sortBy.md
+++ b/packages/graphql/docs/Directives/@sortBy.md
@@ -3,7 +3,7 @@
Probably the most powerful directive to provide sort (`order by` conditions) for your GraphQL queries.
[include:graphql-directive]: @sortBy
-[//]: # (start: b8a3b70da2455b8cbed2b3385a56c1e1cd9865302ab83b073700e4608bd628d2)
+[//]: # (start: 0c8e9abdba8e2ff3e7959a659114f1257f8a4ea44c7e45d3a14c4d952fae36d9)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -15,14 +15,14 @@ on
| ARGUMENT_DEFINITION
```
-[//]: # (end: b8a3b70da2455b8cbed2b3385a56c1e1cd9865302ab83b073700e4608bd628d2)
+[//]: # (end: 0c8e9abdba8e2ff3e7959a659114f1257f8a4ea44c7e45d3a14c4d952fae36d9)
## Basic usage
How to use (and [generated GraphQL schema](../../src/SortBy/Directives/DirectiveTest/Example.expected.graphql)):
[include:example]: ../../src/SortBy/Directives/DirectiveTest/Example.schema.graphql
-[//]: # (start: 49b8762fdb7c1c571d71e331c248f86862b782b2981072697949f5dd0f8616ee)
+[//]: # (start: f25acc8f93904eb379c14bc196a2910b8aefb043eb78258055fda6e8a97c1122)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -50,7 +50,7 @@ type User {
}
```
-[//]: # (end: 49b8762fdb7c1c571d71e331c248f86862b782b2981072697949f5dd0f8616ee)
+[//]: # (end: f25acc8f93904eb379c14bc196a2910b8aefb043eb78258055fda6e8a97c1122)
And:
@@ -75,7 +75,7 @@ Addition rules for Implicit type:
The `@sortByIgnored` can be used as Ignored marker.
[include:graphql-directive]: @sortByIgnored
-[//]: # (start: 9466556f0c9243ad61ee9e72054a332e844bfe6346c488ba279f76aa7a3a0609)
+[//]: # (start: 901001aa3a0a77b903d442b3bc60b868ae0832096d28d9cc01d8044bb5c6bb8f)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -92,7 +92,7 @@ on
| SCALAR
```
-[//]: # (end: 9466556f0c9243ad61ee9e72054a332e844bfe6346c488ba279f76aa7a3a0609)
+[//]: # (end: 901001aa3a0a77b903d442b3bc60b868ae0832096d28d9cc01d8044bb5c6bb8f)
## Operators
diff --git a/packages/graphql/docs/Directives/@stream.md b/packages/graphql/docs/Directives/@stream.md
index af50efe5a..c499da20d 100644
--- a/packages/graphql/docs/Directives/@stream.md
+++ b/packages/graphql/docs/Directives/@stream.md
@@ -7,7 +7,7 @@ Unlike the `@paginate` (and similar) directive, the `@stream` provides a uniform
> The directive is experimental. The true cursor pagination is not implemented yet, the limit/offset is used internally. Any feedback would be greatly appreciated.
[include:graphql-directive]: @stream
-[//]: # (start: c6aae43244e8267f05923095595267c57bd8ff8b55fd9ff5cf802851fbf5c3de)
+[//]: # (start: 40989476b2e056faf0b02b1ab9461df23fa334344e79278fa983f269f3fd0363)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -69,7 +69,7 @@ input StreamBuilder {
}
```
-[//]: # (end: c6aae43244e8267f05923095595267c57bd8ff8b55fd9ff5cf802851fbf5c3de)
+[//]: # (end: 40989476b2e056faf0b02b1ab9461df23fa334344e79278fa983f269f3fd0363)
## Motivation
@@ -176,11 +176,11 @@ Keep in mind:
* Some engines may perform counting (seems actual for `Database` only)
[include:file]: ../../../../docs/Shared/Links.md
-[//]: # (start: a1d73b35e4ad53ef7c5e723c17abd87804cf0221167e796513476212788cd826)
+[//]: # (start: d7f8daa25a800052b6112dd44af19f2413af63e989683a3dc13efa8a95084aba)
[//]: # (warning: Generated automatically. Do not edit.)
[pkg:graphql#@searchBy]: https://github.com/LastDragon-ru/lara-asp/tree/main/packages/graphql/docs/Directives/@searchBy.md
[pkg:graphql#@sortBy]: https://github.com/LastDragon-ru/lara-asp/tree/main/packages/graphql/docs/Directives/@sortBy.md
-[//]: # (end: a1d73b35e4ad53ef7c5e723c17abd87804cf0221167e796513476212788cd826)
+[//]: # (end: d7f8daa25a800052b6112dd44af19f2413af63e989683a3dc13efa8a95084aba)
diff --git a/packages/graphql/docs/Directives/@type.md b/packages/graphql/docs/Directives/@type.md
index 5115edd2b..00e653f6b 100644
--- a/packages/graphql/docs/Directives/@type.md
+++ b/packages/graphql/docs/Directives/@type.md
@@ -3,7 +3,7 @@
Converts scalar into GraphQL Type. Similar to Lighthouse's `@scalar` directive, but uses Laravel Container to resolve instance and also supports PHP enums.
[include:graphql-directive]: @type
-[//]: # (start: 185f96f580a0c2ae26608f2c53ad97a03a28301e4c189b5abe2c3163adecc2f9)
+[//]: # (start: 9cc8aa297d4585260951ac6341e80b5161cd70bef8eefb1ad877eded0553f6d5)
[//]: # (warning: Generated automatically. Do not edit.)
```graphql
@@ -32,4 +32,4 @@ on
| SCALAR
```
-[//]: # (end: 185f96f580a0c2ae26608f2c53ad97a03a28301e4c189b5abe2c3163adecc2f9)
+[//]: # (end: 9cc8aa297d4585260951ac6341e80b5161cd70bef8eefb1ad877eded0553f6d5)
diff --git a/packages/graphql/docs/Scalars/JsonString.md b/packages/graphql/docs/Scalars/JsonString.md
index 2bfce067f..550120304 100644
--- a/packages/graphql/docs/Scalars/JsonString.md
+++ b/packages/graphql/docs/Scalars/JsonString.md
@@ -7,9 +7,9 @@ By default, the type validates the string and throws an error if it is not a val
Please note that the scalar doesn't encode/decode value to/from JSON, it just contains a valid JSON string. If you want automatically convert value to/from JSON, you can use the `JSON` type from [`mll-lab/graphql-php-scalars`](https://github.com/mll-lab/graphql-php-scalars) package. If you need something more typesafe, consider using [`Serializer`][pkg:serializer].
[include:file]: ../../../../docs/Shared/Links.md
-[//]: # (start: a1d73b35e4ad53ef7c5e723c17abd87804cf0221167e796513476212788cd826)
+[//]: # (start: d7f8daa25a800052b6112dd44af19f2413af63e989683a3dc13efa8a95084aba)
[//]: # (warning: Generated automatically. Do not edit.)
[pkg:serializer]: https://github.com/LastDragon-ru/lara-asp/tree/main/packages/serializer
-[//]: # (end: a1d73b35e4ad53ef7c5e723c17abd87804cf0221167e796513476212788cd826)
+[//]: # (end: d7f8daa25a800052b6112dd44af19f2413af63e989683a3dc13efa8a95084aba)
diff --git a/packages/migrator/README.md b/packages/migrator/README.md
index b219bf70a..5fc6590a0 100644
--- a/packages/migrator/README.md
+++ b/packages/migrator/README.md
@@ -7,7 +7,7 @@ This package improves standard Laravel migrations to add support for raw SQL fil
> The Migrator uses the same mechanism as [Squashing Migrations](https://laravel.com/docs/migrations#squashing-migrations) so not all databases are supported, please see Laravel Documentation for more details.
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -29,7 +29,7 @@ This package improves standard Laravel migrations to add support for raw SQL fil
| | `^8.22.1` | `3.0.0 ⋯ 0.2.0` |
| | `^8.0` | `0.1.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "migrator"}})
[//]: # (start: 71480f577837f2b64afb81d2af134daeb17eef704953d93e8f393d804443e2a4)
@@ -102,21 +102,21 @@ class MySeeder extends RawSeeder {
```
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
diff --git a/packages/migrator/UPGRADE.md b/packages/migrator/UPGRADE.md
index 4db3e25b6..d844e9738 100644
--- a/packages/migrator/UPGRADE.md
+++ b/packages/migrator/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,24 +25,24 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
# Upgrade from v6
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
# Upgrade from v5
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
diff --git a/packages/serializer/README.md b/packages/serializer/README.md
index 7aff772e9..313a733ec 100644
--- a/packages/serializer/README.md
+++ b/packages/serializer/README.md
@@ -3,7 +3,7 @@
This package provides a customizable wrapper around the [Symfony Serializer Component](https://symfony.com/doc/current/components/serializer.html) to use it inside Laravel application.
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -19,7 +19,7 @@ This package provides a customizable wrapper around the [Symfony Serializer Comp
| | `^9.21.0` | `5.6.0 ⋯ 5.0.0-beta.1` |
| | `^9.0.0` | `5.0.0-beta.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "serializer"}})
[//]: # (start: d8b5372aebffede51da53eb1cdc31143e965ae14f00992219dae456a565cda4a)
@@ -36,7 +36,7 @@ composer require lastdragon-ru/lara-asp-serializer
# Usage
[include:example]: ./docs/Examples/Usage.php
-[//]: # (start: c709a4b715d1bde109a5d27982a2a5d6f481b5c72338e162e394ccbb6fc9208a)
+[//]: # (start: adef85def212f87b8f157b40eaa0695da87e1a6f63e1e1ebc9fff474ecad3fee)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -92,7 +92,7 @@ LastDragon_ru\LaraASP\Serializer\Docs\Examples\Usage\User {
}
```
-[//]: # (end: c709a4b715d1bde109a5d27982a2a5d6f481b5c72338e162e394ccbb6fc9208a)
+[//]: # (end: adef85def212f87b8f157b40eaa0695da87e1a6f63e1e1ebc9fff474ecad3fee)
# Extending
@@ -115,7 +115,7 @@ php artisan vendor:publish --provider=LastDragon_ru\\LaraASP\\Serializer\\Provid
You can use the [`LastDragon_ru\LaraASP\Serializer\Casts\Serialized`](./src/Casts/Serialized.php) attribute to populate a model attribute to/from an object:
[include:example]: ./docs/Examples/Attribute.php
-[//]: # (start: 772b9d40577fb51685a1f6f6851c03c48d3b8bf3c966be28f918c966eeb102ad)
+[//]: # (start: f35a6e7b23df02996a9581e4c34db9192ceb148e1fa7ed361c57fc6a017bd8e9)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -174,7 +174,7 @@ The `$user->getAttributes()` is:
]
```
-[//]: # (end: 772b9d40577fb51685a1f6f6851c03c48d3b8bf3c966be28f918c966eeb102ad)
+[//]: # (end: f35a6e7b23df02996a9581e4c34db9192ceb148e1fa7ed361c57fc6a017bd8e9)
# Upgrading
@@ -183,13 +183,13 @@ Please follow [Upgrade Guide](UPGRADE.md).
[//]: # (end: e9139abedb89f69284102c9112b548fd7add07cf196259916ea4f1c98977223b)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[^1]:
diff --git a/packages/serializer/UPGRADE.md b/packages/serializer/UPGRADE.md
index 4db3e25b6..d844e9738 100644
--- a/packages/serializer/UPGRADE.md
+++ b/packages/serializer/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,24 +25,24 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
# Upgrade from v6
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
# Upgrade from v5
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
diff --git a/packages/spa/README.md b/packages/spa/README.md
index e6a3142e9..bab98c90b 100644
--- a/packages/spa/README.md
+++ b/packages/spa/README.md
@@ -1,7 +1,7 @@
# (Laravel) SPA Helpers
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -21,7 +21,7 @@
| | `^9.0.0` | `5.0.0-beta.0 ⋯ 0.12.0` |
| | `^8.22.1` | `3.0.0 ⋯ 0.4.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/Installation.md ({"data": {"package": "spa"}})
[//]: # (start: 457a42c9e8cb9eef36f7f83a3cdfc837870f5d9814b59bd304b8383789bc83fb)
@@ -36,21 +36,21 @@ composer require lastdragon-ru/lara-asp-spa
[//]: # (end: 457a42c9e8cb9eef36f7f83a3cdfc837870f5d9814b59bd304b8383789bc83fb)
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
diff --git a/packages/spa/UPGRADE.md b/packages/spa/UPGRADE.md
index 4db3e25b6..d844e9738 100644
--- a/packages/spa/UPGRADE.md
+++ b/packages/spa/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,24 +25,24 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
# Upgrade from v6
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
# Upgrade from v5
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
diff --git a/packages/testing/README.md b/packages/testing/README.md
index 9529252b8..bc0a46cc3 100644
--- a/packages/testing/README.md
+++ b/packages/testing/README.md
@@ -3,7 +3,7 @@
This package provides various useful asserts for [PHPUnit](https://phpunit.de/) and better solution for HTTP tests - testing HTTP response has never been so easy! And this not only about `TestResponse` but any PSR response 😎
[include:exec]: <../../dev/artisan lara-asp-documentator:requirements>
-[//]: # (start: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (start: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[//]: # (warning: Generated automatically. Do not edit.)
# Requirements
@@ -27,7 +27,7 @@ This package provides various useful asserts for [PHPUnit](https://phpunit.de/)
| PHPUnit | `^11.0.0` | `HEAD ⋯ 6.2.0` |
| | `^10.1.0` | `HEAD ⋯ 6.0.0` |
-[//]: # (end: 196f435a1c8bc8d5966e42b9fd090d5ccc17c75206e617d7f8369cd9328846ea)
+[//]: # (end: 0c754acbee0a8071717d81a4c18765bb2d605f138e08492b868c0e3f27e481ed)
[include:template]: ../../docs/Shared/InstallationDev.md ({"data": {"package": "testing"}})
[//]: # (start: 9c57d43303e5ef82308c0c83e328e2a47be808a50cd12d6fc5bcfd9229e2fa7c)
@@ -54,7 +54,7 @@ composer require --dev lastdragon-ru/lara-asp-testing
In the general case, you just need to update `tests/TestCase.php` to include most important things, but you also can include only desired features, please see related traits and extensions below.
[include:example]: ./docs/Examples/TestCase.php
-[//]: # (start: e4763d33cca5eca34565862b6815638a0c60d817f1a34476f47915afd0ad952e)
+[//]: # (start: 12b81ed79328f93948eb5166a1b17448848d73e368c86214bbd70643f3d984d1)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -80,7 +80,7 @@ abstract class TestCase extends BaseTestCase {
}
```
-[//]: # (end: e4763d33cca5eca34565862b6815638a0c60d817f1a34476f47915afd0ad952e)
+[//]: # (end: 12b81ed79328f93948eb5166a1b17448848d73e368c86214bbd70643f3d984d1)
# Comparators
@@ -91,7 +91,7 @@ abstract class TestCase extends BaseTestCase {
## [`DatabaseQueryComparator`](./src/Comparators/DatabaseQueryComparator.php)
[include:docblock]: ./src/Comparators/DatabaseQueryComparator.php
-[//]: # (start: 7a62eb5ab5b51b15a59381fa5096469c57dcc949fdd58877a499377d9bf38783)
+[//]: # (start: f9663658d43ee8d678c25ea8356d1ad3a864f18ce04cffe33cb298d512d09a54)
[//]: # (warning: Generated automatically. Do not edit.)
Compares two `LastDragon_ru\LaraASP\Testing\Database\QueryLog\Query`.
@@ -101,12 +101,12 @@ We are performing following normalization before comparison to be more precise:
* Renumber `laravel_reserved_*` (it will always start from `0` and will not contain gaps)
* Format the query by [`doctrine/sql-formatter`](https://github.com/doctrine/sql-formatter) package
-[//]: # (end: 7a62eb5ab5b51b15a59381fa5096469c57dcc949fdd58877a499377d9bf38783)
+[//]: # (end: f9663658d43ee8d678c25ea8356d1ad3a864f18ce04cffe33cb298d512d09a54)
## [`EloquentModelComparator`](./src/Comparators/EloquentModelComparator.php)
[include:docblock]: ./src/Comparators/EloquentModelComparator.php
-[//]: # (start: 742d5ba3dd2046d479175b032d84d30a4df86f84392aaf531a00a6734f096a5d)
+[//]: # (start: 21a1517908b0ebbdac7d871b4238da730999c4a6e2ae510e80340c75fd71829b)
[//]: # (warning: Generated automatically. Do not edit.)
Compares two Eloquent Models.
@@ -117,17 +117,17 @@ the database may have different types for the same properties. For example,
`string` and (strict) comparison will fail. This comparator normalizes
properties types before comparison.
-[//]: # (end: 742d5ba3dd2046d479175b032d84d30a4df86f84392aaf531a00a6734f096a5d)
+[//]: # (end: 21a1517908b0ebbdac7d871b4238da730999c4a6e2ae510e80340c75fd71829b)
## [`ScalarStrictComparator`](./src/Comparators/ScalarStrictComparator.php)
[include:docblock]: ./src/Comparators/ScalarStrictComparator.php
-[//]: # (start: 3880fe84d738503ce8fff5b3ea187ef860c1d6bf96ce2347e9dc1daeb78f9815)
+[//]: # (start: 99205ddfc4ddcb011425e6a66609a1b037355394e6ecb7fcf0574ee7fac62fb5)
[//]: # (warning: Generated automatically. Do not edit.)
Makes comparison of scalars strict.
-[//]: # (end: 3880fe84d738503ce8fff5b3ea187ef860c1d6bf96ce2347e9dc1daeb78f9815)
+[//]: # (end: 99205ddfc4ddcb011425e6a66609a1b037355394e6ecb7fcf0574ee7fac62fb5)
# Extensions
@@ -136,14 +136,14 @@ Makes comparison of scalars strict.
### [`RefreshDatabaseIfEmpty`](./src/Database/RefreshDatabaseIfEmpty.php) 💀
[include:docblock]: ./src/Database/RefreshDatabaseIfEmpty.php
-[//]: # (start: 8a2c47eb73624557058f09279338b44619ddc48d2bd07d975721ad9383bd1df3)
+[//]: # (start: 409cdf673b12522f3685ee8d9af264a248731e871295df0fae40aebe9fa43c86)
[//]: # (warning: Generated automatically. Do not edit.)
The trait is very similar to standard `Illuminate\Foundation\Testing\RefreshDatabase` but there is one
difference: it will refresh the database only if it is empty. This is very
useful for local testing and allow significantly reduce bootstrap time.
-[//]: # (end: 8a2c47eb73624557058f09279338b44619ddc48d2bd07d975721ad9383bd1df3)
+[//]: # (end: 409cdf673b12522f3685ee8d9af264a248731e871295df0fae40aebe9fa43c86)
```php
).
-[//]: # (end: 86d73ad55f2c494dfe35350837400088c82dfa7457eafd0d30392ba96bbbdc9a)
+[//]: # (end: faab128ff134f31373650be0e1d23f4adffa84372a29292f956b844fb6baae6d)
# Laravel Response Testing
@@ -835,7 +835,7 @@ Limitations/Notes:
[//]: # (end: 998fe7ccccc11e3c54b93f9d6ea507c288be425a1dc4eca1cf5abe09d77c572e)
[include:example]: ./docs/Examples/MockProperties.php
-[//]: # (start: bbc1e289c2ec3a43c467e48c9785aea2ba6bbff92b4c966f1ac934c1b1b6c9d1)
+[//]: # (start: 58e6cbe9ad230f1706e6853e1aefd9a6ead8ed091478b1070fa3c8be9e43dd78)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -877,7 +877,7 @@ $mock
$mock->a();
```
-[//]: # (end: bbc1e289c2ec3a43c467e48c9785aea2ba6bbff92b4c966f1ac934c1b1b6c9d1)
+[//]: # (end: 58e6cbe9ad230f1706e6853e1aefd9a6ead8ed091478b1070fa3c8be9e43dd78)
# Custom Test Requirements
@@ -913,21 +913,21 @@ class SomePackageTest extends TestCase {
```
[include:file]: ../../docs/Shared/Upgrading.md
-[//]: # (start: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (start: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[//]: # (warning: Generated automatically. Do not edit.)
# Upgrading
Please follow [Upgrade Guide](UPGRADE.md).
-[//]: # (end: 3c3826915e1d570b3982fdc6acf484950f0add7bb09d71c8c99b4a0e0fc5b43a)
+[//]: # (end: 5f4a27dda34e5e151a62fe3459daf4bb3b85705d38810060e71fcadc25669c0f)
[include:file]: ../../docs/Shared/Contributing.md
-[//]: # (start: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (start: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
[//]: # (warning: Generated automatically. Do not edit.)
# Contributing
This package is the part of Awesome Set of Packages for Laravel. Please use the [main repository](https://github.com/LastDragon-ru/lara-asp) to [report issues](https://github.com/LastDragon-ru/lara-asp/issues), send [pull requests](https://github.com/LastDragon-ru/lara-asp/pulls), or [ask questions](https://github.com/LastDragon-ru/lara-asp/discussions).
-[//]: # (end: 6b81b030ae74b2d149ec76cbec1b053da8da4e0ac4fd865f560548f3ead955e8)
+[//]: # (end: 3f7cfa48046722fb9d277c71e074ff8406787772f90d17405b7554a4464cbfee)
diff --git a/packages/testing/UPGRADE.md b/packages/testing/UPGRADE.md
index d289b8958..9ec840f67 100644
--- a/packages/testing/UPGRADE.md
+++ b/packages/testing/UPGRADE.md
@@ -1,7 +1,7 @@
# Upgrade Guide
[include:file]: ../../docs/Shared/Upgrade.md
-[//]: # (start: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (start: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
[//]: # (warning: Generated automatically. Do not edit.)
## Instructions
@@ -25,17 +25,17 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
| 🤝 | Backward-compatible change. Please note that despite you can ignore it now, but it will be mandatory in the future. |
|:--:|:--------------------------------------------------------------------------------------------------------------------|
-[//]: # (end: 5af9759519da3fa710fb21785e61682fda687a6ebdfb6f0dde4ed03162cb031d)
+[//]: # (end: 3fcf292b870e49aabe885c416dfaf6c6c66d4571e87d3d3975d9cfe34ea6c9fe)
# Upgrade from v6
[include:file]: ../../docs/Shared/Upgrade/FromV6.md
-[//]: # (start: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (start: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Direct usages of `Container::getInstances()` were replaced by explicit constructor parameters. You may need to update your code accordingly (#151).
-[//]: # (end: 8dae6cc48a78a268dcc7b747e512f85b410c9a9392ffac0734f4b17d390f1883)
+[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
* [ ] Following traits required `app()` method to get access to the Container (#151)
* `\LastDragon_ru\LaraASP\Testing\Assertions\Application\ScheduleAssertions`
@@ -55,11 +55,11 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
# Upgrade from v5
[include:file]: ../../docs/Shared/Upgrade/FromV5.md
-[//]: # (start: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (start: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
[//]: # (warning: Generated automatically. Do not edit.)
* [ ] Laravel v9 is not supported anymore. Migrate to the newer version.
-[//]: # (end: 599c87007f162e34f4fd0c7874d4fcf8676e5d8c761d27a9456b284c7d1d12f2)
+[//]: # (end: 6367638a165291d78965aaeae9ab03b304b0a420eb3f5ad9af0424296cc609ea)
* [ ] Replace `CronableAssertions::assertCronableRegistered()` to `ScheduleAssertions::assertScheduled()`.
diff --git a/packages/testing/docs/Assertions/AssertDatabaseQueryEquals.md b/packages/testing/docs/Assertions/AssertDatabaseQueryEquals.md
index c9220d510..2e8640f9f 100644
--- a/packages/testing/docs/Assertions/AssertDatabaseQueryEquals.md
+++ b/packages/testing/docs/Assertions/AssertDatabaseQueryEquals.md
@@ -3,7 +3,7 @@
Asserts that SQL Query equals SQL Query.
[include:example]: ./AssertDatabaseQueryEqualsTest.php
-[//]: # (start: 65d62248ad4d9d80f20c4988a5dfc7a946864fb5d63547ccee2b721b84c9b46f)
+[//]: # (start: 1b82cb78e263737ccb1a4a8b04b9ba995b0e5b3158260a64ca8bd3616416220b)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -57,4 +57,4 @@ final class AssertDatabaseQueryEqualsTest extends TestCase {
}
```
-[//]: # (end: 65d62248ad4d9d80f20c4988a5dfc7a946864fb5d63547ccee2b721b84c9b46f)
+[//]: # (end: 1b82cb78e263737ccb1a4a8b04b9ba995b0e5b3158260a64ca8bd3616416220b)
diff --git a/packages/testing/docs/Assertions/AssertJsonMatchesSchema.md b/packages/testing/docs/Assertions/AssertJsonMatchesSchema.md
index bf9b55c28..663b1d558 100644
--- a/packages/testing/docs/Assertions/AssertJsonMatchesSchema.md
+++ b/packages/testing/docs/Assertions/AssertJsonMatchesSchema.md
@@ -3,7 +3,7 @@
Asserts that JSON matches [schema](https://json-schema.org/). Validation based on the [Opis JSON Schema](https://github.com/opis/json-schema) package.
[include:example]: ./AssertJsonMatchesSchemaTest.php
-[//]: # (start: a6b4c98bfb1a397c027ee2360f01310c9319d9742b9361bab757e4c1b4d7caa3)
+[//]: # (start: 14b834083ec3dd5506e9e3f58f85f8497006137d303059f7d38fc3728bccbd4f)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -61,4 +61,4 @@ final class AssertJsonMatchesSchemaTest extends TestCase {
}
```
-[//]: # (end: a6b4c98bfb1a397c027ee2360f01310c9319d9742b9361bab757e4c1b4d7caa3)
+[//]: # (end: 14b834083ec3dd5506e9e3f58f85f8497006137d303059f7d38fc3728bccbd4f)
diff --git a/packages/testing/docs/Assertions/AssertPsrResponse.md b/packages/testing/docs/Assertions/AssertPsrResponse.md
index cff2721e1..43b31a260 100644
--- a/packages/testing/docs/Assertions/AssertPsrResponse.md
+++ b/packages/testing/docs/Assertions/AssertPsrResponse.md
@@ -3,7 +3,7 @@
Asserts that PSR Response satisfies given constraint (we have a lot of built-in [constraints](../../src/Constraints/Response) and [responses](../../src/Responses), but, of course, you can create a custom).
[include:example]: ./AssertPsrResponseTest.php
-[//]: # (start: d56396d7203ebdf44cbccb48d522ccf24fea7657aac3b2508e11e1850086dd37)
+[//]: # (start: 291741a02f1b16db5d7b0d47b81f82b5fd9e98f8ae4732059a073f19f06f5775)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -97,4 +97,4 @@ final class AssertPsrResponseTest extends TestCase {
}
```
-[//]: # (end: d56396d7203ebdf44cbccb48d522ccf24fea7657aac3b2508e11e1850086dd37)
+[//]: # (end: 291741a02f1b16db5d7b0d47b81f82b5fd9e98f8ae4732059a073f19f06f5775)
diff --git a/packages/testing/docs/Assertions/AssertQueryLogEquals.md b/packages/testing/docs/Assertions/AssertQueryLogEquals.md
index 9a4b91856..0a490df7c 100644
--- a/packages/testing/docs/Assertions/AssertQueryLogEquals.md
+++ b/packages/testing/docs/Assertions/AssertQueryLogEquals.md
@@ -3,7 +3,7 @@
Asserts that `QueryLog` equals `QueryLog`.
[include:example]: ./AssertQueryLogEqualsTest.php
-[//]: # (start: 709fad07f8fc6f28709758f6f33f1a1773cf0652c99028faa15f621efa619a93)
+[//]: # (start: a49e0d438a4dffcc57ee95b71e064d88cc63d12932af4825af3a26db59bce0a3)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -74,4 +74,4 @@ final class AssertQueryLogEqualsTest extends TestCase {
}
```
-[//]: # (end: 709fad07f8fc6f28709758f6f33f1a1773cf0652c99028faa15f621efa619a93)
+[//]: # (end: a49e0d438a4dffcc57ee95b71e064d88cc63d12932af4825af3a26db59bce0a3)
diff --git a/packages/testing/docs/Assertions/AssertScheduled.md b/packages/testing/docs/Assertions/AssertScheduled.md
index 92424c9d4..c551b2328 100644
--- a/packages/testing/docs/Assertions/AssertScheduled.md
+++ b/packages/testing/docs/Assertions/AssertScheduled.md
@@ -3,7 +3,7 @@
Asserts that Schedule contains task.
[include:example]: ./AssertScheduledTest.php
-[//]: # (start: f506843658b5143b195bd01075e1807073a382bfbeb5f689afa2063fed136a69)
+[//]: # (start: f6ecb0bbb1637366b3cb0769a8e98ecdcdcdc4a8e151c4d9cc08f304dd9df8a1)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -58,4 +58,4 @@ final class AssertScheduledTest extends TestCase {
}
```
-[//]: # (end: f506843658b5143b195bd01075e1807073a382bfbeb5f689afa2063fed136a69)
+[//]: # (end: f6ecb0bbb1637366b3cb0769a8e98ecdcdcdc4a8e151c4d9cc08f304dd9df8a1)
diff --git a/packages/testing/docs/Assertions/AssertScoutQueryEquals.md b/packages/testing/docs/Assertions/AssertScoutQueryEquals.md
index a80e40e35..9f4996446 100644
--- a/packages/testing/docs/Assertions/AssertScoutQueryEquals.md
+++ b/packages/testing/docs/Assertions/AssertScoutQueryEquals.md
@@ -3,7 +3,7 @@
Asserts that Scout Query equals Scout Query.
[include:example]: ./AssertScoutQueryEqualsTest.php
-[//]: # (start: 5046607ec467c82fe8c461c1bb3f7ca5d3c8ea78b67a4cd01448cc96ac775551)
+[//]: # (start: 095a46ecac5d8728830790ea09a3c4fe3fbecbc26ff470a7f1dfc4abe053801d)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -56,4 +56,4 @@ final class AssertScoutQueryEqualsTest extends TestCase {
}
```
-[//]: # (end: 5046607ec467c82fe8c461c1bb3f7ca5d3c8ea78b67a4cd01448cc96ac775551)
+[//]: # (end: 095a46ecac5d8728830790ea09a3c4fe3fbecbc26ff470a7f1dfc4abe053801d)
diff --git a/packages/testing/docs/Assertions/AssertThatResponse.md b/packages/testing/docs/Assertions/AssertThatResponse.md
index 05b8ff1c2..d3c5a85d6 100644
--- a/packages/testing/docs/Assertions/AssertThatResponse.md
+++ b/packages/testing/docs/Assertions/AssertThatResponse.md
@@ -7,7 +7,7 @@ Asserts that PSR Response satisfies given constraint (we have a lot of built-in
> Assertion is deprecated, please use [`assertPsrResponse()`](./AssertPsrResponse.md) instead.
[include:example]: ./AssertThatResponseTest.php
-[//]: # (start: 132bbbc2e0a7ab0e29a2a98ce604860cb8685539926640afeae680ebc8e2c2f3)
+[//]: # (start: f476a946090593d6411394fdbee0737d373265353cb0a009e073aeb1c6af9750)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -101,4 +101,4 @@ final class AssertThatResponseTest extends TestCase {
}
```
-[//]: # (end: 132bbbc2e0a7ab0e29a2a98ce604860cb8685539926640afeae680ebc8e2c2f3)
+[//]: # (end: f476a946090593d6411394fdbee0737d373265353cb0a009e073aeb1c6af9750)
diff --git a/packages/testing/docs/Assertions/AssertXmlMatchesSchema.md b/packages/testing/docs/Assertions/AssertXmlMatchesSchema.md
index 9ea391646..b14081e01 100644
--- a/packages/testing/docs/Assertions/AssertXmlMatchesSchema.md
+++ b/packages/testing/docs/Assertions/AssertXmlMatchesSchema.md
@@ -3,7 +3,7 @@
Asserts that XML matches schema [XSD](https://en.wikipedia.org/wiki/XML_Schema_(W3C)) or [Relax NG](https://en.wikipedia.org/wiki/RELAX_NG). Validation based on the standard methods of [`DOMDocument`](https://www.php.net/manual/en/class.domdocument.php) class.
[include:example]: ./AssertXmlMatchesSchemaTest.php
-[//]: # (start: 85e7c95b662fc2552c7a3083d2b6415feedc20e27ab7e3cc11232f1f3de52c1a)
+[//]: # (start: f32d299baa99ca918c0fc7d63cbc99ee427103a45f7732347fa5a4be6729510b)
[//]: # (warning: Generated automatically. Do not edit.)
```php
@@ -65,4 +65,4 @@ final class AssertXmlMatchesSchemaTest extends TestCase {
}
```
-[//]: # (end: 85e7c95b662fc2552c7a3083d2b6415feedc20e27ab7e3cc11232f1f3de52c1a)
+[//]: # (end: f32d299baa99ca918c0fc7d63cbc99ee427103a45f7732347fa5a4be6729510b)
From 6bfb467718ee42c90c6eff7efb1c5069371c00c3 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Tue, 21 May 2024 10:54:15 +0400
Subject: [PATCH 06/30] `Preprocessor::parse()` will not resolve target.
---
.../src/Preprocessor/Preprocessor.php | 17 +++++++++++------
.../src/Preprocessor/PreprocessorTest.php | 6 +++---
.../documentator/src/Preprocessor/Token.php | 5 +++--
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index c0d597633..ddc41077f 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -178,7 +178,8 @@ public function run(Directory $root, Directory $directory, File $file, array $de
foreach ($parsed->tokens as $hash => $token) {
try {
- $content = $token->instruction->process($token->context, $token->target, $token->parameters);
+ $target = $token->resolver->resolve($token->context, $token->parameters);
+ $content = $token->instruction->process($token->context, $target, $token->parameters);
$content = trim($content);
} catch (PreprocessorError $exception) {
throw $exception;
@@ -233,6 +234,9 @@ protected function parse(Directory $root, Directory $directory, File $file): Tok
}
// Parse each of them
+ $container = $this->container->getInstance();
+ $resolvers = [];
+
foreach ($matches as $match) {
// Instruction?
$name = (string) $match['instruction'];
@@ -261,17 +265,18 @@ protected function parse(Directory $root, Directory $directory, File $file): Tok
}
// Parse
- $context = new Context($root, $directory, $file, $target, $match['parameters']);
- $parameters = $parameters
+ $context = new Context($root, $directory, $file, $target, $match['parameters']);
+ $parameters = $parameters
? $this->serializer->deserialize($parameters, $params, 'json')
: null;
- $resolver = $this->container->getInstance()->make($instruction::getResolver());
- $resolved = $resolver->resolve($context, $parameters);
+ $resolverClass = $instruction::getResolver();
+ $resolverInstance = $resolvers[$resolverClass] ?? $container->make($resolverClass);
+ $resolvers[$resolverClass] = $resolverInstance;
$tokens[$hash] = new Token(
$instruction,
$context,
- $resolved,
+ $resolverInstance,
$parameters,
[
$match[0] => (string) $match['expression'],
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index 681158838..a0dc077be 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -89,7 +89,7 @@ public function testParse(): void {
'88d510d98112f651df2ae08444a402cd8b6516cf4c27ad6115dbb2c03fe9ec62' => new Token(
$a,
new Context($root, $directory, $file, './path/to/file', null),
- './path/to/file',
+ new PreprocessorTest__TargetResolverAsIs(),
null,
[
'[test:empty]: ./path/to/file' => '[test:empty]: ./path/to/file',
@@ -98,7 +98,7 @@ public function testParse(): void {
'4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095' => new Token(
$b,
new Context($root, $directory, $file, './path/to/file', null),
- new PreprocessorTest__Value('./path/to/file/a'),
+ new PreprocessorTest__TargetResolverAsValue(),
new PreprocessorTest__Parameters(),
[
// phpcs:disable Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned
@@ -129,7 +129,7 @@ public function testParse(): void {
'./path/to/file/parametrized',
'{"a": "aa", "b": {"a": "a", "b": "b"}}',
),
- new PreprocessorTest__Value('./path/to/file/parametrized/aa'),
+ new PreprocessorTest__TargetResolverAsValue(),
new PreprocessorTest__Parameters(
'aa',
[
diff --git a/packages/documentator/src/Preprocessor/Token.php b/packages/documentator/src/Preprocessor/Token.php
index 7fbec11d9..a0436c4e4 100644
--- a/packages/documentator/src/Preprocessor/Token.php
+++ b/packages/documentator/src/Preprocessor/Token.php
@@ -3,6 +3,7 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Resolver;
/**
* @internal
@@ -18,9 +19,9 @@ public function __construct(
public readonly Instruction $instruction,
public readonly Context $context,
/**
- * @var TTarget
+ * @var Resolver
*/
- public readonly mixed $target,
+ public readonly Resolver $resolver,
/**
* @var TParameters
*/
From 0de946ff782054f1eebde5866b6ded17cfc50c08 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Tue, 21 May 2024 16:15:32 +0400
Subject: [PATCH 07/30] Instructions instance cache rework.
---
.../src/Preprocessor/Preprocessor.php | 46 +++---------
.../src/Preprocessor/PreprocessorTest.php | 11 +--
.../src/Preprocessor/ResolvedInstruction.php | 70 +++++++++++++++++++
.../documentator/src/Preprocessor/Token.php | 4 +-
4 files changed, 89 insertions(+), 42 deletions(-)
create mode 100644 packages/documentator/src/Preprocessor/ResolvedInstruction.php
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index ddc41077f..3d08f868d 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -24,7 +24,8 @@
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializer;
use Override;
-use function array_column;
+use function array_map;
+use function array_values;
use function hash;
use function is_array;
use function json_decode;
@@ -90,7 +91,7 @@ class Preprocessor implements Task {
REGEXP;
/**
- * @var array>,?Instruction}>
+ * @var array>
*/
private array $instructions = [];
@@ -112,7 +113,7 @@ public function __construct(
* @return list>>
*/
public function getInstructions(): array {
- return array_column($this->instructions, 0);
+ return array_values(array_map(static fn ($i) => $i->getClass(), $this->instructions));
}
/**
@@ -122,30 +123,11 @@ public function getInstructions(): array {
*/
public function addInstruction(Instruction|string $instruction): static {
// @phpstan-ignore-next-line Assigment is fine...
- $this->instructions[$instruction::getName()] = $instruction instanceof Instruction
- ? [$instruction::class, $instruction]
- : [$instruction, null];
+ $this->instructions[$instruction::getName()] = new ResolvedInstruction($this->container, $instruction);
return $this;
}
- /**
- * @return Instruction|null
- */
- protected function getInstruction(string $name): ?Instruction {
- if (!isset($this->instructions[$name])) {
- return null;
- }
-
- if (!isset($this->instructions[$name][1])) {
- $this->instructions[$name][1] = $this->container->getInstance()->make(
- $this->instructions[$name][0],
- );
- }
-
- return $this->instructions[$name][1];
- }
-
/**
* @inheritDoc
*/
@@ -234,20 +216,17 @@ protected function parse(Directory $root, Directory $directory, File $file): Tok
}
// Parse each of them
- $container = $this->container->getInstance();
- $resolvers = [];
-
foreach ($matches as $match) {
// Instruction?
$name = (string) $match['instruction'];
- $instruction = $this->getInstruction($name);
+ $instruction = $this->instructions[$name] ?? null;
if (!$instruction) {
continue;
}
// Hash
- $parameters = $instruction::getParameters();
+ $parameters = $instruction->getClass()::getParameters();
$target = (string) $match['target'];
$target = str_starts_with($target, '<') && str_ends_with($target, '>')
? mb_substr($target, 1, -1)
@@ -265,18 +244,15 @@ protected function parse(Directory $root, Directory $directory, File $file): Tok
}
// Parse
- $context = new Context($root, $directory, $file, $target, $match['parameters']);
- $parameters = $parameters
+ $context = new Context($root, $directory, $file, $target, $match['parameters']);
+ $parameters = $parameters
? $this->serializer->deserialize($parameters, $params, 'json')
: null;
- $resolverClass = $instruction::getResolver();
- $resolverInstance = $resolvers[$resolverClass] ?? $container->make($resolverClass);
- $resolvers[$resolverClass] = $resolverInstance;
$tokens[$hash] = new Token(
- $instruction,
+ $instruction->getInstance(),
+ $instruction->getResolver(),
$context,
- $resolverInstance,
$parameters,
[
$match[0] => (string) $match['expression'],
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index a0dc077be..af2bf491a 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -63,8 +63,6 @@ public function testParse(): void {
$preprocessor = Mockery::mock(Preprocessor::class, MockProperties::class);
$preprocessor->shouldAllowMockingProtectedMethods();
$preprocessor->makePartial();
- $preprocessor->addInstruction($a);
- $preprocessor->addInstruction($b);
$preprocessor
->shouldUseProperty('container')
->value(
@@ -76,6 +74,9 @@ public function testParse(): void {
$this->app()->make(Serializer::class),
);
+ $preprocessor->addInstruction($a);
+ $preprocessor->addInstruction($b);
+
$file = Mockery::mock(File::class);
$file
->shouldReceive('getContent')
@@ -88,8 +89,8 @@ public function testParse(): void {
new TokenList([
'88d510d98112f651df2ae08444a402cd8b6516cf4c27ad6115dbb2c03fe9ec62' => new Token(
$a,
- new Context($root, $directory, $file, './path/to/file', null),
new PreprocessorTest__TargetResolverAsIs(),
+ new Context($root, $directory, $file, './path/to/file', null),
null,
[
'[test:empty]: ./path/to/file' => '[test:empty]: ./path/to/file',
@@ -97,8 +98,8 @@ public function testParse(): void {
),
'4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095' => new Token(
$b,
- new Context($root, $directory, $file, './path/to/file', null),
new PreprocessorTest__TargetResolverAsValue(),
+ new Context($root, $directory, $file, './path/to/file', null),
new PreprocessorTest__Parameters(),
[
// phpcs:disable Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned
@@ -122,6 +123,7 @@ public function testParse(): void {
),
'ebe11a5c6bf74b7f70eec0c6b14ad768e159a9699273d7f07824ef116b37dfd3' => new Token(
$b,
+ new PreprocessorTest__TargetResolverAsValue(),
new Context(
$root,
$directory,
@@ -129,7 +131,6 @@ public function testParse(): void {
'./path/to/file/parametrized',
'{"a": "aa", "b": {"a": "a", "b": "b"}}',
),
- new PreprocessorTest__TargetResolverAsValue(),
new PreprocessorTest__Parameters(
'aa',
[
diff --git a/packages/documentator/src/Preprocessor/ResolvedInstruction.php b/packages/documentator/src/Preprocessor/ResolvedInstruction.php
new file mode 100644
index 000000000..81df21fa8
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/ResolvedInstruction.php
@@ -0,0 +1,70 @@
+>
+ */
+ private readonly string $class;
+ /**
+ * @var Resolver|Resolver|null
+ */
+ private ?Resolver $resolver = null;
+ /**
+ * @var Instruction|null
+ */
+ private ?Instruction $instance = null;
+
+ /**
+ * @param Instruction|class-string> $instruction
+ */
+ public function __construct(
+ protected readonly ContainerResolver $container,
+ Instruction|string $instruction,
+ ) {
+ if (is_object($instruction)) {
+ $this->class = $instruction::class;
+ $this->instance = $instruction;
+ } else {
+ $this->class = $instruction;
+ }
+ }
+
+ /**
+ * @return Instruction
+ */
+ public function getInstance(): Instruction {
+ $this->instance ??= $this->container->getInstance()->make($this->class);
+
+ return $this->instance;
+ }
+
+ /**
+ * @return Resolver|Resolver
+ */
+ public function getResolver(): Resolver {
+ $this->resolver ??= $this->container->getInstance()->make($this->class::getResolver());
+
+ return $this->resolver;
+ }
+
+ /**
+ * @return class-string>
+ */
+ public function getClass(): string {
+ return $this->class;
+ }
+}
diff --git a/packages/documentator/src/Preprocessor/Token.php b/packages/documentator/src/Preprocessor/Token.php
index a0436c4e4..0bdd18544 100644
--- a/packages/documentator/src/Preprocessor/Token.php
+++ b/packages/documentator/src/Preprocessor/Token.php
@@ -17,11 +17,11 @@ public function __construct(
* @var Instruction
*/
public readonly Instruction $instruction,
- public readonly Context $context,
/**
- * @var Resolver
+ * @var Resolver|Resolver
*/
public readonly Resolver $resolver,
+ public readonly Context $context,
/**
* @var TParameters
*/
From d007aafe9e2627d69472594bff2536a042467f4b Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Tue, 21 May 2024 16:20:56 +0400
Subject: [PATCH 08/30] `Resolver` may have dependencies.
---
.../src/Commands/PreprocessTest.php | 13 +-
.../src/Preprocessor/Contracts/Resolver.php | 15 ++-
.../IncludeDocumentList/InstructionTest.php | 8 +-
.../Instructions/IncludeExec/Resolver.php | 13 +-
.../IncludeGraphqlDirective/Resolver.php | 13 +-
.../IncludePackageList/InstructionTest.php | 8 +-
.../src/Preprocessor/Preprocessor.php | 40 +++++-
.../src/Preprocessor/PreprocessorTest.php | 123 ++++++++++++++++--
.../Preprocessor/Targets/DirectoryPath.php | 13 +-
.../Targets/DirectoryPathTest.php | 9 +-
.../src/Preprocessor/Targets/FileContent.php | 7 +-
.../src/Preprocessor/Targets/FilePath.php | 13 +-
.../src/Preprocessor/Targets/FilePathTest.php | 9 +-
13 files changed, 247 insertions(+), 37 deletions(-)
diff --git a/packages/documentator/src/Commands/PreprocessTest.php b/packages/documentator/src/Commands/PreprocessTest.php
index 0b66cfd9b..9de6120bb 100644
--- a/packages/documentator/src/Commands/PreprocessTest.php
+++ b/packages/documentator/src/Commands/PreprocessTest.php
@@ -269,8 +269,19 @@ public function process(Context $context, mixed $target, mixed $parameters): str
* @implements Resolver
*/
class PreprocessTest__Target implements Resolver {
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function getDependencies(Context $context, mixed $parameters): array {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
#[Override]
- public function resolve(Context $context, mixed $parameters): mixed {
+ public function resolve(Context $context, mixed $parameters, array $dependencies): mixed {
return $context->target;
}
}
diff --git a/packages/documentator/src/Preprocessor/Contracts/Resolver.php b/packages/documentator/src/Preprocessor/Contracts/Resolver.php
index 6b8267b3a..4e6f592bf 100644
--- a/packages/documentator/src/Preprocessor/Contracts/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Contracts/Resolver.php
@@ -3,6 +3,7 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
/**
* @template TParameters
@@ -10,9 +11,19 @@
*/
interface Resolver {
/**
- * @param TParameters $parameters
+ * Should return all files on which resolver/instruction depends.
+ *
+ * @return array
+ */
+ public function getDependencies(Context $context, mixed $parameters): array;
+
+ /**
+ * Resolves target into the expected type/value.
+ *
+ * @param TParameters $parameters
+ * @param array $dependencies
*
* @return TValue
*/
- public function resolve(Context $context, mixed $parameters): mixed;
+ public function resolve(Context $context, mixed $parameters, array $dependencies): mixed;
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
index e2b89ea4b..88051b9b8 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
@@ -25,7 +25,7 @@ public function testProcessSameDirectory(): void {
$params = new Parameters();
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $target = (new DirectoryPath())->resolve($context, null);
+ $target = (new DirectoryPath())->resolve($context, null, []);
$actual = $instance->process($context, $target, $params);
self::assertEquals(
@@ -45,7 +45,7 @@ public function testProcessAnotherDirectory(): void {
$params = new Parameters();
$context = new Context($root, $root, $file, basename(self::getTestData()->path('/')), '');
$instance = $this->app()->make(Instruction::class);
- $target = (new DirectoryPath())->resolve($context, null);
+ $target = (new DirectoryPath())->resolve($context, null, []);
$actual = $instance->process($context, $target, $params);
self::assertEquals(
@@ -65,7 +65,7 @@ public function testProcessNestedDirectories(): void {
$params = new Parameters(null);
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $target = (new DirectoryPath())->resolve($context, null);
+ $target = (new DirectoryPath())->resolve($context, null, []);
$actual = $instance->process($context, $target, $params);
self::assertEquals(
@@ -85,7 +85,7 @@ public function testProcessWithoutTitle(): void {
$params = new Parameters();
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $target = (new DirectoryPath())->resolve($context, null);
+ $target = (new DirectoryPath())->resolve($context, null, []);
self::expectExceptionObject(
new DocumentTitleIsMissing($context, 'WithoutTitle.md'),
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
index 884e502a6..ba2414066 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
@@ -16,8 +16,19 @@ public function __construct() {
// empty
}
+ /**
+ * @inheritDoc
+ */
#[Override]
- public function resolve(Context $context, mixed $parameters): string {
+ public function getDependencies(Context $context, mixed $parameters): array {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function resolve(Context $context, mixed $parameters, array $dependencies): string {
return $context->target;
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
index b5a539d9b..215d131b6 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
@@ -16,8 +16,19 @@ public function __construct() {
// empty
}
+ /**
+ * @inheritDoc
+ */
#[Override]
- public function resolve(Context $context, mixed $parameters): string {
+ public function getDependencies(Context $context, mixed $parameters): array {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function resolve(Context $context, mixed $parameters, array $dependencies): string {
return $context->target;
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index aa8eb2171..73a7d37fc 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -32,7 +32,7 @@ public function testProcess(string $expected, string $template): void {
$target = basename(self::getTestData()->path('/packages'));
$params = new Parameters(template: $template);
$context = new Context($root, $root, $file, $target, '');
- $resolved = (new DirectoryPath())->resolve($context, null);
+ $resolved = (new DirectoryPath())->resolve($context, null, []);
$instance = $this->app()->make(Instruction::class);
$actual = $instance->process($context, $resolved, $params);
@@ -53,7 +53,7 @@ public function testProcessNotAPackage(): void {
$target = basename(self::getTestData()->path('/invalid'));
$params = new Parameters();
$context = new Context($root, $root, $file, $target, '');
- $resolved = (new DirectoryPath())->resolve($context, null);
+ $resolved = (new DirectoryPath())->resolve($context, null, []);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -70,7 +70,7 @@ public function testProcessNoReadme(): void {
$target = basename(self::getTestData()->path('/no readme'));
$params = new Parameters();
$context = new Context($root, $root, $file, $target, '');
- $resolved = (new DirectoryPath())->resolve($context, null);
+ $resolved = (new DirectoryPath())->resolve($context, null, []);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -87,7 +87,7 @@ public function testProcessNoTitle(): void {
$target = basename(self::getTestData()->path('/no title'));
$params = new Parameters();
$context = new Context($root, $root, $file, $target, '');
- $resolved = (new DirectoryPath())->resolve($context, null);
+ $resolved = (new DirectoryPath())->resolve($context, null, []);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index 3d08f868d..4d63183a3 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -26,6 +26,7 @@
use function array_map;
use function array_values;
+use function explode;
use function hash;
use function is_array;
use function json_decode;
@@ -141,8 +142,23 @@ public function getExtensions(): array {
*/
#[Override]
public function getDependencies(Directory $root, Directory $directory, File $file): array {
- // TODO: Implement getDependencies() method.
- return [];
+ // Parse
+ $parsed = $this->parse($root, $directory, $file);
+
+ $file->setContext($this, $parsed);
+
+ // Extract dependencies
+ $dependencies = [];
+
+ foreach ($parsed->tokens as $hash => $token) {
+ $raw = $token->resolver->getDependencies($token->context, $token->parameters);
+
+ foreach ($raw as $key => $value) {
+ $dependencies["{$hash}@{$key}"] = $value;
+ }
+ }
+
+ return $dependencies;
}
/**
@@ -151,16 +167,30 @@ public function getDependencies(Directory $root, Directory $directory, File $fil
#[Override]
public function run(Directory $root, Directory $directory, File $file, array $dependencies): bool {
// Parse
- // TODO: Check if Context contains tokens
- $parsed = $this->parse($root, $directory, $file);
+ $parsed = $file->getContext($this) ?? $this->parse($root, $directory, $file);
+
+ if (!($parsed instanceof TokenList)) {
+ return false;
+ }
// Prepare
+ $deps = [];
+
+ foreach ($dependencies as $key => $value) {
+ [$hash, $key] = explode('@', (string) $key, 2) + [null, null];
+
+ if ($hash !== null && $key !== null) {
+ $deps[$hash][$key] = $value;
+ }
+ }
+
+ // Process
$replace = [];
$warning = static::Warning;
foreach ($parsed->tokens as $hash => $token) {
try {
- $target = $token->resolver->resolve($token->context, $token->parameters);
+ $target = $token->resolver->resolve($token->context, $token->parameters, $deps[$hash] ?? []);
$content = $token->instruction->process($token->context, $target, $token->parameters);
$content = trim($content);
} catch (PreprocessorError $exception) {
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index af2bf491a..fcc33b3fa 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -14,6 +14,7 @@
use Mockery;
use Override;
use PHPUnit\Framework\Attributes\CoversClass;
+use stdClass;
use function json_encode;
use function sprintf;
@@ -151,9 +152,17 @@ public function testParse(): void {
}
public function testRun(): void {
- $actual = null;
- $root = Mockery::mock(Directory::class);
- $file = Mockery::mock(File::class);
+ $preprocessor = $this->app()->make(Preprocessor::class)
+ ->addInstruction(new PreprocessorTest__EmptyInstruction())
+ ->addInstruction(new PreprocessorTest__TestInstruction());
+ $actual = null;
+ $root = Mockery::mock(Directory::class);
+ $file = Mockery::mock(File::class);
+ $file
+ ->shouldReceive('getContext')
+ ->once()
+ ->with($preprocessor)
+ ->andReturn(null);
$file
->shouldReceive('getContent')
->atLeast()
@@ -170,10 +179,6 @@ static function (string $content) use ($file, &$actual): File {
},
);
- $preprocessor = $this->app()->make(Preprocessor::class)
- ->addInstruction(new PreprocessorTest__EmptyInstruction())
- ->addInstruction(new PreprocessorTest__TestInstruction());
-
self::assertTrue($preprocessor->run($root, $root, $file, []));
self::assertEquals(
<<<'MARKDOWN'
@@ -238,6 +243,84 @@ static function (string $content) use ($file, &$actual): File {
$actual,
);
}
+
+ public function testRunCached(): void {
+ $a = Mockery::mock(File::class);
+ $b = Mockery::mock(File::class);
+ $c = Mockery::mock(File::class);
+ $d = Mockery::mock(File::class);
+ $e = Mockery::mock(File::class);
+ $context = Mockery::mock(Context::class);
+ $parameters = new stdClass();
+
+ $preprocessor = Mockery::mock(Preprocessor::class);
+ $preprocessor->shouldAllowMockingProtectedMethods();
+ $preprocessor->makePartial();
+ $preprocessor
+ ->shouldReceive('parse')
+ ->never();
+
+ $instruction = Mockery::mock(Instruction::class);
+ $instruction
+ ->shouldReceive('process')
+ ->with($context, 'a', $parameters)
+ ->once()
+ ->andReturn('a');
+ $instruction
+ ->shouldReceive('process')
+ ->with($context, 'b', $parameters)
+ ->once()
+ ->andReturn('b');
+
+ $resolver = Mockery::mock(Resolver::class);
+ $resolver
+ ->shouldReceive('resolve')
+ ->with($context, $parameters, [
+ 'a' => $a,
+ 'c' => $c,
+ ])
+ ->once()
+ ->andReturn('a');
+ $resolver
+ ->shouldReceive('resolve')
+ ->with($context, $parameters, [
+ 'b' => $b,
+ 'd' => $d,
+ ])
+ ->once()
+ ->andReturn('b');
+
+ $tokens = new TokenList([
+ 'a' => new Token($instruction, $resolver, $context, $parameters, []),
+ 'b' => new Token($instruction, $resolver, $context, $parameters, []),
+ ]);
+
+ $root = Mockery::mock(Directory::class);
+ $file = Mockery::mock(File::class);
+ $file
+ ->shouldReceive('getContext')
+ ->once()
+ ->with($preprocessor)
+ ->andReturn($tokens);
+ $file
+ ->shouldReceive('getContent')
+ ->atLeast()
+ ->once()
+ ->andReturn('file content');
+ $file
+ ->shouldReceive('setContent')
+ ->with('file content')
+ ->once()
+ ->andReturnSelf();
+
+ self::assertTrue($preprocessor->run($root, $root, $file, [
+ 'a@a' => $a,
+ 'b@b' => $b,
+ 'a@c' => $c,
+ 'b@d' => $d,
+ 'c@e' => $e,
+ ]));
+ }
}
// @phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
@@ -318,8 +401,19 @@ public function __construct(
* @implements Resolver
*/
class PreprocessorTest__TargetResolverAsIs implements Resolver {
+ /**
+ * @inheritDoc
+ */
#[Override]
- public function resolve(Context $context, mixed $parameters): mixed {
+ public function getDependencies(Context $context, mixed $parameters): array {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function resolve(Context $context, mixed $parameters, array $dependencies): mixed {
return $context->target;
}
}
@@ -331,8 +425,19 @@ public function resolve(Context $context, mixed $parameters): mixed {
* @implements Resolver
*/
class PreprocessorTest__TargetResolverAsValue implements Resolver {
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function getDependencies(Context $context, mixed $parameters): array {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
#[Override]
- public function resolve(Context $context, mixed $parameters): mixed {
+ public function resolve(Context $context, mixed $parameters, array $dependencies): mixed {
return new PreprocessorTest__Value("{$context->target}/{$parameters->a}");
}
}
diff --git a/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php b/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
index baaa28330..ffc77d85d 100644
--- a/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
+++ b/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
@@ -17,8 +17,19 @@ public function __construct() {
// empty
}
+ /**
+ * @inheritDoc
+ */
#[Override]
- public function resolve(Context $context, mixed $parameters): string {
+ public function getDependencies(Context $context, mixed $parameters): array {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function resolve(Context $context, mixed $parameters, array $dependencies): string {
$directory = $context->directory->getDirectory($context->target);
if (!$directory) {
diff --git a/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php b/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
index 7a82dda6e..fcfbfd181 100644
--- a/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
+++ b/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
@@ -22,13 +22,14 @@ public function testResolveRelative(): void {
$dir = new Directory(Path::join(__DIR__, '..'), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
+ $deps = [];
$params = null;
$context = new Context($root, $dir, $file, basename(__DIR__), null);
$resolver = new DirectoryPath();
self::assertSame(
$dir->getDirectory(__DIR__)?->getPath(),
- $resolver->resolve($context, $params),
+ $resolver->resolve($context, $params, $deps),
);
}
@@ -36,13 +37,14 @@ public function testResolveAbsolute(): void {
$dir = new Directory(Path::join(__DIR__, '..'), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
+ $deps = [];
$params = null;
$context = new Context($root, $dir, $file, $dir->getPath(), null);
$resolver = new DirectoryPath();
self::assertSame(
$dir->getPath(),
- $resolver->resolve($context, $params),
+ $resolver->resolve($context, $params, $deps),
);
}
@@ -50,6 +52,7 @@ public function testResolveNotADirectory(): void {
$dir = new Directory(Path::join(__DIR__, '..'), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
+ $deps = [];
$target = 'not/a/directory';
$params = null;
$context = new Context($root, $dir, $file, $target, null);
@@ -64,6 +67,6 @@ public function testResolveNotADirectory(): void {
),
);
- $resolver->resolve($context, $params);
+ $resolver->resolve($context, $params, $deps);
}
}
diff --git a/packages/documentator/src/Preprocessor/Targets/FileContent.php b/packages/documentator/src/Preprocessor/Targets/FileContent.php
index 9967ca068..37d7c006e 100644
--- a/packages/documentator/src/Preprocessor/Targets/FileContent.php
+++ b/packages/documentator/src/Preprocessor/Targets/FileContent.php
@@ -12,9 +12,12 @@
* File path.
*/
class FileContent extends FilePath {
+ /**
+ * @inheritDoc
+ */
#[Override]
- public function resolve(Context $context, mixed $parameters): string {
- $path = parent::resolve($context, $parameters);
+ public function resolve(Context $context, mixed $parameters, array $dependencies): string {
+ $path = parent::resolve($context, $parameters, $dependencies);
$content = file_get_contents($path);
if ($content === false) {
diff --git a/packages/documentator/src/Preprocessor/Targets/FilePath.php b/packages/documentator/src/Preprocessor/Targets/FilePath.php
index 6989b68b3..85e332d6c 100644
--- a/packages/documentator/src/Preprocessor/Targets/FilePath.php
+++ b/packages/documentator/src/Preprocessor/Targets/FilePath.php
@@ -17,8 +17,19 @@ public function __construct() {
// empty
}
+ /**
+ * @inheritDoc
+ */
#[Override]
- public function resolve(Context $context, mixed $parameters): string {
+ public function getDependencies(Context $context, mixed $parameters): array {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ #[Override]
+ public function resolve(Context $context, mixed $parameters, array $dependencies): string {
$file = $context->directory->getFile($context->target);
if (!$file) {
diff --git a/packages/documentator/src/Preprocessor/Targets/FilePathTest.php b/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
index d3bc8e6c5..052f31e48 100644
--- a/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
+++ b/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
@@ -21,13 +21,14 @@ public function testResolveRelative(): void {
$dir = new Directory(Path::join(__DIR__), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
+ $deps = [];
$params = null;
$context = new Context($root, $dir, $file, $file->getName(), null);
$resolver = new FilePath();
self::assertSame(
$file->getPath(),
- $resolver->resolve($context, $params),
+ $resolver->resolve($context, $params, $deps),
);
}
@@ -35,13 +36,14 @@ public function testResolveAbsolute(): void {
$dir = new Directory(Path::join(__DIR__), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
+ $deps = [];
$params = null;
$context = new Context($root, $dir, $file, $file->getPath(), null);
$resolver = new FilePath();
self::assertSame(
$file->getPath(),
- $resolver->resolve($context, $params),
+ $resolver->resolve($context, $params, $deps),
);
}
@@ -49,6 +51,7 @@ public function testResolveNotAFile(): void {
$dir = new Directory(Path::join(__DIR__), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
+ $deps = [];
$target = 'not/a/file';
$params = null;
$context = new Context($root, $dir, $file, $target, null);
@@ -61,6 +64,6 @@ public function testResolveNotAFile(): void {
$context->file->getRelativePath($context->root),
));
- $resolver->resolve($context, $params);
+ $resolver->resolve($context, $params, $deps);
}
}
From ba05c3cc926f32c4471bc3a42fd14b61f564f54c Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Thu, 23 May 2024 13:01:31 +0400
Subject: [PATCH 09/30] Migrated to the new generator-based `Task`.
---
.../src/Commands/PreprocessTest.php | 13 +-
.../src/Preprocessor/Contracts/Resolver.php | 18 +--
.../IncludeDocumentList/InstructionTest.php | 13 +-
.../Instructions/IncludeExec/Resolver.php | 13 +-
.../IncludeGraphqlDirective/Resolver.php | 13 +-
.../IncludePackageList/InstructionTest.php | 9 +-
.../src/Preprocessor/Preprocessor.php | 66 +++------
.../src/Preprocessor/PreprocessorTest.php | 139 ++++--------------
.../Preprocessor/Targets/DirectoryPath.php | 13 +-
.../Targets/DirectoryPathTest.php | 15 +-
.../src/Preprocessor/Targets/FileContent.php | 10 +-
.../src/Preprocessor/Targets/FilePath.php | 13 +-
.../src/Preprocessor/Targets/FilePathTest.php | 27 ++--
phpstan-baseline.neon | 5 +
14 files changed, 94 insertions(+), 273 deletions(-)
diff --git a/packages/documentator/src/Commands/PreprocessTest.php b/packages/documentator/src/Commands/PreprocessTest.php
index 9de6120bb..1c26fa390 100644
--- a/packages/documentator/src/Commands/PreprocessTest.php
+++ b/packages/documentator/src/Commands/PreprocessTest.php
@@ -269,19 +269,8 @@ public function process(Context $context, mixed $target, mixed $parameters): str
* @implements Resolver
*/
class PreprocessTest__Target implements Resolver {
- /**
- * @inheritDoc
- */
- #[Override]
- public function getDependencies(Context $context, mixed $parameters): array {
- return [];
- }
-
- /**
- * @inheritDoc
- */
#[Override]
- public function resolve(Context $context, mixed $parameters, array $dependencies): mixed {
+ public function __invoke(Context $context, mixed $parameters): mixed {
return $context->target;
}
}
diff --git a/packages/documentator/src/Preprocessor/Contracts/Resolver.php b/packages/documentator/src/Preprocessor/Contracts/Resolver.php
index 4e6f592bf..aeb99b0c4 100644
--- a/packages/documentator/src/Preprocessor/Contracts/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Contracts/Resolver.php
@@ -2,28 +2,24 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts;
+use Generator;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use SplFileInfo;
/**
* @template TParameters
* @template TValue
*/
interface Resolver {
- /**
- * Should return all files on which resolver/instruction depends.
- *
- * @return array
- */
- public function getDependencies(Context $context, mixed $parameters): array;
-
/**
* Resolves target into the expected type/value.
*
- * @param TParameters $parameters
- * @param array $dependencies
+ * Generator should be used to resolve any file which the Resolver depends on.
+ *
+ * @param TParameters $parameters
*
- * @return TValue
+ * @return Generator|TValue
*/
- public function resolve(Context $context, mixed $parameters, array $dependencies): mixed;
+ public function __invoke(Context $context, mixed $parameters): mixed;
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
index 88051b9b8..6ea07b3e4 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
@@ -2,9 +2,9 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeDocumentList;
+use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\DirectoryPath;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
@@ -25,8 +25,7 @@ public function testProcessSameDirectory(): void {
$params = new Parameters();
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $target = (new DirectoryPath())->resolve($context, null, []);
- $actual = $instance->process($context, $target, $params);
+ $actual = $instance->process($context, $root->getPath(), $params);
self::assertEquals(
self::getTestData()->content('~SameDirectory.md'),
@@ -45,7 +44,7 @@ public function testProcessAnotherDirectory(): void {
$params = new Parameters();
$context = new Context($root, $root, $file, basename(self::getTestData()->path('/')), '');
$instance = $this->app()->make(Instruction::class);
- $target = (new DirectoryPath())->resolve($context, null, []);
+ $target = Path::join($root->getPath(), $context->target);
$actual = $instance->process($context, $target, $params);
self::assertEquals(
@@ -65,8 +64,7 @@ public function testProcessNestedDirectories(): void {
$params = new Parameters(null);
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $target = (new DirectoryPath())->resolve($context, null, []);
- $actual = $instance->process($context, $target, $params);
+ $actual = $instance->process($context, $root->getPath(), $params);
self::assertEquals(
self::getTestData()->content('~NestedDirectories.md'),
@@ -85,12 +83,11 @@ public function testProcessWithoutTitle(): void {
$params = new Parameters();
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $target = (new DirectoryPath())->resolve($context, null, []);
self::expectExceptionObject(
new DocumentTitleIsMissing($context, 'WithoutTitle.md'),
);
- $instance->process($context, $target, $params);
+ $instance->process($context, $root->getPath(), $params);
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
index ba2414066..0cdbd6da3 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
@@ -16,19 +16,8 @@ public function __construct() {
// empty
}
- /**
- * @inheritDoc
- */
#[Override]
- public function getDependencies(Context $context, mixed $parameters): array {
- return [];
- }
-
- /**
- * @inheritDoc
- */
- #[Override]
- public function resolve(Context $context, mixed $parameters, array $dependencies): string {
+ public function __invoke(Context $context, mixed $parameters): mixed {
return $context->target;
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
index 215d131b6..90a533784 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
@@ -16,19 +16,8 @@ public function __construct() {
// empty
}
- /**
- * @inheritDoc
- */
#[Override]
- public function getDependencies(Context $context, mixed $parameters): array {
- return [];
- }
-
- /**
- * @inheritDoc
- */
- #[Override]
- public function resolve(Context $context, mixed $parameters, array $dependencies): string {
+ public function __invoke(Context $context, mixed $parameters): mixed {
return $context->target;
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index 73a7d37fc..3b1b812fc 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -7,7 +7,6 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageComposerJsonIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\DirectoryPath;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
@@ -32,7 +31,7 @@ public function testProcess(string $expected, string $template): void {
$target = basename(self::getTestData()->path('/packages'));
$params = new Parameters(template: $template);
$context = new Context($root, $root, $file, $target, '');
- $resolved = (new DirectoryPath())->resolve($context, null, []);
+ $resolved = Path::join($root->getPath(), $context->target);
$instance = $this->app()->make(Instruction::class);
$actual = $instance->process($context, $resolved, $params);
@@ -53,7 +52,7 @@ public function testProcessNotAPackage(): void {
$target = basename(self::getTestData()->path('/invalid'));
$params = new Parameters();
$context = new Context($root, $root, $file, $target, '');
- $resolved = (new DirectoryPath())->resolve($context, null, []);
+ $resolved = Path::join($root->getPath(), $context->target);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -70,7 +69,7 @@ public function testProcessNoReadme(): void {
$target = basename(self::getTestData()->path('/no readme'));
$params = new Parameters();
$context = new Context($root, $root, $file, $target, '');
- $resolved = (new DirectoryPath())->resolve($context, null, []);
+ $resolved = Path::join($root->getPath(), $context->target);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -87,7 +86,7 @@ public function testProcessNoTitle(): void {
$target = basename(self::getTestData()->path('/no title'));
$params = new Parameters();
$context = new Context($root, $root, $file, $target, '');
- $resolved = (new DirectoryPath())->resolve($context, null, []);
+ $resolved = Path::join($root->getPath(), $context->target);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index 4d63183a3..5478320c0 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -5,7 +5,9 @@
// @phpcs:disable Generic.Files.LineLength.TooLong
use Exception;
+use Generator;
use LastDragon_ru\LaraASP\Core\Application\ContainerResolver;
+use LastDragon_ru\LaraASP\Core\Utils\Cast;
use LastDragon_ru\LaraASP\Documentator\Commands\Preprocess;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PreprocessingFailed;
@@ -23,10 +25,10 @@
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializer;
use Override;
+use SplFileInfo;
use function array_map;
use function array_values;
-use function explode;
use function hash;
use function is_array;
use function json_decode;
@@ -138,59 +140,27 @@ public function getExtensions(): array {
}
/**
- * @inheritDoc
+ * @return Generator
*/
#[Override]
- public function getDependencies(Directory $root, Directory $directory, File $file): array {
- // Parse
- $parsed = $this->parse($root, $directory, $file);
-
- $file->setContext($this, $parsed);
-
- // Extract dependencies
- $dependencies = [];
-
- foreach ($parsed->tokens as $hash => $token) {
- $raw = $token->resolver->getDependencies($token->context, $token->parameters);
-
- foreach ($raw as $key => $value) {
- $dependencies["{$hash}@{$key}"] = $value;
- }
- }
-
- return $dependencies;
- }
-
- /**
- * @inheritDoc
- */
- #[Override]
- public function run(Directory $root, Directory $directory, File $file, array $dependencies): bool {
- // Parse
- $parsed = $file->getContext($this) ?? $this->parse($root, $directory, $file);
-
- if (!($parsed instanceof TokenList)) {
- return false;
- }
-
- // Prepare
- $deps = [];
-
- foreach ($dependencies as $key => $value) {
- [$hash, $key] = explode('@', (string) $key, 2) + [null, null];
-
- if ($hash !== null && $key !== null) {
- $deps[$hash][$key] = $value;
- }
- }
-
+ public function __invoke(Directory $root, File $file): Generator {
// Process
+ $parsed = $this->parse($root, $file);
$replace = [];
$warning = static::Warning;
foreach ($parsed->tokens as $hash => $token) {
try {
- $target = $token->resolver->resolve($token->context, $token->parameters, $deps[$hash] ?? []);
+ // Resolve target
+ $target = ($token->resolver)($token->context, $token->parameters);
+
+ if ($target instanceof Generator) {
+ yield from $target;
+
+ $target = $target->getReturn();
+ }
+
+ // Run
$content = $token->instruction->process($token->context, $target, $token->parameters);
$content = trim($content);
} catch (PreprocessorError $exception) {
@@ -236,7 +206,7 @@ public function run(Directory $root, Directory $directory, File $file, array $de
return true;
}
- protected function parse(Directory $root, Directory $directory, File $file): TokenList {
+ protected function parse(Directory $root, File $file): TokenList {
// Extract all possible instructions
$tokens = [];
$matches = [];
@@ -246,6 +216,8 @@ protected function parse(Directory $root, Directory $directory, File $file): Tok
}
// Parse each of them
+ $directory = Cast::to(Directory::class, $root->getDirectory($file));
+
foreach ($matches as $match) {
// Instruction?
$name = (string) $match['instruction'];
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index fcc33b3fa..a1f0c68f1 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -14,7 +14,6 @@
use Mockery;
use Override;
use PHPUnit\Framework\Attributes\CoversClass;
-use stdClass;
use function json_encode;
use function sprintf;
@@ -59,7 +58,6 @@ final class PreprocessorTest extends TestCase {
public function testParse(): void {
$a = new PreprocessorTest__EmptyInstruction();
$b = new PreprocessorTest__TestInstruction();
- $root = Mockery::mock(Directory::class);
$directory = Mockery::mock(Directory::class);
$preprocessor = Mockery::mock(Preprocessor::class, MockProperties::class);
$preprocessor->shouldAllowMockingProtectedMethods();
@@ -84,7 +82,14 @@ public function testParse(): void {
->once()
->andReturn(self::MARKDOWN);
- $tokens = $preprocessor->parse($root, $directory, $file);
+ $root = Mockery::mock(Directory::class);
+ $root
+ ->shouldReceive('getDirectory')
+ ->with($file)
+ ->once()
+ ->andReturn($directory);
+
+ $tokens = $preprocessor->parse($root, $file);
self::assertEquals(
new TokenList([
@@ -151,18 +156,12 @@ public function testParse(): void {
);
}
- public function testRun(): void {
+ public function testInvoke(): void {
$preprocessor = $this->app()->make(Preprocessor::class)
->addInstruction(new PreprocessorTest__EmptyInstruction())
->addInstruction(new PreprocessorTest__TestInstruction());
$actual = null;
- $root = Mockery::mock(Directory::class);
$file = Mockery::mock(File::class);
- $file
- ->shouldReceive('getContext')
- ->once()
- ->with($preprocessor)
- ->andReturn(null);
$file
->shouldReceive('getContent')
->atLeast()
@@ -179,7 +178,21 @@ static function (string $content) use ($file, &$actual): File {
},
);
- self::assertTrue($preprocessor->run($root, $root, $file, []));
+ $directory = Mockery::mock(Directory::class);
+ $root = Mockery::mock(Directory::class);
+ $root
+ ->shouldReceive('getDirectory')
+ ->with($file)
+ ->once()
+ ->andReturn($directory);
+
+ $generator = ($preprocessor)($root, $file);
+
+ while ($generator->valid()) {
+ $generator->send($root->getDirectory($file)?->getFile($generator->current()));
+ }
+
+ self::assertTrue($generator->getReturn());
self::assertEquals(
<<<'MARKDOWN'
Bla bla bla [processable]: ./path/to/file should be ignored.
@@ -243,84 +256,6 @@ static function (string $content) use ($file, &$actual): File {
$actual,
);
}
-
- public function testRunCached(): void {
- $a = Mockery::mock(File::class);
- $b = Mockery::mock(File::class);
- $c = Mockery::mock(File::class);
- $d = Mockery::mock(File::class);
- $e = Mockery::mock(File::class);
- $context = Mockery::mock(Context::class);
- $parameters = new stdClass();
-
- $preprocessor = Mockery::mock(Preprocessor::class);
- $preprocessor->shouldAllowMockingProtectedMethods();
- $preprocessor->makePartial();
- $preprocessor
- ->shouldReceive('parse')
- ->never();
-
- $instruction = Mockery::mock(Instruction::class);
- $instruction
- ->shouldReceive('process')
- ->with($context, 'a', $parameters)
- ->once()
- ->andReturn('a');
- $instruction
- ->shouldReceive('process')
- ->with($context, 'b', $parameters)
- ->once()
- ->andReturn('b');
-
- $resolver = Mockery::mock(Resolver::class);
- $resolver
- ->shouldReceive('resolve')
- ->with($context, $parameters, [
- 'a' => $a,
- 'c' => $c,
- ])
- ->once()
- ->andReturn('a');
- $resolver
- ->shouldReceive('resolve')
- ->with($context, $parameters, [
- 'b' => $b,
- 'd' => $d,
- ])
- ->once()
- ->andReturn('b');
-
- $tokens = new TokenList([
- 'a' => new Token($instruction, $resolver, $context, $parameters, []),
- 'b' => new Token($instruction, $resolver, $context, $parameters, []),
- ]);
-
- $root = Mockery::mock(Directory::class);
- $file = Mockery::mock(File::class);
- $file
- ->shouldReceive('getContext')
- ->once()
- ->with($preprocessor)
- ->andReturn($tokens);
- $file
- ->shouldReceive('getContent')
- ->atLeast()
- ->once()
- ->andReturn('file content');
- $file
- ->shouldReceive('setContent')
- ->with('file content')
- ->once()
- ->andReturnSelf();
-
- self::assertTrue($preprocessor->run($root, $root, $file, [
- 'a@a' => $a,
- 'b@b' => $b,
- 'a@c' => $c,
- 'b@d' => $d,
- 'c@e' => $e,
- ]));
- }
}
// @phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
@@ -401,19 +336,8 @@ public function __construct(
* @implements Resolver
*/
class PreprocessorTest__TargetResolverAsIs implements Resolver {
- /**
- * @inheritDoc
- */
#[Override]
- public function getDependencies(Context $context, mixed $parameters): array {
- return [];
- }
-
- /**
- * @inheritDoc
- */
- #[Override]
- public function resolve(Context $context, mixed $parameters, array $dependencies): mixed {
+ public function __invoke(Context $context, mixed $parameters): mixed {
return $context->target;
}
}
@@ -425,19 +349,8 @@ public function resolve(Context $context, mixed $parameters, array $dependencies
* @implements Resolver
*/
class PreprocessorTest__TargetResolverAsValue implements Resolver {
- /**
- * @inheritDoc
- */
- #[Override]
- public function getDependencies(Context $context, mixed $parameters): array {
- return [];
- }
-
- /**
- * @inheritDoc
- */
#[Override]
- public function resolve(Context $context, mixed $parameters, array $dependencies): mixed {
+ public function __invoke(Context $context, mixed $parameters): mixed {
return new PreprocessorTest__Value("{$context->target}/{$parameters->a}");
}
}
diff --git a/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php b/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
index ffc77d85d..42b2673db 100644
--- a/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
+++ b/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
@@ -17,19 +17,8 @@ public function __construct() {
// empty
}
- /**
- * @inheritDoc
- */
#[Override]
- public function getDependencies(Context $context, mixed $parameters): array {
- return [];
- }
-
- /**
- * @inheritDoc
- */
- #[Override]
- public function resolve(Context $context, mixed $parameters, array $dependencies): string {
+ public function __invoke(Context $context, mixed $parameters): mixed {
$directory = $context->directory->getDirectory($context->target);
if (!$directory) {
diff --git a/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php b/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
index fcfbfd181..4cadbd10a 100644
--- a/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
+++ b/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
@@ -18,41 +18,38 @@
*/
#[CoversClass(DirectoryPath::class)]
final class DirectoryPathTest extends TestCase {
- public function testResolveRelative(): void {
+ public function testInvokeRelative(): void {
$dir = new Directory(Path::join(__DIR__, '..'), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
- $deps = [];
$params = null;
$context = new Context($root, $dir, $file, basename(__DIR__), null);
$resolver = new DirectoryPath();
self::assertSame(
$dir->getDirectory(__DIR__)?->getPath(),
- $resolver->resolve($context, $params, $deps),
+ ($resolver)($context, $params),
);
}
- public function testResolveAbsolute(): void {
+ public function testInvokeAbsolute(): void {
$dir = new Directory(Path::join(__DIR__, '..'), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
- $deps = [];
$params = null;
$context = new Context($root, $dir, $file, $dir->getPath(), null);
$resolver = new DirectoryPath();
self::assertSame(
$dir->getPath(),
- $resolver->resolve($context, $params, $deps),
+ ($resolver)($context, $params),
);
}
- public function testResolveNotADirectory(): void {
+ public function testInvokeNotADirectory(): void {
$dir = new Directory(Path::join(__DIR__, '..'), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
- $deps = [];
$target = 'not/a/directory';
$params = null;
$context = new Context($root, $dir, $file, $target, null);
@@ -67,6 +64,6 @@ public function testResolveNotADirectory(): void {
),
);
- $resolver->resolve($context, $params, $deps);
+ ($resolver)($context, $params);
}
}
diff --git a/packages/documentator/src/Preprocessor/Targets/FileContent.php b/packages/documentator/src/Preprocessor/Targets/FileContent.php
index 37d7c006e..0b80d46f0 100644
--- a/packages/documentator/src/Preprocessor/Targets/FileContent.php
+++ b/packages/documentator/src/Preprocessor/Targets/FileContent.php
@@ -7,18 +7,16 @@
use Override;
use function file_get_contents;
+use function is_string;
/**
* File path.
*/
class FileContent extends FilePath {
- /**
- * @inheritDoc
- */
#[Override]
- public function resolve(Context $context, mixed $parameters, array $dependencies): string {
- $path = parent::resolve($context, $parameters, $dependencies);
- $content = file_get_contents($path);
+ public function __invoke(Context $context, mixed $parameters): mixed {
+ $path = parent::__invoke($context, $parameters);
+ $content = is_string($path) ? file_get_contents($path) : false;
if ($content === false) {
throw new TargetIsNotFile($context);
diff --git a/packages/documentator/src/Preprocessor/Targets/FilePath.php b/packages/documentator/src/Preprocessor/Targets/FilePath.php
index 85e332d6c..8fcbd81a6 100644
--- a/packages/documentator/src/Preprocessor/Targets/FilePath.php
+++ b/packages/documentator/src/Preprocessor/Targets/FilePath.php
@@ -17,19 +17,8 @@ public function __construct() {
// empty
}
- /**
- * @inheritDoc
- */
#[Override]
- public function getDependencies(Context $context, mixed $parameters): array {
- return [];
- }
-
- /**
- * @inheritDoc
- */
- #[Override]
- public function resolve(Context $context, mixed $parameters, array $dependencies): string {
+ public function __invoke(Context $context, mixed $parameters): mixed {
$file = $context->directory->getFile($context->target);
if (!$file) {
diff --git a/packages/documentator/src/Preprocessor/Targets/FilePathTest.php b/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
index 052f31e48..c9de9714e 100644
--- a/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
+++ b/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
@@ -17,53 +17,52 @@
*/
#[CoversClass(FilePath::class)]
final class FilePathTest extends TestCase {
- public function testResolveRelative(): void {
+ public function testInvokeRelative(): void {
$dir = new Directory(Path::join(__DIR__), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
- $deps = [];
$params = null;
$context = new Context($root, $dir, $file, $file->getName(), null);
$resolver = new FilePath();
self::assertSame(
$file->getPath(),
- $resolver->resolve($context, $params, $deps),
+ ($resolver)($context, $params),
);
}
- public function testResolveAbsolute(): void {
+ public function testInvokeAbsolute(): void {
$dir = new Directory(Path::join(__DIR__), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
- $deps = [];
$params = null;
$context = new Context($root, $dir, $file, $file->getPath(), null);
$resolver = new FilePath();
self::assertSame(
$file->getPath(),
- $resolver->resolve($context, $params, $deps),
+ ($resolver)($context, $params),
);
}
- public function testResolveNotAFile(): void {
+ public function testInvokeNotAFile(): void {
$dir = new Directory(Path::join(__DIR__), false);
$root = new Directory(Path::join(__DIR__, '../..'), false);
$file = new File(Path::normalize(__FILE__), false);
- $deps = [];
$target = 'not/a/file';
$params = null;
$context = new Context($root, $dir, $file, $target, null);
$resolver = new FilePath();
self::expectException(TargetIsNotFile::class);
- self::expectExceptionMessage(sprintf(
- 'The `%s` is not a file (in `%s`).',
- $target,
- $context->file->getRelativePath($context->root),
- ));
+ self::expectExceptionMessage(
+ sprintf(
+ 'The `%s` is not a file (in `%s`).',
+ $target,
+ $context->file->getRelativePath($context->root),
+ ),
+ );
- $resolver->resolve($context, $params, $deps);
+ ($resolver)($context, $params);
}
}
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index d5c0e95b7..467457ce7 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -5,6 +5,11 @@ parameters:
count: 1
path: packages/core/src/Observer/DispatcherTest.php
+ -
+ message: "#^Generator expects value type LastDragon_ru\\\\LaraASP\\\\Documentator\\\\Processor\\\\FileSystem\\\\File\\|SplFileInfo\\|string, mixed given\\.$#"
+ count: 1
+ path: packages/documentator/src/Preprocessor/Preprocessor.php
+
-
message: "#^Parameter \\#1 \\$offset of method LastDragon_ru\\\\LaraASP\\\\Eloquent\\\\Iterators\\\\IteratorImpl\\\\:\\:setOffset\\(\\) expects int\\|string\\|null, mixed given\\.$#"
count: 1
From 01c3f906804c7985e0cf512c3be2bfbab7be4520 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Thu, 23 May 2024 13:34:21 +0400
Subject: [PATCH 10/30] `Instruction` can also return `Generator`.
---
.../src/Commands/PreprocessTest.php | 6 +++---
.../Preprocessor/Contracts/Instruction.php | 11 +++++++++-
.../IncludeDocBlock/Instruction.php | 2 +-
.../IncludeDocBlock/InstructionTest.php | 4 ++--
.../IncludeDocumentList/Instruction.php | 2 +-
.../IncludeDocumentList/InstructionTest.php | 16 +++++++--------
.../IncludeExample/Instruction.php | 2 +-
.../IncludeExample/InstructionTest.php | 20 +++++++++----------
.../Instructions/IncludeExec/Instruction.php | 2 +-
.../IncludeExec/InstructionTest.php | 4 ++--
.../Instructions/IncludeFile/Instruction.php | 2 +-
.../IncludeFile/InstructionTest.php | 4 ++--
.../IncludeGraphqlDirective/Instruction.php | 2 +-
.../InstructionTest.php | 16 +++++++--------
.../IncludePackageList/Instruction.php | 2 +-
.../IncludePackageList/InstructionTest.php | 16 +++++++--------
.../IncludeTemplate/Instruction.php | 2 +-
.../IncludeTemplate/InstructionTest.php | 16 +++++++--------
.../src/Preprocessor/Preprocessor.php | 9 ++++++++-
.../src/Preprocessor/PreprocessorTest.php | 4 ++--
20 files changed, 79 insertions(+), 63 deletions(-)
diff --git a/packages/documentator/src/Commands/PreprocessTest.php b/packages/documentator/src/Commands/PreprocessTest.php
index 1c26fa390..318b820ee 100644
--- a/packages/documentator/src/Commands/PreprocessTest.php
+++ b/packages/documentator/src/Commands/PreprocessTest.php
@@ -196,7 +196,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
return $target;
}
}
@@ -224,7 +224,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
return $target;
}
}
@@ -252,7 +252,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
return $target;
}
}
diff --git a/packages/documentator/src/Preprocessor/Contracts/Instruction.php b/packages/documentator/src/Preprocessor/Contracts/Instruction.php
index 9d26dcd81..917a268eb 100644
--- a/packages/documentator/src/Preprocessor/Contracts/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Contracts/Instruction.php
@@ -2,7 +2,10 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts;
+use Generator;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use SplFileInfo;
/**
* @template TTarget
@@ -24,8 +27,14 @@ public static function getResolver(): string;
public static function getParameters(): ?string;
/**
+ * Process target with parameters and return result.
+ *
+ * Generator should be used to resolve any file which the Resolver depends on.
+ *
* @param TTarget $target
* @param TParameters $parameters
+ *
+ * @return Generator|string
*/
- public function process(Context $context, mixed $target, mixed $parameters): string;
+ public function __invoke(Context $context, mixed $target, mixed $parameters): Generator|string;
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Instruction.php
index 590298259..254833d58 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Instruction.php
@@ -51,7 +51,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
// Class?
[$class, $context] = ((array) $this->getClass($context, $target) + [null, null]);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
index 72bf6a9f3..bc336a54a 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
@@ -25,7 +25,7 @@ final class InstructionTest extends TestCase {
* @param Closure(self, Context): Exception|string $expected
*/
#[DataProvider('dataProviderProcess')]
- public function testProcess(Closure|string $expected, string $file, Parameters $params): void {
+ public function testInvoke(Closure|string $expected, string $file, Parameters $params): void {
$path = self::getTestData()->path($file);
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -39,7 +39,7 @@ public function testProcess(Closure|string $expected, string $file, Parameters $
$expected = self::getTestData()->content($expected);
}
- self::assertEquals($expected, $instance->process($context, $target, $params));
+ self::assertEquals($expected, ($instance)($context, $target, $params));
}
//
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
index 1f88afe0f..7d5abb98e 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
@@ -46,7 +46,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
/** @var list $documents */
$documents = [];
$path = $context->file->getName();
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
index 6ea07b3e4..8b2a0ab65 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
@@ -18,14 +18,14 @@
*/
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
- public function testProcessSameDirectory(): void {
+ public function testInvokeSameDirectory(): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = new Parameters();
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $root->getPath(), $params);
+ $actual = ($instance)($context, $root->getPath(), $params);
self::assertEquals(
self::getTestData()->content('~SameDirectory.md'),
@@ -37,7 +37,7 @@ public function testProcessSameDirectory(): void {
);
}
- public function testProcessAnotherDirectory(): void {
+ public function testInvokeAnotherDirectory(): void {
$path = self::getTestData()->path('~AnotherDirectory.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -45,7 +45,7 @@ public function testProcessAnotherDirectory(): void {
$context = new Context($root, $root, $file, basename(self::getTestData()->path('/')), '');
$instance = $this->app()->make(Instruction::class);
$target = Path::join($root->getPath(), $context->target);
- $actual = $instance->process($context, $target, $params);
+ $actual = ($instance)($context, $target, $params);
self::assertEquals(
self::getTestData()->content('~AnotherDirectory.md'),
@@ -57,14 +57,14 @@ public function testProcessAnotherDirectory(): void {
);
}
- public function testProcessNestedDirectories(): void {
+ public function testInvokeNestedDirectories(): void {
$path = self::getTestData()->path('nested/Document.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = new Parameters(null);
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $root->getPath(), $params);
+ $actual = ($instance)($context, $root->getPath(), $params);
self::assertEquals(
self::getTestData()->content('~NestedDirectories.md'),
@@ -76,7 +76,7 @@ public function testProcessNestedDirectories(): void {
);
}
- public function testProcessWithoutTitle(): void {
+ public function testInvokeWithoutTitle(): void {
$path = self::getTestData()->path('invalid/Document.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -88,6 +88,6 @@ public function testProcessWithoutTitle(): void {
new DocumentTitleIsMissing($context, 'WithoutTitle.md'),
);
- $instance->process($context, $root->getPath(), $params);
+ ($instance)($context, $root->getPath(), $params);
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
index 635c6ad72..188178152 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
@@ -59,7 +59,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
// Prepare
$content = $target;
$target = $context->target;
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
index e60f02ec7..89cef46fe 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
@@ -20,7 +20,7 @@
*/
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
- public function testProcessNoRun(): void {
+ public function testInvokeNoRun(): void {
$path = self::getTestData()->path('~example.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -34,7 +34,7 @@ public function testProcessNoRun(): void {
->fake();
});
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $content, $params);
+ $actual = ($instance)($context, $content, $params);
self::assertEquals(
<<assertNothingRan();
}
- public function testProcess(): void {
+ public function testInvoke(): void {
$path = self::getTestData()->path('~runnable.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -68,7 +68,7 @@ public function testProcess(): void {
return $factory;
});
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $content, $params);
+ $actual = ($instance)($context, $content, $params);
self::assertEquals(
<<path('~runnable.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -111,7 +111,7 @@ public function testProcessLongOutput(): void {
return $factory;
});
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $content, $params);
+ $actual = ($instance)($context, $content, $params);
self::assertEquals(
<<path('~runnable.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -156,7 +156,7 @@ public function testProcessMarkdown(): void {
return $factory;
});
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $content, $params);
+ $actual = ($instance)($context, $content, $params);
self::assertEquals(
<<path('~runnable.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -195,7 +195,7 @@ public function testProcessMarkdownLongOutput(): void {
return $factory;
});
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $content, $params);
+ $actual = ($instance)($context, $content, $params);
self::assertEquals(
<<factory->newPendingProcess()
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
index 5194b93a6..dbd782c01 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
@@ -16,7 +16,7 @@
*/
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
- public function testProcess(): void {
+ public function testInvoke(): void {
$root = new Directory(Path::normalize(__DIR__), false);
$file = new File(Path::normalize(__FILE__), false);
$params = null;
@@ -34,7 +34,7 @@ public function testProcess(): void {
});
$instance = $this->app()->make(Instruction::class);
- self::assertEquals($expected, $instance->process($context, $command, $params));
+ self::assertEquals($expected, ($instance)($context, $command, $params));
$factory->assertRan(static function (PendingProcess $process) use ($root, $command): bool {
return $process->path === $root->getPath()
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/Instruction.php
index 1d45dc233..e3417c539 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/Instruction.php
@@ -35,7 +35,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
return rtrim($target)."\n";
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
index 1b83441e6..c0e48c554 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
@@ -15,7 +15,7 @@
*/
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
- public function testProcess(): void {
+ public function testInvoke(): void {
$path = self::getTestData()->path('.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -24,6 +24,6 @@ public function testProcess(): void {
$instance = $this->app()->make(Instruction::class);
$expected = self::getTestData()->content('.md');
- self::assertEquals($expected, $instance->process($context, $expected, $params));
+ self::assertEquals($expected, ($instance)($context, $expected, $params));
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Instruction.php
index 761eef3bc..2c025858f 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Instruction.php
@@ -41,7 +41,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
// Dependencies?
if (!$this->printer) {
throw new DependencyIsMissing($context, Printer::class);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
index f5b1df363..13bb0ba70 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
@@ -23,7 +23,7 @@
final class InstructionTest extends TestCase {
//
// =========================================================================
- public function testProcess(): void {
+ public function testInvoke(): void {
$directive = <<<'GRAPHQL'
directive @test
on
@@ -48,7 +48,7 @@ public function testProcess(): void {
$file = Mockery::mock(File::class);
$context = new Context($root, $root, $file, '@test', null);
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $context->target, null);
+ $actual = ($instance)($context, $context->target, null);
self::assertEquals(
<<app()[PrinterContract::class]);
$root = new Directory(Path::normalize(__DIR__), false);
@@ -73,10 +73,10 @@ public function testProcessNoPrinter(): void {
new DependencyIsMissing($context, PrinterContract::class),
);
- $instance->process($context, $context->target, null);
+ ($instance)($context, $context->target, null);
}
- public function testProcessNoDirective(): void {
+ public function testInvokeNoDirective(): void {
$this->override(PrinterContract::class, static function (): PrinterContract {
$resolver = Mockery::mock(DirectiveResolver::class);
$resolver
@@ -100,10 +100,10 @@ public function testProcessNoDirective(): void {
new TargetIsNotDirective($context),
);
- $instance->process($context, $context->target, null);
+ ($instance)($context, $context->target, null);
}
- public function testProcessNoDirectiveResolver(): void {
+ public function testInvokeNoDirectiveResolver(): void {
$this->override(PrinterContract::class, static function (): PrinterContract {
return (new Printer())->setDirectiveResolver(null);
});
@@ -118,6 +118,6 @@ public function testProcessNoDirectiveResolver(): void {
new TargetIsNotDirective($context),
);
- $instance->process($context, $context->target, null);
+ ($instance)($context, $context->target, null);
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
index 4dd29e4b0..d4baaedba 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
@@ -56,7 +56,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
/** @var list $packages */
$packages = [];
$basePath = basename($target);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index 3b1b812fc..78a24e6eb 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -24,7 +24,7 @@ final class InstructionTest extends TestCase {
//
// =========================================================================
#[DataProvider('dataProviderProcess')]
- public function testProcess(string $expected, string $template): void {
+ public function testInvoke(string $expected, string $template): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
$file = new File(Path::normalize(__FILE__), false);
@@ -33,7 +33,7 @@ public function testProcess(string $expected, string $template): void {
$context = new Context($root, $root, $file, $target, '');
$resolved = Path::join($root->getPath(), $context->target);
$instance = $this->app()->make(Instruction::class);
- $actual = $instance->process($context, $resolved, $params);
+ $actual = ($instance)($context, $resolved, $params);
self::assertEquals(
self::getTestData()->content($expected),
@@ -45,7 +45,7 @@ public function testProcess(string $expected, string $template): void {
);
}
- public function testProcessNotAPackage(): void {
+ public function testInvokeNotAPackage(): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
$file = new File(Path::normalize(__FILE__), false);
@@ -59,10 +59,10 @@ public function testProcessNotAPackage(): void {
new PackageComposerJsonIsMissing($context, 'invalid/package'),
);
- $instance->process($context, $resolved, $params);
+ ($instance)($context, $resolved, $params);
}
- public function testProcessNoReadme(): void {
+ public function testInvokeNoReadme(): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
$file = new File(Path::normalize(__FILE__), false);
@@ -76,10 +76,10 @@ public function testProcessNoReadme(): void {
new PackageReadmeIsMissing($context, 'no readme/package'),
);
- $instance->process($context, $resolved, $params);
+ ($instance)($context, $resolved, $params);
}
- public function testProcessNoTitle(): void {
+ public function testInvokeNoTitle(): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
$file = new File(Path::normalize(__FILE__), false);
@@ -93,7 +93,7 @@ public function testProcessNoTitle(): void {
new DocumentTitleIsMissing($context, 'no title/package/README.md'),
);
- $instance->process($context, $resolved, $params);
+ ($instance)($context, $resolved, $params);
}
//
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Instruction.php
index f53960493..dc7c484ae 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Instruction.php
@@ -45,7 +45,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
// Data?
if (!$parameters->data) {
throw new TemplateDataMissed($context);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
index 2a3d07e81..d5601566c 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
@@ -19,7 +19,7 @@
*/
#[CoversClass(Instruction::class)]
final class InstructionTest extends TestCase {
- public function testProcess(): void {
+ public function testInvoke(): void {
$root = new Directory(Path::normalize(__DIR__), false);
$file = new File(Path::normalize(__FILE__), false);
$params = new Parameters([
@@ -38,11 +38,11 @@ public function testProcess(): void {
FILE
,
- $instance->process($context, $content, $params),
+ ($instance)($context, $content, $params),
);
}
- public function testProcessNoData(): void {
+ public function testInvokeNoData(): void {
$root = new Directory(Path::normalize(__DIR__), false);
$file = new File(Path::normalize(__FILE__), false);
$params = new Parameters([]);
@@ -54,10 +54,10 @@ public function testProcessNoData(): void {
new TemplateDataMissed($context),
);
- $instance->process($context, $content, $params);
+ ($instance)($context, $content, $params);
}
- public function testProcessVariablesUnused(): void {
+ public function testInvokeVariablesUnused(): void {
$path = self::getTestData()->path('.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -75,10 +75,10 @@ public function testProcessVariablesUnused(): void {
new TemplateVariablesUnused($context, ['c', 'd']),
);
- $instance->process($context, $content, $params);
+ ($instance)($context, $content, $params);
}
- public function testProcessVariablesMissed(): void {
+ public function testInvokeVariablesMissed(): void {
$path = self::getTestData()->path('.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
@@ -93,6 +93,6 @@ public function testProcessVariablesMissed(): void {
new TemplateVariablesMissed($context, ['b']),
);
- $instance->process($context, $content, $params);
+ ($instance)($context, $content, $params);
}
}
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index 5478320c0..f46a6c658 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -161,7 +161,14 @@ public function __invoke(Directory $root, File $file): Generator {
}
// Run
- $content = $token->instruction->process($token->context, $target, $token->parameters);
+ $content = ($token->instruction)($token->context, $target, $token->parameters);
+
+ if ($content instanceof Generator) {
+ yield from $content;
+
+ $content = $content->getReturn();
+ }
+
$content = trim($content);
} catch (PreprocessorError $exception) {
throw $exception;
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index a1f0c68f1..6a5aa86fa 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -284,7 +284,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
return '';
}
}
@@ -312,7 +312,7 @@ public static function getParameters(): ?string {
}
#[Override]
- public function process(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): string {
return sprintf('result(%s, %s)', $target->value, json_encode($parameters, JSON_THROW_ON_ERROR));
}
}
From f22f8616d7f663f5724e3c64404640e22459f912 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Thu, 23 May 2024 13:44:36 +0400
Subject: [PATCH 11/30] New resolvers.
---
.../Resolvers/DirectoryResolver.php | 27 ++++++++++++++++
.../Preprocessor/Resolvers/FileResolver.php | 32 +++++++++++++++++++
2 files changed, 59 insertions(+)
create mode 100644 packages/documentator/src/Preprocessor/Resolvers/DirectoryResolver.php
create mode 100644 packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
diff --git a/packages/documentator/src/Preprocessor/Resolvers/DirectoryResolver.php b/packages/documentator/src/Preprocessor/Resolvers/DirectoryResolver.php
new file mode 100644
index 000000000..285345039
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/Resolvers/DirectoryResolver.php
@@ -0,0 +1,27 @@
+
+ */
+class DirectoryResolver implements Resolver {
+ #[Override]
+ public function __invoke(Context $context, mixed $parameters): Directory {
+ $directory = $context->root->getDirectory($context->file)?->getDirectory($context->target);
+
+ if (!($directory instanceof Directory)) {
+ throw new TargetIsNotDirectory($context);
+ }
+
+ return $directory;
+ }
+}
diff --git a/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php b/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
new file mode 100644
index 000000000..d7c652fed
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
@@ -0,0 +1,32 @@
+
+ */
+class FileResolver implements Resolver {
+ /**
+ * @return Generator
+ */
+ #[Override]
+ public function __invoke(Context $context, mixed $parameters): Generator {
+ $file = yield $context->target;
+
+ if (!($file instanceof File)) {
+ throw new TargetIsNotFile($context);
+ }
+
+ return $file;
+ }
+}
From 6dd96db5b94cf5810a1fcedbe26feb5c8f82b76e Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Thu, 23 May 2024 13:49:37 +0400
Subject: [PATCH 12/30] `include:docblock` migrated to the new resolver.
---
.../Instructions/IncludeDocBlock/Instruction.php | 9 +++++----
.../Instructions/IncludeDocBlock/InstructionTest.php | 2 +-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Instruction.php
index 254833d58..baaf7f8b4 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Instruction.php
@@ -6,7 +6,8 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotValidPhpFile;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\FileContent;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Resolvers\FileResolver;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Utils\PhpDoc;
use Override;
use PhpParser\NameContext;
@@ -28,7 +29,7 @@
* from `` file. Inline tags include as is except `@see`/`@link`
* which will be replaced to FQCN (if possible). Other tags are ignored.
*
- * @implements InstructionContract
+ * @implements InstructionContract
*/
class Instruction implements InstructionContract {
public function __construct() {
@@ -42,7 +43,7 @@ public static function getName(): string {
#[Override]
public static function getResolver(): string {
- return FileContent::class;
+ return FileResolver::class;
}
#[Override]
@@ -53,7 +54,7 @@ public static function getParameters(): ?string {
#[Override]
public function __invoke(Context $context, mixed $target, mixed $parameters): string {
// Class?
- [$class, $context] = ((array) $this->getClass($context, $target) + [null, null]);
+ [$class, $context] = ((array) $this->getClass($context, $target->getContent()) + [null, null]);
if (!$class || !$context) {
return '';
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
index bc336a54a..e935322cb 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
@@ -29,7 +29,7 @@ public function testInvoke(Closure|string $expected, string $file, Parameters $p
$path = self::getTestData()->path($file);
$root = new Directory(dirname($path), false);
$file = new File($path, false);
- $target = $file->getContent();
+ $target = $file;
$context = new Context($root, $root, $file, $file->getName(), null);
$instance = $this->app()->make(Instruction::class);
From aebc6f83aeab085ed861c1433a4c2c8541cd234b Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Thu, 23 May 2024 13:54:00 +0400
Subject: [PATCH 13/30] `include:file` migrated to the new resolver.
---
.../Instructions/IncludeFile/Instruction.php | 9 +++++----
.../Instructions/IncludeFile/InstructionTest.php | 9 +++------
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/Instruction.php
index e3417c539..f4c556832 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/Instruction.php
@@ -4,7 +4,8 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\FileContent;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Resolvers\FileResolver;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use Override;
use function rtrim;
@@ -12,7 +13,7 @@
/**
* Includes the `` file.
*
- * @implements InstructionContract
+ * @implements InstructionContract
*/
class Instruction implements InstructionContract {
public function __construct() {
@@ -26,7 +27,7 @@ public static function getName(): string {
#[Override]
public static function getResolver(): string {
- return FileContent::class;
+ return FileResolver::class;
}
#[Override]
@@ -36,6 +37,6 @@ public static function getParameters(): ?string {
#[Override]
public function __invoke(Context $context, mixed $target, mixed $parameters): string {
- return rtrim($target)."\n";
+ return rtrim($target->getContent())."\n";
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
index c0e48c554..711a45673 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
@@ -3,13 +3,11 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeFile;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
-use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
+use Mockery;
use PHPUnit\Framework\Attributes\CoversClass;
-use function dirname;
-
/**
* @internal
*/
@@ -17,13 +15,12 @@
final class InstructionTest extends TestCase {
public function testInvoke(): void {
$path = self::getTestData()->path('.md');
- $root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = null;
- $context = new Context($root, $root, $file, $file->getPath(), $params);
+ $context = Mockery::mock(Context::class);
$instance = $this->app()->make(Instruction::class);
$expected = self::getTestData()->content('.md');
- self::assertEquals($expected, ($instance)($context, $expected, $params));
+ self::assertEquals($expected, ($instance)($context, $file, $params));
}
}
From 28c1a96e20000b8fa46cae99d1718ddef0b852e9 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Thu, 23 May 2024 13:57:23 +0400
Subject: [PATCH 14/30] `include:template` migrated to the new resolver.
---
.../Instructions/IncludeTemplate/Instruction.php | 9 +++++----
.../IncludeTemplate/InstructionTest.php | 14 +++++---------
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Instruction.php
index dc7c484ae..1724fe1d5 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Instruction.php
@@ -7,7 +7,8 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TemplateDataMissed;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TemplateVariablesMissed;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TemplateVariablesUnused;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\FileContent;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Resolvers\FileResolver;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use Override;
use function array_diff;
@@ -22,7 +23,7 @@
/**
* Includes the `` as a template.
*
- * @implements InstructionContract
+ * @implements InstructionContract
*/
class Instruction implements InstructionContract {
public function __construct() {
@@ -36,7 +37,7 @@ public static function getName(): string {
#[Override]
public static function getResolver(): string {
- return FileContent::class;
+ return FileResolver::class;
}
#[Override]
@@ -56,7 +57,7 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): st
$used = [];
$known = [];
$count = 0;
- $content = $target;
+ $content = $target->getContent();
do {
$content = (string) preg_replace_callback(
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
index d5601566c..dc27fbb78 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
@@ -21,12 +21,11 @@
final class InstructionTest extends TestCase {
public function testInvoke(): void {
$root = new Directory(Path::normalize(__DIR__), false);
- $file = new File(Path::normalize(__FILE__), false);
+ $file = new File(Path::normalize(self::getTestData()->path('.md')), false);
$params = new Parameters([
'a' => 'Relative',
'b' => 'Inner reference ${a}',
]);
- $content = self::getTestData()->content('.md');
$context = new Context($root, $root, $file, '/path/to/file.md', '');
$instance = $this->app()->make(Instruction::class);
@@ -38,7 +37,7 @@ public function testInvoke(): void {
FILE
,
- ($instance)($context, $content, $params),
+ ($instance)($context, $file, $params),
);
}
@@ -46,7 +45,6 @@ public function testInvokeNoData(): void {
$root = new Directory(Path::normalize(__DIR__), false);
$file = new File(Path::normalize(__FILE__), false);
$params = new Parameters([]);
- $content = 'content';
$context = new Context($root, $root, $file, $file->getPath(), '');
$instance = $this->app()->make(Instruction::class);
@@ -54,7 +52,7 @@ public function testInvokeNoData(): void {
new TemplateDataMissed($context),
);
- ($instance)($context, $content, $params);
+ ($instance)($context, $file, $params);
}
public function testInvokeVariablesUnused(): void {
@@ -67,7 +65,6 @@ public function testInvokeVariablesUnused(): void {
'c' => 'C',
'd' => 'D',
]);
- $content = $file->getContent();
$context = new Context($root, $root, $file, $file->getName(), '');
$instance = $this->app()->make(Instruction::class);
@@ -75,7 +72,7 @@ public function testInvokeVariablesUnused(): void {
new TemplateVariablesUnused($context, ['c', 'd']),
);
- ($instance)($context, $content, $params);
+ ($instance)($context, $file, $params);
}
public function testInvokeVariablesMissed(): void {
@@ -85,7 +82,6 @@ public function testInvokeVariablesMissed(): void {
$params = new Parameters([
'a' => 'A',
]);
- $content = $file->getContent();
$context = new Context($root, $root, $file, $file->getName(), '');
$instance = $this->app()->make(Instruction::class);
@@ -93,6 +89,6 @@ public function testInvokeVariablesMissed(): void {
new TemplateVariablesMissed($context, ['b']),
);
- ($instance)($context, $content, $params);
+ ($instance)($context, $file, $params);
}
}
From 07f7648c7691e93edd1813d149493bbdf4a5294c Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Thu, 23 May 2024 14:36:05 +0400
Subject: [PATCH 15/30] `include:example` migrated to the new resolver.
---
.../IncludeExample/Instruction.php | 43 ++++++++-----------
.../IncludeExample/InstructionTest.php | 10 ++---
2 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
index 188178152..4e727d576 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/Instruction.php
@@ -4,22 +4,21 @@
use Exception;
use Illuminate\Process\Factory;
-use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetExecFailed;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\FileContent;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Resolvers\FileResolver;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use Override;
use function dirname;
-use function is_file;
use function pathinfo;
use function preg_match;
use function preg_match_all;
use function preg_replace_callback;
use function trim;
-use const PATHINFO_EXTENSION;
+use const PATHINFO_FILENAME;
use const PREG_UNMATCHED_AS_NULL;
/**
@@ -31,7 +30,7 @@
* block. You can wrap the output into `text` tags to
* insert it as is.
*
- * @implements InstructionContract
+ * @implements InstructionContract
*/
class Instruction implements InstructionContract {
public const Limit = 50;
@@ -50,7 +49,7 @@ public static function getName(): string {
#[Override]
public static function getResolver(): string {
- return FileContent::class;
+ return FileResolver::class;
}
#[Override]
@@ -60,25 +59,23 @@ public static function getParameters(): ?string {
#[Override]
public function __invoke(Context $context, mixed $target, mixed $parameters): string {
- // Prepare
- $content = $target;
- $target = $context->target;
- $path = $context->file->getPath();
-
- // Process
- $language = $this->getLanguage($path, $target);
- $content = trim($content);
+ // Content
+ $language = $this->getLanguage($context, $target, $parameters);
+ $content = trim($target->getContent());
$content = <<getCommand($path, $target);
+
+ // Command?
+ $command = $this->getCommand($context, $target, $parameters);
if ($command) {
// Call
try {
- $output = $this->factory->newPendingProcess()->path(dirname($path))->run($command)->throw()->output();
+ $dir = dirname($target->getPath());
+ $output = $this->factory->newPendingProcess()->path($dir)->run($command)->throw()->output();
$output = trim($output);
} catch (Exception $exception) {
throw new TargetExecFailed($context, $exception);
@@ -140,17 +137,13 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): st
return $content;
}
- protected function getLanguage(string $path, string $target): string {
- return pathinfo($target, PATHINFO_EXTENSION);
+ protected function getLanguage(Context $context, File $target, mixed $parameters): string {
+ return $target->getExtension();
}
- 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;
+ protected function getCommand(Context $context, File $target, mixed $parameters): ?string {
+ $command = pathinfo($target->getName(), PATHINFO_FILENAME).'.run';
+ $command = $context->root->getDirectory($target)?->getFile($command)?->getPath();
return $command;
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
index 89cef46fe..9ec8aad04 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
@@ -34,7 +34,7 @@ public function testInvokeNoRun(): void {
->fake();
});
$instance = $this->app()->make(Instruction::class);
- $actual = ($instance)($context, $content, $params);
+ $actual = ($instance)($context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- $actual = ($instance)($context, $content, $params);
+ $actual = ($instance)($context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- $actual = ($instance)($context, $content, $params);
+ $actual = ($instance)($context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- $actual = ($instance)($context, $content, $params);
+ $actual = ($instance)($context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- $actual = ($instance)($context, $content, $params);
+ $actual = ($instance)($context, $file, $params);
self::assertEquals(
<<
Date: Fri, 24 May 2024 09:28:03 +0400
Subject: [PATCH 16/30] Added helper to run `Processor` tests.
---
.../IncludeDocBlock/InstructionTest.php | 3 +-
.../IncludeDocumentList/InstructionTest.php | 9 +--
.../IncludeExample/InstructionTest.php | 11 ++--
.../IncludeExec/InstructionTest.php | 3 +-
.../IncludeFile/InstructionTest.php | 3 +-
.../InstructionTest.php | 9 +--
.../IncludePackageList/InstructionTest.php | 9 +--
.../IncludeTemplate/InstructionTest.php | 9 +--
.../src/Preprocessor/PreprocessorTest.php | 11 ++--
.../src/Testing/Package/ProcessorHelper.php | 60 +++++++++++++++++++
10 files changed, 96 insertions(+), 31 deletions(-)
create mode 100644 packages/documentator/src/Testing/Package/ProcessorHelper.php
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
index e935322cb..d2c45bf15 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
@@ -8,6 +8,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotValidPhpFile;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -39,7 +40,7 @@ public function testInvoke(Closure|string $expected, string $file, Parameters $p
$expected = self::getTestData()->content($expected);
}
- self::assertEquals($expected, ($instance)($context, $target, $params));
+ self::assertEquals($expected, ProcessorHelper::runInstruction($instance, $context, $target, $params));
}
//
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
index 8b2a0ab65..7e4f05cdf 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
@@ -7,6 +7,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
@@ -25,7 +26,7 @@ public function testInvokeSameDirectory(): void {
$params = new Parameters();
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $actual = ($instance)($context, $root->getPath(), $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $root->getPath(), $params);
self::assertEquals(
self::getTestData()->content('~SameDirectory.md'),
@@ -45,7 +46,7 @@ public function testInvokeAnotherDirectory(): void {
$context = new Context($root, $root, $file, basename(self::getTestData()->path('/')), '');
$instance = $this->app()->make(Instruction::class);
$target = Path::join($root->getPath(), $context->target);
- $actual = ($instance)($context, $target, $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params);
self::assertEquals(
self::getTestData()->content('~AnotherDirectory.md'),
@@ -64,7 +65,7 @@ public function testInvokeNestedDirectories(): void {
$params = new Parameters(null);
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $actual = ($instance)($context, $root->getPath(), $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $root->getPath(), $params);
self::assertEquals(
self::getTestData()->content('~NestedDirectories.md'),
@@ -88,6 +89,6 @@ public function testInvokeWithoutTitle(): void {
new DocumentTitleIsMissing($context, 'WithoutTitle.md'),
);
- ($instance)($context, $root->getPath(), $params);
+ ProcessorHelper::runInstruction($instance, $context, $root->getPath(), $params);
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
index 9ec8aad04..214d824a1 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
@@ -7,6 +7,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
@@ -34,7 +35,7 @@ public function testInvokeNoRun(): void {
->fake();
});
$instance = $this->app()->make(Instruction::class);
- $actual = ($instance)($context, $file, $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- $actual = ($instance)($context, $file, $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- $actual = ($instance)($context, $file, $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- $actual = ($instance)($context, $file, $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- $actual = ($instance)($context, $file, $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $file, $params);
self::assertEquals(
<<app()->make(Instruction::class);
- self::assertEquals($expected, ($instance)($context, $command, $params));
+ self::assertEquals($expected, ProcessorHelper::runInstruction($instance, $context, $command, $params));
$factory->assertRan(static function (PendingProcess $process) use ($root, $command): bool {
return $process->path === $root->getPath()
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
index 711a45673..1d6e4d56a 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeFile/InstructionTest.php
@@ -4,6 +4,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use Mockery;
use PHPUnit\Framework\Attributes\CoversClass;
@@ -21,6 +22,6 @@ public function testInvoke(): void {
$instance = $this->app()->make(Instruction::class);
$expected = self::getTestData()->content('.md');
- self::assertEquals($expected, ($instance)($context, $file, $params));
+ self::assertEquals($expected, ProcessorHelper::runInstruction($instance, $context, $file, $params));
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
index 13bb0ba70..82f91a62f 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
@@ -9,6 +9,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotDirective;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use LastDragon_ru\LaraASP\GraphQLPrinter\Contracts\DirectiveResolver;
use LastDragon_ru\LaraASP\GraphQLPrinter\Contracts\Printer as PrinterContract;
@@ -48,7 +49,7 @@ public function testInvoke(): void {
$file = Mockery::mock(File::class);
$context = new Context($root, $root, $file, '@test', null);
$instance = $this->app()->make(Instruction::class);
- $actual = ($instance)($context, $context->target, null);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $context->target, null);
self::assertEquals(
<<target, null);
+ ProcessorHelper::runInstruction($instance, $context, $context->target, null);
}
public function testInvokeNoDirective(): void {
@@ -100,7 +101,7 @@ public function testInvokeNoDirective(): void {
new TargetIsNotDirective($context),
);
- ($instance)($context, $context->target, null);
+ ProcessorHelper::runInstruction($instance, $context, $context->target, null);
}
public function testInvokeNoDirectiveResolver(): void {
@@ -118,6 +119,6 @@ public function testInvokeNoDirectiveResolver(): void {
new TargetIsNotDirective($context),
);
- ($instance)($context, $context->target, null);
+ ProcessorHelper::runInstruction($instance, $context, $context->target, null);
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index 78a24e6eb..e36071b4e 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -9,6 +9,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsMissing;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -33,7 +34,7 @@ public function testInvoke(string $expected, string $template): void {
$context = new Context($root, $root, $file, $target, '');
$resolved = Path::join($root->getPath(), $context->target);
$instance = $this->app()->make(Instruction::class);
- $actual = ($instance)($context, $resolved, $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $resolved, $params);
self::assertEquals(
self::getTestData()->content($expected),
@@ -59,7 +60,7 @@ public function testInvokeNotAPackage(): void {
new PackageComposerJsonIsMissing($context, 'invalid/package'),
);
- ($instance)($context, $resolved, $params);
+ ProcessorHelper::runInstruction($instance, $context, $resolved, $params);
}
public function testInvokeNoReadme(): void {
@@ -76,7 +77,7 @@ public function testInvokeNoReadme(): void {
new PackageReadmeIsMissing($context, 'no readme/package'),
);
- ($instance)($context, $resolved, $params);
+ ProcessorHelper::runInstruction($instance, $context, $resolved, $params);
}
public function testInvokeNoTitle(): void {
@@ -93,7 +94,7 @@ public function testInvokeNoTitle(): void {
new DocumentTitleIsMissing($context, 'no title/package/README.md'),
);
- ($instance)($context, $resolved, $params);
+ ProcessorHelper::runInstruction($instance, $context, $resolved, $params);
}
//
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
index dc27fbb78..f7d2ff309 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
@@ -9,6 +9,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TemplateVariablesUnused;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use PHPUnit\Framework\Attributes\CoversClass;
@@ -37,7 +38,7 @@ public function testInvoke(): void {
FILE
,
- ($instance)($context, $file, $params),
+ ProcessorHelper::runInstruction($instance, $context, $file, $params),
);
}
@@ -52,7 +53,7 @@ public function testInvokeNoData(): void {
new TemplateDataMissed($context),
);
- ($instance)($context, $file, $params);
+ ProcessorHelper::runInstruction($instance, $context, $file, $params);
}
public function testInvokeVariablesUnused(): void {
@@ -72,7 +73,7 @@ public function testInvokeVariablesUnused(): void {
new TemplateVariablesUnused($context, ['c', 'd']),
);
- ($instance)($context, $file, $params);
+ ProcessorHelper::runInstruction($instance, $context, $file, $params);
}
public function testInvokeVariablesMissed(): void {
@@ -89,6 +90,6 @@ public function testInvokeVariablesMissed(): void {
new TemplateVariablesMissed($context, ['b']),
);
- ($instance)($context, $file, $params);
+ ProcessorHelper::runInstruction($instance, $context, $file, $params);
}
}
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index 6a5aa86fa..c701efe9d 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -7,6 +7,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Resolver;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializable;
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializer;
@@ -183,16 +184,12 @@ static function (string $content) use ($file, &$actual): File {
$root
->shouldReceive('getDirectory')
->with($file)
- ->once()
+ ->twice()
->andReturn($directory);
- $generator = ($preprocessor)($root, $file);
-
- while ($generator->valid()) {
- $generator->send($root->getDirectory($file)?->getFile($generator->current()));
- }
+ $result = ProcessorHelper::runTask($preprocessor, $root, $file);
- self::assertTrue($generator->getReturn());
+ self::assertTrue($result);
self::assertEquals(
<<<'MARKDOWN'
Bla bla bla [processable]: ./path/to/file should be ignored.
diff --git a/packages/documentator/src/Testing/Package/ProcessorHelper.php b/packages/documentator/src/Testing/Package/ProcessorHelper.php
new file mode 100644
index 000000000..4874996d0
--- /dev/null
+++ b/packages/documentator/src/Testing/Package/ProcessorHelper.php
@@ -0,0 +1,60 @@
+getDirectory($file);
+
+ while ($result->valid()) {
+ $result->send($directory?->getFile($result->current()));
+ }
+
+ $result = $result->getReturn();
+ }
+
+ return $result;
+ }
+
+ /**
+ * @template P of object|null
+ * @template T
+ *
+ * @param Instruction $instruction
+ * @param T $target
+ * @param P $parameters
+ */
+ public static function runInstruction(
+ Instruction $instruction,
+ Context $context,
+ mixed $target,
+ mixed $parameters,
+ ): string {
+ $result = ($instruction)($context, $target, $parameters);
+
+ if ($result instanceof Generator) {
+ $directory = $context->root->getDirectory($context->file);
+
+ while ($result->valid()) {
+ $result->send($directory?->getFile($result->current()));
+ }
+
+ $result = $result->getReturn();
+ }
+
+ return $result;
+ }
+}
From c8d3573d9d8504f45f100ce33e4d82e68c3e10b5 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Fri, 24 May 2024 10:10:20 +0400
Subject: [PATCH 17/30] `include:document-list` migrated to the new resolver.
---
.../IncludeDocumentList/Instruction.php | 42 +++++++++----------
.../IncludeDocumentList/InstructionTest.php | 22 +++++-----
2 files changed, 33 insertions(+), 31 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
index 7d5abb98e..14866cc44 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
@@ -2,17 +2,19 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeDocumentList;
-use LastDragon_ru\LaraASP\Core\Utils\Path;
+use Generator;
+use LastDragon_ru\LaraASP\Core\Utils\Cast;
use LastDragon_ru\LaraASP\Documentator\PackageViewer;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\DirectoryPath;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Resolvers\DirectoryResolver;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Utils\Markdown;
use Override;
-use Symfony\Component\Finder\Finder;
+use SplFileInfo;
-use function file_get_contents;
use function strcmp;
use function usort;
@@ -21,7 +23,7 @@
* must have `# Header` as the first construction. The first paragraph
* after the Header will be used as a summary.
*
- * @implements InstructionContract
+ * @implements InstructionContract
*/
class Instruction implements InstructionContract {
public function __construct(
@@ -37,7 +39,7 @@ public static function getName(): string {
#[Override]
public static function getResolver(): string {
- return DirectoryPath::class;
+ return DirectoryResolver::class;
}
#[Override]
@@ -45,36 +47,34 @@ public static function getParameters(): ?string {
return Parameters::class;
}
+ /**
+ * @return Generator
+ */
#[Override]
- public function __invoke(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): Generator {
/** @var list $documents */
$documents = [];
- $path = $context->file->getName();
- $base = $context->directory->getPath();
- $root = $target;
- $target = Path::normalize($context->target);
- $finder = Finder::create()->in($root)->name('*.md');
-
- if ($parameters->depth !== null) {
- $finder->depth($parameters->depth);
- }
+ $files = $target->getFilesIterator('*.md', $parameters->depth);
+ $self = $context->file->getPath();
+ $dir = Cast::to(Directory::class, $context->root->getDirectory($context->file));
- foreach ($finder->files() as $file) {
+ foreach ($files as $file) {
// Same?
- if ($target === '' && $file->getFilename() === $path) {
+ if ($self === $file->getPath()) {
continue;
}
// Content?
- $content = file_get_contents($file->getPathname());
+ $file = yield $file;
+ $content = $file?->getContent();
- if (!$content) {
+ if (!$file || !$content) {
continue;
}
// Extract
$docTitle = Markdown::getTitle($content);
- $docPath = Path::getRelativePath($base, $file->getPathname());
+ $docPath = $file->getRelativePath($dir);
if ($docTitle) {
$documents[] = [
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
index 7e4f05cdf..1d32ed248 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
@@ -2,7 +2,6 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeDocumentList;
-use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
@@ -26,7 +25,7 @@ public function testInvokeSameDirectory(): void {
$params = new Parameters();
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $actual = ProcessorHelper::runInstruction($instance, $context, $root->getPath(), $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $root, $params);
self::assertEquals(
self::getTestData()->content('~SameDirectory.md'),
@@ -39,13 +38,16 @@ public function testInvokeSameDirectory(): void {
}
public function testInvokeAnotherDirectory(): void {
- $path = self::getTestData()->path('~AnotherDirectory.md');
- $root = new Directory(dirname($path), false);
- $file = new File($path, false);
- $params = new Parameters();
- $context = new Context($root, $root, $file, basename(self::getTestData()->path('/')), '');
+ $path = self::getTestData()->path('~AnotherDirectory.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
+ $params = new Parameters();
+ $context = new Context($root, $root, $file, basename(self::getTestData()->path('/')), '');
+ $target = $root->getDirectory($context->target);
+
+ self::assertNotNull($target);
+
$instance = $this->app()->make(Instruction::class);
- $target = Path::join($root->getPath(), $context->target);
$actual = ProcessorHelper::runInstruction($instance, $context, $target, $params);
self::assertEquals(
@@ -65,7 +67,7 @@ public function testInvokeNestedDirectories(): void {
$params = new Parameters(null);
$context = new Context($root, $root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
- $actual = ProcessorHelper::runInstruction($instance, $context, $root->getPath(), $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $root, $params);
self::assertEquals(
self::getTestData()->content('~NestedDirectories.md'),
@@ -89,6 +91,6 @@ public function testInvokeWithoutTitle(): void {
new DocumentTitleIsMissing($context, 'WithoutTitle.md'),
);
- ProcessorHelper::runInstruction($instance, $context, $root->getPath(), $params);
+ ProcessorHelper::runInstruction($instance, $context, $root, $params);
}
}
From 8f164531ee47e2da04abb2073907d8e252a438fe Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Fri, 24 May 2024 10:58:53 +0400
Subject: [PATCH 18/30] `include:package-list` migrated to the new resolver.
---
.../PackageComposerJsonIsMissing.php | 7 +-
.../Exceptions/PackageReadmeIsMissing.php | 7 +-
.../IncludePackageList/Instruction.php | 114 +++++-------------
.../IncludePackageList/InstructionTest.php | 49 ++++----
.../InstructionTest/Document.md | 3 +
5 files changed, 66 insertions(+), 114 deletions(-)
create mode 100644 packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/Document.md
diff --git a/packages/documentator/src/Preprocessor/Exceptions/PackageComposerJsonIsMissing.php b/packages/documentator/src/Preprocessor/Exceptions/PackageComposerJsonIsMissing.php
index 1b1870b6f..9ed6fc75c 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/PackageComposerJsonIsMissing.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/PackageComposerJsonIsMissing.php
@@ -3,6 +3,7 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use Throwable;
use function sprintf;
@@ -10,21 +11,21 @@
class PackageComposerJsonIsMissing extends InstructionFailed {
public function __construct(
Context $context,
- private readonly string $package,
+ private readonly Directory $package,
Throwable $previous = null,
) {
parent::__construct(
$context,
sprintf(
"The package `%s` doesn't contain `composer.json` (in `%s`).",
- $this->package,
+ $this->package->getRelativePath($context->root),
$context->file->getRelativePath($context->root),
),
$previous,
);
}
- public function getPackage(): string {
+ public function getPackage(): Directory {
return $this->package;
}
}
diff --git a/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php b/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php
index 69c421a7a..59d2c68f1 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php
@@ -3,6 +3,7 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use Throwable;
use function sprintf;
@@ -10,21 +11,21 @@
class PackageReadmeIsMissing extends InstructionFailed {
public function __construct(
Context $context,
- private readonly string $package,
+ private readonly Directory $package,
Throwable $previous = null,
) {
parent::__construct(
$context,
sprintf(
"The package `%s` doesn't contain readme (in `%s`).",
- $this->package,
+ $this->package->getRelativePath($context->root),
$context->file->getRelativePath($context->root),
),
$previous,
);
}
- public function getPackage(): string {
+ public function getPackage(): Directory {
return $this->package;
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
index d4baaedba..64b39cf1e 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
@@ -3,6 +3,8 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList;
use Exception;
+use Generator;
+use LastDragon_ru\LaraASP\Core\Utils\Cast;
use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\PackageViewer;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
@@ -10,17 +12,15 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageComposerJsonIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Targets\DirectoryPath;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Resolvers\DirectoryResolver;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Utils\Markdown;
use Override;
-use Symfony\Component\Finder\Finder;
+use SplFileInfo;
use function assert;
-use function basename;
-use function file_get_contents;
use function is_array;
-use function is_file;
-use function is_string;
use function json_decode;
use function strcmp;
use function usort;
@@ -31,7 +31,7 @@
* Generates package list from `` directory. The readme file will be
* used to determine package name and summary.
*
- * @implements InstructionContract
+ * @implements InstructionContract
*/
class Instruction implements InstructionContract {
public function __construct(
@@ -47,7 +47,7 @@ public static function getName(): string {
#[Override]
public static function getResolver(): string {
- return DirectoryPath::class;
+ return DirectoryResolver::class;
}
#[Override]
@@ -55,62 +55,46 @@ public static function getParameters(): ?string {
return Parameters::class;
}
+ /**
+ * @return Generator
+ */
#[Override]
- public function __invoke(Context $context, mixed $target, mixed $parameters): string {
+ public function __invoke(Context $context, mixed $target, mixed $parameters): Generator {
/** @var list $packages */
$packages = [];
- $basePath = basename($target);
- $directories = Finder::create()
- ->ignoreVCSIgnored(true)
- ->in($target)
- ->depth(0)
- ->exclude('vendor')
- ->exclude('node_modules')
- ->directories();
+ $directories = $target->getDirectoriesIterator(null, 0);
+ $dir = Cast::to(Directory::class, $context->root->getDirectory($context->file));
foreach ($directories as $package) {
// Package?
- $packagePath = $package->getPathname();
- $packageInfo = $this->getPackageInfo($packagePath);
-
- if (!$packageInfo) {
- throw new PackageComposerJsonIsMissing(
- $context,
- Path::join($basePath, $package->getFilename()),
- );
+ $packageFile = yield Path::join($package->getPath(), 'composer.json');
+ $packageInfo = $this->getPackageInfo($packageFile);
+
+ if (!$packageFile || !$packageInfo) {
+ throw new PackageComposerJsonIsMissing($context, $package);
}
// Readme
- $readme = $this->getPackageReadme($packagePath, $packageInfo);
- $content = $readme
- ? file_get_contents(Path::join($packagePath, $readme))
- : false;
-
- if (!$readme || $content === false) {
- throw new PackageReadmeIsMissing(
- $context,
- Path::join($basePath, $package->getFilename()),
- );
+ $readme = yield Path::join($package->getPath(), Cast::toString($packageInfo['readme'] ?: 'README.md'));
+ $content = $readme?->getContent();
+
+ if (!$readme || !$content) {
+ throw new PackageReadmeIsMissing($context, $package);
}
// Extract
$packageTitle = Markdown::getTitle($content);
- $readmePath = Path::join($basePath, $package->getFilename(), $readme);
if ($packageTitle) {
- $upgrade = $this->getPackageUpgrade($packagePath, $packageInfo);
- $upgradePath = $upgrade
- ? Path::join($basePath, $package->getFilename(), $upgrade)
- : null;
-
+ $upgrade = yield Path::join($package->getPath(), 'UPGRADE.md');
$packages[] = [
- 'path' => $readmePath,
+ 'path' => $readme->getRelativePath($dir),
'title' => $packageTitle,
'summary' => Markdown::getSummary($content),
- 'upgrade' => $upgradePath,
+ 'upgrade' => $upgrade?->getRelativePath($dir),
];
} else {
- throw new DocumentTitleIsMissing($context, $readmePath);
+ throw new DocumentTitleIsMissing($context, $readme->getRelativePath($dir));
}
}
@@ -137,11 +121,10 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): st
/**
* @return array|null
*/
- protected function getPackageInfo(string $path): ?array {
+ protected function getPackageInfo(?File $file): ?array {
try {
- $file = Path::join($path, 'composer.json');
- $package = is_file($file) ? file_get_contents($file) : false;
- $package = $package !== false
+ $package = $file?->getContent();
+ $package = $package
? json_decode($package, true, flags: JSON_THROW_ON_ERROR)
: null;
@@ -152,39 +135,4 @@ protected function getPackageInfo(string $path): ?array {
return $package;
}
-
- /**
- * @param array $package
- */
- protected function getPackageReadme(string $path, array $package): ?string {
- return $this->getPackageFile($path, [
- $package['readme'] ?? null,
- 'README.md',
- ]);
- }
-
- /**
- * @param array $package
- */
- protected function getPackageUpgrade(string $path, array $package): ?string {
- return $this->getPackageFile($path, [
- 'UPGRADE.md',
- ]);
- }
-
- /**
- * @param array $variants
- */
- private function getPackageFile(string $path, array $variants): ?string {
- $file = null;
-
- foreach ($variants as $variant) {
- if ($variant && is_string($variant) && is_file(Path::getPath($path, $variant))) {
- $file = $variant;
- break;
- }
- }
-
- return $file;
- }
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index e36071b4e..40c9c796e 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -14,7 +14,6 @@
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
-use function basename;
use function dirname;
/**
@@ -26,15 +25,14 @@ final class InstructionTest extends TestCase {
// =========================================================================
#[DataProvider('dataProviderProcess')]
public function testInvoke(string $expected, string $template): void {
- $path = self::getTestData()->path('Document.md');
+ $path = Path::normalize(self::getTestData()->path('Document.md'));
$root = new Directory(dirname($path), false);
- $file = new File(Path::normalize(__FILE__), false);
- $target = basename(self::getTestData()->path('/packages'));
+ $file = new File($path, false);
+ $target = new Directory(Path::join($root->getPath(), 'packages'), false);
$params = new Parameters(template: $template);
- $context = new Context($root, $root, $file, $target, '');
- $resolved = Path::join($root->getPath(), $context->target);
+ $context = new Context($root, $root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
- $actual = ProcessorHelper::runInstruction($instance, $context, $resolved, $params);
+ $actual = ProcessorHelper::runInstruction($instance, $context, $target, $params);
self::assertEquals(
self::getTestData()->content($expected),
@@ -47,54 +45,55 @@ public function testInvoke(string $expected, string $template): void {
}
public function testInvokeNotAPackage(): void {
- $path = self::getTestData()->path('Document.md');
+ $path = Path::normalize(self::getTestData()->path('Document.md'));
$root = new Directory(dirname($path), false);
- $file = new File(Path::normalize(__FILE__), false);
- $target = basename(self::getTestData()->path('/invalid'));
+ $file = new File($path, false);
+ $target = new Directory(Path::join($root->getPath(), 'invalid'), false);
$params = new Parameters();
- $context = new Context($root, $root, $file, $target, '');
- $resolved = Path::join($root->getPath(), $context->target);
+ $context = new Context($root, $root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
+ $package = $target->getDirectory('package');
+ self::assertNotNull($package);
self::expectExceptionObject(
- new PackageComposerJsonIsMissing($context, 'invalid/package'),
+ new PackageComposerJsonIsMissing($context, $package),
);
- ProcessorHelper::runInstruction($instance, $context, $resolved, $params);
+ ProcessorHelper::runInstruction($instance, $context, $target, $params);
}
public function testInvokeNoReadme(): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
- $file = new File(Path::normalize(__FILE__), false);
- $target = basename(self::getTestData()->path('/no readme'));
+ $file = new File($path, false);
+ $target = new Directory(Path::join($root->getPath(), '/no readme'), false);
$params = new Parameters();
- $context = new Context($root, $root, $file, $target, '');
- $resolved = Path::join($root->getPath(), $context->target);
+ $context = new Context($root, $root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
+ $package = $target->getDirectory('package');
+ self::assertNotNull($package);
self::expectExceptionObject(
- new PackageReadmeIsMissing($context, 'no readme/package'),
+ new PackageReadmeIsMissing($context, $package),
);
- ProcessorHelper::runInstruction($instance, $context, $resolved, $params);
+ ProcessorHelper::runInstruction($instance, $context, $target, $params);
}
public function testInvokeNoTitle(): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
- $file = new File(Path::normalize(__FILE__), false);
- $target = basename(self::getTestData()->path('/no title'));
+ $file = new File($path, false);
+ $target = new Directory(Path::join($root->getPath(), '/no title'), false);
$params = new Parameters();
- $context = new Context($root, $root, $file, $target, '');
- $resolved = Path::join($root->getPath(), $context->target);
+ $context = new Context($root, $root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
new DocumentTitleIsMissing($context, 'no title/package/README.md'),
);
- ProcessorHelper::runInstruction($instance, $context, $resolved, $params);
+ ProcessorHelper::runInstruction($instance, $context, $target, $params);
}
//
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/Document.md b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/Document.md
new file mode 100644
index 000000000..4b5481e8e
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/Document.md
@@ -0,0 +1,3 @@
+# Document
+
+bla bla bla
From 3c6ba5f95822f78d180f0efbfaafdc5c15eba0b4 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Fri, 24 May 2024 11:00:19 +0400
Subject: [PATCH 19/30] Old target resolvers removed.
---
.../Preprocessor/Targets/DirectoryPath.php | 30 --------
.../Targets/DirectoryPathTest.php | 69 -------------------
.../src/Preprocessor/Targets/FileContent.php | 27 --------
.../src/Preprocessor/Targets/FilePath.php | 30 --------
.../src/Preprocessor/Targets/FilePathTest.php | 68 ------------------
5 files changed, 224 deletions(-)
delete mode 100644 packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
delete mode 100644 packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
delete mode 100644 packages/documentator/src/Preprocessor/Targets/FileContent.php
delete mode 100644 packages/documentator/src/Preprocessor/Targets/FilePath.php
delete mode 100644 packages/documentator/src/Preprocessor/Targets/FilePathTest.php
diff --git a/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php b/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
deleted file mode 100644
index 42b2673db..000000000
--- a/packages/documentator/src/Preprocessor/Targets/DirectoryPath.php
+++ /dev/null
@@ -1,30 +0,0 @@
-
- */
-class DirectoryPath implements Resolver {
- public function __construct() {
- // empty
- }
-
- #[Override]
- public function __invoke(Context $context, mixed $parameters): mixed {
- $directory = $context->directory->getDirectory($context->target);
-
- if (!$directory) {
- throw new TargetIsNotDirectory($context);
- }
-
- return $directory->getPath();
- }
-}
diff --git a/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php b/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
deleted file mode 100644
index 4cadbd10a..000000000
--- a/packages/documentator/src/Preprocessor/Targets/DirectoryPathTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
-getDirectory(__DIR__)?->getPath(),
- ($resolver)($context, $params),
- );
- }
-
- public function testInvokeAbsolute(): void {
- $dir = new Directory(Path::join(__DIR__, '..'), false);
- $root = new Directory(Path::join(__DIR__, '../..'), false);
- $file = new File(Path::normalize(__FILE__), false);
- $params = null;
- $context = new Context($root, $dir, $file, $dir->getPath(), null);
- $resolver = new DirectoryPath();
-
- self::assertSame(
- $dir->getPath(),
- ($resolver)($context, $params),
- );
- }
-
- public function testInvokeNotADirectory(): void {
- $dir = new Directory(Path::join(__DIR__, '..'), false);
- $root = new Directory(Path::join(__DIR__, '../..'), false);
- $file = new File(Path::normalize(__FILE__), false);
- $target = 'not/a/directory';
- $params = null;
- $context = new Context($root, $dir, $file, $target, null);
- $resolver = new DirectoryPath();
-
- self::expectException(TargetIsNotDirectory::class);
- self::expectExceptionMessage(
- sprintf(
- 'The `%s` is not a directory (in `%s`).',
- $target,
- $context->file->getRelativePath($context->root),
- ),
- );
-
- ($resolver)($context, $params);
- }
-}
diff --git a/packages/documentator/src/Preprocessor/Targets/FileContent.php b/packages/documentator/src/Preprocessor/Targets/FileContent.php
deleted file mode 100644
index 0b80d46f0..000000000
--- a/packages/documentator/src/Preprocessor/Targets/FileContent.php
+++ /dev/null
@@ -1,27 +0,0 @@
-
- */
-class FilePath implements Resolver {
- public function __construct() {
- // empty
- }
-
- #[Override]
- public function __invoke(Context $context, mixed $parameters): mixed {
- $file = $context->directory->getFile($context->target);
-
- if (!$file) {
- throw new TargetIsNotFile($context);
- }
-
- return $file->getPath();
- }
-}
diff --git a/packages/documentator/src/Preprocessor/Targets/FilePathTest.php b/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
deleted file mode 100644
index c9de9714e..000000000
--- a/packages/documentator/src/Preprocessor/Targets/FilePathTest.php
+++ /dev/null
@@ -1,68 +0,0 @@
-getName(), null);
- $resolver = new FilePath();
-
- self::assertSame(
- $file->getPath(),
- ($resolver)($context, $params),
- );
- }
-
- public function testInvokeAbsolute(): void {
- $dir = new Directory(Path::join(__DIR__), false);
- $root = new Directory(Path::join(__DIR__, '../..'), false);
- $file = new File(Path::normalize(__FILE__), false);
- $params = null;
- $context = new Context($root, $dir, $file, $file->getPath(), null);
- $resolver = new FilePath();
-
- self::assertSame(
- $file->getPath(),
- ($resolver)($context, $params),
- );
- }
-
- public function testInvokeNotAFile(): void {
- $dir = new Directory(Path::join(__DIR__), false);
- $root = new Directory(Path::join(__DIR__, '../..'), false);
- $file = new File(Path::normalize(__FILE__), false);
- $target = 'not/a/file';
- $params = null;
- $context = new Context($root, $dir, $file, $target, null);
- $resolver = new FilePath();
-
- self::expectException(TargetIsNotFile::class);
- self::expectExceptionMessage(
- sprintf(
- 'The `%s` is not a file (in `%s`).',
- $target,
- $context->file->getRelativePath($context->root),
- ),
- );
-
- ($resolver)($context, $params);
- }
-}
From e96523d69ca3dbce4fdf819a1e23c42835183809 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Fri, 24 May 2024 13:03:32 +0400
Subject: [PATCH 20/30] Removed `Context::$directory`.
---
.../documentator/src/Preprocessor/Context.php | 1 -
.../IncludeDocBlock/InstructionTest.php | 2 +-
.../IncludeDocumentList/InstructionTest.php | 8 ++++----
.../IncludeExample/InstructionTest.php | 10 +++++-----
.../Instructions/IncludeExec/Instruction.php | 3 ++-
.../Instructions/IncludeExec/InstructionTest.php | 2 +-
.../IncludeGraphqlDirective/InstructionTest.php | 8 ++++----
.../IncludePackageList/InstructionTest.php | 8 ++++----
.../IncludeTemplate/InstructionTest.php | 8 ++++----
.../src/Preprocessor/Preprocessor.php | 5 +----
.../src/Preprocessor/PreprocessorTest.php | 16 ++++------------
11 files changed, 30 insertions(+), 41 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Context.php b/packages/documentator/src/Preprocessor/Context.php
index e187a87a4..da42cdf20 100644
--- a/packages/documentator/src/Preprocessor/Context.php
+++ b/packages/documentator/src/Preprocessor/Context.php
@@ -8,7 +8,6 @@
class Context {
public function __construct(
public readonly Directory $root,
- public readonly Directory $directory,
public readonly File $file,
public readonly string $target,
public readonly ?string $parameters,
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
index d2c45bf15..5bde86404 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/InstructionTest.php
@@ -31,7 +31,7 @@ public function testInvoke(Closure|string $expected, string $file, Parameters $p
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$target = $file;
- $context = new Context($root, $root, $file, $file->getName(), null);
+ $context = new Context($root, $file, $file->getName(), null);
$instance = $this->app()->make(Instruction::class);
if ($expected instanceof Closure) {
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
index 1d32ed248..bf8a14de5 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
@@ -23,7 +23,7 @@ public function testInvokeSameDirectory(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = new Parameters();
- $context = new Context($root, $root, $file, './', '');
+ $context = new Context($root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
$actual = ProcessorHelper::runInstruction($instance, $context, $root, $params);
@@ -42,7 +42,7 @@ public function testInvokeAnotherDirectory(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = new Parameters();
- $context = new Context($root, $root, $file, basename(self::getTestData()->path('/')), '');
+ $context = new Context($root, $file, basename(self::getTestData()->path('/')), '');
$target = $root->getDirectory($context->target);
self::assertNotNull($target);
@@ -65,7 +65,7 @@ public function testInvokeNestedDirectories(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = new Parameters(null);
- $context = new Context($root, $root, $file, './', '');
+ $context = new Context($root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
$actual = ProcessorHelper::runInstruction($instance, $context, $root, $params);
@@ -84,7 +84,7 @@ public function testInvokeWithoutTitle(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = new Parameters();
- $context = new Context($root, $root, $file, './', '');
+ $context = new Context($root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
index 214d824a1..d56133b16 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExample/InstructionTest.php
@@ -26,7 +26,7 @@ public function testInvokeNoRun(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = null;
- $context = new Context($root, $root, $file, $file->getName(), $params);
+ $context = new Context($root, $file, $file->getName(), $params);
$content = self::getTestData()->content('~example.md');
$expected = trim($content);
$factory = $this->override(Factory::class, function (): Factory {
@@ -54,7 +54,7 @@ public function testInvoke(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = null;
- $context = new Context($root, $root, $file, $file->getName(), $params);
+ $context = new Context($root, $file, $file->getName(), $params);
$content = self::getTestData()->content('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim($content);
@@ -97,7 +97,7 @@ public function testInvokeLongOutput(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = null;
- $context = new Context($root, $root, $file, $file->getPath(), $params);
+ $context = new Context($root, $file, $file->getPath(), $params);
$content = self::getTestData()->content('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim($content);
@@ -142,7 +142,7 @@ public function testInvokeMarkdown(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = null;
- $context = new Context($root, $root, $file, $file->getName(), $params);
+ $context = new Context($root, $file, $file->getName(), $params);
$content = self::getTestData()->content('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim($content);
@@ -181,7 +181,7 @@ public function testInvokeMarkdownLongOutput(): void {
$root = new Directory(dirname($path), false);
$file = new File($path, false);
$params = null;
- $context = new Context($root, $root, $file, $file->getPath(), $params);
+ $context = new Context($root, $file, $file->getPath(), $params);
$content = self::getTestData()->content('~runnable.md');
$command = self::getTestData()->path('~runnable.run');
$expected = trim($content);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Instruction.php
index 7ee23dec7..c79a9503c 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Instruction.php
@@ -9,6 +9,7 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetExecFailed;
use Override;
+use function dirname;
use function trim;
/**
@@ -43,7 +44,7 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): st
try {
return trim(
$this->factory->newPendingProcess()
- ->path($context->directory->getPath())
+ ->path(dirname($context->file->getPath()))
->run($target)
->throw()
->output(),
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
index fe2aff9c7..1896101bf 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/InstructionTest.php
@@ -23,7 +23,7 @@ public function testInvoke(): void {
$params = null;
$expected = 'result';
$command = 'command to execute';
- $context = new Context($root, $root, $file, $command, $params);
+ $context = new Context($root, $file, $command, $params);
$factory = $this->override(Factory::class, function () use ($command, $expected): Factory {
$factory = $this->app()->make(Factory::class);
$factory->preventStrayProcesses();
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
index 82f91a62f..7b34de903 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/InstructionTest.php
@@ -47,7 +47,7 @@ public function testInvoke(): void {
$root = Mockery::mock(Directory::class);
$file = Mockery::mock(File::class);
- $context = new Context($root, $root, $file, '@test', null);
+ $context = new Context($root, $file, '@test', null);
$instance = $this->app()->make(Instruction::class);
$actual = ProcessorHelper::runInstruction($instance, $context, $context->target, null);
@@ -67,7 +67,7 @@ public function testInvokeNoPrinter(): void {
$root = new Directory(Path::normalize(__DIR__), false);
$file = new File(Path::normalize(__FILE__), false);
$target = '@test';
- $context = new Context($root, $root, $file, $target, null);
+ $context = new Context($root, $file, $target, null);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -94,7 +94,7 @@ public function testInvokeNoDirective(): void {
$root = new Directory(Path::normalize(__DIR__), false);
$file = new File(Path::normalize(__FILE__), false);
$target = '@test';
- $context = new Context($root, $root, $file, $target, null);
+ $context = new Context($root, $file, $target, null);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -112,7 +112,7 @@ public function testInvokeNoDirectiveResolver(): void {
$root = new Directory(Path::normalize(__DIR__), false);
$file = new File(Path::normalize(__FILE__), false);
$target = '@test';
- $context = new Context($root, $root, $file, $target, null);
+ $context = new Context($root, $file, $target, null);
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index 40c9c796e..0181fe9db 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -30,7 +30,7 @@ public function testInvoke(string $expected, string $template): void {
$file = new File($path, false);
$target = new Directory(Path::join($root->getPath(), 'packages'), false);
$params = new Parameters(template: $template);
- $context = new Context($root, $root, $file, $target->getPath(), '');
+ $context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
$actual = ProcessorHelper::runInstruction($instance, $context, $target, $params);
@@ -50,7 +50,7 @@ public function testInvokeNotAPackage(): void {
$file = new File($path, false);
$target = new Directory(Path::join($root->getPath(), 'invalid'), false);
$params = new Parameters();
- $context = new Context($root, $root, $file, $target->getPath(), '');
+ $context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
$package = $target->getDirectory('package');
@@ -68,7 +68,7 @@ public function testInvokeNoReadme(): void {
$file = new File($path, false);
$target = new Directory(Path::join($root->getPath(), '/no readme'), false);
$params = new Parameters();
- $context = new Context($root, $root, $file, $target->getPath(), '');
+ $context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
$package = $target->getDirectory('package');
@@ -86,7 +86,7 @@ public function testInvokeNoTitle(): void {
$file = new File($path, false);
$target = new Directory(Path::join($root->getPath(), '/no title'), false);
$params = new Parameters();
- $context = new Context($root, $root, $file, $target->getPath(), '');
+ $context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
index f7d2ff309..501f8e43a 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/InstructionTest.php
@@ -27,7 +27,7 @@ public function testInvoke(): void {
'a' => 'Relative',
'b' => 'Inner reference ${a}',
]);
- $context = new Context($root, $root, $file, '/path/to/file.md', '');
+ $context = new Context($root, $file, '/path/to/file.md', '');
$instance = $this->app()->make(Instruction::class);
self::assertEquals(
@@ -46,7 +46,7 @@ public function testInvokeNoData(): void {
$root = new Directory(Path::normalize(__DIR__), false);
$file = new File(Path::normalize(__FILE__), false);
$params = new Parameters([]);
- $context = new Context($root, $root, $file, $file->getPath(), '');
+ $context = new Context($root, $file, $file->getPath(), '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -66,7 +66,7 @@ public function testInvokeVariablesUnused(): void {
'c' => 'C',
'd' => 'D',
]);
- $context = new Context($root, $root, $file, $file->getName(), '');
+ $context = new Context($root, $file, $file->getName(), '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
@@ -83,7 +83,7 @@ public function testInvokeVariablesMissed(): void {
$params = new Parameters([
'a' => 'A',
]);
- $context = new Context($root, $root, $file, $file->getName(), '');
+ $context = new Context($root, $file, $file->getName(), '');
$instance = $this->app()->make(Instruction::class);
self::expectExceptionObject(
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index f46a6c658..7a566e8e0 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -7,7 +7,6 @@
use Exception;
use Generator;
use LastDragon_ru\LaraASP\Core\Application\ContainerResolver;
-use LastDragon_ru\LaraASP\Core\Utils\Cast;
use LastDragon_ru\LaraASP\Documentator\Commands\Preprocess;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PreprocessingFailed;
@@ -223,8 +222,6 @@ protected function parse(Directory $root, File $file): TokenList {
}
// Parse each of them
- $directory = Cast::to(Directory::class, $root->getDirectory($file));
-
foreach ($matches as $match) {
// Instruction?
$name = (string) $match['instruction'];
@@ -253,7 +250,7 @@ protected function parse(Directory $root, File $file): TokenList {
}
// Parse
- $context = new Context($root, $directory, $file, $target, $match['parameters']);
+ $context = new Context($root, $file, $target, $match['parameters']);
$parameters = $parameters
? $this->serializer->deserialize($parameters, $params, 'json')
: null;
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index c701efe9d..aad316c95 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -59,7 +59,6 @@ final class PreprocessorTest extends TestCase {
public function testParse(): void {
$a = new PreprocessorTest__EmptyInstruction();
$b = new PreprocessorTest__TestInstruction();
- $directory = Mockery::mock(Directory::class);
$preprocessor = Mockery::mock(Preprocessor::class, MockProperties::class);
$preprocessor->shouldAllowMockingProtectedMethods();
$preprocessor->makePartial();
@@ -83,13 +82,7 @@ public function testParse(): void {
->once()
->andReturn(self::MARKDOWN);
- $root = Mockery::mock(Directory::class);
- $root
- ->shouldReceive('getDirectory')
- ->with($file)
- ->once()
- ->andReturn($directory);
-
+ $root = Mockery::mock(Directory::class);
$tokens = $preprocessor->parse($root, $file);
self::assertEquals(
@@ -97,7 +90,7 @@ public function testParse(): void {
'88d510d98112f651df2ae08444a402cd8b6516cf4c27ad6115dbb2c03fe9ec62' => new Token(
$a,
new PreprocessorTest__TargetResolverAsIs(),
- new Context($root, $directory, $file, './path/to/file', null),
+ new Context($root, $file, './path/to/file', null),
null,
[
'[test:empty]: ./path/to/file' => '[test:empty]: ./path/to/file',
@@ -106,7 +99,7 @@ public function testParse(): void {
'4a9c0bb168ac831e7b45d8d7a78694c12ee0a3273de7562cdbc47cdb7f64e095' => new Token(
$b,
new PreprocessorTest__TargetResolverAsValue(),
- new Context($root, $directory, $file, './path/to/file', null),
+ new Context($root, $file, './path/to/file', null),
new PreprocessorTest__Parameters(),
[
// phpcs:disable Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned
@@ -133,7 +126,6 @@ public function testParse(): void {
new PreprocessorTest__TargetResolverAsValue(),
new Context(
$root,
- $directory,
$file,
'./path/to/file/parametrized',
'{"a": "aa", "b": {"a": "a", "b": "b"}}',
@@ -184,7 +176,7 @@ static function (string $content) use ($file, &$actual): File {
$root
->shouldReceive('getDirectory')
->with($file)
- ->twice()
+ ->once()
->andReturn($directory);
$result = ProcessorHelper::runTask($preprocessor, $root, $file);
From 7d150ee0e3b04b3e0ae5f84f8ddb57ade2b29de3 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Fri, 24 May 2024 13:38:46 +0400
Subject: [PATCH 21/30] `lara-asp-documentator:preprocess` will show correct
result for skipped files.
---
packages/documentator/src/Commands/Preprocess.php | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/packages/documentator/src/Commands/Preprocess.php b/packages/documentator/src/Commands/Preprocess.php
index 2d24c0862..19990d065 100644
--- a/packages/documentator/src/Commands/Preprocess.php
+++ b/packages/documentator/src/Commands/Preprocess.php
@@ -79,14 +79,19 @@ public function __invoke(Formatter $formatter): void {
(new Processor())
->task($this->preprocessor)
- ->run($path, function (string $path, bool $success, float $duration) use ($formatter, $width): void {
+ ->run($path, function (string $path, ?bool $success, float $duration) use ($formatter, $width): void {
+ [$resultMessage, $resultColor] = match (true) {
+ $success === false => ['FAIL', 'red'],
+ $success === true => ['DONE', 'green'],
+ default => ['SKIP', 'gray'],
+ };
+
$duration = $formatter->duration($duration);
- $result = $success ? 'DONE' : 'FAIL';
- $length = $width - (mb_strlen($path) + mb_strlen($duration) + mb_strlen($result) + 5);
+ $length = $width - (mb_strlen($path) + mb_strlen($duration) + mb_strlen($resultMessage) + 5);
$line = $path
.' '.($length > 0 ? ''.str_repeat('.', $length).'>' : '')
.' '."{$duration}>"
- .' '.($success ? "{$result}>" : "{$result}>");
+ .' '."{$resultMessage}>";
$this->output->writeln($line);
});
From 8e73f033e3c6727c5113ec8ef651d24ce1d8c210 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Fri, 24 May 2024 14:54:06 +0400
Subject: [PATCH 22/30] Code cleanup.
---
.../IncludeDocumentList/Instruction.php | 4 +---
.../IncludePackageList/Instruction.php | 14 ++++++--------
.../IncludePackageList/InstructionTest.php | 8 ++++----
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
index 14866cc44..8b2dcd4f1 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
@@ -3,7 +3,6 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeDocumentList;
use Generator;
-use LastDragon_ru\LaraASP\Core\Utils\Cast;
use LastDragon_ru\LaraASP\Documentator\PackageViewer;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
@@ -56,7 +55,6 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
$documents = [];
$files = $target->getFilesIterator('*.md', $parameters->depth);
$self = $context->file->getPath();
- $dir = Cast::to(Directory::class, $context->root->getDirectory($context->file));
foreach ($files as $file) {
// Same?
@@ -74,7 +72,7 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
// Extract
$docTitle = Markdown::getTitle($content);
- $docPath = $file->getRelativePath($dir);
+ $docPath = $file->getRelativePath($context->file);
if ($docTitle) {
$documents[] = [
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
index 64b39cf1e..3136217ab 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
@@ -5,7 +5,6 @@
use Exception;
use Generator;
use LastDragon_ru\LaraASP\Core\Utils\Cast;
-use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\PackageViewer;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
@@ -63,11 +62,10 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
/** @var list $packages */
$packages = [];
$directories = $target->getDirectoriesIterator(null, 0);
- $dir = Cast::to(Directory::class, $context->root->getDirectory($context->file));
foreach ($directories as $package) {
// Package?
- $packageFile = yield Path::join($package->getPath(), 'composer.json');
+ $packageFile = yield $package->getPath('composer.json');
$packageInfo = $this->getPackageInfo($packageFile);
if (!$packageFile || !$packageInfo) {
@@ -75,7 +73,7 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
}
// Readme
- $readme = yield Path::join($package->getPath(), Cast::toString($packageInfo['readme'] ?: 'README.md'));
+ $readme = yield $package->getPath(Cast::toString($packageInfo['readme'] ?: 'README.md'));
$content = $readme?->getContent();
if (!$readme || !$content) {
@@ -86,15 +84,15 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
$packageTitle = Markdown::getTitle($content);
if ($packageTitle) {
- $upgrade = yield Path::join($package->getPath(), 'UPGRADE.md');
+ $upgrade = yield $package->getPath('UPGRADE.md');
$packages[] = [
- 'path' => $readme->getRelativePath($dir),
+ 'path' => $readme->getRelativePath($context->file),
'title' => $packageTitle,
'summary' => Markdown::getSummary($content),
- 'upgrade' => $upgrade?->getRelativePath($dir),
+ 'upgrade' => $upgrade?->getRelativePath($context->file),
];
} else {
- throw new DocumentTitleIsMissing($context, $readme->getRelativePath($dir));
+ throw new DocumentTitleIsMissing($context, $readme->getRelativePath($context->file));
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index 0181fe9db..264f11f10 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -28,7 +28,7 @@ public function testInvoke(string $expected, string $template): void {
$path = Path::normalize(self::getTestData()->path('Document.md'));
$root = new Directory(dirname($path), false);
$file = new File($path, false);
- $target = new Directory(Path::join($root->getPath(), 'packages'), false);
+ $target = new Directory($root->getPath('packages'), false);
$params = new Parameters(template: $template);
$context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
@@ -48,7 +48,7 @@ public function testInvokeNotAPackage(): void {
$path = Path::normalize(self::getTestData()->path('Document.md'));
$root = new Directory(dirname($path), false);
$file = new File($path, false);
- $target = new Directory(Path::join($root->getPath(), 'invalid'), false);
+ $target = new Directory($root->getPath('invalid'), false);
$params = new Parameters();
$context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
@@ -66,7 +66,7 @@ public function testInvokeNoReadme(): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
- $target = new Directory(Path::join($root->getPath(), '/no readme'), false);
+ $target = new Directory($root->getPath('no readme'), false);
$params = new Parameters();
$context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
@@ -84,7 +84,7 @@ public function testInvokeNoTitle(): void {
$path = self::getTestData()->path('Document.md');
$root = new Directory(dirname($path), false);
$file = new File($path, false);
- $target = new Directory(Path::join($root->getPath(), '/no title'), false);
+ $target = new Directory($root->getPath('no title'), false);
$params = new Parameters();
$context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
From 1e395fce6c7eaa2c46096a6b4d7e4fb888afa285 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Fri, 24 May 2024 18:34:46 +0400
Subject: [PATCH 23/30] `DocumentTitleIsMissing` excepts `File` instead of
`string`.
---
.../Exceptions/DocumentTitleIsMissing.php | 7 +++---
.../IncludeDocumentList/Instruction.php | 22 +++++++++---------
.../IncludeDocumentList/InstructionTest.php | 4 +++-
.../IncludePackageList/Instruction.php | 23 ++++++++++---------
.../IncludePackageList/InstructionTest.php | 4 +++-
5 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/packages/documentator/src/Preprocessor/Exceptions/DocumentTitleIsMissing.php b/packages/documentator/src/Preprocessor/Exceptions/DocumentTitleIsMissing.php
index 27ab07111..1ac1cd054 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/DocumentTitleIsMissing.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/DocumentTitleIsMissing.php
@@ -3,6 +3,7 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
+use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use Throwable;
use function sprintf;
@@ -10,21 +11,21 @@
class DocumentTitleIsMissing extends InstructionFailed {
public function __construct(
Context $context,
- private readonly string $document,
+ private readonly File $document,
Throwable $previous = null,
) {
parent::__construct(
$context,
sprintf(
"The `%s` doesn't contain `# Header` (in `%s`).",
- $this->document,
+ $this->document->getRelativePath($context->file),
$context->file->getRelativePath($context->root),
),
$previous,
);
}
- public function getDocument(): string {
+ public function getDocument(): File {
return $this->document;
}
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
index 8b2dcd4f1..6bb88536e 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
@@ -70,19 +70,19 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
continue;
}
- // Extract
+ // Title?
$docTitle = Markdown::getTitle($content);
- $docPath = $file->getRelativePath($context->file);
-
- if ($docTitle) {
- $documents[] = [
- 'path' => $docPath,
- 'title' => $docTitle,
- 'summary' => Markdown::getSummary($content),
- ];
- } else {
- throw new DocumentTitleIsMissing($context, $docPath);
+
+ if (!$docTitle) {
+ throw new DocumentTitleIsMissing($context, $file);
}
+
+ // Add
+ $documents[] = [
+ 'path' => $file->getRelativePath($context->file),
+ 'title' => $docTitle,
+ 'summary' => Markdown::getSummary($content),
+ ];
}
// Empty?
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
index bf8a14de5..dc7e6b288 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/InstructionTest.php
@@ -86,9 +86,11 @@ public function testInvokeWithoutTitle(): void {
$params = new Parameters();
$context = new Context($root, $file, './', '');
$instance = $this->app()->make(Instruction::class);
+ $expected = $root->getFile('WithoutTitle.md');
+ self::assertNotNull($expected);
self::expectExceptionObject(
- new DocumentTitleIsMissing($context, 'WithoutTitle.md'),
+ new DocumentTitleIsMissing($context, $expected),
);
ProcessorHelper::runInstruction($instance, $context, $root, $params);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
index 3136217ab..74b5cf254 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
@@ -80,20 +80,21 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
throw new PackageReadmeIsMissing($context, $package);
}
- // Extract
+ // Title?
$packageTitle = Markdown::getTitle($content);
- if ($packageTitle) {
- $upgrade = yield $package->getPath('UPGRADE.md');
- $packages[] = [
- 'path' => $readme->getRelativePath($context->file),
- 'title' => $packageTitle,
- 'summary' => Markdown::getSummary($content),
- 'upgrade' => $upgrade?->getRelativePath($context->file),
- ];
- } else {
- throw new DocumentTitleIsMissing($context, $readme->getRelativePath($context->file));
+ if (!$packageTitle) {
+ throw new DocumentTitleIsMissing($context, $readme);
}
+
+ // Add
+ $upgrade = yield $package->getPath('UPGRADE.md');
+ $packages[] = [
+ 'path' => $readme->getRelativePath($context->file),
+ 'title' => $packageTitle,
+ 'summary' => Markdown::getSummary($content),
+ 'upgrade' => $upgrade?->getRelativePath($context->file),
+ ];
}
// Packages?
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index 264f11f10..c6bf07a6a 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -88,9 +88,11 @@ public function testInvokeNoTitle(): void {
$params = new Parameters();
$context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
+ $expected = $root->getFile('no title/package/README.md');
+ self::assertNotNull($expected);
self::expectExceptionObject(
- new DocumentTitleIsMissing($context, 'no title/package/README.md'),
+ new DocumentTitleIsMissing($context, $expected),
);
ProcessorHelper::runInstruction($instance, $context, $target, $params);
From eb4fbe212cf17304071e8271cc0341d3363a00ff Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Sat, 25 May 2024 10:04:58 +0400
Subject: [PATCH 24/30] `ProcessorHelpers` fixes.
---
.../src/Testing/Package/ProcessorHelper.php | 57 +++++++++++++------
1 file changed, 40 insertions(+), 17 deletions(-)
diff --git a/packages/documentator/src/Testing/Package/ProcessorHelper.php b/packages/documentator/src/Testing/Package/ProcessorHelper.php
index 4874996d0..e64024c1b 100644
--- a/packages/documentator/src/Testing/Package/ProcessorHelper.php
+++ b/packages/documentator/src/Testing/Package/ProcessorHelper.php
@@ -3,11 +3,17 @@
namespace LastDragon_ru\LaraASP\Documentator\Testing\Package;
use Generator;
+use LastDragon_ru\LaraASP\Core\Utils\Cast;
+use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Task;
+use LastDragon_ru\LaraASP\Documentator\Processor\Exceptions\FileDependencyNotFound;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
+use SplFileInfo;
+
+use function dirname;
/**
* @internal
@@ -15,16 +21,9 @@
class ProcessorHelper {
public static function runTask(Task $task, Directory $root, File $file): mixed {
$result = ($task)($root, $file);
-
- if ($result instanceof Generator) {
- $directory = $root->getDirectory($file);
-
- while ($result->valid()) {
- $result->send($directory?->getFile($result->current()));
- }
-
- $result = $result->getReturn();
- }
+ $result = $result instanceof Generator
+ ? self::getResult($root, $file, $result)
+ : $result;
return $result;
}
@@ -44,17 +43,41 @@ public static function runInstruction(
mixed $parameters,
): string {
$result = ($instruction)($context, $target, $parameters);
+ $result = $result instanceof Generator
+ ? Cast::toString(self::getResult($context->root, $context->file, $result))
+ : $result;
+
+ return $result;
+ }
- if ($result instanceof Generator) {
- $directory = $context->root->getDirectory($context->file);
+ /**
+ * @param Generator $generator
+ */
+ protected static function getResult(Directory $root, File $file, Generator $generator): mixed {
+ while ($generator->valid()) {
+ $generator->send(self::getFile($root, $file, $generator));
+ }
+
+ return $generator->getReturn();
+ }
- while ($result->valid()) {
- $result->send($directory?->getFile($result->current()));
- }
+ /**
+ * @param Generator $generator
+ */
+ protected static function getFile(Directory $root, File $file, Generator $generator): File {
+ $path = $generator->current();
+ $path = match (true) {
+ $path instanceof SplFileInfo => $path->getPathname(),
+ $path instanceof File => $path->getPath(),
+ default => $path,
+ };
+ $directory = dirname($file->getPath());
+ $dependency = $root->getFile(Path::getPath($directory, $path));
- $result = $result->getReturn();
+ if (!$dependency) {
+ throw new FileDependencyNotFound($root, $file, $path);
}
- return $result;
+ return $dependency;
}
}
From 485168a38a488bfa8c08d342e840e46bab871678 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Sat, 25 May 2024 10:05:46 +0400
Subject: [PATCH 25/30] Resolved dependency cannot be `null` (update).
---
.../Preprocessor/Contracts/Instruction.php | 2 +-
.../src/Preprocessor/Contracts/Resolver.php | 4 +--
...IsMissing.php => PackageReadmeIsEmpty.php} | 4 +--
.../Exceptions/TargetIsNotFile.php | 22 ----------------
.../IncludeDocumentList/Instruction.php | 6 ++---
.../IncludePackageList/Instruction.php | 25 +++++++++++--------
.../IncludePackageList/InstructionTest.php | 23 +++++++++++++++--
.../empty readme/package/README.md | 0
.../empty readme/package/composer.json | 5 ++++
.../invalid/package/composer.json | 1 +
.../src/Preprocessor/Preprocessor.php | 2 +-
.../src/Preprocessor/PreprocessorTest.php | 9 +------
.../Preprocessor/Resolvers/FileResolver.php | 11 ++------
13 files changed, 54 insertions(+), 60 deletions(-)
rename packages/documentator/src/Preprocessor/Exceptions/{PackageReadmeIsMissing.php => PackageReadmeIsEmpty.php} (85%)
delete mode 100644 packages/documentator/src/Preprocessor/Exceptions/TargetIsNotFile.php
create mode 100644 packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/empty readme/package/README.md
create mode 100644 packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/empty readme/package/composer.json
create mode 100644 packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/invalid/package/composer.json
diff --git a/packages/documentator/src/Preprocessor/Contracts/Instruction.php b/packages/documentator/src/Preprocessor/Contracts/Instruction.php
index 917a268eb..d226efdc6 100644
--- a/packages/documentator/src/Preprocessor/Contracts/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Contracts/Instruction.php
@@ -34,7 +34,7 @@ public static function getParameters(): ?string;
* @param TTarget $target
* @param TParameters $parameters
*
- * @return Generator|string
+ * @return Generator|string
*/
public function __invoke(Context $context, mixed $target, mixed $parameters): Generator|string;
}
diff --git a/packages/documentator/src/Preprocessor/Contracts/Resolver.php b/packages/documentator/src/Preprocessor/Contracts/Resolver.php
index aeb99b0c4..4cd7f8409 100644
--- a/packages/documentator/src/Preprocessor/Contracts/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Contracts/Resolver.php
@@ -8,7 +8,7 @@
use SplFileInfo;
/**
- * @template TParameters
+ * @template TParameters of object|null
* @template TValue
*/
interface Resolver {
@@ -19,7 +19,7 @@ interface Resolver {
*
* @param TParameters $parameters
*
- * @return Generator|TValue
+ * @return Generator|TValue
*/
public function __invoke(Context $context, mixed $parameters): mixed;
}
diff --git a/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php b/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsEmpty.php
similarity index 85%
rename from packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php
rename to packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsEmpty.php
index 59d2c68f1..1b5db245f 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsMissing.php
+++ b/packages/documentator/src/Preprocessor/Exceptions/PackageReadmeIsEmpty.php
@@ -8,7 +8,7 @@
use function sprintf;
-class PackageReadmeIsMissing extends InstructionFailed {
+class PackageReadmeIsEmpty extends InstructionFailed {
public function __construct(
Context $context,
private readonly Directory $package,
@@ -17,7 +17,7 @@ public function __construct(
parent::__construct(
$context,
sprintf(
- "The package `%s` doesn't contain readme (in `%s`).",
+ 'The package `%s` readme is empty or not readable (in `%s`).',
$this->package->getRelativePath($context->root),
$context->file->getRelativePath($context->root),
),
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotFile.php b/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotFile.php
deleted file mode 100644
index f633721b1..000000000
--- a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotFile.php
+++ /dev/null
@@ -1,22 +0,0 @@
-target,
- $context->file->getRelativePath($context->root),
- ),
- $previous,
- );
- }
-}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
index 6bb88536e..85276fd5b 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocumentList/Instruction.php
@@ -47,7 +47,7 @@ public static function getParameters(): ?string {
}
/**
- * @return Generator
+ * @return Generator
*/
#[Override]
public function __invoke(Context $context, mixed $target, mixed $parameters): Generator {
@@ -64,9 +64,9 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
// Content?
$file = yield $file;
- $content = $file?->getContent();
+ $content = $file->getContent();
- if (!$file || !$content) {
+ if (!$content) {
continue;
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
index 74b5cf254..18b50b7d6 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
@@ -5,12 +5,13 @@
use Exception;
use Generator;
use LastDragon_ru\LaraASP\Core\Utils\Cast;
+use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\PackageViewer;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageComposerJsonIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsMissing;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsEmpty;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Resolvers\DirectoryResolver;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
@@ -20,6 +21,7 @@
use function assert;
use function is_array;
+use function is_file;
use function json_decode;
use function strcmp;
use function usort;
@@ -55,7 +57,7 @@ public static function getParameters(): ?string {
}
/**
- * @return Generator
+ * @return Generator
*/
#[Override]
public function __invoke(Context $context, mixed $target, mixed $parameters): Generator {
@@ -68,16 +70,16 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
$packageFile = yield $package->getPath('composer.json');
$packageInfo = $this->getPackageInfo($packageFile);
- if (!$packageFile || !$packageInfo) {
+ if (!$packageInfo) {
throw new PackageComposerJsonIsMissing($context, $package);
}
// Readme
$readme = yield $package->getPath(Cast::toString($packageInfo['readme'] ?: 'README.md'));
- $content = $readme?->getContent();
+ $content = $readme->getContent();
- if (!$readme || !$content) {
- throw new PackageReadmeIsMissing($context, $package);
+ if (!$content) {
+ throw new PackageReadmeIsEmpty($context, $package);
}
// Title?
@@ -88,12 +90,15 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
}
// Add
- $upgrade = yield $package->getPath('UPGRADE.md');
+ $upgrade = $package->getPath('UPGRADE.md');
+ $upgrade = is_file($upgrade)
+ ? Path::getRelativePath($context->file->getPath(), $upgrade)
+ : null;
$packages[] = [
'path' => $readme->getRelativePath($context->file),
'title' => $packageTitle,
'summary' => Markdown::getSummary($content),
- 'upgrade' => $upgrade?->getRelativePath($context->file),
+ 'upgrade' => $upgrade,
];
}
@@ -120,9 +125,9 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
/**
* @return array|null
*/
- protected function getPackageInfo(?File $file): ?array {
+ protected function getPackageInfo(File $file): ?array {
try {
- $package = $file?->getContent();
+ $package = $file->getContent();
$package = $package
? json_decode($package, true, flags: JSON_THROW_ON_ERROR)
: null;
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index c6bf07a6a..3799ff1d5 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -6,7 +6,8 @@
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageComposerJsonIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsMissing;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsEmpty;
+use LastDragon_ru\LaraASP\Documentator\Processor\Exceptions\FileDependencyNotFound;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
@@ -74,7 +75,25 @@ public function testInvokeNoReadme(): void {
self::assertNotNull($package);
self::expectExceptionObject(
- new PackageReadmeIsMissing($context, $package),
+ new FileDependencyNotFound($context->root, $context->file, 'no readme/package/README.md'),
+ );
+
+ ProcessorHelper::runInstruction($instance, $context, $target, $params);
+ }
+
+ public function testInvokeEmptyReadme(): void {
+ $path = self::getTestData()->path('Document.md');
+ $root = new Directory(dirname($path), false);
+ $file = new File($path, false);
+ $target = new Directory($root->getPath('empty readme'), false);
+ $params = new Parameters();
+ $context = new Context($root, $file, $target->getPath(), '');
+ $instance = $this->app()->make(Instruction::class);
+ $package = $target->getDirectory('package');
+
+ self::assertNotNull($package);
+ self::expectExceptionObject(
+ new PackageReadmeIsEmpty($context, $package),
);
ProcessorHelper::runInstruction($instance, $context, $target, $params);
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/empty readme/package/README.md b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/empty readme/package/README.md
new file mode 100644
index 000000000..e69de29bb
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/empty readme/package/composer.json b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/empty readme/package/composer.json
new file mode 100644
index 000000000..0a9113a4a
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/empty readme/package/composer.json
@@ -0,0 +1,5 @@
+{
+ "name": "lastdragon-ru/lara-asp-documentator",
+ "homepage": "https://github.com/LastDragon-ru/lara-asp",
+ "readme": "README.md"
+}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/invalid/package/composer.json b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/invalid/package/composer.json
new file mode 100644
index 000000000..609bdea41
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest/invalid/package/composer.json
@@ -0,0 +1 @@
+broken json
diff --git a/packages/documentator/src/Preprocessor/Preprocessor.php b/packages/documentator/src/Preprocessor/Preprocessor.php
index 7a566e8e0..54dcdeff2 100644
--- a/packages/documentator/src/Preprocessor/Preprocessor.php
+++ b/packages/documentator/src/Preprocessor/Preprocessor.php
@@ -139,7 +139,7 @@ public function getExtensions(): array {
}
/**
- * @return Generator
+ * @return Generator
*/
#[Override]
public function __invoke(Directory $root, File $file): Generator {
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index aad316c95..2fbe57355 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -171,14 +171,7 @@ static function (string $content) use ($file, &$actual): File {
},
);
- $directory = Mockery::mock(Directory::class);
- $root = Mockery::mock(Directory::class);
- $root
- ->shouldReceive('getDirectory')
- ->with($file)
- ->once()
- ->andReturn($directory);
-
+ $root = Mockery::mock(Directory::class);
$result = ProcessorHelper::runTask($preprocessor, $root, $file);
self::assertTrue($result);
diff --git a/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php b/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
index d7c652fed..088756f1f 100644
--- a/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
+++ b/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
@@ -5,7 +5,6 @@
use Generator;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Resolver;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\TargetIsNotFile;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
use Override;
use SplFileInfo;
@@ -17,16 +16,10 @@
*/
class FileResolver implements Resolver {
/**
- * @return Generator
+ * @return Generator
*/
#[Override]
public function __invoke(Context $context, mixed $parameters): Generator {
- $file = yield $context->target;
-
- if (!($file instanceof File)) {
- throw new TargetIsNotFile($context);
- }
-
- return $file;
+ return yield $context->target;
}
}
From fe8c5a9cdcf18b653d1dd3b4e11aed40315418f6 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Sat, 25 May 2024 12:01:11 +0400
Subject: [PATCH 26/30] `Processor` call fix.
---
packages/documentator/src/Commands/Preprocess.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/documentator/src/Commands/Preprocess.php b/packages/documentator/src/Commands/Preprocess.php
index 19990d065..c4a5d4216 100644
--- a/packages/documentator/src/Commands/Preprocess.php
+++ b/packages/documentator/src/Commands/Preprocess.php
@@ -79,7 +79,7 @@ public function __invoke(Formatter $formatter): void {
(new Processor())
->task($this->preprocessor)
- ->run($path, function (string $path, ?bool $success, float $duration) use ($formatter, $width): void {
+ ->run($path, null, function (string $path, ?bool $success, float $duration) use ($formatter, $width): void {
[$resultMessage, $resultColor] = match (true) {
$success === false => ['FAIL', 'red'],
$success === true => ['DONE', 'green'],
From b92ea737463c72799a2b0f8c9ac57b88b1004062 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Sun, 26 May 2024 09:26:03 +0400
Subject: [PATCH 27/30] Exceptions moved to related Instruction.
---
.../Exceptions/TargetIsNotValidPhpFile.php | 3 +-
.../IncludeDocBlock/Instruction.php | 2 +-
.../IncludeDocBlock/InstructionTest.php | 2 +-
.../Exceptions/DocumentTitleIsMissing.php | 3 +-
.../IncludeDocumentList/Instruction.php | 2 +-
.../IncludeDocumentList/InstructionTest.php | 2 +-
.../Exceptions/TargetIsNotDirective.php | 3 +-
.../IncludeGraphqlDirective/Instruction.php | 4 +-
.../InstructionTest.php | 4 +-
.../PackageComposerJsonIsMissing.php | 3 +-
.../Exceptions/PackageReadmeIsEmpty.php | 12 +++++-
.../PackageReadmeTitleIsMissing.php | 39 +++++++++++++++++++
.../IncludePackageList/Instruction.php | 12 +++---
.../IncludePackageList/InstructionTest.php | 16 +++++---
.../Exceptions/TemplateDataMissed.php | 3 +-
.../Exceptions/TemplateVariablesMissed.php | 3 +-
.../Exceptions/TemplateVariablesUnused.php | 3 +-
.../IncludeTemplate/Instruction.php | 6 +--
.../IncludeTemplate/InstructionTest.php | 6 +--
19 files changed, 97 insertions(+), 31 deletions(-)
rename packages/documentator/src/Preprocessor/{ => Instructions/IncludeDocBlock}/Exceptions/TargetIsNotValidPhpFile.php (75%)
rename packages/documentator/src/Preprocessor/{ => Instructions/IncludeDocumentList}/Exceptions/DocumentTitleIsMissing.php (81%)
rename packages/documentator/src/Preprocessor/{ => Instructions/IncludeGraphqlDirective}/Exceptions/TargetIsNotDirective.php (74%)
rename packages/documentator/src/Preprocessor/{ => Instructions/IncludePackageList}/Exceptions/PackageComposerJsonIsMissing.php (82%)
rename packages/documentator/src/Preprocessor/{ => Instructions/IncludePackageList}/Exceptions/PackageReadmeIsEmpty.php (59%)
create mode 100644 packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Exceptions/PackageReadmeTitleIsMissing.php
rename packages/documentator/src/Preprocessor/{ => Instructions/IncludeTemplate}/Exceptions/TemplateDataMissed.php (73%)
rename packages/documentator/src/Preprocessor/{ => Instructions/IncludeTemplate}/Exceptions/TemplateVariablesMissed.php (82%)
rename packages/documentator/src/Preprocessor/{ => Instructions/IncludeTemplate}/Exceptions/TemplateVariablesUnused.php (82%)
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotValidPhpFile.php b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php
similarity index 75%
rename from packages/documentator/src/Preprocessor/Exceptions/TargetIsNotValidPhpFile.php
rename to packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php
index c25f6c4a6..113094a36 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TargetIsNotValidPhpFile.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php
@@ -1,8 +1,9 @@
package->getRelativePath($context->root),
+ $this->readme->getRelativePath($context->root),
$context->file->getRelativePath($context->root),
),
$previous,
@@ -28,4 +32,8 @@ public function __construct(
public function getPackage(): Directory {
return $this->package;
}
+
+ public function getReadme(): File {
+ return $this->readme;
+ }
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Exceptions/PackageReadmeTitleIsMissing.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Exceptions/PackageReadmeTitleIsMissing.php
new file mode 100644
index 000000000..5ef43308e
--- /dev/null
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Exceptions/PackageReadmeTitleIsMissing.php
@@ -0,0 +1,39 @@
+package->getRelativePath($context->root),
+ $this->readme->getRelativePath($context->root),
+ $context->file->getRelativePath($context->root),
+ ),
+ $previous,
+ );
+ }
+
+ public function getPackage(): Directory {
+ return $this->package;
+ }
+
+ public function getReadme(): File {
+ return $this->readme;
+ }
+}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
index 18b50b7d6..c0b87d4ec 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/Instruction.php
@@ -2,6 +2,8 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList;
+// @phpcs:disable Generic.Files.LineLength.TooLong
+
use Exception;
use Generator;
use LastDragon_ru\LaraASP\Core\Utils\Cast;
@@ -9,9 +11,9 @@
use LastDragon_ru\LaraASP\Documentator\PackageViewer;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageComposerJsonIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsEmpty;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList\Exceptions\PackageComposerJsonIsMissing;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList\Exceptions\PackageReadmeIsEmpty;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList\Exceptions\PackageReadmeTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Resolvers\DirectoryResolver;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
@@ -79,14 +81,14 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): Ge
$content = $readme->getContent();
if (!$content) {
- throw new PackageReadmeIsEmpty($context, $package);
+ throw new PackageReadmeIsEmpty($context, $package, $readme);
}
// Title?
$packageTitle = Markdown::getTitle($content);
if (!$packageTitle) {
- throw new DocumentTitleIsMissing($context, $readme);
+ throw new PackageReadmeTitleIsMissing($context, $package, $readme);
}
// Add
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
index 3799ff1d5..bb452de3d 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludePackageList/InstructionTest.php
@@ -2,11 +2,13 @@
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList;
+// @phpcs:disable Generic.Files.LineLength.TooLong
+
use LastDragon_ru\LaraASP\Core\Utils\Path;
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\DocumentTitleIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageComposerJsonIsMissing;
-use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\PackageReadmeIsEmpty;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList\Exceptions\PackageComposerJsonIsMissing;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList\Exceptions\PackageReadmeIsEmpty;
+use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludePackageList\Exceptions\PackageReadmeTitleIsMissing;
use LastDragon_ru\LaraASP\Documentator\Processor\Exceptions\FileDependencyNotFound;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
@@ -90,10 +92,12 @@ public function testInvokeEmptyReadme(): void {
$context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
$package = $target->getDirectory('package');
+ $expected = $root->getFile('empty readme/package/README.md');
self::assertNotNull($package);
+ self::assertNotNull($expected);
self::expectExceptionObject(
- new PackageReadmeIsEmpty($context, $package),
+ new PackageReadmeIsEmpty($context, $package, $expected),
);
ProcessorHelper::runInstruction($instance, $context, $target, $params);
@@ -107,11 +111,13 @@ public function testInvokeNoTitle(): void {
$params = new Parameters();
$context = new Context($root, $file, $target->getPath(), '');
$instance = $this->app()->make(Instruction::class);
+ $package = $target->getDirectory('package');
$expected = $root->getFile('no title/package/README.md');
+ self::assertNotNull($package);
self::assertNotNull($expected);
self::expectExceptionObject(
- new DocumentTitleIsMissing($context, $expected),
+ new PackageReadmeTitleIsMissing($context, $package, $expected),
);
ProcessorHelper::runInstruction($instance, $context, $target, $params);
diff --git a/packages/documentator/src/Preprocessor/Exceptions/TemplateDataMissed.php b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Exceptions/TemplateDataMissed.php
similarity index 73%
rename from packages/documentator/src/Preprocessor/Exceptions/TemplateDataMissed.php
rename to packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Exceptions/TemplateDataMissed.php
index 53ce49a37..7073c8b4c 100644
--- a/packages/documentator/src/Preprocessor/Exceptions/TemplateDataMissed.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeTemplate/Exceptions/TemplateDataMissed.php
@@ -1,8 +1,9 @@
Date: Sun, 26 May 2024 10:19:53 +0400
Subject: [PATCH 28/30] Generics parameters normalization.
---
packages/documentator/src/Commands/PreprocessTest.php | 2 +-
.../documentator/src/Preprocessor/Contracts/Instruction.php | 2 +-
packages/documentator/src/Preprocessor/Contracts/Resolver.php | 4 ++--
.../src/Preprocessor/Instructions/IncludeExec/Resolver.php | 2 +-
.../Instructions/IncludeGraphqlDirective/Resolver.php | 2 +-
packages/documentator/src/Preprocessor/PreprocessorTest.php | 4 ++--
.../documentator/src/Preprocessor/ResolvedInstruction.php | 4 ++--
.../src/Preprocessor/Resolvers/DirectoryResolver.php | 2 +-
.../documentator/src/Preprocessor/Resolvers/FileResolver.php | 2 +-
packages/documentator/src/Preprocessor/Token.php | 2 +-
10 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/packages/documentator/src/Commands/PreprocessTest.php b/packages/documentator/src/Commands/PreprocessTest.php
index 318b820ee..69978b9cf 100644
--- a/packages/documentator/src/Commands/PreprocessTest.php
+++ b/packages/documentator/src/Commands/PreprocessTest.php
@@ -266,7 +266,7 @@ public function __invoke(Context $context, mixed $target, mixed $parameters): st
* @internal
* @noinspection PhpMultipleClassesDeclarationsInOneFile
*
- * @implements Resolver
+ * @implements Resolver
*/
class PreprocessTest__Target implements Resolver {
#[Override]
diff --git a/packages/documentator/src/Preprocessor/Contracts/Instruction.php b/packages/documentator/src/Preprocessor/Contracts/Instruction.php
index d226efdc6..2510c1856 100644
--- a/packages/documentator/src/Preprocessor/Contracts/Instruction.php
+++ b/packages/documentator/src/Preprocessor/Contracts/Instruction.php
@@ -15,7 +15,7 @@ interface Instruction {
public static function getName(): string;
/**
- * @return class-string|Resolver>
+ * @return class-string|Resolver>
*/
public static function getResolver(): string;
diff --git a/packages/documentator/src/Preprocessor/Contracts/Resolver.php b/packages/documentator/src/Preprocessor/Contracts/Resolver.php
index 4cd7f8409..273d532be 100644
--- a/packages/documentator/src/Preprocessor/Contracts/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Contracts/Resolver.php
@@ -8,8 +8,8 @@
use SplFileInfo;
/**
+ * @template TTarget
* @template TParameters of object|null
- * @template TValue
*/
interface Resolver {
/**
@@ -19,7 +19,7 @@ interface Resolver {
*
* @param TParameters $parameters
*
- * @return Generator|TValue
+ * @return Generator|TTarget
*/
public function __invoke(Context $context, mixed $parameters): mixed;
}
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
index 0cdbd6da3..a2b2ab08d 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeExec/Resolver.php
@@ -9,7 +9,7 @@
/**
* Path to the executable.
*
- * @implements ResolverContract
+ * @implements ResolverContract
*/
class Resolver implements ResolverContract {
public function __construct() {
diff --git a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
index 90a533784..c8ab05a54 100644
--- a/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
+++ b/packages/documentator/src/Preprocessor/Instructions/IncludeGraphqlDirective/Resolver.php
@@ -9,7 +9,7 @@
/**
* Directive name (started with `@` sign)
*
- * @implements ResolverContract
+ * @implements ResolverContract
*/
class Resolver implements ResolverContract {
public function __construct() {
diff --git a/packages/documentator/src/Preprocessor/PreprocessorTest.php b/packages/documentator/src/Preprocessor/PreprocessorTest.php
index 2fbe57355..0869f97f9 100644
--- a/packages/documentator/src/Preprocessor/PreprocessorTest.php
+++ b/packages/documentator/src/Preprocessor/PreprocessorTest.php
@@ -315,7 +315,7 @@ public function __construct(
* @internal
* @noinspection PhpMultipleClassesDeclarationsInOneFile
*
- * @implements Resolver
+ * @implements Resolver
*/
class PreprocessorTest__TargetResolverAsIs implements Resolver {
#[Override]
@@ -328,7 +328,7 @@ public function __invoke(Context $context, mixed $parameters): mixed {
* @internal
* @noinspection PhpMultipleClassesDeclarationsInOneFile
*
- * @implements Resolver
+ * @implements Resolver
*/
class PreprocessorTest__TargetResolverAsValue implements Resolver {
#[Override]
diff --git a/packages/documentator/src/Preprocessor/ResolvedInstruction.php b/packages/documentator/src/Preprocessor/ResolvedInstruction.php
index 81df21fa8..acbb6e5b1 100644
--- a/packages/documentator/src/Preprocessor/ResolvedInstruction.php
+++ b/packages/documentator/src/Preprocessor/ResolvedInstruction.php
@@ -20,7 +20,7 @@ class ResolvedInstruction {
*/
private readonly string $class;
/**
- * @var Resolver|Resolver|null
+ * @var Resolver|Resolver|null
*/
private ?Resolver $resolver = null;
/**
@@ -53,7 +53,7 @@ public function getInstance(): Instruction {
}
/**
- * @return Resolver|Resolver
+ * @return Resolver|Resolver
*/
public function getResolver(): Resolver {
$this->resolver ??= $this->container->getInstance()->make($this->class::getResolver());
diff --git a/packages/documentator/src/Preprocessor/Resolvers/DirectoryResolver.php b/packages/documentator/src/Preprocessor/Resolvers/DirectoryResolver.php
index 285345039..2de4821c3 100644
--- a/packages/documentator/src/Preprocessor/Resolvers/DirectoryResolver.php
+++ b/packages/documentator/src/Preprocessor/Resolvers/DirectoryResolver.php
@@ -11,7 +11,7 @@
/**
* Directory path.
*
- * @implements Resolver
+ * @implements Resolver
*/
class DirectoryResolver implements Resolver {
#[Override]
diff --git a/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php b/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
index 088756f1f..82328d065 100644
--- a/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
+++ b/packages/documentator/src/Preprocessor/Resolvers/FileResolver.php
@@ -12,7 +12,7 @@
/**
* File path.
*
- * @implements Resolver
+ * @implements Resolver
*/
class FileResolver implements Resolver {
/**
diff --git a/packages/documentator/src/Preprocessor/Token.php b/packages/documentator/src/Preprocessor/Token.php
index 0bdd18544..e17158ae8 100644
--- a/packages/documentator/src/Preprocessor/Token.php
+++ b/packages/documentator/src/Preprocessor/Token.php
@@ -18,7 +18,7 @@ public function __construct(
*/
public readonly Instruction $instruction,
/**
- * @var Resolver|Resolver
+ * @var Resolver|Resolver
*/
public readonly Resolver $resolver,
public readonly Context $context,
From ed227274e9462cf809744e42da0970cf2055f9b1 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Sun, 26 May 2024 10:36:53 +0400
Subject: [PATCH 29/30] UPGRADE update.
---
packages/documentator/UPGRADE.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/packages/documentator/UPGRADE.md b/packages/documentator/UPGRADE.md
index 944fd9070..ab034f82c 100644
--- a/packages/documentator/UPGRADE.md
+++ b/packages/documentator/UPGRADE.md
@@ -37,7 +37,9 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
[//]: # (end: b0b74ef74f156294a37f3ec42299e221e5e693f3b42297f5cfa79cab99b1df7e)
-* [ ] Migrate to the new contract `\LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction`.
+* [ ] Migrate to the new contract:
+ * `\LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction`
+ * `\LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Resolver`.
# Upgrade from v5
From f09fa8359b6cd1d9a657894069088ed22b981038 Mon Sep 17 00:00:00 2001
From: Aleksei Lebedev <1329824+LastDragon-ru@users.noreply.github.com>
Date: Sun, 26 May 2024 10:55:17 +0400
Subject: [PATCH 30/30] dev: `monorepo-builder` will not check `src`.
---
monorepo-builder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/monorepo-builder.php b/monorepo-builder.php
index 9d1e4983b..06a64dab2 100644
--- a/monorepo-builder.php
+++ b/monorepo-builder.php
@@ -4,5 +4,5 @@
return static function (MBConfig $config): void {
$config->packageDirectories([__DIR__.'/packages']);
- $config->packageDirectoriesExcludes(['dev']);
+ $config->packageDirectoriesExcludes(['dev', 'src']);
};