Skip to content

Commit 127968c

Browse files
committed
Apply rectorphp and php-cs-fixer to example and test
1 parent 261b0b6 commit 127968c

File tree

12 files changed

+21
-40
lines changed

12 files changed

+21
-40
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
## [Unreleased]
1616

17-
1817
### Added
1918

2019
* Added rector

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ After code changes, please run:
158158
```bash
159159
composer check
160160
./vendor/bin/rector process
161+
./vendor/bin/php-cs-fixer fix example
161162
./vendor/bin/php-cs-fixer fix source
163+
./vendor/bin/php-cs-fixer fix test
162164
```
163165

164166
## Links

example/DataFlowManipulator/run.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ class StringProcess implements ExecutableInterface
4444
*/
4545
public function execute($input = null)
4646
{
47-
$input .= PHP_EOL . __METHOD__;
48-
49-
return $input;
47+
return $input . (PHP_EOL . __METHOD__);
5048
}
5149
}
5250

@@ -62,7 +60,6 @@ class DataFlowManipulator implements ExecutableInterface
6260
private $stringProcess;
6361

6462
/**
65-
* @param ArrayProcess $process
6663
* @return $this
6764
*/
6865
public function setArrayProcess(ArrayProcess $process)
@@ -73,7 +70,6 @@ public function setArrayProcess(ArrayProcess $process)
7370
}
7471

7572
/**
76-
* @param StringProcess $process
7773
* @return $this
7874
*/
7975
public function setStringProcess(StringProcess $process)
@@ -92,7 +88,7 @@ public function execute($input = null)
9288
{
9389
if (is_array($input)) {
9490
return $this->arrayProcess->execute($input);
95-
} else if (is_string($input)) {
91+
} elseif (is_string($input)) {
9692
return $this->stringProcess->execute($input);
9793
} else {
9894
throw new ExecutableException('input must be from type of array or string');
@@ -110,6 +106,6 @@ public function execute($input = null)
110106
echo 'string' . PHP_EOL;
111107
echo var_export($output, true) . PHP_EOL;
112108

113-
$output = $pipe->execute(array('Hello World'));
109+
$output = $pipe->execute(['Hello World']);
114110
echo 'array' . PHP_EOL;
115111
echo var_export($output, true) . PHP_EOL;

example/FailingExecution/run.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @author stev leibelt <artodeto@bazzline.net>
4-
* @since 2014-11-08
4+
* @since 2014-11-08
55
*/
66

77
namespace Example\FailingExecution;
@@ -35,10 +35,9 @@ class ProcessTwo implements ExecutableInterface
3535
{
3636
/**
3737
* @param mixed $input
38-
* @return mixed
3938
* @throws \Net\Bazzline\Component\ProcessPipe\ExecutableException
4039
*/
41-
public function execute($input = null)
40+
public function execute($input = null): never
4241
{
4342
throw new ExecutableException(__METHOD__ . ' has failed');
4443
}

example/InputArray/run.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @author stev leibelt <artodeto@bazzline.net>
4-
* @since 2014-11-08
4+
* @since 2014-11-08
55
*/
66

77
namespace Example\InputArray;
@@ -51,11 +51,7 @@ public function execute($input = null)
5151
}
5252
}
5353

54-
$input = array(
55-
'name' => 'foo',
56-
'steps' => array(),
57-
'times' => array()
58-
);
54+
$input = ['name' => 'foo', 'steps' => [], 'times' => []];
5955
$pipe = new Pipe();
6056

6157
$pipe->pipe(

example/InputGenerator/run.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @author stev leibelt <artodeto@bazzline.net>
4-
* @since 2014-11-08
4+
* @since 2014-11-08
55
*/
66

77
namespace Example\InputGenerator;
@@ -23,14 +23,7 @@ class DataGeneratorProcess implements ExecutableInterface
2323
*/
2424
public function execute($input = null)
2525
{
26-
$input = array();
27-
$input[] = array(
28-
microtime(true),
29-
'debug',
30-
'new generated log data'
31-
);
32-
33-
return $input;
26+
return [[microtime(true), 'debug', 'new generated log data']];
3427
}
3528
}
3629

@@ -46,11 +39,7 @@ class ProcessTwo implements ExecutableInterface
4639
*/
4740
public function execute($input = null)
4841
{
49-
$input[] = array(
50-
microtime(true),
51-
'debug',
52-
'hello world'
53-
);
42+
$input[] = [microtime(true), 'debug', 'hello world'];
5443

5544
return $input;
5645
}

example/InputTransformer/run.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @author stev leibelt <artodeto@bazzline.net>
4-
* @since 2014-11-08
4+
* @since 2014-11-08
55
*/
66

77
namespace Example\InputTransformer;
@@ -29,7 +29,7 @@ public function execute($input = null)
2929
throw new ExecutableException('input must be instance of object');
3030
}
3131

32-
$array = array();
32+
$array = [];
3333

3434
foreach (get_object_vars($input) as $property => $value) {
3535
$array[$property] = $value;

example/InputValidator/run.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class ProcessOne implements ExecutableInterface
2525
*/
2626
public function execute($input = null)
2727
{
28-
$input .= ' ' . __METHOD__;
29-
30-
return $input;
28+
return $input . (' ' . __METHOD__);
3129
}
3230
}
3331

example/NoInput/run.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @author stev leibelt <artodeto@bazzline.net>
4-
* @since 2014-11-08
4+
* @since 2014-11-08
55
*/
66

77
namespace Example\NoInput;

rector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
return RectorConfig::configure()
99
->withPaths([
10-
__DIR__ . '/source'
10+
__DIR__ . '/example',
11+
__DIR__ . '/source',
12+
__DIR__ . '/test'
1113
])
1214
// uncomment to reach your current PHP version
1315
->withPhpSets(php83: true)

0 commit comments

Comments
 (0)