DDC-373: Improper use of ternary operator in EntityManager::create() #464

Closed
opened 2026-01-22 12:39:08 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 25, 2010).

Jira issue originally created by user susokary:

It seems to me that you make an improper use of ternary operator in EntityManager::create() since revision #6226.
In last revision available, you can see, line #605 of lib/Doctrine/ORM/EntityManager.php, this instruction : $config = $config ?: new Configuration();
Instead of, I guess, this one : $config = $config ? $config : new Configuration();
What do you think ?

Originally created by @doctrinebot on GitHub (Feb 25, 2010). Jira issue originally created by user susokary: It seems to me that you make an improper use of ternary operator in EntityManager::create() since revision #6226. In last revision available, you can see, line #605 of lib/Doctrine/ORM/EntityManager.php, this instruction : $config = $config ?: new Configuration(); Instead of, I guess, this one : $config = $config ? $config : new Configuration(); What do you think ?
admin added the Bug label 2026-01-22 12:39:08 +01:00
admin closed this issue 2026-01-22 12:39:10 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 25, 2010):

Comment created by jnye:

"Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise." -- http://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary

@doctrinebot commented on GitHub (Feb 25, 2010): Comment created by jnye: "Since PHP 5.3, it is possible to leave out the middle part of the ternary operator. Expression expr1 ?: expr3 returns expr1 if expr1 evaluates to TRUE, and expr3 otherwise." -- http://www.php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary
Author
Owner

@doctrinebot commented on GitHub (Feb 25, 2010):

Comment created by susokary:

You're totally right !
Thanks for your quick answer.
But, since there, I don't understand why modifying this line gave us a benefit, while we're currently using PHP 5.3.3-dev.

jpierre@jpierre-desktop:/$ php -v
PHP 5.3.3-dev (cli) (built: Feb 12 2010 00:10:46)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.0beta3-dev, Copyright (c) 2002-2010, by Derick Rethans

The fact is that, before rewriting this instruction, it was impossible for us to get a "doctrine.orm.manager" service in our Symfony 2 controller created according to this tutorial : http://www.noelguilbert.com/?post/2010/02/21/Utiliser-Doctrine-2-avec-Symfony

We need to dig this strange situation.
Thanks for your help.

Greetings from France.
Jérôme.

@doctrinebot commented on GitHub (Feb 25, 2010): Comment created by susokary: You're totally right ! Thanks for your quick answer. But, since there, I don't understand why modifying this line gave us a benefit, while we're currently using PHP 5.3.3-dev. jpierre@jpierre-desktop:/$ php -v PHP 5.3.3-dev (cli) (built: Feb 12 2010 00:10:46) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies with Xdebug v2.1.0beta3-dev, Copyright (c) 2002-2010, by Derick Rethans The fact is that, before rewriting this instruction, it was impossible for us to get a "doctrine.orm.manager" service in our Symfony 2 controller created according to this tutorial : http://www.noelguilbert.com/?post/2010/02/21/Utiliser-Doctrine-2-avec-Symfony We need to dig this strange situation. Thanks for your help. Greetings from France. Jérôme.
Author
Owner

@doctrinebot commented on GitHub (Mar 5, 2010):

Comment created by romanb:

$config = $config ?: new Configuration();

and

$config = $config ? $config : new Configuration();

is exactly the same thing. Your problem must have been caused by something else.

@doctrinebot commented on GitHub (Mar 5, 2010): Comment created by romanb: $config = $config ?: new Configuration(); and $config = $config ? $config : new Configuration(); is exactly the same thing. Your problem must have been caused by something else.
Author
Owner

@doctrinebot commented on GitHub (Mar 5, 2010):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Mar 5, 2010): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#464