Skip to content

Commit

Permalink
raise min MSI,
Browse files Browse the repository at this point in the history
[rector] Rector fixes,
avoid case where we build "is_null(null)"
  • Loading branch information
clemzarch committed Aug 11, 2023
1 parent 78d8dff commit 940910b
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 53 deletions.
4 changes: 2 additions & 2 deletions infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"@default": true
},
"testFramework":"phpunit",
"minMsi": 30,
"minCoveredMsi": 40
"minMsi": 50,
"minCoveredMsi": 60
}
4 changes: 2 additions & 2 deletions src/Builder/Capacity/Extractor/ListPerPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getNode(): Node
new Node\Stmt\Expression(
expr: new Node\Expr\Yield_(
value: new Node\Expr\New_(
class: new Node\Name\FullyQualified(name: 'Kiboko\\Component\\Bucket\\AcceptanceResultBucket'),
class: new Node\Name\FullyQualified(name: \Kiboko\Component\Bucket\AcceptanceResultBucket::class),
args: [
new Node\Arg(
new Node\Expr\Variable('item')
Expand All @@ -99,7 +99,7 @@ class: new Node\Name\FullyQualified(name: 'Kiboko\\Component\\Bucket\\Acceptance
),
],
],
);
);
}

private function compileSearch(): array

Check failure on line 105 in src/Builder/Capacity/Extractor/ListPerPage.php

View workflow job for this annotation

GitHub Actions / phpstan8

Method Kiboko\Plugin\Akeneo\Builder\Capacity\Extractor\ListPerPage::compileSearch() return type has no value type specified in iterable type array.

Check failure on line 105 in src/Builder/Capacity/Extractor/ListPerPage.php

View workflow job for this annotation

GitHub Actions / phpstan6

Method Kiboko\Plugin\Akeneo\Builder\Capacity\Extractor\ListPerPage::compileSearch() return type has no value type specified in iterable type array.

Check failure on line 105 in src/Builder/Capacity/Extractor/ListPerPage.php

View workflow job for this annotation

GitHub Actions / phpstan7

