for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace FondBot\Application;
use Exception;
use Whoops\Run;
use Monolog\Logger;
use Psr\Log\LoggerInterface;
use Monolog\Handler\StreamHandler;
use Whoops\Handler\PrettyPageHandler;
use League\Container\ServiceProvider\AbstractServiceProvider;
use League\Container\ServiceProvider\BootableServiceProviderInterface;
class LogServiceProvider extends AbstractServiceProvider implements BootableServiceProviderInterface
{
protected $provides = [
LoggerInterface::class,
];
/**
* Method will be invoked on registration of a service provider implementing
* this interface. Provides ability for eager loading of Service Providers.
*
* @return void
*/
public function boot(): void
$this->getContainer()->share(LoggerInterface::class, function () {
$logger = new Logger('FondBot');
$logger->pushHandler(new StreamHandler(
$this->getContainer()->get('resources_path').'/logs/app.log'
));
return $logger;
});
$whoops = new Run;
$whoops->pushHandler(new PrettyPageHandler);
new \Whoops\Handler\PrettyPageHandler()
object<Whoops\Handler\PrettyPageHandler>
callable
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
$whoops->pushHandler(function (Exception $exception, $inspector, $run) {
$inspector
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$run
/** @var LoggerInterface $logger */
$logger = $this->getContainer()->get(LoggerInterface::class);
$logger->error($exception);
$whoops->register();
}
* Use the register method to register items with the container via the
* protected $this->container property or the `getContainer` method
* from the ContainerAwareTrait.
public function register(): void
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: