diff --git a/examples/TSVtoSIE.php b/examples/TSVtoSIE.php index 72b592f..60125e7 100644 --- a/examples/TSVtoSIE.php +++ b/examples/TSVtoSIE.php @@ -99,7 +99,7 @@ public function parseBalance(string $value, Company $company, FiscalYear $fiscal // account - try fetch it from the company $account = $company->getAccount($data['account_id']); // account not found? create it. - if (! $account instanceof Account) { + if ($account === null) { $account = (new Account($data['account_id'])) ->setName($data['account_name']); $company->addAccount($account); @@ -172,7 +172,7 @@ public function parseTransactions(string $value, Company $company, int $skipHead // account $account = $company->getAccount($data['account_no']); - if (! $account instanceof Account) { + if ($account === null) { $account = (new Account($data['account_no'])) ->setName($data['account_name']); $company->addAccount($account); @@ -189,13 +189,13 @@ public function parseTransactions(string $value, Company $company, int $skipHead if ($data['result_unit'] !== '') { // find dimension (pre-defined) $dim = $company->getDimension(Dimension::DIMENSION_COST_CENTRE); - if (!$dim instanceof Dimension) { + if ($dim === null) { throw new \LogicException('Expected to find dimension: DIMENSION_COST_CENTRE'); } // find / create object $object = $dim->getObject($data['result_unit']); - if (! $object instanceof DimensionObject) { + if ($object === null) { $object = (new DimensionObject($data['result_unit'])) ->setDimension($dim) ->setName('Resultatenhet ' . $data['result_unit']); //We don't have this data, so just set it @@ -210,13 +210,13 @@ public function parseTransactions(string $value, Company $company, int $skipHead if ($data['project'] !== '') { // find dimension (pre-defined) $dim = $company->getDimension(Dimension::DIMENSION_PROJECT); - if (!$dim instanceof Dimension) { + if ($dim === null) { throw new \LogicException('Expected to find dimension: DIMENSION_PROJECT'); } // find / create object $object = $dim->getObject($data['project']); - if (! $object instanceof DimensionObject) { + if ($object === null) { $object = (new DimensionObject($data['project'])) ->setDimension($dim) ->setName('Projekt ' . $data['project']); //We don't have this data, so just set it diff --git a/rector.php b/rector.php index 9eb4e30..d872222 100644 --- a/rector.php +++ b/rector.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector; use Rector\Config\RectorConfig; use Rector\Php53\Rector\Ternary\TernaryToElvisRector; use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; @@ -38,6 +39,7 @@ // DTOs looks a bit ugly with this, lets consider if we want this ->withSkip([ ClassPropertyAssignToConstructorPromotionRector::class, + FlipTypeControlToUseExclusiveTypeRector::class, // this is conflicting with our phpstan rules - either they should change or this needs to be skipped TernaryToElvisRector::class, ]) diff --git a/src/SIE/Data/Transaction.php b/src/SIE/Data/Transaction.php index fc20479..2660531 100644 --- a/src/SIE/Data/Transaction.php +++ b/src/SIE/Data/Transaction.php @@ -189,7 +189,7 @@ public function setRegistrationSign(string $registrationSign): self */ public function validate(): void { - if (! $this->account instanceof Account) { + if ($this->account === null) { throw new DomainException('Mandatory field: account'); }