refactor: Cleanup git state - commit all staged changes

Major refactoring cleanup:
- Add new controller architecture (class-controller-*.php)
- Add new settings-v2 UI (views/settings-v2/)
- Add new CSS architecture (agentic-sidebar.css, tokens)
- Add esbuild build pipeline (scripts/build.js, package.json)
- Add composer dependencies (vendor/)
- Add frontend src directory (assets/js/src/index.jsx)
- Add documentation files
- Remove old/obsolete files (class-settings.php, old CSS)

This commits all pending changes from previous refactoring efforts.
This commit is contained in:
Dwindi Ramadhana
2026-06-17 05:27:58 +07:00
parent d3f142222c
commit 690991c526
7963 changed files with 941566 additions and 67372 deletions

View File

@@ -0,0 +1,276 @@
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link https://phpdoc.org
*/
namespace phpDocumentor\JsonPath;
use phpDocumentor\JsonPath\AST\Comparison;
use phpDocumentor\JsonPath\AST\CurrentNode;
use phpDocumentor\JsonPath\AST\FieldAccess;
use phpDocumentor\JsonPath\AST\FieldName;
use phpDocumentor\JsonPath\AST\FilterNode;
use phpDocumentor\JsonPath\AST\FunctionCall;
use phpDocumentor\JsonPath\AST\Path;
use phpDocumentor\JsonPath\AST\RootNode;
use phpDocumentor\JsonPath\AST\Value;
use phpDocumentor\JsonPath\AST\Wildcard;
use phpDocumentor\JsonPath\Fixtures\Book;
use phpDocumentor\JsonPath\Fixtures\Commic;
use phpDocumentor\JsonPath\Fixtures\Store;
use PHPUnit\Framework\TestCase;
use stdClass;
use function iterator_to_array;
final class ExecutorTest extends TestCase
{
public function testQueryRootSource(): void
{
$store = new Store();
$executor = new Executor();
$result = $executor->evaluate(
new Path(
[
new RootNode(),
new FieldAccess(new FieldName('store')),
],
),
['store' => $store],
);
self::assertSame([$store], iterator_to_array($result, false));
}
public function testQueryRootSourceObject(): void
{
$root = new stdClass();
$store = new Store();
$root->store = $store;
$executor = new Executor();
$result = $executor->evaluate(
new Path(
[
new RootNode(),
new FieldAccess(new FieldName('store')),
],
),
$root,
);
self::assertSame([$store], iterator_to_array($result));
}
public function testQuerySubProperty(): void
{
$root = new stdClass();
$store = new Store();
$store->addBook(new Book('First book'));
$store->addBook(new Book('Second book'));
$root->store = $store;
$executor = new Executor();
$result = $executor->evaluate(
new Path(
[
new RootNode(),
new FieldAccess(new FieldName('store')),
new FieldAccess(new FieldName('books')),
new FieldAccess(new Wildcard()),
],
),
$root,
);
self::assertSame($store->getBooks(), iterator_to_array($result, false));
}
public function testQuerySubPropertyByFilter(): void
{
$book = new Book('phpDoc');
$root = new stdClass();
$store = new Store();
$store->addBook(new Book('First book'));
$store->addBook($book);
$store->addBook(new Book('Second book'));
$root->store = $store;
$executor = new Executor();
$result = $executor->evaluate(
new Path(
[
new RootNode(),
new FieldAccess(new FieldName('store')),
new FieldAccess(new FieldName('books')),
new FieldAccess(new Wildcard()),
new FilterNode(
new Comparison(
new Path([
new CurrentNode(),
new FieldAccess(new FieldName('title')),
]),
'==',
new Value(
'phpDoc',
),
),
),
],
),
$root,
);
self::assertSame([$book], iterator_to_array($result, false));
}
public function testQuerySubPropertyByFilterFunctionCall(): void
{
$book = new Commic('phpDoc');
$root = new stdClass();
$store = new Store();
$store->addBook(new Book('First book'));
$store->addBook($book);
$store->addBook(new Book('Second book'));
$root->store = $store;
$executor = new Executor();
$result = $executor->evaluate(
new Path(
[
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('books'),
),
new FieldAccess(
new Wildcard(),
),
new FilterNode(
new Comparison(
new FunctionCall(
'type',
new Path([
new CurrentNode(),
]),
),
'==',
new Value(
'Commic',
),
),
),
],
),
$root,
);
self::assertSame([$book], iterator_to_array($result, false));
}
public function testQueryWithWildcard(): void
{
$books = [
'phpDoc',
'First book',
'Second book',
];
$root = new stdClass();
$root->store = $this->createStore($books);
$executor = new Executor();
$result = $executor->evaluate(
new Path(
[
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('books'),
),
new FilterNode(
new Wildcard(),
),
new FieldAccess(
new FieldName('title'),
),
],
),
$root,
);
self::assertSame($books, iterator_to_array($result, false));
}
public function testQueryCollectionInCollection(): void
{
$books = [
'phpDoc',
'First book',
'Second book',
];
$root = new stdClass();
$root->stores = [];
$root->stores[] = $this->createStore($books);
$root->stores[] = $this->createStore(['foo', 'bar']);
$root->stores[] = $this->createStore($books);
$executor = new Executor();
$result = $executor->evaluate(
new Path(
[
new RootNode(),
new FieldAccess(
new FieldName('stores'),
),
new FilterNode(
new Wildcard(),
),
new FieldAccess(
new FieldName('books'),
),
new FilterNode(
new Comparison(
new Path([
new CurrentNode(),
new FieldAccess(new FieldName('title')),
]),
'==',
new Value(
'phpDoc',
),
),
),
new FieldAccess(
new FieldName('title'),
),
],
),
$root,
);
self::assertEquals(['phpDoc', 'phpDoc'], iterator_to_array($result, false));
}
private function createStore(array $books): Store
{
$store = new Store();
foreach ($books as $title) {
$store->addBook(new Book($title));
}
return $store;
}
}

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link https://phpdoc.org
*/
namespace phpDocumentor\JsonPath\Fixtures;
class Book
{
public function __construct(private readonly string $title)
{
}
public function getTitle(): string
{
return $this->title;
}
}

