Conditions | 1 |
Paths | 1 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
55 | protected function getStub($name) |
||
56 | { |
||
57 | $namespace = Container::getInstance()->getNamespace(); |
||
|
|||
58 | |||
59 | $namespace = $namespace.'LangBundler\\Mods'; |
||
60 | |||
61 | $stub = $this->filesystem->get( |
||
62 | dirname(__DIR__).DIRECTORY_SEPARATOR.'BundleItems'.DIRECTORY_SEPARATOR.'ModStub.php'); |
||
63 | |||
64 | $stub = str_replace( |
||
65 | 'LaravelLangBundler\BundleItems', |
||
66 | $namespace, |
||
67 | $stub |
||
68 | ); |
||
69 | |||
70 | $stub = str_replace( |
||
71 | 'ModStub', |
||
72 | $name, |
||
73 | $stub |
||
74 | ); |
||
75 | |||
76 | return $stub; |
||
77 | } |
||
78 | } |
||
79 |
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 sub-classes 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 parent class: