Skip to content

Commit b2581d4

Browse files
committed
wippity wip
1 parent 91e3219 commit b2581d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+698
-607
lines changed

app/Commands/CompileBinaryCommand.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace App\Commands;
44

5-
use App\Parser\Walker;
65
use Illuminate\Support\Facades\File;
76
use Illuminate\Support\Facades\Process;
87
use LaravelZero\Framework\Commands\Command;
@@ -32,7 +31,6 @@ public function handle(): void
3231
confirm('Continue?', true);
3332
}
3433

35-
3634
$extensions = collect([
3735
'bcmath',
3836
'calendar',

app/Commands/DetectCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Commands;
44

55
use App\Parser\DetectWalker;
6-
use App\Parser\Walker;
76
use Illuminate\Support\Facades\File;
87
use LaravelZero\Framework\Commands\Command;
98

@@ -23,7 +22,7 @@ public function handle(): void
2322

2423
// file_put_contents(__DIR__ . '/code.txt', $this->argument('code'));
2524

26-
$walker = new DetectWalker($code, !!$this->option('debug'));
25+
$walker = new DetectWalker($code, (bool) $this->option('debug'));
2726
$result = $walker->walk();
2827

2928
if (app()->isLocal()) {

app/Commands/ParseCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function handle(): void
2020
$code = file_get_contents(__DIR__ . '/../../tests/snippets/parse/' . $this->option('from-file') . '.php');
2121
}
2222

23-
$walker = new Walker($code, !!$this->option('debug'));
23+
$walker = new Walker($code, (bool) $this->option('debug'));
2424
$result = $walker->walk();
2525

2626
if (app()->isLocal()) {

app/Contexts/AbstractContext.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function initNew(AbstractContext $newContext)
4444
return $newContext;
4545
}
4646

47-
public function searchForVar(string $name): AssignmentValue | string | null
47+
public function searchForVar(string $name): AssignmentValue|string|null
4848
{
4949
if ($this instanceof ClosureValue) {
5050
foreach ($this->parameters->children as $param) {
@@ -63,6 +63,15 @@ public function searchForVar(string $name): AssignmentValue | string | null
6363
return $this->parent?->searchForVar($name) ?? null;
6464
}
6565

66+
public function searchForProperty(string $name)
67+
{
68+
if ($this instanceof ClassDefinition) {
69+
return collect($this->properties)->first(fn ($prop) => $prop['name'] === $name);
70+
}
71+
72+
return $this->parent?->searchForProperty($name) ?? null;
73+
}
74+
6675
public function pristine(): bool
6776
{
6877
return $this->freshObject === $this->freshArray();
@@ -80,7 +89,7 @@ public function toArray(): array
8089
$this->autocompleting ? ['autocompleting' => true] : [],
8190
$this->castToArray(),
8291
($this->label !== '') ? ['label' => $this->label] : [],
83-
($this->hasChildren) ? ['children' => array_map(fn($child) => $child->toArray(), $this->children)] : [],
92+
($this->hasChildren) ? ['children' => array_map(fn ($child) => $child->toArray(), $this->children)] : [],
8493
);
8594
}
8695

app/Contexts/ArrayItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function toArray(): array
2323
public function castToArray(): array
2424
{
2525
return [
26-
'key' => $this->getKey()?->toArray(),
26+
'key' => $this->getKey()?->toArray(),
2727
'value' => $this->getValue()?->toArray(),
2828

2929
] + $this->getAutoCompletingValueData();

app/Contexts/ArrayValue.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,26 @@ protected function extraData(): array
2222

2323
if (count($this->children) === 0) {
2424
return [
25-
'autocompletingKey' => true,
25+
'autocompletingKey' => true,
2626
'autocompletingValue' => true,
2727
];
2828
}
2929

3030
$valueToAutocomplete = collect($this->children)->first(
31-
fn($child) => $child->toArray()['autocompletingValue'] ?? false,
31+
fn ($child) => $child->toArray()['autocompletingValue'] ?? false,
3232
);
3333

3434
if ($valueToAutocomplete) {
3535
return [
36-
'autocompletingKey' => false,
36+
'autocompletingKey' => false,
3737
'autocompletingValue' => true,
3838
];
3939
}
4040

4141
$firstChild = $this->children[0];
4242

4343
return [
44-
'autocompletingKey' => $firstChild->hasKey,
44+
'autocompletingKey' => $firstChild->hasKey,
4545
'autocompletingValue' => !$firstChild->hasKey,
4646
];
4747
}

app/Contexts/Assignment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function type(): string
2323
public function castToArray(): array
2424
{
2525
return [
26-
'name' => $this->name,
26+
'name' => $this->name,
2727
'value' => $this->value->toArray(),
2828
];
2929
}

app/Contexts/Base.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class Base extends AbstractContext
66
{
7-
87
public function type(): string
98
{
109
return 'base';

app/Contexts/ClassDefinition.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class ClassDefinition extends AbstractContext
1010

1111
public array $implements = [];
1212

13+
public array $properties = [];
14+
1315
public function type(): string
1416
{
1517
return 'classDefinition';
@@ -18,9 +20,10 @@ public function type(): string
1820
public function castToArray(): array
1921
{
2022
return [
21-
'name' => $this->name,
22-
'extends' => $this->extends,
23+
'name' => $this->name,
24+
'extends' => $this->extends,
2325
'implements' => $this->implements,
26+
'properties' => $this->properties,
2427
];
2528
}
2629
}

app/Contexts/ClosureValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ClosureValue extends AbstractContext implements HasParameters
1010

1111
public function init()
1212
{
13-
$this->parameters = new Parameters();
13+
$this->parameters = new Parameters;
1414
}
1515

1616
public function type(): string

0 commit comments

Comments
 (0)