本文整理汇总了PHP中Zend\Code\Generator\ParameterGenerator::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP ParameterGenerator::getType方法的具体用法?PHP ParameterGenerator::getType怎么用?PHP ParameterGenerator::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Code\Generator\ParameterGenerator
的用法示例。
在下文中一共展示了ParameterGenerator::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTypeGetterAndSetterPersistValue
public function testTypeGetterAndSetterPersistValue()
{
$parameterGenerator = new ParameterGenerator();
$parameterGenerator->setType('Foo');
$this->assertEquals('Foo', $parameterGenerator->getType());
}
示例2: create
/**
* Process and create code/files
*/
public function create()
{
$class = ClassGen::classGen($this->name, $this->namespace, ['Phrest\\SDK\\Request\\AbstractRequest', 'Phrest\\SDK\\Request\\RequestOptions', 'Phrest\\SDK\\PhrestSDK'], 'AbstractRequest');
// Path
$path = '/' . $this->version . '/' . strtolower($this->entityName) . $this->getPlaceholderUriFromUrl($this->action->url);
$property = ClassGen::property('path', 'private', $path, 'string');
$class->addPropertyFromGenerator($property);
// Properties and constructor parameters
/** @var ParameterGenerator[] $parameters */
$parameters = [];
// Get properties
$getParams = $this->generateGetParamsFromUrl($this->action->url);
if (!empty($getParams)) {
foreach ($getParams as $getParam) {
$class->addPropertyFromGenerator(ClassGen::property($getParam, 'public', null));
$parameter = new ParameterGenerator($getParam);
$parameter->setDefaultValue(null);
$parameters[$getParam] = $parameter;
}
}
// Post properties
if (!empty($this->action->postParams)) {
foreach ($this->action->postParams as $name => $type) {
if ($class->hasProperty($name)) {
continue;
}
$class->addPropertyFromGenerator(ClassGen::property($name, 'public', null, $type));
$parameter = new ParameterGenerator($name, $type);
$parameter->setDefaultValue(null);
$parameters[$name] = $parameter;
}
}
// Constructor
if (!empty($parameters)) {
$constructor = ClassGen::constructor($parameters);
$class->addMethodFromGenerator($constructor);
}
// Create method
$create = ClassGen::method('create', [], 'public', $this->getCreateBody());
$class->addMethodFromGenerator($create);
// Setters
foreach ($parameters as $parameter) {
$class->addMethodFromGenerator(ClassGen::setter($parameter->getName(), $parameter->getType()));
}
return $class;
}