I need to communicate that function bar of class MyNamespace\Foo needs some modifications. I'm using an imperative OOP language with syntax similar to Java. Is there a shorter way to say this? MyNamespace\Foo\bar() looks close enough but not sure if that's correct.

有帮助吗?

解决方案

The following is usually used in PHP: MyNamespace\Foo::bar()


Edit: Reply to comment

Since static methods can be called dynamically, you could use MyNamespace\Foo->bar() to cover for both cases. However, standard usage I've always seen across all documentation, and usage that IDEs can generally recognize in docblocks when you ctrl+click through them all seem to be with double-colon, as originally noted.

I haven't seen Doctrine's approach in many cases.

其他提示

If it's similar to Java why not using the dot notation: myNamespace.Foo.bar()?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top