Hi All, I am upgrading Spryker from 202009 to 2022...
# help
l
Hi All, I am upgrading Spryker from 202009 to 202212. Most of the changes have done,
code:sniff:style
and
code:sniff:architecture
are working well. But when I run phpstan I have some errors that I think it should not be there. For instance in the following file from the b2b-demo-shop https://github.com/spryker-shop/b2b-demo-shop/blob/master/src/Pyz/Zed/CustomerAccess/Persistence/CustomerAccessRepository.php phpstan shows the following errors
Copy code
Line   Pyz/Zed/CustomerAccess/Persistence/CustomerAccessRepository.php
 ------ ----------------------------------------------------------------------------------------------------------------------
  52     Parameter #1 $customerAccessEntities of method
         Pyz\Zed\CustomerAccess\Persistence\Propel\Mapper\CustomerAccessMapper::mapEntitiesToCustomerAccessTransfer() expects
         Propel\Runtime\Collection\ObjectCollection, Propel\Runtime\Collection\Collection given.
  67     Parameter #1 $customerAccessEntities of method
         Pyz\Zed\CustomerAccess\Persistence\Propel\Mapper\CustomerAccessMapper::mapEntitiesToCustomerAccessTransfer() expects
         Propel\Runtime\Collection\ObjectCollection, Propel\Runtime\Collection\Collection given.
  82     Parameter #1 $customerAccessEntities of method
         Pyz\Zed\CustomerAccess\Persistence\Propel\Mapper\CustomerAccessMapper::mapEntitiesToCustomerAccessTransfer() expects
         Propel\Runtime\Collection\ObjectCollection, Propel\Runtime\Collection\Collection given.
 ------ ----------------------------------------------------------------------------------------------------------------------
This is the code for the first error, the others are because of the same:
Copy code
$unauthenticatedCustomerAccessEntity = $this->getFactory()
            ->getPyzUnauthenticatedCustomerAccessQuery()
            ->filterByIsRestricted(false)
            ->find();

        return $this->getFactory()
            ->createPyzCustomerAccessMapper()
            ->mapEntitiesToCustomerAccessTransfer($unauthenticatedCustomerAccessEntity, new CustomerAccessTransfer());
Why phpstan complains about Collection, when the
find
function is really returning an ObjectCollection and not a Collection. Thanks in advance.
q
perhaps you need to regenerate propel models? did you try
- vendor/bin/console propel:model:build
?
did you check with xdebug that `$unauthenticatedCustomerAccessEntity`object is
ObjectCollection
?