Skip to content

Commit

Permalink
Update typing_in_psalm.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL authored and muglug committed Feb 7, 2020
1 parent dcc855d commit a7355fa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/annotating_code/typing_in_psalm.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,26 @@ function foo(string $s) : string {
}
}
```

If the class constants share a common prefix, you can specify them all using a wildcard:

```php
class A {
const STATUS_FOO = 'foo';
const STATUS_BAR = 'bar';
}

/**
* @param A::STATUS_* $s
*/
function foo(string $s) : string {
switch ($s) {
case A::STATUS_FOO:
return 'hello';

default:
// any other status
return 'goodbye';
}
}
```

0 comments on commit a7355fa

Please sign in to comment.