public static function fromReflection(Zend_Reflection_Method $reflectionMethod) { $method = new self(); $method->setSourceContent($reflectionMethod->getContents(false)); $method->setSourceDirty(false); if ($reflectionMethod->getDocComment() != '') { $method->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionMethod->getDocblock())); } $method->setFinal($reflectionMethod->isFinal()); if ($reflectionMethod->isPrivate()) { $method->setVisibility(self::VISIBILITY_PRIVATE); } elseif ($reflectionMethod->isProtected()) { $method->setVisibility(self::VISIBILITY_PROTECTED); } else { $method->setVisibility(self::VISIBILITY_PUBLIC); } $method->setStatic($reflectionMethod->isStatic()); $method->setName($reflectionMethod->getName()); foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $method->setParameter(Zend_CodeGenerator_Php_Parameter::fromReflection($reflectionParameter)); } $body = $reflectionMethod->getBody(); $body2 = str_replace("\n\n", "\n", $body); $body2 = preg_replace("|^\n\\s{4}|muU", "\n", $body2); $body2 = preg_replace("|^\\s{4}|muU", "", $body2); // $body2 = str_replace(' ', '.', $body2); //dmDebug::kill($body, "\n".$body2); $method->setBody($body2); return $method; }
/** * fromReflection() * * @param MethodReflection $reflectionMethod * @return MethodGenerator */ public static function fromReflection(MethodReflection $reflectionMethod) { $method = new self(); $method->setSourceContent($reflectionMethod->getContents(false)); $method->setSourceDirty(false); if ($reflectionMethod->getDocComment() != '') { $method->setDocBlock(DocBlockGenerator::fromReflection($reflectionMethod->getDocBlock())); } $method->setFinal($reflectionMethod->isFinal()); if ($reflectionMethod->isPrivate()) { $method->setVisibility(self::VISIBILITY_PRIVATE); } elseif ($reflectionMethod->isProtected()) { $method->setVisibility(self::VISIBILITY_PROTECTED); } else { $method->setVisibility(self::VISIBILITY_PUBLIC); } $method->setStatic($reflectionMethod->isStatic()); $method->setName($reflectionMethod->getName()); foreach ($reflectionMethod->getParameters() as $reflectionParameter) { $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter)); } $method->setBody($reflectionMethod->getBody()); return $method; }
/** * @param array $data * * @return Token */ public static function __set_state(array $data) { $token = new self(); $token->setParameter($data['isParameter']); $token->setRequirements($data['requirements']); $token->setExpression($data['expression']); return $token; }
public static function buildContainer($rootPath) { $container = new self(); $container->addCompilerPass(new RouterTagCompilerPass()); $container->setProxyInstantiator(new RuntimeInstantiator()); $container->setParameter('app_root', $rootPath); $loader = new YamlFileLoader($container, new FileLocator($rootPath . '/config')); $loader->load('services.yml'); $container->compile(); return $container; }
public static function loadFromPath($path, array $params = NULL) { $view = new self(); $view->path = trim($path, '/'); preg_match('/\\/?([^\\/]+)$/', $path, $match); //Find the view handle $view->handle = $match[1]; $pathname = sprintf('%s/%s/%s.config.xml', VIEWS, $view->path, $view->handle); if (!file_exists($pathname)) { throw new ViewException(__('View, %s, could not be found.', array($pathname)), self::ERROR_VIEW_NOT_FOUND); } $doc = @simplexml_load_file($pathname); if (!$doc instanceof SimpleXMLElement) { throw new ViewException(__('Failed to load view configuration file: %s', array($pathname)), self::ERROR_FAILED_TO_LOAD); } foreach ($doc as $name => $value) { if (isset($value->item)) { $stack = array(); foreach ($value->item as $item) { array_push($stack, (string) $item); } $view->{$name} = $stack; } else { $view->{$name} = (string) $value; } } if (isset($doc->attributes()->guid)) { $view->guid = (string) $doc->attributes()->guid; } else { $view->guid = uniqid(); } if (!is_null($params)) { if (!is_array($view->{'url-parameters'}) || count($view->{'url-parameters'}) <= 0) { throw new ViewException(__('This view does not accept parameters.', array($pathname)), self::ERROR_DOES_NOT_ACCEPT_PARAMETERS); } if (count($params) > count($view->{'url-parameters'})) { throw new ViewException(__('Too many parameters supplied.', array($pathname)), self::ERROR_TOO_MANY_PARAMETERS); } foreach ($params as $index => $p) { $view->setParameter($view->{'url-parameters'}[$index], $p); } } $template = sprintf('%s/%s/%s.xsl', VIEWS, $view->path, $view->handle); if (file_exists($template) && is_readable($template)) { $view->template = file_get_contents($template); } return $view; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['file_to_generate' => [], 'parameter' => null, 'proto_file' => []], $values); $message->setParameter($values['parameter']); foreach ($values['file_to_generate'] as $item) { $message->addFileToGenerate($item); } foreach ($values['proto_file'] as $item) { $message->addProtoFile($item); } return $message; }
/** * @param \Modera\ConfigBundle\Entity\ConfigurationEntry $entry * @param string $parameter * * @return MissingConfigurationParameterException */ public static function create(ConfigurationEntry $entry, $parameter) { $me = new self(sprintf('%s::getServerHandlerConfig(): configuration property "%s" for ConfigurationEntry with id "%s" is not provided!', get_class($entry), $parameter, $entry->getId())); $me->setParameter($parameter); return $me; }