mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-02 03:10:15 +02:00
Use callable typehint where possible + Removed dead code (#996)
* Removed dead code * Use callable typehint where possible * Removed PHP5.3 workaround
This commit is contained in:
committed by
Jordi Boggiano
parent
91a0f40927
commit
5a041bab8f
@@ -28,9 +28,6 @@ trait ProcessableHandlerTrait
|
|||||||
*/
|
*/
|
||||||
public function pushProcessor(callable $callback): HandlerInterface
|
public function pushProcessor(callable $callback): HandlerInterface
|
||||||
{
|
{
|
||||||
if (!is_callable($callback)) {
|
|
||||||
throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given');
|
|
||||||
}
|
|
||||||
array_unshift($this->processors, $callback);
|
array_unshift($this->processors, $callback);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -109,12 +109,8 @@ class TestHandler extends AbstractProcessingHandler
|
|||||||
}, $level);
|
}, $level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasRecordThatPasses($predicate, $level)
|
public function hasRecordThatPasses(callable $predicate, $level)
|
||||||
{
|
{
|
||||||
if (!is_callable($predicate)) {
|
|
||||||
throw new \InvalidArgumentException("Expected a callable for hasRecordThatPasses");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($this->recordsByLevel[$level])) {
|
if (!isset($this->recordsByLevel[$level])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -19,13 +19,7 @@ use Monolog\Test\TestCase;
|
|||||||
*/
|
*/
|
||||||
class RotatingFileHandlerTest extends TestCase
|
class RotatingFileHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
private $lastError;
|
||||||
* This var should be private but then the anonymous function
|
|
||||||
* in the `setUp` method won't be able to set it. `$this` cant't
|
|
||||||
* be used in the anonymous function in `setUp` because PHP 5.3
|
|
||||||
* does not support it.
|
|
||||||
*/
|
|
||||||
public $lastError;
|
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
@@ -35,10 +29,8 @@ class RotatingFileHandlerTest extends TestCase
|
|||||||
$this->markTestSkipped($dir.' must be writable to test the RotatingFileHandler.');
|
$this->markTestSkipped($dir.' must be writable to test the RotatingFileHandler.');
|
||||||
}
|
}
|
||||||
$this->lastError = null;
|
$this->lastError = null;
|
||||||
$self = $this;
|
set_error_handler(function ($code, $message) {
|
||||||
// workaround with &$self used for PHP 5.3
|
$this->lastError = [
|
||||||
set_error_handler(function ($code, $message) use (&$self) {
|
|
||||||
$self->lastError = [
|
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user