Skip to content

Commit

Permalink
Merge pull request #1239 from tentwentyfour/development
Browse files Browse the repository at this point in the history
chore: Replace get_class() by static::class
  • Loading branch information
atanas-vasilev-dev authored Jul 19, 2024
2 parents d913a51 + f179788 commit 5839f74
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions core/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function factory() {
* @return \Carbon_Fields\Container\Container
*/
public static function make() {
return call_user_func_array( array( get_class(), 'factory' ), func_get_args() );
return call_user_func_array( array( static::class, 'factory' ), func_get_args() );
}

/**
Expand All @@ -46,9 +46,9 @@ public static function __callStatic( $method, $arguments ) {
if ( strpos( $method, 'make_' ) === 0 ) {
$raw_type = substr_replace( $method, '', 0, 5 );
array_unshift( $arguments, $raw_type );
return call_user_func_array( array( get_class(), 'factory' ), $arguments );
return call_user_func_array( array( static::class, 'factory' ), $arguments );
} else {
trigger_error( sprintf( 'Call to undefined function: %s::%s().', get_class(), $method ), E_USER_ERROR );
trigger_error( sprintf( 'Call to undefined function: %s::%s().', static::class, $method ), E_USER_ERROR );
}
}
}
2 changes: 1 addition & 1 deletion core/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public static function factory( $raw_type, $id, $name = '' ) {
* @return Container
*/
public static function make() {
return call_user_func_array( array( get_class(), 'factory' ), func_get_args() );
return call_user_func_array( array( static::class, 'factory' ), func_get_args() );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/Container/Nav_Menu_Item_Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct( $id, $title, $type, $condition_collection, $conditi
}

// Register the custom edit walker only once
$callable = array( get_class(), 'edit_walker' );
$callable = array( $this, 'edit_walker' );
if ( ! has_filter( 'wp_edit_nav_menu_walker', $callable ) ) {
add_filter( 'wp_edit_nav_menu_walker', $callable, 10, 2 );
}
Expand Down
2 changes: 1 addition & 1 deletion core/Container/Theme_Options_Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ protected function register_page() {
* @return Container $this
*/
public function set_page_parent( $parent ) {
if ( is_a( $parent, get_class() ) ) {
if ( is_a( $parent, static::class ) ) {
$this->settings['parent'] = $parent->get_page_file();
return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion core/Datastore/Datastore.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ public static function factory( $raw_type ) {
* @return Datastore_Interface
*/
public static function make() {
return call_user_func_array( array( get_class(), 'factory' ), func_get_args() );
return call_user_func_array( array( static::class, 'factory' ), func_get_args() );
}
}
6 changes: 3 additions & 3 deletions core/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function factory() {
* @return \Carbon_Fields\Field\Field
*/
public static function make() {
return call_user_func_array( array( get_class(), 'factory' ), func_get_args() );
return call_user_func_array( array( static::class, 'factory' ), func_get_args() );
}

/**
Expand All @@ -67,9 +67,9 @@ public static function __callStatic( $method, $arguments ) {
if ( strpos( $method, 'make_' ) === 0 ) {
$raw_type = substr_replace( $method, '', 0, 5 );
array_unshift( $arguments, $raw_type );
return call_user_func_array( array( get_class(), 'factory' ), $arguments );
return call_user_func_array( array( static::class, 'factory' ), $arguments );
} else {
trigger_error( sprintf( 'Call to undefined function: %s::%s().', get_class(), $method ), E_USER_ERROR );
trigger_error( sprintf( 'Call to undefined function: %s::%s().', static::class, $method ), E_USER_ERROR );
}
}
}
6 changes: 3 additions & 3 deletions core/Field/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public static function factory( $raw_type, $name, $label = null ) {
* @return Field
*/
public static function make() {
return call_user_func_array( array( get_class(), 'factory' ), func_get_args() );
return call_user_func_array( array( static::class, 'factory' ), func_get_args() );
}

/**
Expand Down Expand Up @@ -293,8 +293,8 @@ public function get_type() {
public function activate() {
$this->admin_init();

add_action( 'admin_print_footer_scripts', array( get_class(), 'admin_hook_scripts' ), 5 );
add_action( 'admin_print_footer_scripts', array( get_class(), 'admin_hook_styles' ), 5 );
add_action( 'admin_print_footer_scripts', array( $this, 'admin_hook_scripts' ), 5 );
add_action( 'admin_print_footer_scripts', array( $this, 'admin_hook_styles' ), 5 );
static::activate_field_type( get_class( $this ) );

do_action( 'carbon_fields_field_activated', $this );
Expand Down

0 comments on commit 5839f74

Please sign in to comment.