fix: remove object type hints from Loader to support string class names
The add_action(), add_filter(), and add() methods used `object` type hints for the $component parameter, but several hooks pass string class names (for static method callbacks). PHP 8.3 strict typing rejects strings where `object` is declared, causing a fatal TypeError that crashes the entire site. Removed the `object` type hint to accept both object instances and string class names, which is required for WordPress static callbacks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -51,7 +51,7 @@ class Peptide_News_Loader {
|
||||
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
||||
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
||||
*/
|
||||
public function add_action( string $hook, object $component, string $callback, int $priority = 10, int $accepted_args = 1 ): void {
|
||||
public function add_action( string $hook, $component, string $callback, int $priority = 10, int $accepted_args = 1 ): void {
|
||||
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class Peptide_News_Loader {
|
||||
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
||||
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
||||
*/
|
||||
public function add_filter( string $hook, object $component, string $callback, int $priority = 10, int $accepted_args = 1 ): void {
|
||||
public function add_filter( string $hook, $component, string $callback, int $priority = 10, int $accepted_args = 1 ): void {
|
||||
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class Peptide_News_Loader {
|
||||
* @param int $accepted_args The number of arguments that should be passed to the $callback.
|
||||
* @return array The collection of actions and filters registered with WordPress.
|
||||
*/
|
||||
private function add( array $hooks, string $hook, object $component, string $callback, int $priority, int $accepted_args ): array {
|
||||
private function add( array $hooks, string $hook, $component, string $callback, int $priority, int $accepted_args ): array {
|
||||
$hooks[] = array(
|
||||
'hook' => $hook,
|
||||
'component' => $component,
|
||||
|
||||
Reference in New Issue
Block a user