Skip to content
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

DDC-4158: Incorrect Typehinting by EntityGeneration for custom types #4911

Closed
doctrinebot opened this issue Dec 4, 2015 · 8 comments
Closed

Comments

@doctrinebot
Copy link

Jira issue originally created by user bas:

Type hinting on generated entities is either incorrect - or I'm doing it wrong - in three places.

Goal:
Use custom Types (MySQL POINT) and have doctrine generate correct entities from xml mappings.

Observations:

  1. Things go wrong in three places.
  2. Configuration variations will only get me a non working POINT type
  3. I'm not sure if
  • The requested goal is even supported (EntityGenerator has an TypeAlias but that is not configurable)
  • My configuration options are set correctly

Questions:

  1. You would think that a FQCN for (My\Lib\Dbal\Types\Geography\CoordinateType::getName) and within the xml-mapping would do the trick? Should it?
  2. All in all I think that the EntityGenerator isn't aware of the doctrine_type_mappings. I need someone to confirm that thit is a valid issue and I would like to talk about a solution (make the typeAliasses configurable).

Result:
Since I'm working with doctrine-orm-module so I'll give those relevant configuration options;

    /****
     * @var geo_coordinate // wrong, should be /My/Lib/Coordinate
     */
    private $geoPoint;

    /****
     * Set geoPoint
     *
     * @param geo_coordinate $geoPoint  // wrong, should be /My/Lib/Coordinate $geoPoint
     *
     * @return Address
     */
    public function setGeoPoint($geoPoint)  // wrong, should be setGeoPoint(/My/Lib/Coordinate $geoPoint)
    {
        $this->geoPoint = $geoPoint;

        return $this;
    }

Configuration used:

   // field definition in orm mapping
    <field name="geoPoint" type="geo*coordinate" nullable="true" column="geo*point"/>
   // doctrine configuration for doctrine-orm-module
    'doctrine' => [
        'configuration' => [
            'orm_default' => [
                'types' => [
                    'geo_coordinate' => My\Lib\Dbal\Types\Geography\CoordinateType::class,
                ],
            ],
        ],
        'connection'    => [
            'orm_default' => [
                'doctrine*type*mappings' => [
                   // tried, fcqn => 'geo_coordinate' too
                    'geo*coordinate' => 'geo*coordinate',
                ],
            ],
        ],
    ],
@ghost
Copy link

ghost commented Jan 5, 2016

We need a solution to fix the issue misd-service-development/phone-number-bundle#73

@Ocramius
Copy link
Member

Ocramius commented Jan 5, 2016

I can't find the original issue, but this is a won't fix, as it would involve modifying the DBAL type system just to provide the hints to be used for a DBAL type (even though a DBAL type does not guarantee returning the same type over different input values).

Entity generation still needs manual editing by a user.

@ghost
Copy link

ghost commented Jan 6, 2016

@Ocramius Another idea would be to do this ..

@param $geoPoint

.. instead of this ..

@param geo_coordinate $geoPoint

.. if the type is unknown.

@Ocramius
Copy link
Member

Ocramius commented Jan 6, 2016

That seems reasonable

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 6 January 2016 at 12:37, JHGitty notifications@github.com wrote:

@Ocramius https://github.com/Ocramius Another idea would be to do this:

@param $geoPoint

instead of this:

@param geo_coordinate $geoPoint

in the case if the type is unknown.


Reply to this email directly or view it on GitHub
#4911 (comment)
.

@ghost
Copy link

ghost commented Jan 6, 2016

@Ocramius Could you fix this? Would be great 👍

@Ocramius
Copy link
Member

Ocramius commented Jan 6, 2016

Can't fix myself/not a priority. Consider sending a patch, if you need this
change.
On Jan 6, 2016 14:59, "JHGitty" notifications@github.com wrote:

@Ocramius https://github.com/Ocramius Could you fix this? Would be
great [image: 👍]


Reply to this email directly or view it on GitHub
#4911 (comment)
.

@ghost
Copy link

ghost commented Jan 7, 2016

@Ocramius Could you please reopen this ticket to be sure this will not be forgotten?

@Ocramius Ocramius reopened this Jan 7, 2016
@Ocramius Ocramius removed the Won't Fix label Jan 7, 2016
@Majkl578
Copy link
Contributor

EntityGenerator is going to be removed in Doctrine 3.0 and 2.x is feature-complete. Sorry for troubles.

@Majkl578 Majkl578 assigned Majkl578 and unassigned Ocramius Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants