Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
632 changes: 16 additions & 616 deletions analyzer-baseline.toml

Large diffs are not rendered by default.

102 changes: 24 additions & 78 deletions lint-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,6 @@ code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/RowGateway/Feature/FeatureSet.php"
code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/RowGateway/RowGateway.php"
code = "no-else-clause"
Expand Down Expand Up @@ -906,78 +900,6 @@ code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/TableGateway/Feature/EventFeature.php"
code = "no-shorthand-ternary"
message = "Use of the shorthand ternary operator."
count = 1

[[issues]]
file = "src/TableGateway/Feature/EventFeature.php"
code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/TableGateway/Feature/FeatureSet.php"
code = "kan-defect"
message = "Class has a high kan defect score."
count = 1

[[issues]]
file = "src/TableGateway/Feature/FeatureSet.php"
code = "too-many-methods"
message = "Class has too many methods."
count = 1

[[issues]]
file = "src/TableGateway/Feature/GlobalAdapterFeature.php"
code = "no-isset"
message = "Use of the `isset` construct."
count = 2

[[issues]]
file = "src/TableGateway/Feature/MetadataFeature.php"
code = "no-else-clause"
message = "Avoid `else` clauses."
count = 2

[[issues]]
file = "src/TableGateway/Feature/RowGatewayFeature.php"
code = "no-else-clause"
message = "Avoid `else` clauses."
count = 1

[[issues]]
file = "src/TableGateway/Feature/RowGatewayFeature.php"
code = "no-else-clause"
message = "Avoid `elseif` clauses."
count = 1

[[issues]]
file = "src/TableGateway/Feature/RowGatewayFeature.php"
code = "no-isset"
message = "Use of the `isset` construct."
count = 2

[[issues]]
file = "src/TableGateway/Feature/SequenceFeature.php"
code = "strict-behavior"
message = "Call to `array_search` must enforce strict comparison."
count = 1

[[issues]]
file = "src/TableGateway/Feature/SequenceFeature.php"
code = "string-style"
message = "String concatenation can be replaced with interpolation."
count = 3

[[issues]]
file = "src/TableGateway/Feature/SequenceFeature.php"
code = "tagged-todo"
message = "TODO should be tagged with (@username) or (#issue)."
count = 1

[[issues]]
file = "src/TableGateway/TableGateway.php"
code = "no-shorthand-ternary"
Expand Down Expand Up @@ -9245,3 +9167,27 @@ file = "test/unit/TableGateway/TableGatewayTest.php"
code = "strict-assertions"
message = "Use strict assertions in PHPUnit tests."
count = 2

[[issues]]
file = "src/RowGateway/Feature/FeatureSet.php"
code = "too-many-methods"
message = 'Class has too many methods.'
count = 1

[[issues]]
file = "src/TableGateway/Feature/FeatureSet.php"
code = "kan-defect"
message = 'Class has a high kan defect score.'
count = 1

[[issues]]
file = "src/TableGateway/Feature/FeatureSet.php"
code = "too-many-methods"
message = 'Class has too many methods.'
count = 1

[[issues]]
file = "src/TableGateway/Feature/EventFeature.php"
code = "too-many-methods"
message = 'Class has too many methods.'
count = 1
2 changes: 2 additions & 0 deletions mago.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ baseline = "lint-baseline.toml"
baseline = "analyzer-baseline.toml"
class-initializers = [
"PhpDb\\ResultSet\\AbstractResultSet::initialize",
"PhpDb\\TableGateway\\Feature\\AbstractFeature::setTableGateway",
"PhpDb\\RowGateway\\Feature\\AbstractFeature::setRowGateway",
]
3 changes: 3 additions & 0 deletions src/Feature/FeatureInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace PhpDb\Feature;

/**
* @api
*/
interface FeatureInterface
{
/** @return array<string, string[]> */
Expand Down
4 changes: 4 additions & 0 deletions src/RowGateway/Feature/AbstractFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
use PhpDb\RowGateway\Exception;
use PhpDb\RowGateway\Exception\RuntimeException;

/**
* @api
*/
abstract class AbstractFeature extends AbstractRowGateway implements FeatureInterface
{
protected AbstractRowGateway $rowGateway;

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

/** @return array<string, string[]> */
Expand Down
3 changes: 3 additions & 0 deletions src/RowGateway/Feature/FeatureInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use PhpDb\Feature\FeatureInterface as BaseFeatureInterface;
use PhpDb\RowGateway\AbstractRowGateway;

/**
* @api
*/
interface FeatureInterface extends BaseFeatureInterface
{
public function setRowGateway(AbstractRowGateway $rowGateway): void;
Expand Down
31 changes: 30 additions & 1 deletion src/RowGateway/Feature/FeatureSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
*/
class FeatureSet
{
final public const APPLY_HALT = 'halt';
final public const string APPLY_HALT = 'halt';

protected ?AbstractRowGateway $rowGateway = null;

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

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

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.4)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.3)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.4)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.5)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.3)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.5)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.4)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.3)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

Check notice on line 24 in src/RowGateway/Feature/FeatureSet.php

View workflow job for this annotation

GitHub Actions / qa / Mago (PHP 8.5)

unused-property

Property `$magicSpecifications` is never used. >Property `$magicSpecifications` is declared here. This property is declared but never read or written within the class. Help: Consider prefixing the property with an underscore (`$_`) to indicate that it is intentionally unused, or remove it if it is not needed.

/** @param FeatureInterface[] $features */
public function __construct(array $features = [])
{
if ([] !== $features) {
Expand All @@ -38,6 +40,7 @@
return $this;
}

/** @param FeatureInterface[] $features */
public function addFeatures(array $features): static
{
foreach ($features as $feature) {
Expand All @@ -46,6 +49,12 @@
return $this;
}

/**
* @param array<array-key, mixed> $args
*
* @mago-expect analysis:string-member-selector
* @mago-expect analysis:mixed-assignment
*/
public function apply(string $method, array $args): void
{
foreach ($this->features as $feature) {
Expand All @@ -60,31 +69,51 @@
}
}

/**
* @mago-expect analysis:unused-parameter
*
* @param array<array-key, mixed> $arguments
*/
public function callMagicCall(string $method, array $arguments): mixed
{
return null;
}

/**
* @mago-expect analysis:unused-parameter
*/
public function callMagicGet(string $property): mixed
{
return null;
}

/**
* @mago-expect analysis:unused-parameter
*/
public function callMagicSet(string $property, mixed $value): mixed
{
return null;
}

/**
* @mago-expect analysis:unused-parameter
*/
public function canCallMagicCall(string $method): bool
{
return false;
}

/**
* @mago-expect analysis:unused-parameter
*/
public function canCallMagicGet(string $property): false
{
return false;
}

/**
* @mago-expect analysis:unused-parameter
*/
public function canCallMagicSet(string $property): false
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/TableGateway/AbstractTableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* @property AdapterInterface $adapter
* @property int $lastInsertValue
* @property string $table
* @property TableIdentifier|string|array|null $table
*/
abstract class AbstractTableGateway implements TableGatewayInterface
{
Expand Down
4 changes: 4 additions & 0 deletions src/TableGateway/Feature/AbstractFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
use Override;
use PhpDb\TableGateway\AbstractTableGateway;

/**
* @api
*/
abstract class AbstractFeature extends AbstractTableGateway implements FeatureInterface
{
protected AbstractTableGateway $tableGateway;

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

/** @return array<string, string[]> */
Expand Down
9 changes: 7 additions & 2 deletions src/TableGateway/Feature/EventFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

use function get_class;

/**
* @api
*/
class EventFeature extends AbstractFeature implements EventFeatureEventsInterface, EventsCapableInterface
{
protected EventManagerInterface $eventManager;

protected ?EventFeature\TableGatewayEvent $event;
protected EventFeature\TableGatewayEvent $event;

public function __construct(
?EventManagerInterface $eventManager = null,
Expand All @@ -37,7 +40,9 @@ public function __construct(
TableGateway::class,
]);

$this->event = $tableGatewayEvent ?: new EventFeature\TableGatewayEvent();
$this->event = $tableGatewayEvent instanceof EventFeature\TableGatewayEvent
? $tableGatewayEvent
: new EventFeature\TableGatewayEvent();
}

/**
Expand Down
15 changes: 13 additions & 2 deletions src/TableGateway/Feature/EventFeature/TableGatewayEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
use Override;
use PhpDb\TableGateway\AbstractTableGateway;

class TableGatewayEvent implements EventInterface
/**
* @implements EventInterface<AbstractTableGateway|null, array<array-key, mixed>|object>
*/
final class TableGatewayEvent implements EventInterface
{
protected ?AbstractTableGateway $target = null;

protected ?string $name = null;

/** @var array<array-key, mixed>|object */
protected array|object $params = [];

#[Override]
Expand Down Expand Up @@ -77,6 +81,8 @@ public function setName($name): void
*
* @param string|int $name
* @param mixed $value
*
* @mago-expect analysis:possibly-invalid-array-access
*/
#[Override]
public function setParam($name, $value): void
Expand All @@ -87,8 +93,10 @@ public function setParam($name, $value): void
/**
* Set event parameters
*
* @param array|object $params
* @param array<array-key, mixed>|object $params
* @phpstan-ignore selfOut.type
*
* @mago-expect analysis:unused-template-parameter
*/
#[Override]
public function setParams($params): void
Expand All @@ -101,6 +109,9 @@ public function setParams($params): void
*
* @param object|string|null $target
* @phpstan-ignore selfOut.type
*
* @mago-expect analysis:unused-template-parameter
* @mago-expect analysis:property-type-coercion
*/
#[Override]
public function setTarget($target): void
Expand Down
22 changes: 12 additions & 10 deletions src/TableGateway/Feature/EventFeatureEventsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@
* into a separate interface that EventFeature implements; the change keeps
* backwards compatibility, while simultaneously removing the need to add
* another hard dependency to the component.
*
* @api
*/
interface EventFeatureEventsInterface
{
public const EVENT_PRE_INITIALIZE = 'preInitialize';
public const EVENT_POST_INITIALIZE = 'postInitialize';
public const string EVENT_PRE_INITIALIZE = 'preInitialize';
public const string EVENT_POST_INITIALIZE = 'postInitialize';

public const EVENT_PRE_SELECT = 'preSelect';
public const EVENT_POST_SELECT = 'postSelect';
public const string EVENT_PRE_SELECT = 'preSelect';
public const string EVENT_POST_SELECT = 'postSelect';

public const EVENT_PRE_INSERT = 'preInsert';
public const EVENT_POST_INSERT = 'postInsert';
public const string EVENT_PRE_INSERT = 'preInsert';
public const string EVENT_POST_INSERT = 'postInsert';

public const EVENT_PRE_DELETE = 'preDelete';
public const EVENT_POST_DELETE = 'postDelete';
public const string EVENT_PRE_DELETE = 'preDelete';
public const string EVENT_POST_DELETE = 'postDelete';

public const EVENT_PRE_UPDATE = 'preUpdate';
public const EVENT_POST_UPDATE = 'postUpdate';
public const string EVENT_PRE_UPDATE = 'preUpdate';
public const string EVENT_POST_UPDATE = 'postUpdate';
}
3 changes: 3 additions & 0 deletions src/TableGateway/Feature/FeatureInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use PhpDb\Feature\FeatureInterface as BaseFeatureInterface;
use PhpDb\TableGateway\AbstractTableGateway;

/**
* @api
*/
interface FeatureInterface extends BaseFeatureInterface
{
public function setTableGateway(AbstractTableGateway $tableGateway): void;
Expand Down
Loading
Loading