Skip to content

Commit c5f6264

Browse files
authored
Merge pull request #174 from simon-mundy/qa/feature-src
Feature - Reformatting for linting, format and analysis with Mago
2 parents b57f549 + d6f702c commit c5f6264

32 files changed

Lines changed: 1117 additions & 1859 deletions

‎analyzer-baseline.toml‎

Lines changed: 25 additions & 618 deletions
Large diffs are not rendered by default.

‎lint-baseline.toml‎

Lines changed: 46 additions & 856 deletions
Large diffs are not rendered by default.

‎mago.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ baseline = "lint-baseline.toml"
1515
baseline = "analyzer-baseline.toml"
1616
class-initializers = [
1717
"PhpDb\\ResultSet\\AbstractResultSet::initialize",
18+
"PhpDb\\TableGateway\\Feature\\AbstractFeature::setTableGateway",
19+
"PhpDb\\RowGateway\\Feature\\AbstractFeature::setRowGateway",
1820
]

‎src/Feature/FeatureInterface.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace PhpDb\Feature;
66

7+
/**
8+
* @api
9+
*/
710
interface FeatureInterface
811
{
912
/** @return array<string, string[]> */

‎src/RowGateway/Feature/AbstractFeature.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
use PhpDb\RowGateway\Exception;
1010
use PhpDb\RowGateway\Exception\RuntimeException;
1111

12+
/**
13+
* @api
14+
*/
1215
abstract class AbstractFeature extends AbstractRowGateway implements FeatureInterface
1316
{
1417
protected AbstractRowGateway $rowGateway;
1518

19+
/** @var array<string, mixed> */
1620
protected array $sharedData = [];
1721

1822
/** @return array<string, string[]> */

‎src/RowGateway/Feature/FeatureInterface.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use PhpDb\Feature\FeatureInterface as BaseFeatureInterface;
88
use PhpDb\RowGateway\AbstractRowGateway;
99

10+
/**
11+
* @api
12+
*/
1013
interface FeatureInterface extends BaseFeatureInterface
1114
{
1215
public function setRowGateway(AbstractRowGateway $rowGateway): void;

‎src/RowGateway/Feature/FeatureSet.php‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
*/
1414
class FeatureSet
1515
{
16-
final public const APPLY_HALT = 'halt';
16+
final public const string APPLY_HALT = 'halt';
1717

1818
protected ?AbstractRowGateway $rowGateway = null;
1919

2020
/** @var FeatureInterface[] */
2121
protected array $features = [];
2222

23+
/** @var array<array-key, mixed> */
2324
protected array $magicSpecifications = [];
2425

26+
/** @param FeatureInterface[] $features */
2527
public function __construct(array $features = [])
2628
{
2729
if ([] !== $features) {
@@ -38,6 +40,7 @@ public function addFeature(FeatureInterface $feature): static
3840
return $this;
3941
}
4042

43+
/** @param FeatureInterface[] $features */
4144
public function addFeatures(array $features): static
4245
{
4346
foreach ($features as $feature) {
@@ -46,6 +49,12 @@ public function addFeatures(array $features): static
4649
return $this;
4750
}
4851

52+
/**
53+
* @param array<array-key, mixed> $args
54+
*
55+
* @mago-expect analysis:string-member-selector
56+
* @mago-expect analysis:mixed-assignment
57+
*/
4958
public function apply(string $method, array $args): void
5059
{
5160
foreach ($this->features as $feature) {
@@ -60,31 +69,51 @@ public function apply(string $method, array $args): void
6069
}
6170
}
6271

72+
/**
73+
* @mago-expect analysis:unused-parameter
74+
*
75+
* @param array<array-key, mixed> $arguments
76+
*/
6377
public function callMagicCall(string $method, array $arguments): mixed
6478
{
6579
return null;
6680
}
6781

82+
/**
83+
* @mago-expect analysis:unused-parameter
84+
*/
6885
public function callMagicGet(string $property): mixed
6986
{
7087
return null;
7188
}
7289

90+
/**
91+
* @mago-expect analysis:unused-parameter
92+
*/
7393
public function callMagicSet(string $property, mixed $value): mixed
7494
{
7595
return null;
7696
}
7797

98+
/**
99+
* @mago-expect analysis:unused-parameter
100+
*/
78101
public function canCallMagicCall(string $method): bool
79102
{
80103
return false;
81104
}
82105

106+
/**
107+
* @mago-expect analysis:unused-parameter
108+
*/
83109
public function canCallMagicGet(string $property): false
84110
{
85111
return false;
86112
}
87113

114+
/**
115+
* @mago-expect analysis:unused-parameter
116+
*/
88117
public function canCallMagicSet(string $property): false
89118
{
90119
return false;

‎src/TableGateway/AbstractTableGateway.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* @property AdapterInterface $adapter
3333
* @property int $lastInsertValue
34-
* @property string $table
34+
* @property TableIdentifier|string|array|null $table
3535
*/
3636
abstract class AbstractTableGateway implements TableGatewayInterface
3737
{

‎src/TableGateway/Feature/AbstractFeature.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
use Override;
88
use PhpDb\TableGateway\AbstractTableGateway;
99

10+
/**
11+
* @api
12+
*/
1013
abstract class AbstractFeature extends AbstractTableGateway implements FeatureInterface
1114
{
1215
protected AbstractTableGateway $tableGateway;
1316

17+
/** @var array<string, mixed> */
1418
protected array $sharedData = [];
1519

1620
/** @return array<string, string[]> */

‎src/TableGateway/Feature/EventFeature.php‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919

2020
use function get_class;
2121

22+
/**
23+
* @api
24+
*/
2225
class EventFeature extends AbstractFeature implements EventFeatureEventsInterface, EventsCapableInterface
2326
{
2427
protected EventManagerInterface $eventManager;
2528

26-
protected ?EventFeature\TableGatewayEvent $event;
29+
protected EventFeature\TableGatewayEvent $event;
2730

2831
public function __construct(
2932
?EventManagerInterface $eventManager = null,
@@ -37,7 +40,9 @@ public function __construct(
3740
TableGateway::class,
3841
]);
3942

40-
$this->event = $tableGatewayEvent ?: new EventFeature\TableGatewayEvent();
43+
$this->event = $tableGatewayEvent instanceof EventFeature\TableGatewayEvent
44+
? $tableGatewayEvent
45+
: new EventFeature\TableGatewayEvent();
4146
}
4247

4348
/**

0 commit comments

Comments
 (0)