Skip to content

"One of array element" type #10347

Closed Answered by javaDeveloperKid
javaDeveloperKid asked this question in Support
Discussion options

You must be logged in to vote

Got it.

class A 
{
  private const MY_CONST_ARRAY = ['foo', 'bar'];

  /**
   * @return value-of<self::MY_CONST_ARRAY>
   */
   function f(): string
   {
       return array_rand(self::MY_CONST_ARRAY);
   }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by javaDeveloperKid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Support
Labels
None yet
1 participant