Method Kiboko\Plugin\Akeneo\Builder\Capacity\Extractor\ListPerPage::compileSearch() return type has no value type specified in iterable type array.
Expand Down
4 changes: 2 additions & 2 deletions src/Builder/Capacity/Loader/Upsert.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getNode(): Node
var: new Node\Expr\Variable('line'),
expr: new Node\Expr\Yield_(
value: new Node\Expr\New_(
class: new Node\Name\FullyQualified(name: 'Kiboko\\Component\\Bucket\\AcceptanceResultBucket'),
class: new Node\Name\FullyQualified(name: \Kiboko\Component\Bucket\AcceptanceResultBucket::class),
args: [
new Node\Arg(
value: new Node\Expr\Variable('line'),
Expand All @@ -109,7 +109,7 @@ class: new Node\Name\FullyQualified(name: 'Kiboko\\Component\\Bucket\\Acceptance
new Node\Stmt\Catch_(
types: [
new Node\Name\FullyQualified(
name: 'Akeneo\\Pim\\ApiClient\\Exception\\HttpException',
name: \Akeneo\Pim\ApiClient\Exception\HttpException::class,
),
],
var: new Node\Expr\Variable('exception'),
Expand Down
22 changes: 10 additions & 12 deletions src/Builder/Capacity/Lookup/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ public function getNode(): Node
return (new IsolatedValueAppendingBuilder(
new Node\Expr\Variable('input'),
new Node\Expr\Variable('lookup'),
[
new Node\Stmt\If_(
array_filter([
$this->code ? new Node\Stmt\If_(
cond: new Node\Expr\FuncCall(
name: new Node\Name('is_null'),
args: array_filter(
[
null !== $this->code ? new Node\Arg(
value: $this->code,
) : null,
],
),
args: [
new Node\Arg(
value: $this->code,
),
],
),
subNodes: [
'stmts' => [
Expand All @@ -78,7 +76,7 @@ public function getNode(): Node
),
],
],
),
) : null,
new Node\Stmt\TryCatch(
stmts: [
new Node\Stmt\Expression(
Expand Down Expand Up @@ -117,7 +115,7 @@ public function getNode(): Node
catches: [
new Node\Stmt\Catch_(
types: [
new Node\Name\FullyQualified('Akeneo\Pim\ApiClient\Exception\HttpException'),
new Node\Name\FullyQualified(\Akeneo\Pim\ApiClient\Exception\HttpException::class),
],
var: new Node\Expr\Variable('exception'),
stmts: [
Expand Down Expand Up @@ -169,7 +167,7 @@ public function getNode(): Node
new Node\Stmt\Return_(
expr: new Node\Expr\Variable('items'),
),
],
]),
new Node\Expr\Variable('bucket')
))->getNode();
}
Expand Down
22 changes: 10 additions & 12 deletions src/Builder/Capacity/Lookup/ListPerPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,15 @@ public function getNode(): Node
return (new IsolatedValueAppendingBuilder(
new Node\Expr\Variable('input'),
new Node\Expr\Variable('lookup'),
[
new Node\Stmt\If_(
array_filter([
$this->code ? new Node\Stmt\If_(
cond: new Node\Expr\FuncCall(
name: new Node\Name('is_null'),
args: array_filter(
[
null !== $this->code ? new Node\Arg(
value: $this->code,
) : null,
],
),
args: [
new Node\Arg(
value: $this->code,
),
],
),
subNodes: [
'stmts' => [
Expand All @@ -78,7 +76,7 @@ public function getNode(): Node
),
],
],
),
) : null,
new Node\Stmt\TryCatch(
stmts: [
new Node\Stmt\Expression(
Expand Down Expand Up @@ -117,7 +115,7 @@ public function getNode(): Node
catches: [
new Node\Stmt\Catch_(
types: [
new Node\Name\FullyQualified('Akeneo\Pim\ApiClient\Exception\HttpException'),
new Node\Name\FullyQualified(\Akeneo\Pim\ApiClient\Exception\HttpException::class),
],
var: new Node\Expr\Variable('exception'),
stmts: [
Expand Down Expand Up @@ -169,7 +167,7 @@ public function getNode(): Node
new Node\Stmt\Return_(
expr: new Node\Expr\Variable('items'),
),
],
]),
new Node\Expr\Variable('bucket')
))->getNode();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function withFileSystem(Node\Expr $fileSystem): self
public function getNode(): Node\Expr\MethodCall
{
$instance = new Node\Expr\New_(
new Node\Name\FullyQualified('Akeneo\\Pim\\ApiClient\\AkeneoPimClientBuilder'),
new Node\Name\FullyQualified(\Akeneo\Pim\ApiClient\AkeneoPimClientBuilder::class),
[
new Node\Arg($this->baseUrl),
],
Expand Down
10 changes: 5 additions & 5 deletions src/Builder/ConditionalLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function compileAllAlternatives(): Node
expr: new Node\Expr\Assign(
var: new Node\Expr\Variable('bucket'),
expr: new Node\Expr\New_(
new Node\Name\FullyQualified('Kiboko\Component\Bucket\ComplexResultBucket')
new Node\Name\FullyQualified(\Kiboko\Component\Bucket\ComplexResultBucket::class)
)
)
),
Expand Down Expand Up @@ -126,7 +126,7 @@ class: new Node\Stmt\Class_(
name: null,
subNodes: [
'implements' => [
new Node\Name\FullyQualified(name: 'Kiboko\\Contract\\Pipeline\\TransformerInterface'),
new Node\Name\FullyQualified(name: \Kiboko\Contract\Pipeline\TransformerInterface::class),
],
'stmts' => [
new Node\Stmt\ClassMethod(
Expand All @@ -136,12 +136,12 @@ class: new Node\Stmt\Class_(
'params' => [
new Node\Param(
var: new Node\Expr\Variable('client'),
type: new Node\Name\FullyQualified(name: 'Akeneo\\Pim\\ApiClient\\AkeneoPimClientInterface'),
type: new Node\Name\FullyQualified(name: \Akeneo\Pim\ApiClient\AkeneoPimClientInterface::class),
flags: Node\Stmt\Class_::MODIFIER_PUBLIC,
),
new Node\Param(
var: new Node\Expr\Variable('logger'),
type: new Node\Name\FullyQualified(name: 'Psr\\Log\\LoggerInterface'),
type: new Node\Name\FullyQualified(name: \Psr\Log\LoggerInterface::class),
flags: Node\Stmt\Class_::MODIFIER_PUBLIC,
),
],
Expand Down Expand Up @@ -170,7 +170,7 @@ class: new Node\Stmt\Class_(
),
args: [
new Node\Arg(value: $this->client),
new Node\Arg(value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified('Psr\\Log\\NullLogger'))),
new Node\Arg(value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified(\Psr\Log\NullLogger::class))),
],
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Builder/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class: new Node\Stmt\Class_(
name: null,
subNodes: [
'implements' => [
new Node\Name\FullyQualified(name: 'Kiboko\\Contract\\Pipeline\\ExtractorInterface'),
new Node\Name\FullyQualified(name: \Kiboko\Contract\Pipeline\ExtractorInterface::class),
],
'stmts' => [
new Node\Stmt\ClassMethod(
Expand All @@ -59,12 +59,12 @@ class: new Node\Stmt\Class_(
'params' => [
new Node\Param(
var: new Node\Expr\Variable('client'),
type: new Node\Name\FullyQualified(name: 'Akeneo\\Pim\\ApiClient\\AkeneoPimClientInterface'),
type: new Node\Name\FullyQualified(name: \Akeneo\Pim\ApiClient\AkeneoPimClientInterface::class),
flags: Node\Stmt\Class_::MODIFIER_PUBLIC,
),
new Node\Param(
var: new Node\Expr\Variable('logger'),
type: new Node\Name\FullyQualified(name: 'Psr\\Log\\LoggerInterface'),
type: new Node\Name\FullyQualified(name: \Psr\Log\LoggerInterface::class),
flags: Node\Stmt\Class_::MODIFIER_PUBLIC,
),
],
Expand Down Expand Up @@ -215,7 +215,7 @@ class: new Node\Stmt\Class_(
),
args: [
new Node\Arg(value: $this->client),
new Node\Arg(value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified('Psr\\Log\\NullLogger'))),
new Node\Arg(value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified(\Psr\Log\NullLogger::class))),
],
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Builder/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class: new Node\Stmt\Class_(
name: null,
subNodes: [
'implements' => [
new Node\Name\FullyQualified(name: 'Kiboko\\Contract\\Pipeline\\LoaderInterface'),
new Node\Name\FullyQualified(name: \Kiboko\Contract\Pipeline\LoaderInterface::class),
],
'stmts' => [
new Node\Stmt\ClassMethod(
Expand All @@ -59,12 +59,12 @@ class: new Node\Stmt\Class_(
'params' => [
new Node\Param(
var: new Node\Expr\Variable('client'),
type: new Node\Name\FullyQualified(name: 'Akeneo\\Pim\\ApiClient\\AkeneoPimClientInterface'),
type: new Node\Name\FullyQualified(name: \Akeneo\Pim\ApiClient\AkeneoPimClientInterface::class),
flags: Node\Stmt\Class_::MODIFIER_PUBLIC,
),
new Node\Param(
var: new Node\Expr\Variable('logger'),
type: new Node\Name\FullyQualified(name: 'Psr\\Log\\LoggerInterface'),
type: new Node\Name\FullyQualified(name: \Psr\Log\LoggerInterface::class),
flags: Node\Stmt\Class_::MODIFIER_PUBLIC,
),
],
Expand Down Expand Up @@ -136,7 +136,7 @@ class: new Node\Stmt\Class_(
),
args: [
new Node\Arg(value: $this->client),
new Node\Arg(value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified('Psr\\Log\\NullLogger'))),
new Node\Arg(value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified(\Psr\Log\NullLogger::class))),
],
);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Builder/Lookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class: new Node\Stmt\Class_(
name: null,
subNodes: [
'implements' => [
new Node\Name\FullyQualified(name: 'Kiboko\\Contract\\Pipeline\\TransformerInterface'),
new Node\Name\FullyQualified(name: \Kiboko\Contract\Pipeline\TransformerInterface::class),
],
'stmts' => [
new Node\Stmt\ClassMethod(
Expand All @@ -71,12 +71,12 @@ class: new Node\Stmt\Class_(
'params' => [
new Node\Param(
var: new Node\Expr\Variable('client'),
type: new Node\Name\FullyQualified(name: 'Akeneo\\Pim\\ApiClient\\AkeneoPimClientInterface'),
type: new Node\Name\FullyQualified(name: \Akeneo\Pim\ApiClient\AkeneoPimClientInterface::class),
flags: Node\Stmt\Class_::MODIFIER_PUBLIC,
),
new Node\Param(
var: new Node\Expr\Variable('logger'),
type: new Node\Name\FullyQualified(name: 'Psr\\Log\\LoggerInterface'),
type: new Node\Name\FullyQualified(name: \Psr\Log\LoggerInterface::class),
flags: Node\Stmt\Class_::MODIFIER_PUBLIC,
),
],
Expand Down Expand Up @@ -107,7 +107,7 @@ class: new Node\Stmt\Class_(
expr: new Node\Expr\Assign(
var: new Node\Expr\Variable('bucket'),
expr: new Node\Expr\New_(
new Node\Name\FullyQualified('Kiboko\Component\Bucket\ComplexResultBucket')
new Node\Name\FullyQualified(\Kiboko\Component\Bucket\ComplexResultBucket::class)
)
)
),
Expand All @@ -122,7 +122,7 @@ class: new Node\Stmt\Class_(
),
args: [
new Node\Arg(value: $this->client),
new Node\Arg(value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified('Psr\\Log\\NullLogger'))),
new Node\Arg(value: $this->logger ?? new Node\Expr\New_(new Node\Name\FullyQualified(\Psr\Log\NullLogger::class))),
],
);
}
Expand Down
1 change: 0 additions & 1 deletion src/Capacity/Extractor/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use PhpParser\Node;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

use function Kiboko\Component\SatelliteToolbox\Configuration\compileValue;
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValueWhenExpression;

final class All implements Akeneo\Capacity\CapacityInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Capacity/Lookup/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ private function compileFilters(array ...$filters): Node\Expr
public function getBuilder(array $config): Builder
{
$builder = (new Akeneo\Builder\Capacity\Lookup\All())
->withType((string) $config['type'])
->withEndpoint(new Node\Identifier(sprintf('get%sApi', ucfirst((string) $config['type']))))
->withType($config['type'])
;

if (isset($config['search']) && \is_array($config['search'])) {
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ public function getConfigTreeBuilder(): \Symfony\Component\Config\Definition\Bui
->validate()
->ifNotInArray(array_keys(self::$endpoints))
->thenInvalid(
sprintf('the value should be one of [%s]', implode(', ', array_keys(self::$endpoints)))
)
sprintf('the value should be one of [%s]', implode(', ', array_keys(self::$endpoints)))
)
->end()
->end()
->scalarNode('method')->end()
Expand Down

0 comments on commit 940910b

Please sign in to comment.