0

In PHP it's common to type annotate variables like this:

  /**
   * @var boolean
   */
  protected $isLoaded;

But what about the return types in functions? Does PHP Type Annotation support the return type of a function?

If so, how can I annotate the return type of the function in class diagram

-getName(): String

?

I would expect something like:

  /**
   * @return String
   */
  private function getName() {}

But it's ignored.

2

1 Answer 1

1

That would just be:

/**
 * @return string
 */
private function getName(): string {}

The annotation is optional at this point.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.