Skip to content

Commit eac7335

Browse files
committed
wip
1 parent e32e819 commit eac7335

7 files changed

+23
-22
lines changed

Diff for: app/Commands/CompileBinaryCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CompileBinaryCommand extends Command
1313
{
1414
protected $signature = 'compile-binary';
1515

16-
protected $description = 'Parse the given PHP code';
16+
protected $description = 'Compile the binary for the current version';
1717

1818
public function handle(): void
1919
{

Diff for: app/Commands/ContextTypeScriptGeneratorCommand.php

+11-17
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
namespace App\Commands;
44

5-
use App\Parser\DetectWalker;
6-
use Illuminate\Support\Facades\File;
75
use LaravelZero\Framework\Commands\Command;
86

9-
use function Laravel\Prompts\info;
10-
117
class ContextTypeScriptGeneratorCommand extends Command
128
{
139
protected $signature = 'generate-ts';
@@ -19,9 +15,9 @@ public function handle(): void
1915
$this->line('namespace AutocompleteParsingResult {');
2016

2117
$classes = collect(glob(base_path('app/Contexts/*.php')))
22-
->filter(fn($file) => !str_contains($file, 'Abstract'));
18+
->filter(fn ($file) => !str_contains($file, 'Abstract'));
2319

24-
$this->line("type Result = " . $classes->map(fn($file) => pathinfo($file, PATHINFO_FILENAME))->join(' | ') . ';');
20+
$this->line('type Result = ' . $classes->map(fn ($file) => pathinfo($file, PATHINFO_FILENAME))->join(' | ') . ';');
2521

2622
$this->newLine();
2723

@@ -36,34 +32,32 @@ public function handle(): void
3632
$reflection = new \ReflectionClass($inst);
3733

3834
$this->line("type: '{$inst->type()}';");
39-
$this->line("parent: Result | null;");
35+
$this->line('parent: Result | null;');
4036

4137
if ($reflection->getProperty('hasChildren')->getValue($inst)) {
42-
$this->line("children: Result[];");
38+
$this->line('children: Result[];');
4339
}
4440

4541
$properties = collect($reflection->getProperties(\ReflectionProperty::IS_PUBLIC))
46-
->filter(fn($prop) => !in_array($prop->getName(), [
42+
->filter(fn ($prop) => !in_array($prop->getName(), [
4743
'children',
4844
'autocompleting',
4945
'freshObject',
5046
'hasChildren',
5147
'parent',
52-
'label'
48+
'label',
5349
]))
54-
->map(fn($prop) => [
55-
'name' => $prop->getName(),
56-
'type' => str_replace('App\Contexts\\', '', $prop->getType()?->getName() ?? 'any'),
57-
'default' => $prop->getValue($inst)
50+
->map(fn ($prop) => [
51+
'name' => $prop->getName(),
52+
'type' => str_replace('App\Contexts\\', '', $prop->getType()?->getName() ?? 'any'),
53+
'default' => $prop->getValue($inst),
5854
])
5955
->each(function ($prop) {
6056
$addon = ($prop['default'] === null) ? ' | null' : '';
6157
$this->line("{$prop['name']}: {$prop['type']}{$addon};");
6258
});
6359

64-
65-
66-
$this->line("}");
60+
$this->line('}');
6761
$this->newLine();
6862
});
6963

Diff for: app/Contexts/Argument.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function isAutoCompleting(): bool
2525
}
2626

2727
return collect($this->children)->first(
28-
fn($child) => $child->autocompleting
28+
fn ($child) => $child->autocompleting
2929
) !== null;
3030
}
3131
}

Diff for: app/Parser/DetectWalker.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function walk(?Node $node = null)
7575
}
7676

7777
// TODO: These results are not unique maybe?
78-
return collect($this->items)->unique(fn($item) => json_encode($item))->values();
78+
return collect($this->items)->unique(fn ($item) => json_encode($item))->values();
7979
}
8080

8181
protected function parsePotentialBlade(InlineHtml $node)
@@ -421,7 +421,7 @@ protected function parseArgument($argument)
421421
return [
422422
'type' => 'string',
423423
'value' => $argument->getStringContentsText(),
424-
'name' => $argument->parent instanceof ArgumentExpression ? $argument->parent->name?->getText($this->sourceFile->getFullText()) : null,
424+
'name' => $argument->parent instanceof ArgumentExpression ? $argument->parent->name?->getText($this->sourceFile->getFullText()) : null,
425425
'start' => [
426426
'line' => $range->start->line,
427427
'column' => $range->start->character,

Diff for: app/Parsers/ArgumentExpressionParser.php

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use App\Contexts\AbstractContext;
66
use App\Contexts\Argument;
7-
use App\Contexts\MethodCall;
87
use Microsoft\PhpParser\Node\Expression\ArgumentExpression;
98

109
class ArgumentExpressionParser extends AbstractParser

Diff for: bin/php-parser-0.1.1

16.9 KB
Binary file not shown.

Diff for: pint.json

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"preset": "laravel",
3+
"exclude": [
4+
"bin",
5+
"source",
6+
"downloads",
7+
"builds",
8+
"buildroot",
9+
"tests/snippets"
10+
],
311
"rules": {
412
"concat_space": {
513
"spacing": "one"

0 commit comments

Comments
 (0)