- Forced variable typing

This commit is contained in:
Dave M. 2023-11-03 20:03:34 -04:00
parent 951c93fc63
commit 5e44f36dbc
11 changed files with 56 additions and 29 deletions

View File

@ -2,6 +2,7 @@
"name": "mcnd/negundo-client",
"description": "Negundo client which allow sending dump(), error and tasks reports",
"keywords": ["negundo","dev","debug","psr15","middleware"],
"type": "library",
"license": "MIT",
"authors": [
{
@ -13,5 +14,19 @@
"psr-4": {
"Negundo\\Client\\": "src/"
}
},
"require": {
"php": "^8.2",
"ext-curl": "*",
"ext-json": "*"
},
"extra" : {
"lean" : {
"autoload": {
"definitions" : [
"meta/negundo.php"
]
}
}
}
}

12
meta/negundo.php Normal file
View File

@ -0,0 +1,12 @@
<?php
use function DI\autowire, DI\create, DI\get;
use Negundo\Client\{ SoftwareConfig, Dump, Task, NegundoMiddleware };
return [
SoftwareConfig::class => create(SoftwareConfig::class)->constructor(getenv('NEGUNDO_HASH'), getenv('NEGUNDO_SERVER')),
NegundoMiddleware::class => autowire(NegundoMiddleware::class),
Dump::class => autowire(Dump::class),
Task::class => autowire(Task::class),
];

View File

@ -2,17 +2,17 @@
namespace Negundo\Client {
class Dump {
public static /* array */ $instances = [];
public static array $instances = [];
# public /*string*/ $serverUrl = "http://dev.cslsj.qc.ca/debug/dump/report/%s";
# public string $serverUrl = "http://dev.cslsj.qc.ca/debug/dump/report/%s";
protected /* SoftwareConfig */ $config;
protected SoftwareConfig $config;
protected /*array*/ $sent = [];
protected array $sent = [];
protected /* TransportInterface */ $transport;
protected Transport\TransportInterface $transport;
protected /* Util\DumpHandler */ $dumpHandler;
protected Util\DumpHandler $dumpHandler;
public function __construct(SoftwareConfig $config, ? DataInterface $dataManipulator = null, Transport\TransportInterface $transport = null)
{

View File

@ -5,21 +5,21 @@ namespace Negundo\Client;
use Closure;
abstract class Handler {
protected /* SoftwareConfig */ $config;
protected SoftwareConfig $config;
public /* bool */ $registerErrorHandler = true;
public bool $registerErrorHandler = true;
public /* bool */ $registerExceptionHandler = true;
public bool $registerExceptionHandler = true;
public /* bool */ $registerFatalErrorHandler = true;
public bool $registerFatalErrorHandler = true;
protected /*Closure*/ $callback;
protected Closure $callback;
protected /*array*/ $sent = [];
protected Transport\TransportInterface $transport;
protected /* TransportInterface */ $transport;
protected Util\ExceptionHandler $exceptionHandler;
protected /* Util\ExceptionHandler */ $exceptionHandler;
protected array $sent = [];
public abstract function handleException(\Throwable $ex) : array;
@ -33,7 +33,7 @@ abstract class Handler {
$this->registerHandlers();
}
public function registerHandlers()
public function registerHandlers() : void
{
$this->registerExceptionHandler && set_exception_handler(function(\Throwable $ex) {
$this->pushData($ex);

View File

@ -12,7 +12,7 @@ class NegundoMiddleware extends Handler implements MiddlewareInterface {
protected ServerRequestInterface $request;
public $registerExceptionHandler = false;
public bool $registerExceptionHandler = false;
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
{

View File

@ -4,9 +4,9 @@ namespace Negundo\Client;
class SoftwareConfig
{
public /*string*/ $serverUrl;
public string $serverUrl;
public /* string */ $softwareHash;
public string $softwareHash;
public function __construct(string $softwareHash, string $serverUrl)
{

View File

@ -4,15 +4,15 @@ namespace Negundo\Client {
class Task {
public static /* array */ $instances = [];
public static array $instances = [];
protected /*array*/ $sent = [];
protected array $sent = [];
protected /* TransportInterface */ $transport;
protected Transport\TransportInterface $transport;
protected /* Util\TaskHandler */ $taskHandler;
protected Util\TaskHandler $taskHandler;
protected /* SoftwareConfig */ $config;
protected SoftwareConfig $config;
public function __construct(SoftwareConfig $config, ? DataInterface $dataManipulator = null, Transport\TransportInterface $transport = null)
{

View File

@ -159,7 +159,7 @@ class Curl implements TransportInterface {
35 => "A problem occurred somewhere in the SSL/TLS handshake. You really want the error buffer and read the message there as it pinpoints the problem slightly more. Could be certificates (file formats, paths, permissions), passwords, and others.",
36 => "The download could not be resumed because the specified offset was out of the file boundary.",
37 => "A file given with FILE:// couldn't be opened. Most likely because the file path doesn't identify an existing file. Did you check file permissions? ",
35 => "LDAP cannot bind. LDAP bind operation failed.",
38 => "LDAP cannot bind. LDAP bind operation failed.",
39 => "LDAP search failed.",
41 => "Function not found. A required zlib function was not found.",
42 => "Aborted by callback. A callback returned \"abort\" to libcurl.",

View File

@ -6,7 +6,7 @@ use Negundo\Client\DataInterface;
class DumpHandler {
public /*DataInterface*/ $dataManipulator;
public DataInterface $dataManipulator;
public function __construct(DataInterface $dataManipulator = null)
{

View File

@ -6,7 +6,7 @@ use Negundo\Client\DataInterface;
class ExceptionHandler {
public /*DataInterface*/ $dataManipulator;
public ? DataInterface $dataManipulator;
public function __construct(DataInterface $dataManipulator = null)
{

View File

@ -6,7 +6,7 @@ use Negundo\Client\DataInterface;
class TaskHandler {
public /*DataInterface*/ $dataManipulator;
public DataInterface $dataManipulator;
public function __construct(DataInterface $dataManipulator = null)
{
@ -20,8 +20,8 @@ class TaskHandler {
array_shift($backtrace);
$trace = $backtrace[0] ?? [
"line" => -1,
"file" => "unknown",
"line" => -1,
];
$post = [