private function createVar(LinkedFlowScope $scope, $name, $type)
 {
     $type = $this->registry->resolveType($type);
     $this->functionScope->declareVar($name)->setNameNode($n = new \PHPParser_Node_Expr_Variable($name));
     $scope->inferSlotType($name, $type);
     $n->setAttribute('type', $type);
     return $n;
 }
 private function assertTypeEquals($expectedType, PhpType $restrictedType = null)
 {
     if (null === $expectedType) {
         $this->assertNull($restrictedType);
     } else {
         $resolvedExpectedType = $this->registry->resolveType($expectedType);
         $this->assertNotNull($restrictedType);
         $this->assertTrue($resolvedExpectedType->equals($restrictedType), sprintf('Failed to assert that expected type "%s" equals the actual type "%s".', $resolvedExpectedType, $restrictedType));
     }
 }
Пример #3
0
 /**
  * Converts a value from its database representation to its PHP representation
  * of this type.
  *
  * @param mixed $value The value to convert.
  * @param AbstractPlatform $platform The currently used database platform.
  * @return mixed The PHP representation of the value.
  */
 public function convertToPHPValue($value, AbstractPlatform $platform)
 {
     $value = is_resource($value) ? stream_get_contents($value) : $value;
     if (empty($value)) {
         return null;
     }
     if (null === self::$typeRegistry) {
         self::$typeRegistry = new TypeRegistry();
     }
     // We cannot lookup classes in the cache as this would result in another
     // database query during the currently executed query, and consequentially
     // in a FATAL error inside Doctrine's hydrators.
     return self::$typeRegistry->resolveType($value, TypeRegistry::LOOKUP_NO_CACHE);
 }
Пример #4
0
 /**
  * @dataProvider getTypesUnderTests
  * @group typesUnder
  */
 public function testGetTypesUnder($method, $a, $b, $expectedRestrictedA, $expectedRestrictedB, array $extends = array())
 {
     $this->setUpInheritance($extends);
     $a = $this->registry->resolveType($a);
     $b = $this->registry->resolveType($b);
     list($restrictedA, $restrictedB) = $a->{'getTypesUnder' . $method}($b);
     if (null === $expectedRestrictedA) {
         $this->assertNull($restrictedA, sprintf('Expected null, but found type "%s".', $restrictedA));
     } else {
         $this->assertNotNull($restrictedA);
         $expectedRestrictedA = $this->registry->resolveType($expectedRestrictedA);
         $this->assertTrue($expectedRestrictedA->equals($restrictedA), sprintf('Failed to assert that expected type "%s" equals actual type "%s".', $expectedRestrictedA, $restrictedA));
     }
     if (null === $expectedRestrictedB) {
         $this->assertNull($restrictedB, sprintf('Expected null, but found type "%s".', $restrictedB));
     } else {
         $this->assertNotNull($restrictedB);
         $expectedRestrictedB = $this->registry->resolveType($expectedRestrictedB);
         $this->assertTrue($expectedRestrictedB->equals($restrictedB), sprintf('Failed to assert that expected type "%s" equals actual type "%s".', $expectedRestrictedB, $restrictedB));
     }
 }