Skip to content

Commit 2f320ba

Browse files
committed
simplify fixture
1 parent dc96123 commit 2f320ba

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

rules-tests/Php85/Rector/FuncCall/ArrayKeyExistsNullToEmptyStringRector/Fixture/skip_defined_int_or_string.php.inc

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,19 @@ namespace Rector\Tests\Php85\Rector\FuncCall\ArrayKeyExistsNullToEmptyStringRect
55
final class SkipDefinedIntOrString
66
{
77
/**
8-
* @var array<int, array{unique_key: int|string, label: string}>
8+
* @var array<string|int, bool>
99
*/
10-
private array $todos = [
11-
0 => [
12-
'unique_key' => 1,
13-
'label' => 'test 1',
14-
],
15-
1 => [
16-
'unique_key' => 'fallback_todo',
17-
'label' => 'fallback todo 1',
18-
],
10+
private array $shownTodos = [
11+
0 => false,
12+
'fallback_todo' => true,
1913
];
2014

21-
/**
22-
* @var array<int|string, string>
23-
*/
24-
public array $selectedTodos = [];
25-
26-
public function run(int $index): string
15+
public function run(string|int $index): void
2716
{
28-
if (!array_key_exists($index, $this->todos)) {
29-
return 'Todo not found';
30-
}
31-
32-
if (!array_key_exists($this->todos[$index]['unique_key'], $this->selectedTodos)) {
33-
$this->selectedTodos[$this->todos[$index]['unique_key']] = $this->todos[$index]['label'];
34-
return 'Todo selected !';
17+
if (! array_key_exists($index, $this->shownTodos)) {
18+
return;
3519
}
3620

37-
return 'Todo already selected !';
21+
$this->shownTodos[$index] = true;
3822
}
3923
}

0 commit comments

Comments
 (0)