Skip to content

Commit 27cf73a

Browse files
authored
Add conventions around PHP code in the project (#68)
* Add convention tests over packages definitions * Add conventions around classes docblocks * Add conventions around public method docblocks
1 parent dc52597 commit 27cf73a

File tree

68 files changed

+823
-45
lines changed

Some content is hidden

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

68 files changed

+823
-45
lines changed

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
"psr/container": "^1.0",
2323
"psr/event-dispatcher": "^1.0",
2424
"psr/log": "^1.0|^2.0|^3.0",
25+
"symfony/config": "^5.0|^6.0",
2526
"symfony/console": "^5.0|^6.0",
27+
"symfony/dependency-injection": "^5.0|^6.0",
28+
"symfony/http-kernel": "^5.0|^6.0",
2629
"symfony/framework-bundle": "^5.0|^6.0",
2730
"symfony/messenger": "^5.0|^6.0",
2831
"symfony/serializer": "^5.0|^6.0",
@@ -45,6 +48,7 @@
4548
"yokai/batch-doctrine-dbal": "self.version",
4649
"yokai/batch-doctrine-orm": "self.version",
4750
"yokai/batch-doctrine-persistence": "self.version",
51+
"yokai/batch-flysystem": "self.version",
4852
"yokai/batch-symfony-console": "self.version",
4953
"yokai/batch-symfony-framework": "self.version",
5054
"yokai/batch-symfony-messenger": "self.version",

src/batch-box-spout/src/Reader/HeaderStrategy.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public function setHeaders(array $headers): bool
7575
}
7676

7777
/**
78+
* Build the associative item, a combination of headers and values.
79+
*
7880
* @throws InvalidRowSizeException
7981
*
8082
* @phpstan-param array<int, string> $row

src/batch-box-spout/src/Reader/Options/SheetFilter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public static function nameIs(string $name, string ...$names): self
5555
}
5656

5757
/**
58+
* Iterate over valid sheets for the provided filter.
59+
*
5860
* @return Generator&SheetInterface[]
5961
* @phpstan-return Generator<SheetInterface>
6062
* @internal

src/batch-box-spout/src/Writer/WriteToSheetItem.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ private function __construct(
2121
}
2222

2323
/**
24+
* Static constructor from array data.
25+
*
2426
* @param array<int|string, mixed> $item
2527
*/
2628
public static function array(string $sheet, array $item, Style $style = null): self
2729
{
2830
return new self($sheet, WriterEntityFactory::createRowFromArray($item, $style));
2931
}
3032

33+
/**
34+
* Static constructor from {@see Row} object.
35+
*/
3136
public static function row(string $sheet, Row $item): self
3237
{
3338
return new self($sheet, $item);

src/batch-doctrine-dbal/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"php": "^8.0",
1515
"ext-json": "*",
1616
"doctrine/dbal": "^2.11",
17+
"doctrine/persistence": "^2.0",
1718
"yokai/batch": "^0.4.0"
1819
},
1920
"autoload": {

src/batch-doctrine-dbal/src/DoctrineDBALJobExecutionStorage.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,14 @@
1717
use Yokai\Batch\Exception\JobExecutionNotFoundException;
1818
use Yokai\Batch\Exception\RuntimeException;
1919
use Yokai\Batch\JobExecution;
20+
use Yokai\Batch\Storage\JobExecutionStorageInterface;
2021
use Yokai\Batch\Storage\Query;
2122
use Yokai\Batch\Storage\QueryableJobExecutionStorageInterface;
2223

24+
/**
25+
* This {@see JobExecutionStorageInterface} will store
26+
* {@see JobExecution} in an SQL database using doctrine/dbal.
27+
*/
2328
final class DoctrineDBALJobExecutionStorage implements QueryableJobExecutionStorageInterface
2429
{
2530
private const DEFAULT_OPTIONS = [
@@ -46,6 +51,9 @@ public function __construct(ConnectionRegistry $doctrine, array $options)
4651
$this->connection = $connection;
4752
}
4853

54+
/**
55+
* Create required table for this storage.
56+
*/
4957
public function createSchema(): void
5058
{
5159
$assetFilter = $this->connection->getConfiguration()->getSchemaAssetsFilter();

src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public function __construct(
2727
}
2828

2929
/**
30+
* Convert a {@see JobExecution} object to a row data array.
31+
*
3032
* @phpstan-return array<string, mixed>
3133
*/
3234
public function toRow(JobExecution $jobExecution): array
@@ -47,6 +49,8 @@ public function toRow(JobExecution $jobExecution): array
4749
}
4850

4951
/**
52+
* Convert a row data array to a {@see JobExecution} object.
53+
*
5054
* @phpstan-param array<string, mixed> $data
5155
*/
5256
public function fromRow(array $data, JobExecution $parent = null): JobExecution
@@ -97,7 +101,7 @@ public function fromRow(array $data, JobExecution $parent = null): JobExecution
97101
/**
98102
* @phpstan-return array<string, mixed>
99103
*/
100-
public function toChildRow(JobExecution $jobExecution): array
104+
private function toChildRow(JobExecution $jobExecution): array
101105
{
102106
return [
103107
'job_name' => $jobExecution->getJobName(),

src/batch-doctrine-orm/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"require": {
1414
"php": "^8.0",
1515
"doctrine/orm": "^2.8",
16+
"doctrine/persistence": "^2.0",
1617
"yokai/batch": "^0.4.0"
1718
},
1819
"autoload": {

src/batch-symfony-console/src/CommandRunner.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Symfony\Component\Console\Input\ArrayInput;
88
use Symfony\Component\Process\PhpExecutableFinder;
99

10+
/**
11+
* Utility class that knows how to run command asynchronously.
12+
*/
1013
class CommandRunner
1114
{
1215
private string $consolePath;
@@ -25,6 +28,8 @@ public function __construct(
2528
}
2629

2730
/**
31+
* Run a command asynchronously.
32+
*
2833
* @phpstan-param array<string, mixed> $arguments
2934
*/
3035
public function runAsync(string $commandName, string $logFilename, array $arguments = []): void

src/batch-symfony-console/src/RunCommandJobLauncher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* This {@see JobLauncherInterface} will execute job via an asynchronous symfony command.
1515
*
16-
* Example, if you call {@see RunCommandJobLauncher::launch('import', ['foo'=>'bar'])},
16+
* Example, if you call RunCommandJobLauncher::launch('import', ['foo'=>'bar']),
1717
* this command will run (with absolute pathes) :
1818
*
1919
* php bin/console yokai:batch:run import '{"foo":"bar"}' >> var/log/batch_execute.log 2>&1 &

0 commit comments

Comments
 (0)