diff --git a/CLAUDE.md b/CLAUDE.md index a5a46144..651d0c6f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -295,6 +295,13 @@ ## API Response Status Codes - When returning JSON responses with explicit status codes, always use `Symfony\Component\HttpFoundation\Response` constants instead of magic numbers. - Example: `Response::HTTP_CREATED` instead of `201`, `Response::HTTP_NO_CONTENT` instead of `204`. +## String Interpolation + +- When injecting variables into strings, prefer **double-quoted interpolation** with curly braces over concatenation with `.`. + - PHP: `"workspace.{$workspace->id}"` instead of `'workspace.'.$workspace->id`. + - Use curly braces `{}` even for simple variables to keep the boundary explicit and to allow object/array access without ambiguity. + - Single quotes are still preferred when the string has no interpolation. + ## TryPost.it Documentation - All our documentation to final user it's under https://docs.trypost.it diff --git a/app/Events/NotificationCreated.php b/app/Events/NotificationCreated.php index 416d35e5..61ab125b 100644 --- a/app/Events/NotificationCreated.php +++ b/app/Events/NotificationCreated.php @@ -24,7 +24,7 @@ public function broadcastAs(): string public function broadcastOn(): array { return [ - new PrivateChannel('workspace.'.$this->notification->workspace_id.'.user.'.$this->notification->user_id), + new PrivateChannel("workspace.{$this->notification->workspace_id}.user.{$this->notification->user_id}"), ]; } diff --git a/app/Events/PostCommentCreated.php b/app/Events/PostCommentCreated.php index f0e0140d..d2f50f70 100644 --- a/app/Events/PostCommentCreated.php +++ b/app/Events/PostCommentCreated.php @@ -26,7 +26,7 @@ public function broadcastAs(): string public function broadcastOn(): array { return [ - new PrivateChannel('post.'.$this->comment->post_id), + new PrivateChannel("post.{$this->comment->post_id}"), ]; } diff --git a/app/Events/PostCreated.php b/app/Events/PostCreated.php index 060e81b9..013f20d5 100644 --- a/app/Events/PostCreated.php +++ b/app/Events/PostCreated.php @@ -25,7 +25,7 @@ public function broadcastAs(): string public function broadcastOn(): array { return [ - new PrivateChannel('workspace.'.$this->post->workspace_id), + new PrivateChannel("workspace.{$this->post->workspace_id}"), ]; } diff --git a/app/Events/PostDeleted.php b/app/Events/PostDeleted.php index b33bbe51..75fca6e7 100644 --- a/app/Events/PostDeleted.php +++ b/app/Events/PostDeleted.php @@ -26,7 +26,7 @@ public function broadcastAs(): string public function broadcastOn(): array { return [ - new PrivateChannel('workspace.'.$this->workspaceId), + new PrivateChannel("workspace.{$this->workspaceId}"), ]; } diff --git a/app/Events/PostPlatformStatusUpdated.php b/app/Events/PostPlatformStatusUpdated.php index 6d2544f6..b4f540c3 100644 --- a/app/Events/PostPlatformStatusUpdated.php +++ b/app/Events/PostPlatformStatusUpdated.php @@ -25,8 +25,8 @@ public function broadcastAs(): string public function broadcastOn(): array { return [ - new PrivateChannel('post.'.$this->postPlatform->post_id), - new PrivateChannel('workspace.'.$this->postPlatform->post->workspace_id), + new PrivateChannel("post.{$this->postPlatform->post_id}"), + new PrivateChannel("workspace.{$this->postPlatform->post->workspace_id}"), ]; } diff --git a/tests/Unit/Events/PostCreatedTest.php b/tests/Unit/Events/PostCreatedTest.php index df664bf8..33069d9e 100644 --- a/tests/Unit/Events/PostCreatedTest.php +++ b/tests/Unit/Events/PostCreatedTest.php @@ -21,7 +21,7 @@ expect($channels)->toHaveCount(1); expect($channels[0])->toBeInstanceOf(PrivateChannel::class); - expect($channels[0]->name)->toBe('private-workspace.'.$workspace->id); + expect($channels[0]->name)->toBe("private-workspace.{$workspace->id}"); }); test('event broadcasts with the post id', function () { diff --git a/tests/Unit/Events/PostPlatformStatusUpdatedTest.php b/tests/Unit/Events/PostPlatformStatusUpdatedTest.php index 6ab0de1c..c753e0e2 100644 --- a/tests/Unit/Events/PostPlatformStatusUpdatedTest.php +++ b/tests/Unit/Events/PostPlatformStatusUpdatedTest.php @@ -34,9 +34,9 @@ expect($channels)->toHaveCount(2); expect($channels[0])->toBeInstanceOf(PrivateChannel::class); - expect($channels[0]->name)->toBe('private-post.'.$this->post->id); + expect($channels[0]->name)->toBe("private-post.{$this->post->id}"); expect($channels[1])->toBeInstanceOf(PrivateChannel::class); - expect($channels[1]->name)->toBe('private-workspace.'.$this->workspace->id); + expect($channels[1]->name)->toBe("private-workspace.{$this->workspace->id}"); }); test('event broadcasts with the post id', function () {