Skip to content

Commit

Permalink
update to PHPStan 1.8 & strict rules 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed Jul 11, 2022
1 parent 1fbc39d commit bdafb59
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"marc-mabe/php-enum": "~3.0",
"mockery/mockery": "~1.2",
"phpstan/extension-installer": "1.1.0",
"phpstan/phpstan": "1.7.10",
"phpstan/phpstan": "1.8.0",
"phpstan/phpstan-deprecation-rules": "1.0.0",
"phpstan/phpstan-nette": "1.0.0",
"phpstan/phpstan-mockery": "1.1.0",
"phpstan/phpstan-strict-rules": "1.1.0",
"phpstan/phpstan-strict-rules": "1.3.0",
"nextras/orm-phpstan": "~1.0",
"marc-mabe/php-enum-phpstan": "dev-master",
"tracy/tracy": "~2.3"
Expand Down
4 changes: 2 additions & 2 deletions src/Collection/Functions/ConjunctionOperatorFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function processArrayExpression(
$callback = $helper->createFilter($arg, $aggregator);
$valueReference = $callback($entity);
if ($valueReference->aggregator === null) {
if ($valueReference->value == false) {
if ($valueReference->value == false) { // @phpstan-ignore-line Loose comparison https://github.com/nextras/orm/issues/586
return new ArrayPropertyValueReference(
/* $result = */false,
null,
Expand Down Expand Up @@ -93,7 +93,7 @@ public function processArrayExpression(

$aggregator = $aggregators[$key];
$result = $aggregator->aggregateValues($valuesBatch);
if ($result == false) {
if ($result == false) { // @phpstan-ignore-line Loose comparison https://github.com/nextras/orm/issues/586
return new ArrayPropertyValueReference(
/* $result = */false,
null,
Expand Down
4 changes: 2 additions & 2 deletions src/Collection/Functions/DisjunctionOperatorFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function processArrayExpression(
$callback = $helper->createFilter($arg, $aggregator);
$valueReference = $callback($entity);
if ($valueReference->aggregator === null) {
if ($valueReference->value == true) {
if ($valueReference->value == true) { // @phpstan-ignore-line Loose comparison https://github.com/nextras/orm/issues/586
return new ArrayPropertyValueReference(
/* $result = */true,
null,
Expand Down Expand Up @@ -86,7 +86,7 @@ public function processArrayExpression(

$aggregator = $aggregators[$key];
$result = $aggregator->aggregateValues($valuesBatch);
if ($result == true) {
if ($result == true) { // @phpstan-ignore-line Loose comparison https://github.com/nextras/orm/issues/586
return new ArrayPropertyValueReference(
/* $result = */true,
null,
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ public function &__get(string $name): IRepository

/**
* @return IRepository[]
* @phpstan-return list<IRepository<IEntity>>>
* @phpstan-return list<IRepository<IEntity>>
*/
private function getLoadedRepositories()
private function getLoadedRepositories(): array
{
$repositories = [];
foreach (array_keys($this->configuration[0]) as $className) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ function buildDic(string $config): Container
}

$container = buildDic(__DIR__ . '/dic-extension-order.neon');
Assert::true($container->getByType(IModel::class) != null);
Assert::count(1, $container->findByType(IModel::class));
Assert::type(Model::class, $container->getByType(IModel::class));
8 changes: 2 additions & 6 deletions tests/cases/unit/Entity/AbstractEntity.is_modified.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace NextrasTests\Orm\Entity\Fragments;

use Mockery;
use Nextras\Orm\Entity\AbstractEntity;
use Nextras\Orm\Entity\IEntity;
use Nextras\Orm\Entity\Reflection\EntityMetadata;
use Nextras\Orm\Entity\Reflection\PropertyMetadata;
use Nextras\Orm\Repository\IRepository;
Expand All @@ -20,7 +19,7 @@ use Tester\Assert;
require_once __DIR__ . '/../../../bootstrap.php';


abstract class DataEntityFragmentIsModifiedTest extends AbstractEntity
class DataEntityFragmentIsModifiedTest extends AbstractEntity
{
public function __construct(EntityMetadata $metadata)
{
Expand All @@ -44,10 +43,7 @@ class AbstractEntityIsModifiedTest extends TestCase
$metadata = Mockery::mock(EntityMetadata::class);
$metadata->shouldReceive('getProperty')->with('property');

/** @var DataEntityFragmentIsModifiedTest $entity */
$entity = Mockery::mock(DataEntityFragmentIsModifiedTest::class)->makePartial();
$entity->__construct($metadata);

$entity = new DataEntityFragmentIsModifiedTest($metadata);
Assert::true($entity->isModified());
Assert::true($entity->isModified('property'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DbalValueOperatorFunctionTest extends TestCase


/**
* @return array<array{BaseCompareFunction, array<mixed>, array<mixed>}>>
* @return array<array{BaseCompareFunction, array<mixed>, array<mixed>}>
*/
protected function operatorTestProvider(): array
{
Expand Down
3 changes: 2 additions & 1 deletion tests/inc/model/author/AuthorsMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace NextrasTests\Orm;


use Nextras\Dbal\Platforms\PostgreSqlPlatform;
use Nextras\Orm\Mapper\Dbal\DbalMapper;


Expand All @@ -13,7 +14,7 @@ final class AuthorsMapper extends DbalMapper
{
public function getTableName(): string
{
if ($this->connection->getPlatform()->getName() == 'pgsql') {
if ($this->connection->getPlatform()->getName() === PostgreSqlPlatform::NAME) {
return 'public.authors';
} else {
return 'authors';
Expand Down

0 comments on commit bdafb59

Please sign in to comment.