From 189493b045ebbadba0bea4a019a1e3a5aebaeb74 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 19 Apr 2026 23:07:48 +0300 Subject: [PATCH] php cs fixer --- app/Node/JsonNodeRepository.php | 2 +- app/Text/JsonTextRepository.php | 2 +- app/View/ViewController.php | 6 +++--- bootstrap/app.php | 2 +- data/seedDb.php | 4 ++-- data/wipeDb.php | 4 ++-- public/index.php | 2 +- tests/Fakes/FakeTextRepository.php | 2 +- tests/Unit/Node/UseCases/BulkCreateNodesTest.php | 4 ++-- tests/Unit/Node/UseCases/CreateNodeTest.php | 4 ++-- tests/Unit/Plan/UseCases/CreatePlanTest.php | 13 +++++++------ .../UseCases/CreateScheduledNodeTest.php | 4 ++-- tests/Unit/Text/UseCases/CreateTextTest.php | 4 ++-- tests/Unit/User/UseCases/CreateUserTest.php | 2 +- .../BulkCreateNodesControllerTest.php | 8 ++++---- tests/e2e/Controllers/NodeControllerTest.php | 16 ++++++++-------- tests/e2e/Controllers/TextControllerTest.php | 8 ++++---- 17 files changed, 44 insertions(+), 43 deletions(-) diff --git a/app/Node/JsonNodeRepository.php b/app/Node/JsonNodeRepository.php index a466bc0..b24a0d8 100644 --- a/app/Node/JsonNodeRepository.php +++ b/app/Node/JsonNodeRepository.php @@ -14,7 +14,7 @@ class JsonNodeRepository implements NodeRepository public function __construct( private TextRepository $textRepository, ) { - $this->filePath = __DIR__.'/../../data/nodes.json'; + $this->filePath = __DIR__ . '/../../data/nodes.json'; } public function create(CreateNodeDto $dto): Node diff --git a/app/Text/JsonTextRepository.php b/app/Text/JsonTextRepository.php index fc8640d..26c5e76 100644 --- a/app/Text/JsonTextRepository.php +++ b/app/Text/JsonTextRepository.php @@ -12,7 +12,7 @@ class JsonTextRepository implements TextRepository public function __construct() { - $this->filePath = __DIR__.'/../../data/texts.json'; + $this->filePath = __DIR__ . '/../../data/texts.json'; } public function create(CreateTextDto $dto): Text diff --git a/app/View/ViewController.php b/app/View/ViewController.php index 580c53e..742b4be 100644 --- a/app/View/ViewController.php +++ b/app/View/ViewController.php @@ -8,7 +8,7 @@ class ViewController { public function admin(Response $response): Response { - $html = file_get_contents(__DIR__.'/../../views/templates/admin.php', true); + $html = file_get_contents(__DIR__ . '/../../views/templates/admin.php', true); $response->getBody()->write($html); return $response; @@ -16,7 +16,7 @@ class ViewController public function texts(Response $response): Response { - $html = file_get_contents(__DIR__.'/../../views/templates/texts.php', true); + $html = file_get_contents(__DIR__ . '/../../views/templates/texts.php', true); $response->getBody()->write($html); return $response; @@ -24,7 +24,7 @@ class ViewController public function text(Response $response): Response { - $html = file_get_contents(__DIR__.'/../../views/templates/text.php', true); + $html = file_get_contents(__DIR__ . '/../../views/templates/text.php', true); $response->getBody()->write($html); return $response; diff --git a/bootstrap/app.php b/bootstrap/app.php index 4f98720..6dfce21 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -7,7 +7,7 @@ use App\View\ViewController; use App\Text\TextController; use App\Node\NodeController; -$container = require __DIR__.'/container.php'; +$container = require __DIR__ . '/container.php'; $app = Bridge::create($container); // change first param to false for production diff --git a/data/seedDb.php b/data/seedDb.php index 28bc820..b9f2b31 100644 --- a/data/seedDb.php +++ b/data/seedDb.php @@ -3,7 +3,7 @@ $texts = [ [ 'id' => 0, - 'name' => 'test text' + 'name' => 'test text', ], ]; @@ -28,6 +28,6 @@ $fileDataMap = [ ]; foreach ($fileDataMap as $file => $data) { - $path = __DIR__."/$file"; + $path = __DIR__ . "/$file"; file_put_contents($path, json_encode($data, JSON_PRETTY_PRINT)); } diff --git a/data/wipeDb.php b/data/wipeDb.php index 2d71990..c36b4af 100644 --- a/data/wipeDb.php +++ b/data/wipeDb.php @@ -6,7 +6,7 @@ $files = [ ]; foreach ($files as $file) { - echo __DIR__."/$file"; - $path = __DIR__."/$file"; + echo __DIR__ . "/$file"; + $path = __DIR__ . "/$file"; file_put_contents($path, json_encode([], JSON_PRETTY_PRINT)); } diff --git a/public/index.php b/public/index.php index b57c8ab..2ef2a9a 100644 --- a/public/index.php +++ b/public/index.php @@ -2,6 +2,6 @@ require __DIR__ . '/../vendor/autoload.php'; -$app = require __DIR__.'/../bootstrap/app.php'; +$app = require __DIR__ . '/../bootstrap/app.php'; $app->run(); diff --git a/tests/Fakes/FakeTextRepository.php b/tests/Fakes/FakeTextRepository.php index 388e01c..7dac270 100644 --- a/tests/Fakes/FakeTextRepository.php +++ b/tests/Fakes/FakeTextRepository.php @@ -29,7 +29,7 @@ class FakeTextRepository implements TextRepository { $text = array_find( $this->existingTexts, - function (Text $text) use ($id){ + function (Text $text) use ($id) { return $text->getId() === $id; } ); diff --git a/tests/Unit/Node/UseCases/BulkCreateNodesTest.php b/tests/Unit/Node/UseCases/BulkCreateNodesTest.php index 13b16d0..b3f6240 100644 --- a/tests/Unit/Node/UseCases/BulkCreateNodesTest.php +++ b/tests/Unit/Node/UseCases/BulkCreateNodesTest.php @@ -21,10 +21,10 @@ class BulkCreateNodesTest extends TestCase public function setUp(): void { - $this->textRepo = new FakeTextRepository; + $this->textRepo = new FakeTextRepository(); $this->textRepo->create(new CreateTextDto(name: 'text')); - $this->nodeRepo = new FakeNodeRepository; + $this->nodeRepo = new FakeNodeRepository(); $text = $this->textRepo->find(0); $this->parentNode = $this->nodeRepo->create(new CreateNodeDto( text: $text, diff --git a/tests/Unit/Node/UseCases/CreateNodeTest.php b/tests/Unit/Node/UseCases/CreateNodeTest.php index e617079..68d4dfa 100644 --- a/tests/Unit/Node/UseCases/CreateNodeTest.php +++ b/tests/Unit/Node/UseCases/CreateNodeTest.php @@ -21,11 +21,11 @@ class CreateNodeTest extends TestCase public function setUp(): void { - $this->textRepo = new FakeTextRepository; + $this->textRepo = new FakeTextRepository(); $this->textRepo->create(new CreateTextDto( name: 'text' )); - $this->nodeRepo = new FakeNodeRepository; + $this->nodeRepo = new FakeNodeRepository(); $this->useCase = new CreateNode( nodeRepo: $this->nodeRepo, textRepo: $this->textRepo, diff --git a/tests/Unit/Plan/UseCases/CreatePlanTest.php b/tests/Unit/Plan/UseCases/CreatePlanTest.php index a5bdf02..32f9162 100644 --- a/tests/Unit/Plan/UseCases/CreatePlanTest.php +++ b/tests/Unit/Plan/UseCases/CreatePlanTest.php @@ -30,11 +30,11 @@ class CreatePlanTest extends TestCase public function setUp(): void { - $this->planRepo = new FakePlanRepository; - $this->userRepo = new FakeUserRepository; - $this->textRepo = new FakeTextRepository; - $this->nodeRepo = new FakeNodeRepository; - $this->scheduledNodeRepo = new FakeScheduledNodeRepository; + $this->planRepo = new FakePlanRepository(); + $this->userRepo = new FakeUserRepository(); + $this->textRepo = new FakeTextRepository(); + $this->nodeRepo = new FakeNodeRepository(); + $this->scheduledNodeRepo = new FakeScheduledNodeRepository(); $this->userRepo->create(new CreateUserDto( email: new EmailAddress('test@test.com'), )); @@ -121,7 +121,8 @@ class CreatePlanTest extends TestCase textId: 0, )); $this->assertEquals( - 1, $this->scheduledNodeRepo->getNumberOfTimesCreateCalled() + 1, + $this->scheduledNodeRepo->getNumberOfTimesCreateCalled() ); } } diff --git a/tests/Unit/ScheduledNode/UseCases/CreateScheduledNodeTest.php b/tests/Unit/ScheduledNode/UseCases/CreateScheduledNodeTest.php index ced285a..43617bd 100644 --- a/tests/Unit/ScheduledNode/UseCases/CreateScheduledNodeTest.php +++ b/tests/Unit/ScheduledNode/UseCases/CreateScheduledNodeTest.php @@ -26,8 +26,8 @@ class CreateScheduledNodeTest extends TestCase public function setUp(): void { - $this->scheduledNodeRepo = new FakeScheduledNodeRepository; - $this->planRepo = new FakePlanRepository; + $this->scheduledNodeRepo = new FakeScheduledNodeRepository(); + $this->planRepo = new FakePlanRepository(); $this->planRepo->create(new CreatePlanDto( name: 'testplan', user: new User(0, new EmailAddress('test@test.com')), diff --git a/tests/Unit/Text/UseCases/CreateTextTest.php b/tests/Unit/Text/UseCases/CreateTextTest.php index 4119662..8b9cb56 100644 --- a/tests/Unit/Text/UseCases/CreateTextTest.php +++ b/tests/Unit/Text/UseCases/CreateTextTest.php @@ -20,8 +20,8 @@ class CreateTextTest extends TestCase protected function setUp(): void { - $this->textRepo = new FakeTextRepository; - $this->nodeRepo = new FakeNodeRepository; + $this->textRepo = new FakeTextRepository(); + $this->nodeRepo = new FakeNodeRepository(); $this->useCase = new CreateText( $this->textRepo, $this->nodeRepo, diff --git a/tests/Unit/User/UseCases/CreateUserTest.php b/tests/Unit/User/UseCases/CreateUserTest.php index 0725a94..0867537 100644 --- a/tests/Unit/User/UseCases/CreateUserTest.php +++ b/tests/Unit/User/UseCases/CreateUserTest.php @@ -12,7 +12,7 @@ class CreateUserTest extends TestCase { public function test_create_user(): void { - $userRepo = new FakeUserRepository; + $userRepo = new FakeUserRepository(); $useCase = new CreateUser($userRepo); $useCase->execute(new CreateUserRequest( email: 'test@test.com', diff --git a/tests/e2e/Controllers/BulkCreateNodesControllerTest.php b/tests/e2e/Controllers/BulkCreateNodesControllerTest.php index 0ff3f0c..8dfcb25 100644 --- a/tests/e2e/Controllers/BulkCreateNodesControllerTest.php +++ b/tests/e2e/Controllers/BulkCreateNodesControllerTest.php @@ -23,10 +23,10 @@ class BulkCreateNodesControllerTest extends TestCase public function setUp(): void { - $this->textRepo = new FakeTextRepository; + $this->textRepo = new FakeTextRepository(); $text = $this->textRepo->create(new CreateTextDto(name: 'test text')); - $this->nodeRepo = new FakeNodeRepository; + $this->nodeRepo = new FakeNodeRepository(); $this->nodeRepo->create(new CreateNodeDto( text: $text, title: 'Root Node', @@ -44,8 +44,8 @@ class BulkCreateNodesControllerTest extends TestCase private function makeRequest(array $data): ServerRequestInterface { - $body = (new StreamFactory())->createStream(json_encode($data)); - return (new ServerRequestFactory()) + $body = new StreamFactory()->createStream(json_encode($data)); + return new ServerRequestFactory() ->createServerRequest('POST', 'http://localhost/api/nodes/bulk') ->withHeader('Content-Type', 'application/json') ->withBody($body); diff --git a/tests/e2e/Controllers/NodeControllerTest.php b/tests/e2e/Controllers/NodeControllerTest.php index ab01495..fffb89f 100644 --- a/tests/e2e/Controllers/NodeControllerTest.php +++ b/tests/e2e/Controllers/NodeControllerTest.php @@ -21,10 +21,10 @@ class NodeControllerTest extends TestCase public function setUp(): void { - $this->textRepo = new FakeTextRepository; + $this->textRepo = new FakeTextRepository(); $this->textRepo->create(new CreateTextDto(name: 'test text')); - $this->nodeRepo = new FakeNodeRepository; + $this->nodeRepo = new FakeNodeRepository(); $this->controller = new NodeController($this->nodeRepo, $this->textRepo); } @@ -93,12 +93,12 @@ class NodeControllerTest extends TestCase parentNode: null, )); - $body = (new StreamFactory())->createStream(json_encode([ + $body = new StreamFactory()->createStream(json_encode([ 'textId' => 0, 'title' => 'Child Node', 'parentNodeId' => $rootNode->getId(), ])); - $request = (new ServerRequestFactory()) + $request = new ServerRequestFactory() ->createServerRequest('POST', 'http://localhost/api/nodes') ->withHeader('Content-Type', 'application/json') ->withBody($body); @@ -118,11 +118,11 @@ class NodeControllerTest extends TestCase public function test_create_node_returns_400_when_title_missing(): void { - $body = (new StreamFactory())->createStream(json_encode([ + $body = new StreamFactory()->createStream(json_encode([ 'textId' => 0, 'parentNodeId' => null, ])); - $request = (new ServerRequestFactory()) + $request = new ServerRequestFactory() ->createServerRequest('POST', 'http://localhost/api/nodes') ->withHeader('Content-Type', 'application/json') ->withBody($body); @@ -138,12 +138,12 @@ class NodeControllerTest extends TestCase public function test_create_node_returns_404_when_text_not_found(): void { - $body = (new StreamFactory())->createStream(json_encode([ + $body = new StreamFactory()->createStream(json_encode([ 'textId' => 99, 'title' => 'Some Node', 'parentNodeId' => null, ])); - $request = (new ServerRequestFactory()) + $request = new ServerRequestFactory() ->createServerRequest('POST', 'http://localhost/api/nodes') ->withHeader('Content-Type', 'application/json') ->withBody($body); diff --git a/tests/e2e/Controllers/TextControllerTest.php b/tests/e2e/Controllers/TextControllerTest.php index bcf1e30..3289598 100644 --- a/tests/e2e/Controllers/TextControllerTest.php +++ b/tests/e2e/Controllers/TextControllerTest.php @@ -19,7 +19,7 @@ class TextControllerTest extends TestCase public function setUp(): void { - $this->textRepo = new FakeTextRepository; + $this->textRepo = new FakeTextRepository(); $this->textRepo->create(new CreateTextDto( name: 'test text', )); @@ -56,7 +56,7 @@ class TextControllerTest extends TestCase [ 'id' => 1, 'name' => 'test text 2', - ] + ], ]), $response->getBody() ); @@ -64,7 +64,7 @@ class TextControllerTest extends TestCase public function test_create_text(): void { - $request = (new ServerRequestFactory()) + $request = new ServerRequestFactory() ->createServerRequest('POST', 'http://localhost/texts') ->withParsedBody(['name' => 'my new text']); @@ -73,7 +73,7 @@ class TextControllerTest extends TestCase new Response(), new CreateText( $this->textRepo, - new FakeNodeRepository, + new FakeNodeRepository(), ), ); $this->assertEquals(