Skip to content

Comments

Normalize identifiers to the correct type#1014

Merged
soyuka merged 1 commit intoapi-platform:masterfrom
teohhanhui:hotfix/identifiers-type-conversion
Apr 8, 2017
Merged

Normalize identifiers to the correct type#1014
soyuka merged 1 commit intoapi-platform:masterfrom
teohhanhui:hotfix/identifiers-type-conversion

Conversation

@teohhanhui
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

Improve compatibility with declare(strict_types=1);

Should be backported to 2.0

$doctrineMetadataIdentifier = $manager->getClassMetadata($resourceClass)->getIdentifier();
$doctrineClassMetadata = $manager->getClassMetadata($resourceClass);
$doctrineIdentifierFields = $doctrineClassMetadata->getIdentifier();
$isOrm = interface_exists(EntityManagerInterface::class) && $manager instanceof EntityManagerInterface;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call to interface_exists is useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PHPStan will complain:

  • Existence of classes and interfaces in instanceof, catch, typehints, other language constructs and even annotations. PHP does not do this and just stays silent instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we skip the check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PHPStan is trying to help us avoid typos and missing imports.

$keyValue = explode('=', $identifier);
$identifiersMap[$keyValue[0]] = $keyValue[1];
foreach (explode(';', $id) as $identifier) {
$identifierPair = explode('=', $identifier);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice name!

@dunglas
Copy link
Member

dunglas commented Apr 1, 2017

@teohhanhui can you merge it in 2.0?

@dunglas
Copy link
Member

dunglas commented Apr 7, 2017

@teohhanhui do you want me to do the merge or can you handle it?

@dunglas
Copy link
Member

dunglas commented Apr 8, 2017

After double thinking about it, as it's a large patch and this problem doesn't impact users directly, I propose to merge it only in 2.0. WDYT?

@soyuka
Copy link
Member

soyuka commented Apr 8, 2017

@dunglas we can't merge this in 2.0 as the IdentifierManagerTrait was a feature introduced recently in master ;)

@soyuka soyuka force-pushed the hotfix/identifiers-type-conversion branch from 8d6f7e9 to ca31152 Compare April 8, 2017 09:12
@soyuka soyuka force-pushed the hotfix/identifiers-type-conversion branch from ca31152 to 42fd15b Compare April 8, 2017 09:17
@soyuka soyuka merged commit 219da4f into api-platform:master Apr 8, 2017
@soyuka
Copy link
Member

soyuka commented Apr 8, 2017

thanks @teohhanhui

@teohhanhui
Copy link
Contributor Author

This needs to be backported to 2.0

@teohhanhui teohhanhui deleted the hotfix/identifiers-type-conversion branch April 9, 2017 04:44
teohhanhui added a commit to teohhanhui/api-platform-core that referenced this pull request May 4, 2017
teohhanhui added a commit to teohhanhui/api-platform-core that referenced this pull request May 5, 2017
teohhanhui added a commit to teohhanhui/api-platform-core that referenced this pull request May 15, 2017
dunglas added a commit that referenced this pull request May 15, 2017
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
…rs-type-conversion

Normalize identifiers to the correct type
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
hoangnd25 pushed a commit to hoangnd25/core that referenced this pull request Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants