سؤال

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