Skip to content

Commit afcc0a5

Browse files
committed
Removed default value for nonstandard field + ran php-cs-fixer
1 parent 3a304d5 commit afcc0a5

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

src/Builder/Loader.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Kiboko\Plugin\CSV\Builder;
66

77
use Kiboko\Contract\Configurator\StepBuilderInterface;
8-
use PhpParser\Builder\Method;
98
use PhpParser\Node;
109

1110
final class Loader implements StepBuilderInterface
@@ -102,7 +101,7 @@ public function getNode(): Node
102101
$arguments = [
103102
new Node\Arg(
104103
value: new Node\Expr\New_(
105-
class: $this->withNonStandard === true ?
104+
class: true === $this->withNonStandard ?
106105
new Node\Stmt\Class_(
107106
name: 'SplFileObject',
108107
subNodes: [
@@ -137,9 +136,11 @@ class: $this->withNonStandard === true ?
137136
type: 'string',
138137
),
139138
],
140-
'returnType' => new Node\Expr\BinaryOp\LogicalXor(
141-
left: new Node\Expr\ConstFetch(new Node\Name('int')),
142-
right: new Node\Expr\ConstFetch(new Node\Name('false')),
139+
'returnType' => new Node\UnionType(
140+
types: [
141+
new Node\Name('int'),
142+
new Node\Name('false'),
143+
],
143144
),
144145
'stmts' => [
145146
new Node\Stmt\Return_(
@@ -148,8 +149,8 @@ class: $this->withNonStandard === true ?
148149
name: 'fwrite',
149150
args: [
150151
new Node\Arg(
151-
value: new Node\Expr\AssignOp\Concat(
152-
var: new Node\Expr\FuncCall(
152+
value: new Node\Expr\BinaryOp\Concat(
153+
left: new Node\Expr\FuncCall(
153154
name: new Node\Name('implode'),
154155
args: [
155156
new Node\Arg(
@@ -160,7 +161,7 @@ class: $this->withNonStandard === true ?
160161
),
161162
],
162163
),
163-
expr: new Node\Expr\Variable('eol')
164+
right: new Node\Expr\Variable('eol')
164165
),
165166
),
166167
],

src/Builder/MultipleFilesLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function getNode(): Node
110110
$arguments = [
111111
new Node\Arg(
112112
value: new Node\Expr\New_(
113-
class: $this->withoutEnclosure ? new Node\Name\FullyQualified('GyroscopsGenerated\\SplFileObject') : new Node\Name\FullyQualified('SplFileObject') ,
113+
class: $this->withoutEnclosure ? new Node\Name\FullyQualified('GyroscopsGenerated\\SplFileObject') : new Node\Name\FullyQualified('SplFileObject'),
114114
args: [
115115
new Node\Arg(
116116
value: $this->filePath

src/Configuration/Extractor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
namespace Kiboko\Plugin\CSV\Configuration;
66

7-
use function Kiboko\Component\SatelliteToolbox\Configuration\asExpression;
8-
use function Kiboko\Component\SatelliteToolbox\Configuration\isExpression;
97
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
108
use Symfony\Component\Config\Definition\ConfigurationInterface;
119

10+
use function Kiboko\Component\SatelliteToolbox\Configuration\asExpression;
11+
use function Kiboko\Component\SatelliteToolbox\Configuration\isExpression;
12+
1213
final class Extractor implements ConfigurationInterface
1314
{
1415
public function getConfigTreeBuilder(): TreeBuilder

src/Configuration/Loader.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
namespace Kiboko\Plugin\CSV\Configuration;
66

7-
use function Kiboko\Component\SatelliteToolbox\Configuration\asExpression;
8-
use function Kiboko\Component\SatelliteToolbox\Configuration\isExpression;
97
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
108
use Symfony\Component\Config\Definition\ConfigurationInterface;
9+
10+
use function Kiboko\Component\SatelliteToolbox\Configuration\asExpression;
11+
use function Kiboko\Component\SatelliteToolbox\Configuration\isExpression;
1112
use function Kiboko\Component\SatelliteToolbox\Configuration\mutuallyExclusiveFields;
1213

1314
final class Loader implements ConfigurationInterface
@@ -19,7 +20,7 @@ public function getConfigTreeBuilder(): TreeBuilder
1920
/* @phpstan-ignore-next-line */
2021
$builder->getRootNode()
2122
->beforeNormalization()
22-
->always(mutuallyExclusiveFields('nonstandard', 'enclosure', 'escape'))
23+
->always(mutuallyExclusiveFields('nonstandard', 'enclosure', 'escape'))
2324
->end()
2425
->children()
2526
->scalarNode('file_path')
@@ -65,9 +66,7 @@ public function getConfigTreeBuilder(): TreeBuilder
6566
->thenInvalid('Value cannot be null')
6667
->end()
6768
->end()
68-
->booleanNode('nonstandard')
69-
->defaultFalse()
70-
->end()
69+
->booleanNode('nonstandard')->end()
7170
->end()
7271
;
7372

src/Factory/Extractor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
namespace Kiboko\Plugin\CSV\Factory;
66

7-
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValue;
8-
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValueWhenExpression;
97
use Kiboko\Contract\Configurator;
108
use Kiboko\Plugin\CSV;
119
use Symfony\Component\Config\Definition\ConfigurationInterface;
1210
use Symfony\Component\Config\Definition\Exception as Symfony;
1311
use Symfony\Component\Config\Definition\Processor;
1412
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1513

14+
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValue;
15+
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValueWhenExpression;
16+
1617
final class Extractor implements Configurator\FactoryInterface
1718
{
1819
private Processor $processor;

src/Factory/Loader.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44

55
namespace Kiboko\Plugin\CSV\Factory;
66

7-
use Kiboko\Component\Packaging\Asset\InMemory;
8-
use Kiboko\Component\Packaging\File;
9-
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValue;
10-
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValueWhenExpression;
117
use Kiboko\Contract\Configurator;
128
use Kiboko\Plugin\CSV;
139
use Symfony\Component\Config\Definition\ConfigurationInterface;
1410
use Symfony\Component\Config\Definition\Exception as Symfony;
1511
use Symfony\Component\Config\Definition\Processor;
1612
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
1713

14+
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValue;
15+
use function Kiboko\Component\SatelliteToolbox\Configuration\compileValueWhenExpression;
16+
1817
final class Loader implements Configurator\FactoryInterface
1918
{
2019
private Processor $processor;
@@ -83,7 +82,7 @@ public function compile(array $config): Repository\Loader
8382
}
8483
}
8584

86-
if (array_key_exists('nonstandard', $config) && $config['nonstandard'] === true) {
85+
if (\array_key_exists('nonstandard', $config) && true === $config['nonstandard']) {
8786
$loader->withNonStandard();
8887
}
8988

0 commit comments

Comments
 (0)