Skip to content

Commit f2cf92a

Browse files
committed
Fix Attributes::registerAttributeCallback() signature
1 parent 3b3b86d commit f2cf92a

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/Attributes.php

+4-14
Original file line numberDiff line numberDiff line change
@@ -365,29 +365,19 @@ public function setPrefix($prefix)
365365
/**
366366
* Register callback for an attribute
367367
*
368-
* @param string $name Name of the attribute to register the callback for
369-
* @param callable $callback Callback to call when retrieving the attribute
370-
* @param callable $setterCallback Callback to call when setting the attribute
368+
* @param string $name Name of the attribute to register the callback for
369+
* @param ?callable $callback Callback to call when retrieving the attribute
370+
* @param ?callable $setterCallback Callback to call when setting the attribute
371371
*
372372
* @return $this
373-
*
374-
* @throws InvalidArgumentException If $callback is not callable or if $setterCallback is set and not callable
375373
*/
376-
public function registerAttributeCallback($name, $callback, $setterCallback = null)
374+
public function registerAttributeCallback(string $name, ?callable $callback, ?callable $setterCallback = null): self
377375
{
378376
if ($callback !== null) {
379-
if (! is_callable($callback)) {
380-
throw new InvalidArgumentException(__METHOD__ . ' expects a callable callback');
381-
}
382-
383377
$this->callbacks[$name] = $callback;
384378
}
385379

386380
if ($setterCallback !== null) {
387-
if (! is_callable($setterCallback)) {
388-
throw new InvalidArgumentException(__METHOD__ . ' expects a callable setterCallback');
389-
}
390-
391381
$this->setterCallbacks[$name] = $setterCallback;
392382
}
393383

0 commit comments

Comments
 (0)