Forgetting to add indexes keyword results in php error #6550

Open
opened 2026-01-22 15:34:53 +01:00 by admin · 0 comments
Owner

Originally created by @JohJohan on GitHub (Oct 6, 2020).

Forgetting to add keyword indexes will result in a php error example code:

<?php

declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Class Blog.
 *
 * @ORM\Table(name="blog", {
 *     @ORM\Index(name="blog_id_idx", columns={"id"})
 *}
 *)
 * @ORM\Entity
 */
class Blog
{
}

This will cause this PHP error:

In ClassMetadataInfo.php line 2299:

Warning: strpos() expects parameter 1 to be string, array given

This is caused here:
e0eb82a3b1/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php (L2356)

My suggestion is to add some validation and throw a exception maby a MappingException.

I will like to do this let me know if i should.

Originally created by @JohJohan on GitHub (Oct 6, 2020). Forgetting to add keyword `indexes` will result in a php error example code: ``` php <?php declare(strict_types=1); namespace App\Entity; use Doctrine\ORM\Mapping as ORM; /** * Class Blog. * * @ORM\Table(name="blog", { * @ORM\Index(name="blog_id_idx", columns={"id"}) *} *) * @ORM\Entity */ class Blog { } ``` This will cause this PHP error: ```bash In ClassMetadataInfo.php line 2299: Warning: strpos() expects parameter 1 to be string, array given ``` This is caused here: https://github.com/doctrine/orm/blob/e0eb82a3b12a3fd0878b5d56c3c293c04c168329/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2356 My suggestion is to add some validation and throw a exception maby a `MappingException`. I will like to do this let me know if i should.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6550