public function persist(Parameter $param, AbstractFunction $function) { switch (true) { case $function instanceof GlobalFunction: $stmt = $this->fStmt; break; case $function instanceof Method: $stmt = $this->mStmt; break; default: throw new \InvalidArgumentException('Unsupported AbstractFunction implementation ' . get_class($function)); } $stmt->bindValue(1, $function->getId(), \PDO::PARAM_INT); $stmt->bindValue(2, $param->getName()); $stmt->bindValue(3, $this->phpType->convertToDatabaseValue($param->getPhpType(), $this->platform)); $stmt->bindValue(4, $param->getIndex(), \PDO::PARAM_INT); $stmt->bindValue(5, $param->isPassedByRef() ? 1 : 0, \PDO::PARAM_INT); $stmt->bindValue(6, $param->isOptional() ? 1 : 0, \PDO::PARAM_INT); $stmt->execute(); }
private function inferTypesForParameter(Parameter $param, AbstractFunction $function, Clazz $clazz = null) { if (($type = $param->getPhpType()) && !$type->isUnknownType() && !$type->isNullType() && !$type->isFalse() && !$type->isAllType()) { return; } $allowsNull = $type && $type->isNullType(); if (null !== ($node = $param->getAstNode())) { $type = $this->parser->getTypeFromParamAnnotation($node, $param->getName()); // Check whether we can use the type of a overridden method. // We only do this if we find a parent method that has been defined // on an interface (I), or if we find an abstract method (II). if (null === $type && $function instanceof Method && null !== $clazz) { foreach ($this->findOverriddenMethodsForDocInheritance($function->getName(), $clazz) as $parentMethod) { if (null !== ($docType = $parentMethod->getParamDocType($param->getIndex()))) { $type = $this->parser->getType($docType); break; } } } } if (null === $type) { $type = $this->registry->getNativeType('unknown'); } else { if ($allowsNull) { $type = $this->registry->createNullableType($type); } } $param->setPhpType($type); if ($node) { $node->setAttribute('type', $type); } }