Make phpstan happier
This commit is contained in:
parent
3dd033cfb7
commit
a5c8fff889
3 changed files with 18 additions and 12 deletions
18
src/App.php
18
src/App.php
|
|
@ -38,6 +38,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||
use Slim;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Symfony\Bridge\Twig\Extension as SymfonyTwigExtensions;
|
||||
use Symfony\Component\Filesystem\Exception\IOException;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\Translation;
|
||||
use Twig;
|
||||
|
|
@ -126,10 +127,10 @@ class App
|
|||
->useAutowiring(true)
|
||||
->useAnnotations(true)
|
||||
;
|
||||
#if ((new Filesystem())->exists($this->getCachePath())) {
|
||||
# $container->enableCompilation($this->getCachePath());
|
||||
# $container->writeProxiesToFile(true, "{$this->getCachePath()}/injection-proxies");
|
||||
#}
|
||||
//if ((new Filesystem())->exists($this->getCachePath())) {
|
||||
// $container->enableCompilation($this->getCachePath());
|
||||
// $container->writeProxiesToFile(true, "{$this->getCachePath()}/injection-proxies");
|
||||
//}
|
||||
$container = $container->build();
|
||||
|
||||
$container->set(Slim\Views\Twig::class, function (
|
||||
|
|
@ -151,7 +152,12 @@ class App
|
|||
}
|
||||
|
||||
if (!(new Filesystem())->exists($twigCachePath)) {
|
||||
(new Filesystem())->mkdir($twigCachePath, 0777);
|
||||
try {
|
||||
(new Filesystem())->mkdir($twigCachePath, 0777);
|
||||
} catch (IOException $IOException) {
|
||||
unset($twigSettings['cache']);
|
||||
$this->getLogger()->warning(sprintf('Could not create Twig cache (%s), Twig cache disabled ', $twigCachePath));
|
||||
}
|
||||
}
|
||||
|
||||
$loader = new FilesystemLoader();
|
||||
|
|
@ -186,7 +192,7 @@ class App
|
|||
$twig->offsetSet('language', $translator->trans($selectedLanguage));
|
||||
|
||||
// Set some default parameters
|
||||
$twig->offsetSet('app_name', defined('APP_NAME') ? APP_NAME : "APP_NAME not set");
|
||||
$twig->offsetSet('app_name', defined('APP_NAME') ? APP_NAME : 'APP_NAME not set');
|
||||
$twig->offsetSet('year', date('Y'));
|
||||
$twig->offsetSet('session', $sessionService);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ use Twig\TwigFilter;
|
|||
|
||||
class ArrayValuesTwigExtension extends AbstractExtension
|
||||
{
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Array_Values Twig Extension';
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
public function getFilters(): array
|
||||
{
|
||||
$filters = [];
|
||||
$methods = ['values'];
|
||||
|
|
@ -23,7 +23,7 @@ class ArrayValuesTwigExtension extends AbstractExtension
|
|||
return $filters;
|
||||
}
|
||||
|
||||
public function values($array)
|
||||
public function values($array): string
|
||||
{
|
||||
return array_values($array);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ use Twig\TwigFilter;
|
|||
|
||||
class FilterAlphanumericOnlyTwigExtension extends AbstractExtension
|
||||
{
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'Filter Alphanumeric Only Twig Extension';
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
public function getFilters(): array
|
||||
{
|
||||
$filters = [];
|
||||
$methods = ['filteralphaonly'];
|
||||
|
|
@ -23,7 +23,7 @@ class FilterAlphanumericOnlyTwigExtension extends AbstractExtension
|
|||
return $filters;
|
||||
}
|
||||
|
||||
public function filteralphaonly($string)
|
||||
public function filteralphaonly($string): string
|
||||
{
|
||||
return preg_replace('/[^a-z0-9_]+/i', '', $string);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue