-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Solucionado bug al eliminar registros del log.
- Pequeñas correcciones al código.
- Loading branch information
Showing
2 changed files
with
9 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?php | ||
/** | ||
* This file is part of FacturaScripts | ||
* Copyright (C) 2019-2020 Carlos Garcia Gomez <[email protected]> | ||
* Copyright (C) 2019-2022 Carlos Garcia Gomez <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
|
@@ -16,6 +16,7 @@ | |
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
namespace FacturaScripts\Core\Base; | ||
|
||
use BadMethodCallException; | ||
|
@@ -35,9 +36,9 @@ trait ExtensionsTrait | |
|
||
/** | ||
* Executes the first matched extension. | ||
* | ||
* | ||
* @param string $name | ||
* @param array $arguments | ||
* @param array $arguments | ||
* | ||
* @return mixed | ||
* | ||
|
@@ -47,30 +48,28 @@ public function __call($name, $arguments = []) | |
{ | ||
foreach (static::$extensions as $ext) { | ||
if ($ext['name'] === $name && $ext['function'] instanceof Closure) { | ||
return \call_user_func_array($ext['function']->bindTo($this, static::class), $arguments); | ||
return call_user_func_array($ext['function']->bindTo($this, static::class), $arguments); | ||
} | ||
} | ||
|
||
throw new BadMethodCallException('Method ' . $name . ' does not exist on class ' . static::class . '.'); | ||
} | ||
|
||
/** | ||
* | ||
* @param mixed $extension | ||
*/ | ||
public static function addExtension($extension) | ||
{ | ||
$methods = (new ReflectionClass($extension))->getMethods(ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED); | ||
foreach ($methods as $method) { | ||
$method->setAccessible(true); | ||
\array_unshift(self::$extensions, ['name' => $method->name, 'function' => $method->invoke($extension)]); | ||
array_unshift(self::$extensions, ['name' => $method->name, 'function' => $method->invoke($extension)]); | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param string $name | ||
* @param array $arguments | ||
* @param array $arguments | ||
* | ||
* @return mixed | ||
*/ | ||
|
@@ -81,7 +80,7 @@ public function pipe($name, ...$arguments) | |
if ($ext['name'] !== $name) { | ||
continue; | ||
} elseif ($ext['function'] instanceof Closure) { | ||
$return = \call_user_func_array($ext['function']->bindTo($this, static::class), $arguments); | ||
$return = call_user_func_array($ext['function']->bindTo($this, static::class), $arguments); | ||
} | ||
|
||
if ($return !== null) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters