Make firePostCreateHook() backwards compatability with all Laravel 5.6 #24916
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original
MigrationCreator::firePostCreateHook()
of laravel 5.6 did not receive a parameter. Since this method is protected, the intent I believe is to allow developers to extend that class and optionally override that method. However, by adding a parameter to the method signature, any subclass overriding that method would break.Recently, an enhancement was added so that this method receives the table name (ref: #24621). This can be useful, however, as noted above, it is not backwards compatible.
To fix this, I'm assigning the $table as a variable of the instance during the
create()
method, which immediately calls thefirePostCreateHook()
. I'm passing$this->table
to the callback rather so that the test in the pull request above still passes as well.This is beneficial to developers that rely on the assumptions of the contribution guidelines. It provides assurance that using and extending laravel classes' newest minor versions will not inadvertently break their code. This is only a small benefit, but moreover, it does uphold the guidelines to ensure backwards compatibility.