当前位置: 首页>>代码示例>>PHP>>正文


PHP ParameterGenerator::generate方法代码示例

本文整理汇总了PHP中Zend\Code\Generator\ParameterGenerator::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP ParameterGenerator::generate方法的具体用法?PHP ParameterGenerator::generate怎么用?PHP ParameterGenerator::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Code\Generator\ParameterGenerator的用法示例。


在下文中一共展示了ParameterGenerator::generate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGenerateIsCorrect

 public function testGenerateIsCorrect()
 {
     $parameterGenerator = new ParameterGenerator();
     $parameterGenerator->setType('Foo');
     $parameterGenerator->setName('bar');
     $parameterGenerator->setDefaultValue(15);
     $this->assertEquals('Foo $bar = 15', $parameterGenerator->generate());
     $parameterGenerator->setDefaultValue('foo');
     $this->assertEquals('Foo $bar = \'foo\'', $parameterGenerator->generate());
 }
开发者ID:rikaix,项目名称:zf2,代码行数:10,代码来源:ParameterGeneratorTest.php

示例2: getMethods

 protected function getMethods()
 {
     $methods = [$this->getConstructor()];
     foreach ($this->properties as $propertyName) {
         $setterParam = new ParameterGenerator($propertyName);
         $methodGenerator = new MethodGenerator('set' . ucfirst($propertyName), [$setterParam]);
         $methodGenerator->setBody('$this->' . $propertyName . ' = ' . $setterParam->generate() . ';' . PHP_EOL . PHP_EOL . 'return $this;');
         $methods[] = $methodGenerator;
         $methodGenerator = new MethodGenerator('get' . ucfirst($propertyName));
         $methodGenerator->setBody('return $this->' . $propertyName . ';');
         $methods[] = $methodGenerator;
     }
     foreach ($this->edgeProperties as $edgeCollection => $targetCollection) {
         $setterParam = new ParameterGenerator(lcfirst($edgeCollection));
         $methodGenerator = new MethodGenerator('add' . $edgeCollection, [$setterParam]);
         $methodGenerator->setBody('$this->lazyAddNeighbor($this, \'' . $edgeCollection . '\', ' . $setterParam->generate() . ');');
         $methods[] = $methodGenerator;
         $setterParam = new ParameterGenerator(lcfirst($edgeCollection));
         $methodGenerator = new MethodGenerator('remove' . $edgeCollection, [$setterParam]);
         $methodGenerator->setBody('$this->lazyRemoveNeighbor($this, \'' . $edgeCollection . '\', ' . $setterParam->generate() . ');');
         $methods[] = $methodGenerator;
         $setterParam = new ParameterGenerator(lcfirst($edgeCollection));
         $methodGenerator = new MethodGenerator('set' . $edgeCollection, [$setterParam]);
         $methodGenerator->setBody('$this->lazySetNeighbor($this, \'' . $edgeCollection . '\', ' . $setterParam->generate() . ');');
         $methods[] = $methodGenerator;
         $defaultValue = new ValueGenerator([], ValueGenerator::TYPE_ARRAY);
         $setterParam = new ParameterGenerator('filter', null, $defaultValue);
         $methodGenerator = new MethodGenerator('get' . $edgeCollection, [$setterParam]);
         $methodGenerator->setBody('return $this->lazyGetNeighbor(\'' . $edgeCollection . '\', \'' . $targetCollection . '\', $filter);');
         $methods[] = $methodGenerator;
     }
     return $methods;
 }
开发者ID:cyberrebell,项目名称:arango-odm,代码行数:33,代码来源:DocumentGenerator.php

示例3: testGeneratedParametersHaveEscapedDefaultValues

 /**
  * @group 6023
  *
  * @coversNothing
  */
 public function testGeneratedParametersHaveEscapedDefaultValues()
 {
     $parameter = new ParameterGenerator();
     $parameter->setName('foo');
     $parameter->setDefaultValue("\\'");
     $parameter->setType('stdClass');
     $this->assertSame("stdClass \$foo = '\\\\\\''", $parameter->generate());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:13,代码来源:ParameterGeneratorTest.php


注:本文中的Zend\Code\Generator\ParameterGenerator::generate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。