Skip to content
Permalink
Browse files

Updated phpstan to v0.12

  • Loading branch information
adaamz authored and aleswita committed Dec 15, 2019
1 parent cad503e commit 147c541317ccac9abf5b3c771d953621f7c4bf2b
Showing with 26 additions and 11 deletions.
  1. +5 −5 composer.json
  2. +8 −0 phpstan.neon
  3. +1 −1 src/DI/TranslationExtension.php
  4. +11 −4 src/Latte/Macros.php
  5. +1 −1 src/LocalesResolvers/Session.php
@@ -61,13 +61,13 @@
],
"phpstan-install": [
"mkdir -p temp/phpstan",
"composer require -d temp/phpstan phpstan/phpstan:^0.11",
"composer require -d temp/phpstan phpstan/phpstan-deprecation-rules:^0.11",
"composer require -d temp/phpstan phpstan/phpstan-nette:^0.11",
"composer require -d temp/phpstan phpstan/phpstan-strict-rules:^0.11"
"composer require -d temp/phpstan phpstan/phpstan:^0.12",
"composer require -d temp/phpstan phpstan/phpstan-deprecation-rules:^0.12",
"composer require -d temp/phpstan phpstan/phpstan-nette:^0.12",
"composer require -d temp/phpstan phpstan/phpstan-strict-rules:^0.12"
],
"phpstan": [
"temp/phpstan/vendor/bin/phpstan analyse -l max -c phpstan.neon src"
"temp/phpstan/vendor/bin/phpstan analyse -c phpstan.neon"
],
"coverage": [
"tester tests/Tests -s -p phpdbg --coverage ./coverage.xml --coverage-src ./src"
@@ -5,6 +5,9 @@ includes:
- %rootDir%/../phpstan-strict-rules/rules.neon

parameters:
level: max
paths:
- src
ignoreErrors:
# src\Loaders\Doctrine.php
# src\Loaders\Doctrine.php
@@ -33,3 +36,8 @@ parameters:

# src\Translator.php
- '#^Method Contributte\\Translation\\Translator\:\:computeFallbackLocales\(\) has parameter \$locale with no typehint specified\.$#'

-
count: 1
message: '~^Method Contributte\\Translation\\Translator::setFallbackLocales\(\) has parameter \$locales with no value type specified in iterable type array\.$~'
path: 'src/Translator.php'
@@ -219,7 +219,7 @@ public function beforeCompile(): void
if ($this->config->logger === true) {
$psrLogger = $builder->getDefinitionByType(Psr\Log\LoggerInterface::class);

} elseif (is_string($this->config->logger)) {
} elseif (is_string($this->config->logger) && class_exists($this->config->logger)) {
$reflection = new ReflectionClass($this->config->logger);

if (!$reflection->implementsInterface(Psr\Log\LoggerInterface::class)) {
@@ -8,6 +8,11 @@
class Macros extends Latte\Macros\MacroSet
{

final public function __construct(Latte\Compiler $compiler)
{
parent::__construct($compiler);
}

public static function install(Latte\Compiler $compiler): void
{
$me = new static($compiler);
@@ -21,10 +26,9 @@ public static function install(Latte\Compiler $compiler): void
*
* {_ ...}
*
* @return mixed
* @throws Latte\CompileException
*/
public function macroTranslate(Latte\MacroNode $node, Latte\PhpWriter $writer)
public function macroTranslate(Latte\MacroNode $node, Latte\PhpWriter $writer): ?string
{
if ($node->closing) {
if (strpos($node->content, '<?php') === false) {
@@ -47,15 +51,16 @@ public function macroTranslate(Latte\MacroNode $node, Latte\PhpWriter $writer)

return $writer->write('echo %modify(call_user_func($this->filters->translate, %node.word, %node.args))');
}

return null;
}

/**
* {translate ...}
*
* @return mixed
* @throws Latte\CompileException
*/
public function macroPrefix(Latte\MacroNode $node, Latte\PhpWriter $writer)
public function macroPrefix(Latte\MacroNode $node, Latte\PhpWriter $writer): ?string
{
if ($node->closing) {
if ($node->content !== null && $node->content !== '') {
@@ -69,6 +74,8 @@ public function macroPrefix(Latte\MacroNode $node, Latte\PhpWriter $writer)

return $writer->write('$this->global->translator->prefix = [%node.word];');
}

return null;
}

}
@@ -19,7 +19,7 @@ class Session implements ResolverInterface
/** @var Nette\Http\Session */
private $session;

/** @var Nette\Http\SessionSection */
/** @var Nette\Http\SessionSection<string, mixed> */
private $sessionSection;

public function __construct(Nette\Http\IResponse $httpResponse, Nette\Http\Session $session)

0 comments on commit 147c541

Please sign in to comment.
You can’t perform that action at this time.