Skip to content

Commit

Permalink
Use spread operator instead of class reflections for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
nmolham-godaddy committed Aug 26, 2024
1 parent cb070f7 commit 0193463
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions woocommerce/Traits/CanGetNewInstanceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits;

use ReflectionClass;

defined('ABSPATH') or exit;

if (trait_exists('\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Traits\\CanGetNewInstanceTrait')) {
Expand All @@ -43,8 +41,8 @@ trait CanGetNewInstanceTrait
*
* @return static
*/
public static function getNewInstance()
public static function getNewInstance(...$args)
{
return (new ReflectionClass(static::class))->newInstanceArgs(func_get_args());
return new static(...$args);
}
}

0 comments on commit 0193463

Please sign in to comment.