Skip to content

Commit

Permalink
fixed bugs reported by PhpStan (#212)(#211)(#210)(#208)(#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored and dg committed Jul 19, 2019
1 parent 2f52649 commit a37036c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Bridges/DITracy/ContainerPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class ContainerPanel implements Tracy\IBarPanel
{
use Nette\SmartObject;

/** @var int */
/** @var float|null */
public static $compilationTime;

/** @var Nette\DI\Container */
private $container;

/** @var int|null */
/** @var float|null */
private $elapsedTime;


Expand Down
1 change: 0 additions & 1 deletion src/DI/Config/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public static function merge($left, $right)

/**
* Return true if array prevents merging and removes this information.
* @return mixed
*/
public static function takeParent(&$data): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/DI/Definitions/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class Definition
{
use Nette\SmartObject;

/** @var string */
/** @var string|null */
private $name;

/** @var string|null class or interface name */
Expand Down
2 changes: 1 addition & 1 deletion src/DI/Extensions/DIExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class DIExtension extends Nette\DI\CompilerExtension
/** @var bool */
private $debugMode;

/** @var int */
/** @var float */
private $time;


Expand Down
15 changes: 7 additions & 8 deletions src/DI/Extensions/InjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ public function getConfigSchema(): Nette\Schema\Schema
public function beforeCompile()
{
foreach ($this->getContainerBuilder()->getDefinitions() as $def) {
if (
$def->getTag(self::TAG_INJECT)
&& ($def = $def instanceof Definitions\FactoryDefinition ? $def->getResultDefinition() : $def)
&& ($def instanceof Definitions\ServiceDefinition)
) {
$this->updateDefinition($def);
if ($def->getTag(self::TAG_INJECT)) {
$def = $def instanceof Definitions\FactoryDefinition ? $def->getResultDefinition() : $def;
if ($def instanceof Definitions\ServiceDefinition) {
$this->updateDefinition($def);
}
}
}
}
Expand Down Expand Up @@ -142,9 +141,9 @@ public static function callInjects(DI\Container $container, $service): void

/**
* @param object|string $class
* @param DI\Resolver|DI\Container $container
* @param DI\Container|DI\ContainerBuilder|null $container
*/
private static function checkType($class, string $name, ?string $type, $container = null): void
private static function checkType($class, string $name, ?string $type, $container): void
{
$propName = Reflection::toString(new \ReflectionProperty($class, $name));
if (!$type) {
Expand Down
1 change: 1 addition & 0 deletions src/DI/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public static function prefixServiceName($config, string $namespace)
/**
* Returns an annotation value.
* @param \Reflector|\ReflectionMethod $ref
*/
public static function parseAnnotation(\Reflector $ref, string $name): ?string
{
Expand Down
2 changes: 1 addition & 1 deletion src/DI/PhpGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public function toString(Nette\PhpGenerator\ClassType $class): string

public function generateMethod(Definitions\Definition $def): Nette\PhpGenerator\Method
{
$name = $def->getName();
try {
$name = $def->getName();
$method = new Nette\PhpGenerator\Method(Container::getMethodName($name));
$method->setVisibility('public');
$method->setReturnType($def->getType());
Expand Down

0 comments on commit a37036c

Please sign in to comment.