Skip to content

Commit e8e6a64

Browse files
Format
1 parent c744f5e commit e8e6a64

File tree

4 files changed

+22
-29
lines changed

4 files changed

+22
-29
lines changed

rector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
66
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
77
use Rector\Config\RectorConfig;
8+
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
89
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
910
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
1011
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
@@ -47,4 +48,7 @@
4748
ClosureToArrowFunctionRector::class,
4849
FirstClassCallableRector::class,
4950
NewlineAfterStatementRector::class,
51+
RemoveUnusedPrivateMethodRector::class => [
52+
__DIR__.'/tests/MethodsTest.php',
53+
],
5054
]);

src/Pipe.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66

77
class Pipe
88
{
9-
protected mixed $value;
10-
11-
public function __construct(mixed $value)
9+
public function __construct(protected mixed $value)
1210
{
13-
$this->value = $value;
14-
1511
if (! defined('PIPED_VALUE')) {
1612
define('PIPED_VALUE', 'PIPED_VALUE-'.uniqid('', true));
1713
}

src/PipeProxy.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@
88

99
class PipeProxy
1010
{
11-
protected Pipe $item;
12-
protected object $object;
13-
14-
public function __construct(Pipe $item, object $object)
15-
{
16-
$this->item = $item;
17-
$this->object = $object;
18-
}
11+
public function __construct(protected Pipe $item, protected object $object) {}
1912

2013
public function __call(string $method, array $arguments): Pipe
2114
{

tests/MethodsTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function it can transform a value using a closure(): void
8888
$this->assertSame(
8989
'prefixed-string',
9090
take('string')
91-
->pipe(function (string $value) {
91+
->pipe(function (string $value): string {
9292
return 'prefixed-'.$value;
9393
})
9494
->get()
@@ -147,6 +147,11 @@ public function it can transform a value using a proxied public class 
147147
);
148148
}
149149

150+
public function uppercase(string $value): string
151+
{
152+
return mb_strtoupper($value);
153+
}
154+
150155
/**
151156
* @test
152157
*/
@@ -174,6 +179,16 @@ public function it can transform a value using a proxied private class
174179
);
175180
}
176181

182+
private function lowercase(string $value): string
183+
{
184+
return mb_strtolower($value);
185+
}
186+
187+
private function join(string ...$values): string
188+
{
189+
return implode('-', $values);
190+
}
191+
177192
/**
178193
* @test
179194
*/
@@ -199,19 +214,4 @@ public function it can transform a value while accepting pipe parameters
199214
->get()
200215
);
201216
}
202-
203-
public function uppercase(string $value): string
204-
{
205-
return mb_strtoupper($value);
206-
}
207-
208-
private function lowercase(string $value): string
209-
{
210-
return mb_strtolower($value);
211-
}
212-
213-
private function join(string ...$values): string
214-
{
215-
return implode('-', $values);
216-
}
217217
}

0 commit comments

Comments
 (0)