diff --git a/composer.json b/composer.json index 882dff4..200ae39 100644 --- a/composer.json +++ b/composer.json @@ -20,15 +20,13 @@ ], "require": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0", - "laminas/laminas-filter": "^2.37", "laminas/laminas-servicemanager": "^3.22", "laminas/laminas-validator": "^2.64" }, "require-dev": { "phpunit/phpunit": "^10.2", "laminas/laminas-coding-standard": "^2.5", - "vimeo/psalm": "^5.13", - "ext-curl": "*" + "vimeo/psalm": "^5.13" }, "autoload": { "psr-4": { diff --git a/src/Filter/FilterInterface.php b/src/Filter/FilterInterface.php index 3ceea26..d8a71dc 100644 --- a/src/Filter/FilterInterface.php +++ b/src/Filter/FilterInterface.php @@ -9,5 +9,5 @@ interface FilterInterface /** * Returns TRUE to accept the message, FALSE to block it. */ - public function filter(array $event); + public function filter(array $event): bool|int|null; } diff --git a/src/Filter/Priority.php b/src/Filter/Priority.php index b78c214..0b05cb3 100644 --- a/src/Filter/Priority.php +++ b/src/Filter/Priority.php @@ -47,7 +47,7 @@ public function __construct(iterable|int $priority, ?string $operator = null) /** * Returns TRUE to accept the message, FALSE to block it. */ - public function filter(array $event): null|bool|int + public function filter(array $event): bool|int|null { return version_compare((string) $event['priority'], (string) $this->priority, $this->operator); } diff --git a/src/Formatter/Base.php b/src/Formatter/Base.php index bce0f91..428f9ae 100644 --- a/src/Formatter/Base.php +++ b/src/Formatter/Base.php @@ -94,11 +94,11 @@ protected function normalize(mixed $value): mixed if ($value instanceof DateTime) { $value = $value->format($this->getDateTimeFormat()); } elseif ($value instanceof Traversable) { - $value = @json_encode(iterator_to_array($value), $jsonFlags); + $value = json_encode(iterator_to_array($value), $jsonFlags); } elseif (is_array($value)) { - $value = @json_encode($value, $jsonFlags); + $value = json_encode($value, $jsonFlags); } elseif (is_object($value) && ! method_exists($value, '__toString')) { - $value = sprintf('object(%s) %s', $value::class, @json_encode($value)); + $value = sprintf('object(%s) %s', $value::class, json_encode($value)); } elseif (is_resource($value)) { $value = sprintf('resource(%s)', get_resource_type($value)); } elseif (! is_object($value)) { @@ -111,7 +111,7 @@ protected function normalize(mixed $value): mixed /** * {@inheritDoc} */ - public function getDateTimeFormat() + public function getDateTimeFormat(): string { return $this->dateTimeFormat; } @@ -119,9 +119,9 @@ public function getDateTimeFormat() /** * {@inheritDoc} */ - public function setDateTimeFormat($dateTimeFormat): static + public function setDateTimeFormat(string $dateTimeFormat): static { - $this->dateTimeFormat = (string) $dateTimeFormat; + $this->dateTimeFormat = $dateTimeFormat; return $this; } } diff --git a/src/Formatter/FormatterInterface.php b/src/Formatter/FormatterInterface.php index bff4111..7b46042 100644 --- a/src/Formatter/FormatterInterface.php +++ b/src/Formatter/FormatterInterface.php @@ -24,12 +24,12 @@ public function format(iterable $event): iterable|string; /** * Get the format specifier for DateTime objects */ - public function getDateTimeFormat(); + public function getDateTimeFormat(): string; /** * Set the format specifier for DateTime objects * * @see http://php.net/manual/en/function.date.php */ - public function setDateTimeFormat(string $dateTimeFormat); + public function setDateTimeFormat(string $dateTimeFormat): static; } diff --git a/src/Formatter/Json.php b/src/Formatter/Json.php index 02b4418..8afb4b1 100644 --- a/src/Formatter/Json.php +++ b/src/Formatter/Json.php @@ -33,7 +33,7 @@ public function format(iterable $event): string $event['timestamp'] = $event['timestamp']->format($this->getDateTimeFormat()); } - return @json_encode( + return json_encode( $event, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK | JSON_PRESERVE_ZERO_FRACTION ); @@ -50,9 +50,9 @@ public function getDateTimeFormat(): string /** * {@inheritDoc} */ - public function setDateTimeFormat($dateTimeFormat): static + public function setDateTimeFormat(string $dateTimeFormat): static { - $this->dateTimeFormat = (string) $dateTimeFormat; + $this->dateTimeFormat = $dateTimeFormat; return $this; } } diff --git a/src/Manager/FilterPluginManager.php b/src/Manager/FilterPluginManager.php index ef3dae8..27c90fd 100644 --- a/src/Manager/FilterPluginManager.php +++ b/src/Manager/FilterPluginManager.php @@ -12,7 +12,6 @@ use Laminas\ServiceManager\AbstractPluginManager; use Laminas\ServiceManager\Exception\InvalidServiceException; use Laminas\ServiceManager\Factory\InvokableFactory; -use Psr\Container\ContainerInterface; use function gettype; use function is_object; @@ -51,11 +50,6 @@ class FilterPluginManager extends AbstractPluginManager */ protected $sharedByDefault = false; - public function __construct(ContainerInterface $container, array $config = []) - { - parent::__construct($container, $config); - } - /** * Validate the plugin is of the expected type. * diff --git a/src/Manager/FormatterPluginManager.php b/src/Manager/FormatterPluginManager.php index 1dc8871..f94a795 100644 --- a/src/Manager/FormatterPluginManager.php +++ b/src/Manager/FormatterPluginManager.php @@ -9,7 +9,6 @@ use Laminas\ServiceManager\AbstractPluginManager; use Laminas\ServiceManager\Exception\InvalidServiceException; use Laminas\ServiceManager\Factory\InvokableFactory; -use Psr\Container\ContainerInterface; use function gettype; use function is_object; @@ -41,11 +40,6 @@ class FormatterPluginManager extends AbstractPluginManager */ protected $sharedByDefault = false; - public function __construct(ContainerInterface $container, array $config = []) - { - parent::__construct($container, $config); - } - /** * Validate the plugin is of the expected type. * diff --git a/src/Manager/ProcessorPluginManager.php b/src/Manager/ProcessorPluginManager.php index e0e9d6b..0eab386 100644 --- a/src/Manager/ProcessorPluginManager.php +++ b/src/Manager/ProcessorPluginManager.php @@ -12,7 +12,6 @@ use Laminas\ServiceManager\AbstractPluginManager; use Laminas\ServiceManager\Exception\InvalidServiceException; use Laminas\ServiceManager\Factory\InvokableFactory; -use Psr\Container\ContainerInterface; use function gettype; use function is_object; @@ -50,11 +49,6 @@ class ProcessorPluginManager extends AbstractPluginManager */ protected $sharedByDefault = false; - public function __construct(ContainerInterface $container, array $config = []) - { - parent::__construct($container, $config); - } - /** * Validate the plugin is of the expected type. * diff --git a/src/Manager/WriterPluginManager.php b/src/Manager/WriterPluginManager.php index c699820..adeb236 100644 --- a/src/Manager/WriterPluginManager.php +++ b/src/Manager/WriterPluginManager.php @@ -10,7 +10,6 @@ use Dot\Log\Writer\WriterInterface; use Laminas\ServiceManager\AbstractPluginManager; use Laminas\ServiceManager\Exception\InvalidServiceException; -use Psr\Container\ContainerInterface; use function gettype; use function is_object; @@ -49,11 +48,6 @@ class WriterPluginManager extends AbstractPluginManager */ protected $sharedByDefault = false; - public function __construct(ContainerInterface $container, array $config = []) - { - parent::__construct($container, $config); - } - /** * Validate the plugin is of the expected type. * diff --git a/src/Processor/ProcessorInterface.php b/src/Processor/ProcessorInterface.php index 545bca2..7483f44 100644 --- a/src/Processor/ProcessorInterface.php +++ b/src/Processor/ProcessorInterface.php @@ -9,5 +9,5 @@ interface ProcessorInterface /** * Processes a log message before it is given to the writers */ - public function process(array $event); + public function process(array $event): array; } diff --git a/src/Writer/AbstractWriter.php b/src/Writer/AbstractWriter.php index 79fa0b7..e656057 100644 --- a/src/Writer/AbstractWriter.php +++ b/src/Writer/AbstractWriter.php @@ -265,7 +265,7 @@ public function setConvertWriteErrorsToExceptions(bool $convertErrors): void /** * Perform shutdown activities such as closing open resources */ - public function shutdown() + public function shutdown(): void { } diff --git a/src/Writer/WriterInterface.php b/src/Writer/WriterInterface.php index 6621fc5..d0b3992 100644 --- a/src/Writer/WriterInterface.php +++ b/src/Writer/WriterInterface.php @@ -22,10 +22,10 @@ public function setFormatter(FormatterInterface|string $formatter): WriterInterf /** * Write a log message */ - public function write(array $event); + public function write(array $event): void; /** * Perform shutdown activities */ - public function shutdown(); + public function shutdown(): void; } diff --git a/test/ConfigProviderTest.php b/test/ConfigProviderTest.php index a6fabf6..4c4662f 100644 --- a/test/ConfigProviderTest.php +++ b/test/ConfigProviderTest.php @@ -45,7 +45,7 @@ public function testDependenciesHasAliases() $this->assertArrayHasKey(WriterPluginManager::class, $this->config['dependencies']['aliases']); } - public function testDependenciesHasAbstractFactories() + public function testDependenciesHasAbstractFactories(): void { $this->assertArrayHasKey('abstract_factories', $this->config['dependencies']); } diff --git a/test/Factory/LoggerAbstractServiceFactoryTest.php b/test/Factory/LoggerAbstractServiceFactoryTest.php index 8f0a05e..c34affc 100644 --- a/test/Factory/LoggerAbstractServiceFactoryTest.php +++ b/test/Factory/LoggerAbstractServiceFactoryTest.php @@ -38,7 +38,7 @@ protected function setUp(): void /** * @throws ContainerExceptionInterface */ - public function testWillInstantiate() + public function testWillInstantiate(): void { $this->container ->method('has') diff --git a/test/LoggerTest.php b/test/LoggerTest.php index f81fa43..03a815a 100644 --- a/test/LoggerTest.php +++ b/test/LoggerTest.php @@ -135,8 +135,6 @@ public static function provideTestFilters(): array ['regex', ['regex' => '/[0-9]+/']], ]; - // Conditionally enabled until laminas-validator is forwards-compatible - // with laminas-servicemanager v3. if (class_exists(Digits::class)) { $data[] = ['validator', ['validator' => new Digits()]]; } diff --git a/test/Mock.php b/test/Mock.php index c603dd6..533f91f 100644 --- a/test/Mock.php +++ b/test/Mock.php @@ -10,17 +10,13 @@ class Mock extends AbstractWriter { /** * array of log events - * - * @var array */ - public $events = []; + public array $events = []; /** * shutdown called? - * - * @var bool */ - public $shutdown = false; + public bool $shutdown = false; /** * Write a message to the log. @@ -32,10 +28,8 @@ public function doWrite(array $event): void /** * Record shutdown - * - * @return void */ - public function shutdown() + public function shutdown(): void { $this->shutdown = true; } diff --git a/test/MockFilter.php b/test/MockFilter.php index a109635..dc86e56 100644 --- a/test/MockFilter.php +++ b/test/MockFilter.php @@ -10,10 +10,8 @@ class MockFilter implements FilterInterface { /** * array of log events - * - * @var array */ - public $events = []; + public array $events = []; /** * Returns TRUE to accept the message diff --git a/test/Processor/BackTraceTest.php b/test/Processor/BackTraceTest.php index 2970229..49dcfca 100644 --- a/test/Processor/BackTraceTest.php +++ b/test/Processor/BackTraceTest.php @@ -16,18 +16,18 @@ protected function setUp(): void $this->subject = new Backtrace(); } - public function testWillInstantiate() + public function testWillInstantiate(): void { $this->assertInstanceOf(Backtrace::class, $this->subject); } - public function testProcess() + public function testProcess(): void { $result = $this->subject->process([]); $this->assertArrayHasKey('extra', $result); } - public function testGetIgnoredNamespaces() + public function testGetIgnoredNamespaces(): void { $result = $this->subject->getIgnoredNamespaces(); $this->assertIsArray($result); diff --git a/test/Writer/StreamTest.php b/test/Writer/StreamTest.php index 8aa8e90..eba06c5 100644 --- a/test/Writer/StreamTest.php +++ b/test/Writer/StreamTest.php @@ -10,8 +10,8 @@ use Dot\Log\Writer\Stream; use ErrorException; use PHPUnit\Framework\TestCase; +use stdClass; -use function curl_init; use function fopen; class StreamTest extends TestCase @@ -59,7 +59,7 @@ public function testWillNotInstantiateWithWrongResource(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Resource is not a stream nor a string; received "object"'); - new Stream(['stream' => curl_init('url')]); + new Stream(['stream' => new stdClass()]); } /**