View File

@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link https://phpdoc.org
*/
namespace phpDocumentor\JsonPath\Fixtures;
class Commic extends Book
{
}

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link https://phpdoc.org
*/
namespace phpDocumentor\JsonPath\Fixtures;
class Store
{
/** @var Book[] */
private array $books = [];
public function __construct()
{
}
public function getAddress(): string
{
return 'My Address';
}
public function addBook(Book $book): void
{
$this->books[] = $book;
}
public function getBooks(): array
{
return $this->books;
}
}

View File

@@ -0,0 +1,282 @@
<?php
declare(strict_types=1);
/**
* This file is part of phpDocumentor.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @link https://phpdoc.org
*/
namespace phpDocumentor\JsonPath\Parser;
use Generator;
use Parsica\Parsica\Parser;
use phpDocumentor\JsonPath\AST\Comparison;
use phpDocumentor\JsonPath\AST\CurrentNode;
use phpDocumentor\JsonPath\AST\FieldAccess;
use phpDocumentor\JsonPath\AST\FieldName;
use phpDocumentor\JsonPath\AST\FilterNode;
use phpDocumentor\JsonPath\AST\FunctionCall;
use phpDocumentor\JsonPath\AST\Path;
use phpDocumentor\JsonPath\AST\RootNode;
use phpDocumentor\JsonPath\AST\Value;
use phpDocumentor\JsonPath\AST\Wildcard;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class ParserBuilderTest extends TestCase
{
private Parser $parser;
protected function setUp(): void
{
$this->parser = (new ParserBuilder())->build();
}
public function testRootNodeIsParsed(): void
{
$result = $this->parser->tryString('$');
self::assertEquals(new RootNode(), $result->output());
}
public function testCurrentNodeIsParsed(): void
{
$result = $this->parser->tryString('@');
self::assertEquals(new CurrentNode(), $result->output());
}
public function testCurrentNodeChildren(): void
{
$result = $this->parser->tryString('@.*');
self::assertEquals(new Path([new CurrentNode(), new FieldAccess(new Wildcard())]), $result->output());
}
public function testRootFieldAccess(): void
{
$result = $this->parser->tryString('$.store');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
]),
$result->output(),
);
}
public function testRootFieldAccessArrayLike(): void
{
$result = $this->parser->tryString('$[\'store\']');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
]),
$result->output(),
);
}
public function testRootFieldChildAccess(): void
{
$result = $this->parser->tryString('$.store.address');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('address'),
),
]),
$result->output(),
);
}
#[DataProvider('operatorProvider')]
public function testFilterExpression(string $operator): void
{
$result = $this->parser->tryString('$.store.books[?(@.title ' . $operator . ' "phpDoc")]');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('books'),
),
new FilterNode(
new Comparison(
new Path([
new CurrentNode(),
new FieldAccess(new FieldName('title')),
]),
$operator,
new Value(
'phpDoc',
),
),
),
]),
$result->output(),
);
}
/** @return Generator<string, string> */
public static function operatorProvider(): Generator
{
$operators = [
'==',
'!=',
'starts_with',
];
foreach ($operators as $operator) {
yield $operator => [$operator];
}
}
public function testFilterExpressionCurrentObjectProperyWildCard(): void
{
$result = $this->parser->tryString('$.store.books[?(@.* == "phpDoc")]');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('books'),
),
new FilterNode(
new Comparison(
new Path([
new CurrentNode(),
new FieldAccess(new Wildcard()),
]),
'==',
new Value(
'phpDoc',
),
),
),
]),
$result->output(),
);
}
public function testFilterExpressionCurrentObjectTypeEquals(): void
{
$result = $this->parser->tryString('$.store.books[?(type(@) == "api")]');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('books'),
),
new FilterNode(
new Comparison(
new FunctionCall(
'type',
new CurrentNode(),
),
'==',
new Value(
'api',
),
),
),
]),
$result->output(),
);
}
public function testFilterExpressionCurrentObjectChildrenTypeEquals(): void
{
$result = $this->parser->tryString('$.store.books[?(type(@.*) == "api")]');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('books'),
),
new FilterNode(
new Comparison(
new FunctionCall(
'type',
new Path([
new CurrentNode(),
new FieldAccess(new Wildcard()),
]),
),
'==',
new Value(
'api',
),
),
),
]),
$result->output(),
);
}
public function testFilterExpressionWildcard(): void
{
$result = $this->parser->tryString('$.store.books_title[*]');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('books_title'),
),
new FilterNode(
new Wildcard(),
),
]),
$result->output(),
);
}
public function testFilterExpressionWildcardNested(): void
{
$result = $this->parser->tryString('$.store.books_title.*[*]');
self::assertEquals(
new Path([
new RootNode(),
new FieldAccess(
new FieldName('store'),
),
new FieldAccess(
new FieldName('books_title'),
),
new FieldAccess(
new Wildcard(),
),
new FilterNode(
new Wildcard(),
),
]),
$result->output(),
);
}
}