opensoft / doctrine-postgres-types

Provide common Doctrine types for Postgres in use at Opensoft
68 stars 25 forks source link

XMLType on nullable columns return true instead of null #21

Open HansPeterOrding opened 3 years ago

HansPeterOrding commented 3 years ago

The method convertToPHPValue of class XMLType returns boolean true if nullable column equals null. The use of short comparison operator is causing this issue. Solution:

This block:

public function convertToPHPValue($value, AbstractPlatform $platform)
{
    return $value === null ?: new \SimpleXMLElement($value);
}

Should be replaced by this:

public function convertToPHPValue($value, AbstractPlatform $platform)
{
    return $value === null ? null : new \SimpleXMLElement($value);
}

Or for PHP versions >= 7:

public function convertToPHPValue($value, AbstractPlatform $platform)
{
    return $value === null ?? new \SimpleXMLElement($value);
}

See [PR-22]](https://github.com/opensoft/doctrine-postgres-types/pull/22) for PHP version > 5 fix.