Skip to content

Commit

Permalink
phpstan: upgrade to 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Feb 2, 2019
1 parent 7114bac commit cc41197
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -33,8 +33,8 @@
"nette/tester": "~2.1",
"marc-mabe/php-enum": "~3.0",
"mockery/mockery": "~1.2",
"phpstan/phpstan-shim": "0.10.7",
"phpstan/phpstan-nette": "0.10.1",
"phpstan/phpstan-shim": "0.11.1",
"phpstan/phpstan-nette": "0.11",
"tracy/tracy": "~2.3"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/AbstractEntity.php
Expand Up @@ -448,7 +448,7 @@ private function &internalGetValue(PropertyMetadata $metadata, string $name)
} else {
$value = $this->data[$name];
}
if (!isset($value) && !$metadata->isNullable) {
if ($value === null && !$metadata->isNullable) {
$class = get_class($this);
throw new InvalidStateException("Property {$class}::\${$name} is not set.");
}
Expand Down
5 changes: 3 additions & 2 deletions src/Mapper/Dbal/StorageReflection/StorageReflection.php
Expand Up @@ -229,21 +229,22 @@ public function addModifier(string $storageKey, string $saveModifier): StorageRe

protected function findManyHasManyPrimaryColumns($joinTable, $sourceTable, $targetTable): array
{
$sourceId = $targetId = null;
$useFQN = strpos($sourceTable, '.') !== false;
$keys = $this->platform->getForeignKeys($joinTable);
foreach ($keys as $column => $meta) {
$table = $useFQN
? $meta['ref_table']
: preg_replace('#^(.*\.)?(.*)$#', '$2', $meta['ref_table']);

if ($table === $sourceTable && !isset($sourceId)) {
if ($table === $sourceTable && $sourceId === null) {
$sourceId = $column;
} elseif ($table === $targetTable) {
$targetId = $column;
}
}

if (!isset($sourceId, $targetId)) {
if ($sourceId === null || $targetId === null) {
throw new InvalidStateException("No primary keys detected for many has many '{$joinTable}' join table.");
}

Expand Down
7 changes: 3 additions & 4 deletions src/Mapper/Memory/RelationshipMapperOneHasMany.php
Expand Up @@ -39,9 +39,6 @@ public function clearCache()
}


/**
* @return EntityIterator
*/
public function getIterator(IEntity $parent, ICollection $collection): Iterator
{
$className = $this->metadata->relationship->entityMetadata->className;
Expand All @@ -52,6 +49,8 @@ public function getIterator(IEntity $parent, ICollection $collection): Iterator

public function getIteratorCount(IEntity $parent, ICollection $collection): int
{
return count($this->getIterator($parent, $collection));
$iterator = $this->getIterator($parent, $collection);
assert($iterator instanceof \Countable);
return count($iterator);
}
}
2 changes: 1 addition & 1 deletion src/TestHelper/EntityCreator.php
Expand Up @@ -98,7 +98,7 @@ protected function random(PropertyMetadata $property)
}
}

if (!$possibilities) {
if (count($possibilities) === 0) {
return null;
}

Expand Down

0 comments on commit cc41197

Please sign in to comment.