1 | <?php |
||
10 | class Builder extends \Illuminate\Database\Schema\Builder |
||
11 | { |
||
12 | /** |
||
13 | * Create a new database Schema manager. |
||
14 | * |
||
15 | * @param Connection $connection |
||
16 | */ |
||
17 | public function __construct(Connection $connection) |
||
21 | |||
22 | /** |
||
23 | * Determine if the given table exists. |
||
24 | * |
||
25 | * @param string $table |
||
26 | * |
||
27 | * @return bool |
||
28 | */ |
||
29 | public function hasTable($table) |
||
37 | |||
38 | /** |
||
39 | * Create a new table on the schema. |
||
40 | * |
||
41 | * @param string $table |
||
42 | * @param Closure $callback |
||
43 | * |
||
44 | * @return bool |
||
45 | */ |
||
46 | public function create($table, Closure $callback = null) |
||
54 | |||
55 | /** |
||
56 | * Drop a table from the schema. |
||
57 | * |
||
58 | * @param string $table |
||
59 | * |
||
60 | * @return bool |
||
61 | */ |
||
62 | public function drop($table) |
||
68 | |||
69 | /** |
||
70 | * Modify a table on the schema. |
||
71 | * |
||
72 | * @param string $table |
||
73 | * @param Closure $callback |
||
74 | * |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function table($table, Closure $callback) |
||
84 | |||
85 | /** |
||
86 | * Create a new command set with a Closure. |
||
87 | * |
||
88 | * @param string $table |
||
89 | * @param Closure $callback |
||
90 | * |
||
91 | * @return Blueprint |
||
92 | */ |
||
93 | protected function createBlueprint($table, Closure $callback = null) |
||
97 | } |
||
98 |
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: