Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kenprogrammer's avatar

PHP OOP

What do we call this kind of class instantiation?

(new PublishPostAction())->execute($post);
0 likes
6 replies
Sinnbeck's avatar

I don't think it has any special word except class instantiation. What are you comparing it to?

2 likes
kenprogrammer's avatar

@Sinnbeck I see it being used in some Laravel tutorials. I just wanted to know so that I can check on PHP Docs to grasp the concept better

mabdullahsari's avatar
Level 16

If you mean the concept behind it, it's just the GoF Command pattern named as "Action"s.

2 likes
jlrdw's avatar

Looks like it's calling a method in a class. Which is what I call it.

2 likes

Please or to participate in this conversation.