Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

refactor: prefer string interpolation over concatenation for channel names

Paulo Castellano4f3d9ff01553
diff --git a/CLAUDE.md b/CLAUDE.md
index a5a461448..651d0c6fb 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -295,6 +295,13 @@ Vue components must have a single root element.
- 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 416d35e51..61ab125b1 100644
--- a/app/Events/NotificationCreated.php
+++ b/app/Events/NotificationCreated.php
@@ -24,7 +24,7 @@ class NotificationCreated implements ShouldBroadcast
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 f0e0140d2..d2f50f708 100644
--- a/app/Events/PostCommentCreated.php
+++ b/app/Events/PostCommentCreated.php
@@ -26,7 +26,7 @@ class PostCommentCreated implements ShouldBroadcast
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 060e81b97..013f20d50 100644
--- a/app/Events/PostCreated.php
+++ b/app/Events/PostCreated.php
@@ -25,7 +25,7 @@ class PostCreated implements ShouldBroadcast
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 b33bbe51a..75fca6e7c 100644
--- a/app/Events/PostDeleted.php
+++ b/app/Events/PostDeleted.php
@@ -26,7 +26,7 @@ class PostDeleted implements ShouldBroadcast
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 6d2544f6e..b4f540c33 100644
--- a/app/Events/PostPlatformStatusUpdated.php
+++ b/app/Events/PostPlatformStatusUpdated.php
@@ -25,8 +25,8 @@ class PostPlatformStatusUpdated implements ShouldBroadcast
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 df664bf8e..33069d9ea 100644
--- a/tests/Unit/Events/PostCreatedTest.php
+++ b/tests/Unit/Events/PostCreatedTest.php
@@ -21,7 +21,7 @@ test('event broadcasts on the workspace channel', function () {
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 6ab0de1c0..c753e0e21 100644
--- a/tests/Unit/Events/PostPlatformStatusUpdatedTest.php
+++ b/tests/Unit/Events/PostPlatformStatusUpdatedTest.php
@@ -34,9 +34,9 @@ test('event broadcasts on the per-post and per-workspace channels', function ()
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 () {