-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call to an undefined method Sylius\Component\Core\Repository\*::findOneBy*() and other magic methods #576
Comments
You can check this by running PHPStan with Xdebug and seeing where it ends in EntityRepositoryClassReflectionExtension but in my opinion this can only work if OrderInterface is an entity and has a field named |
In this line, entityClassNames is empty. Here's the value of $templateTypeMap :
$entityClassType :
$entityClassNames is an empty array and field name is fine. (I've changed to "name" because name exists on the order entity). I've changed the repository to use my entity instead of the interface, the error and data previously shared is the same.
|
I got it to work by modifying these. Whatever I change in phpdoc of Sylius\Component\Core\Repository\OrderRepositoryInterface has no effect. /**
* @template T of OrderInterface
*
* @extends BaseOrderRepositoryInterface<T>
*/
interface OrderRepositoryInterface extends BaseOrderRepositoryInterface Modifying type in @template had no effect /**
* @template T of Order
*
* @extends RepositoryInterface<T>
*/
interface OrderRepositoryInterface extends RepositoryInterface Dropping @template and using my own entity works here use App\Entity\Order\Order;
/**
* @extends RepositoryInterface<Order>
*/
interface OrderRepositoryInterface extends RepositoryInterface |
And finally for a clean solution : Following this tutorial : https://docs.sylius.com/en/1.12/customization/repository.html App\Repository\OrderRepositoryInterface <?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\Order\Order;
use Sylius\Component\Core\Repository\OrderRepositoryInterface as BaseOrderRepositoryInterface;
/**
* @extends BaseOrderRepositoryInterface<Order>
*/
interface OrderRepositoryInterface extends \Sylius\Component\Core\Repository\OrderRepositoryInterface
{
} The doctrine configuration is required : parameters:
doctrine:
objectManagerLoader: tests/object-manager.php This only work for Sylius 1.13+. There was no template phpdoc before. Maybe the @extends with ObjectManager would work |
On any released version of Sylius-Standard, I couldn't get phpstan-doctrine to work.
Full error :
Here's a minimal reproducer :
phpstan.neon
I've configured an object-manager.php test just in case and it doesn't improve the detection.
Sylius do not use ServerEntityManager
The text was updated successfully, but these errors were encountered: