1 | <?php declare(strict_types=1); |
||
11 | class Catalog extends OperatorResource implements \OpenStack\Common\Auth\Catalog |
||
12 | { |
||
13 | /** @var []Service */ |
||
14 | public $services; |
||
15 | 4 | ||
16 | /** |
||
17 | 4 | * @inheritdoc |
|
18 | 4 | */ |
|
19 | 4 | protected function getAliases(): array |
|
25 | |||
26 | public function populateFromArray(array $data): self |
||
34 | 5 | ||
35 | 1 | /** |
|
36 | * Retrieve a base URL for a service, according to its catalog name, type, region. |
||
37 | * |
||
38 | 4 | * @param string $name The name of the service as it appears in the catalog. |
|
39 | 4 | * @param string $type The type of the service as it appears in the catalog. |
|
40 | 2 | * @param string $region The region of the service as it appears in the catalog. |
|
41 | * @param string $urlType Unused. |
||
42 | 2 | * |
|
43 | * @return false|string FALSE if no URL found |
||
44 | 2 | */ |
|
45 | public function getServiceUrl(string $name, string $type, string $region, string $urlType): string |
||
62 | } |
||
63 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: