public function testForEquality(PhpType $that) { if ($that->isFalse()) { return TernaryValue::get('true'); } return parent::testForEquality($that); }
/** * @param boolean $allowNull */ private function refineTypeForAnnotation(PhpType $type, $allowNull = false) { if ($type->isNullType()) { return $allowNull ? $type : null; } if ($type->isUnknownType() || $type->isNoType() || $type->isAllType()) { return null; } // Just adding "false" does not make much sense as it could simply be omitted, // so let's at least widen it a bit and assume boolean. if ($type->isFalse()) { return $this->registry->getNativeType('boolean'); } return $type; }
/** * Computes the restricted types given a non-successful shallow equality comparison. * * @return PhpType[] The first element is the restricted this type, the second element is the restricted type of the * passed type. */ public function getTypesUnderShallowInequality(PhpType $that) { // union types if ($that->isUnionType()) { $p = $that->toMaybeUnionType()->getTypesUnderShallowInequality($this); return array($p[1], $p[0]); } // Other types. // There are only two types whose shallow inequality is deterministically // true -- null and false. We can just enumerate them. Should we ever add // a true type, this needs to be added here as well. if ($this->isNullType() && $that->isNullType()) { return array(null, null); } if ($this->isFalse() && $that->isFalse()) { return array(null, null); } return array($this, $that); }