Skip to content

Commit f953237

Browse files
refactor(documentator)!: Preprocessor moved to Processor namespace (#176)
2 parents 75d30bd + 04af351 commit f953237

File tree

117 files changed

+254
-315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+254
-315
lines changed

packages/dev/src/App/Example.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use Illuminate\Contracts\Foundation\Application;
77
use LastDragon_ru\LaraASP\Core\Application\ApplicationResolver;
88
use LastDragon_ru\LaraASP\Core\Utils\ConfigMerger;
9-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeExample\Contracts\Runner;
109
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
10+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeExample\Contracts\Runner;
1111
use LogicException;
1212
use Override;
1313
use PhpParser\ErrorHandler\Collecting;

packages/dev/src/App/Provider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace LastDragon_ru\LaraASP\Dev\App;
44

55
use Illuminate\Support\ServiceProvider;
6-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeExample\Contracts\Runner;
6+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeExample\Contracts\Runner;
77
use Override;
88

99
class Provider extends ServiceProvider {

packages/documentator/UPGRADE.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Please also see [changelog](https://github.com/LastDragon-ru/lara-asp/releases)
3838
[//]: # (end: 470dd21d18d5886f1873b1247130ac8173ed99258e41418c6bd32162325d628b)
3939

4040
* [ ] Migrate to the new contract:
41-
* `\LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction`
42-
* `\LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Parameters`.
41+
* `\LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Instruction`
42+
* `\LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Parameters`.
4343

44-
* [ ] Instruction `include:example` not check/run `<example>.run` file anymore. The `\LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeExample\Contracts\Runner` should be used/provided instead.
44+
* [ ] Instruction `include:example` not check/run `<example>.run` file anymore. The `\LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeExample\Contracts\Runner` should be used/provided instead.
4545

4646
* [ ] `LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Task::__invoke()` should yield a `LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Dependency` instead of file.
4747

packages/documentator/src/Commands/Commands.php

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
use function is_dir;
1818

19-
// @phpcs:disable Generic.Files.LineLength.TooLong
20-
2119
#[AsCommand(
2220
name : Commands::Name,
2321
description: 'Saves help for each command in the `namespace` into a separate file in the `target` directory.',

packages/documentator/src/Commands/Preprocess.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
use LastDragon_ru\LaraASP\Core\Utils\Cast;
77
use LastDragon_ru\LaraASP\Core\Utils\Path;
88
use LastDragon_ru\LaraASP\Documentator\Package;
9-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
10-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Parameters;
11-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Preprocessor;
129
use LastDragon_ru\LaraASP\Documentator\Processor\Processor;
1310
use LastDragon_ru\LaraASP\Documentator\Processor\Result;
11+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Instruction;
12+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Parameters;
13+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Task;
1414
use LastDragon_ru\LaraASP\Documentator\Utils\Markdown;
1515
use LastDragon_ru\LaraASP\Documentator\Utils\PhpDoc;
1616
use LastDragon_ru\LaraASP\Formatter\Formatter;
@@ -39,7 +39,7 @@
3939
use function var_export;
4040

4141
/**
42-
* @see Preprocessor
42+
* @see Task
4343
*/
4444
#[AsCommand(
4545
name : Preprocess::Name,
@@ -70,7 +70,7 @@ class Preprocess extends Command {
7070
HELP;
7171

7272
public function __construct(
73-
protected readonly Preprocessor $preprocessor,
73+
protected readonly Task $preprocess,
7474
) {
7575
parent::__construct();
7676
}
@@ -100,7 +100,7 @@ public function __invoke(Formatter $formatter): void {
100100
};
101101

102102
$duration = (new Processor())
103-
->task($this->preprocessor)
103+
->task($this->preprocess)
104104
->run($path, $exclude, $listener);
105105

106106
$this->output->newLine();
@@ -116,11 +116,11 @@ public function getProcessedHelp(): string {
116116
}
117117

118118
protected function getProcessedHelpDescription(): string {
119-
return $this->getDocBlock(new ReflectionClass(Preprocessor::class));
119+
return $this->getDocBlock(new ReflectionClass(Task::class));
120120
}
121121

122122
protected function getProcessedHelpInstructions(): string {
123-
$instructions = $this->preprocessor->getInstructions();
123+
$instructions = $this->preprocess->getInstructions();
124124
$help = [];
125125

126126
foreach ($instructions as $instruction) {

packages/documentator/src/Commands/PreprocessTest.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace LastDragon_ru\LaraASP\Documentator\Commands;
44

5-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
6-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction;
7-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Parameters;
8-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Preprocessor;
5+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
6+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Instruction;
7+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Parameters;
8+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Task;
99
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
1010
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializable;
1111
use Mockery;
@@ -18,9 +18,9 @@
1818
#[CoversClass(Preprocess::class)]
1919
final class PreprocessTest extends TestCase {
2020
public function testGetProcessedHelpInstructions(): void {
21-
$preprocessor = Mockery::mock(Preprocessor::class);
22-
$preprocessor->shouldAllowMockingProtectedMethods();
23-
$preprocessor
21+
$preprocess = Mockery::mock(Task::class);
22+
$preprocess->shouldAllowMockingProtectedMethods();
23+
$preprocess
2424
->shouldReceive('getInstructions')
2525
->once()
2626
->andReturn([
@@ -29,7 +29,7 @@ public function testGetProcessedHelpInstructions(): void {
2929
PreprocessTest__InstructionNotSerializable::class,
3030
]);
3131

32-
$command = new class($preprocessor) extends Preprocess {
32+
$command = new class($preprocess) extends Preprocess {
3333
#[Override]
3434
public function getProcessedHelpInstructions(): string {
3535
return parent::getProcessedHelpInstructions();
@@ -79,8 +79,8 @@ public function getProcessedHelpInstructions(): string {
7979
}
8080

8181
public function testGetProcessedHelpInstructionTarget(): void {
82-
$preprocessor = Mockery::mock(Preprocessor::class);
83-
$command = new class($preprocessor) extends Preprocess {
82+
$preprocess = Mockery::mock(Task::class);
83+
$command = new class($preprocess) extends Preprocess {
8484
#[Override]
8585
public function getProcessedHelpInstructionTarget(
8686
string $instruction,
@@ -107,8 +107,8 @@ public function getProcessedHelpInstructionTarget(
107107
}
108108

109109
public function testGetProcessedHelpInstructionParameters(): void {
110-
$preprocessor = Mockery::mock(Preprocessor::class);
111-
$command = new class($preprocessor) extends Preprocess {
110+
$preprocess = Mockery::mock(Task::class);
111+
$command = new class($preprocess) extends Preprocess {
112112
#[Override]
113113
public function getProcessedHelpInstructionParameters(
114114
string $instruction,
@@ -138,8 +138,8 @@ public function getProcessedHelpInstructionParameters(
138138
}
139139

140140
public function testGetProcessedHelpInstructionParametersNoParameters(): void {
141-
$preprocessor = Mockery::mock(Preprocessor::class);
142-
$command = new class($preprocessor) extends Preprocess {
141+
$preprocess = Mockery::mock(Task::class);
142+
$command = new class($preprocess) extends Preprocess {
143143
#[Override]
144144
public function getProcessedHelpInstructionParameters(
145145
string $instruction,
@@ -160,8 +160,8 @@ public function getProcessedHelpInstructionParameters(
160160
}
161161

162162
public function testGetProcessedHelpInstructionParametersNotSerializable(): void {
163-
$preprocessor = Mockery::mock(Preprocessor::class);
164-
$command = new class($preprocessor) extends Preprocess {
163+
$preprocess = Mockery::mock(Task::class);
164+
$command = new class($preprocess) extends Preprocess {
165165
#[Override]
166166
public function getProcessedHelpInstructionParameters(
167167
string $instruction,

packages/documentator/src/Preprocessor/Exceptions/PreprocessorError.php

-9
This file was deleted.

packages/documentator/src/Preprocessor/Exceptions/TargetIsNotDirectory.php

-22
This file was deleted.

packages/documentator/src/Preprocessor/Context.php packages/documentator/src/Processor/Tasks/Preprocess/Context.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess;
44

55
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
66
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;

packages/documentator/src/Preprocessor/Contracts/Instruction.php packages/documentator/src/Processor/Tasks/Preprocess/Contracts/Instruction.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts;
44

55
use Generator;
6-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
76
use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Dependency;
7+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
88

99
/**
1010
* @template TParameters of Parameters

packages/documentator/src/Preprocessor/Contracts/Parameters.php packages/documentator/src/Processor/Tasks/Preprocess/Contracts/Parameters.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts;
44

55
/**
66
* @property-read string $target

packages/documentator/src/Preprocessor/Exceptions/DependencyIsMissing.php packages/documentator/src/Processor/Tasks/Preprocess/Exceptions/DependencyIsMissing.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Exceptions;
44

5-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
5+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
66
use Throwable;
77

88
use function sprintf;

packages/documentator/src/Preprocessor/Exceptions/InstructionFailed.php packages/documentator/src/Processor/Tasks/Preprocess/Exceptions/InstructionFailed.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Exceptions;
44

5-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
5+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
66
use Throwable;
77

8-
abstract class InstructionFailed extends PreprocessorError {
8+
abstract class InstructionFailed extends PreprocessError {
99
public function __construct(
1010
private readonly Context $context,
1111
string $message,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Exceptions;
4+
5+
use LastDragon_ru\LaraASP\Documentator\Processor\Exceptions\ProcessorError;
6+
7+
abstract class PreprocessError extends ProcessorError {
8+
// empty
9+
}

packages/documentator/src/Preprocessor/Exceptions/PreprocessingFailed.php packages/documentator/src/Processor/Tasks/Preprocess/Exceptions/PreprocessFailed.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Exceptions;
44

5-
use LastDragon_ru\LaraASP\Documentator\PackageException;
65
use Throwable;
76

8-
class PreprocessingFailed extends PackageException {
7+
class PreprocessFailed extends PreprocessError {
98
public function __construct(
109
Throwable $previous = null,
1110
) {

packages/documentator/src/Preprocessor/Instructions/IncludeArtisan/Exceptions/ArtisanCommandError.php packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandError.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan\Exceptions;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeArtisan\Exceptions;
44

5-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
6-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\InstructionFailed;
5+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
6+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Exceptions\InstructionFailed;
77
use Throwable;
88

99
use function sprintf;

packages/documentator/src/Preprocessor/Instructions/IncludeArtisan/Exceptions/ArtisanCommandFailed.php packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Exceptions/ArtisanCommandFailed.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan\Exceptions;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeArtisan\Exceptions;
44

5-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
6-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\InstructionFailed;
5+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
6+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Exceptions\InstructionFailed;
77
use Throwable;
88

99
use function sprintf;

packages/documentator/src/Preprocessor/Instructions/IncludeArtisan/Instruction.php packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Instruction.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeArtisan;
44

55
use Exception;
66
use Illuminate\Contracts\Console\Kernel;
77
use LastDragon_ru\LaraASP\Core\Application\ApplicationResolver;
8-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
9-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Instruction as InstructionContract;
10-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\InstructionFailed;
11-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan\Exceptions\ArtisanCommandError;
12-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan\Exceptions\ArtisanCommandFailed;
8+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
9+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Instruction as InstructionContract;
10+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Exceptions\InstructionFailed;
11+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeArtisan\Exceptions\ArtisanCommandError;
12+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeArtisan\Exceptions\ArtisanCommandFailed;
1313
use Override;
1414
use Symfony\Component\Console\Command\Command;
1515
use Symfony\Component\Console\Input\StringInput;

packages/documentator/src/Preprocessor/Instructions/IncludeArtisan/InstructionTest.php packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/InstructionTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeArtisan;
44

55
use Composer\InstalledVersions;
66
use Composer\Semver\VersionParser;
77
use Illuminate\Contracts\Console\Kernel;
88
use LastDragon_ru\LaraASP\Core\Application\ApplicationResolver;
99
use LastDragon_ru\LaraASP\Core\Utils\Path;
10-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
11-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan\Exceptions\ArtisanCommandFailed;
1210
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory;
1311
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File;
12+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
13+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeArtisan\Exceptions\ArtisanCommandFailed;
1414
use LastDragon_ru\LaraASP\Documentator\Testing\Package\ProcessorHelper;
1515
use LastDragon_ru\LaraASP\Documentator\Testing\Package\TestCase;
1616
use Mockery;

packages/documentator/src/Preprocessor/Instructions/IncludeArtisan/Parameters.php packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeArtisan/Parameters.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeArtisan;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeArtisan;
44

5-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Contracts\Parameters as ParametersContract;
5+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Contracts\Parameters as ParametersContract;
66
use LastDragon_ru\LaraASP\Serializer\Contracts\Serializable;
77

88
class Parameters implements ParametersContract, Serializable {

packages/documentator/src/Preprocessor/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php packages/documentator/src/Processor/Tasks/Preprocess/Instructions/IncludeDocBlock/Exceptions/TargetIsNotValidPhpFile.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php declare(strict_types = 1);
22

3-
namespace LastDragon_ru\LaraASP\Documentator\Preprocessor\Instructions\IncludeDocBlock\Exceptions;
3+
namespace LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Instructions\IncludeDocBlock\Exceptions;
44

5-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Context;
6-
use LastDragon_ru\LaraASP\Documentator\Preprocessor\Exceptions\InstructionFailed;
5+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Context;
6+
use LastDragon_ru\LaraASP\Documentator\Processor\Tasks\Preprocess\Exceptions\InstructionFailed;
77
use Throwable;
88

99
use function sprintf;

0 commit comments

Comments
 (0)