-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.6] make model factory after method signatures more consistent #23676
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,11 +116,12 @@ public function state($class, $state, $attributes) | |
* | ||
* @param string $class | ||
* @param callable $callback | ||
* @param string $name | ||
* @return $this | ||
*/ | ||
public function afterMaking($class, $callback) | ||
public function afterMaking($class, callable $callback, $name = 'default') | ||
{ | ||
$this->afterMaking[$class]['default'][] = $callback; | ||
$this->afterMaking[$class][$name][] = $callback; | ||
|
||
return $this; | ||
} | ||
|
@@ -133,23 +134,22 @@ public function afterMaking($class, $callback) | |
* @param callable $callback | ||
* @return $this | ||
*/ | ||
public function afterMakingState($class, $state, $callback) | ||
public function afterMakingState($class, $state, callable $callback) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
{ | ||
$this->afterMaking[$class][$state][] = $callback; | ||
|
||
return $this; | ||
return $this->afterMaking($class, $callback, $state); | ||
} | ||
|
||
/** | ||
* Define a callback to run after creating a model. | ||
* | ||
* @param string $class | ||
* @param callable $callback | ||
* @param string $name | ||
* @return $this | ||
*/ | ||
public function afterCreating($class, $callback) | ||
public function afterCreating($class, callable $callback, $name = 'default') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. etc |
||
{ | ||
$this->afterCreating[$class]['default'][] = $callback; | ||
$this->afterCreating[$class][$name][] = $callback; | ||
|
||
return $this; | ||
} | ||
|
@@ -162,11 +162,9 @@ public function afterCreating($class, $callback) | |
* @param callable $callback | ||
* @return $this | ||
*/ | ||
public function afterCreatingState($class, $state, $callback) | ||
public function afterCreatingState($class, $state, callable $callback) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to add this, please do it on master. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did and @taylorotwell said to put it here. #23670 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The feature has not been tagged yet so no worries about breaking changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right, good. |
||
{ | ||
$this->afterCreating[$class][$state][] = $callback; | ||
|
||
return $this; | ||
return $this->afterCreating($class, $callback, $state); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this extra type from the definition. It's a breaking change to the signature.