Booleans and null should be compared strictly

  • Minor
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.strict_boolean_comparison_should_be_used

  1. ->from($this->className, 'p');
  2. } elseif ($this->objectManager instanceof \Doctrine\ODM\MongoDB\DocumentManager) {
  3. /** @var \Doctrine\ODM\MongoDB\Query\Builder $builder */
  4. $builder = $this->objectManager->createQueryBuilder($this->className);
  5. if (!empty($fields) && true == $distinct) {

    With booleans and null, only strict comparison (with === operator) should be used to lower bug risks and to improve performances.

    Time to fix: about 15 minutes
    Permalink
    Last edited by Cedrick Oka
  6. $builder->distinct($fields[0]);
  7. }
  8. $builder->count();
  9. } else {