當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassType::setAbstract方法代碼示例

本文整理匯總了PHP中Nette\PhpGenerator\ClassType::setAbstract方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassType::setAbstract方法的具體用法?PHP ClassType::setAbstract怎麽用?PHP ClassType::setAbstract使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\PhpGenerator\ClassType的用法示例。


在下文中一共展示了ClassType::setAbstract方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generateClassType


//.........這裏部分代碼省略.........
                     $comment = $typesDescription[$fieldClassName];
                 }
             }
             if (!$config->isInterface) {
                 /** $field @var \Nette\PhpGenerator\Property */
                 $field = $this->currentClass->addProperty($name);
                 $field->setStatic($isStatic);
                 if ($config->isEnum) {
                     $field->setVisibility('protected');
                 } else {
                     $field->setVisibility('private');
                 }
                 $field->addComment($comment)->addComment('@var ' . $fieldClassFull);
             }
             $createSetter = $config->haveSetter;
             if (array_key_exists('setter', $fieldProperties)) {
                 $createSetter = $fieldProperties['setter'];
             }
             $createGetter = $config->haveGetter;
             if (array_key_exists('getter', $fieldProperties)) {
                 $createGetter = $fieldProperties['getter'];
             }
             if ($config->isInterface) {
                 if ($createGetter) {
                     $this->addGetter($name, $fieldClassFull, $isStatic, false);
                 }
                 if ($createSetter) {
                     $this->addSetter($name, $fieldClassFull, $isStatic, false);
                 }
             } else {
                 if ($createGetter) {
                     $this->addGetter($name, $fieldClassFull, $isStatic, true);
                 }
                 if ($createSetter) {
                     $this->addSetter($name, $fieldClassFull, $isStatic, true);
                 }
             }
             if (!$isAutoinizialize) {
                 $first = false;
             }
         }
         if ($config->haveConstructor) {
             $methodConstructor->setBody($body, []);
         }
     }
     //end fields
     if (array_key_exists('methods', $properties)) {
         $body = '';
         foreach ($properties['methods'] as $methodName => $methodsProperties) {
             $this->info('Aggiungo method', ['class' => $this->currentClass->getName(), 'methodName' => $methodName, 'methodProp' => $methodsProperties]);
             /** $newMethodCall @var \Nette\PhpGenerator\Method */
             $newMethodCall = $this->currentClass->addMethod($methodName);
             $newMethodCall->setFinal(true);
             $newMethodCall->setStatic(false);
             if (array_key_exists('static', $methodsProperties)) {
                 $newMethodCall->setStatic($methodsProperties['static']);
             }
             if (array_key_exists('description', $methodsProperties)) {
                 $newMethodCall->setVisibility($methodsProperties['visibility']);
             } else {
                 $newMethodCall->setVisibility('public');
             }
             if (array_key_exists('description', $methodsProperties)) {
                 $newMethodCall->addComment($methodsProperties['description']);
             } else {
                 $returnType = 'void';
                 if (array_key_exists('@return', $methodsProperties)) {
                     $returnType = $methodsProperties['@return'];
                     //TODO: .'|null' va messo in quale condizione?
                     $newMethodCall->addComment('@return ' . $returnType);
                 } else {
                     //NOPE
                 }
             }
             if (array_key_exists('params', $methodsProperties)) {
                 foreach ($methodsProperties['params'] as $paramName => $paramProp) {
                     if (array_key_exists('class', $paramProp)) {
                         $newMethodCall->addParameter($paramName)->setTypeHint($paramProp['class']);
                     }
                     if (array_key_exists('primitive', $paramProp)) {
                         $newMethodCall->addParameter($paramName);
                     }
                 }
             }
             $body = ' // FIMXE: da implementare ';
             if (array_key_exists('body', $methodsProperties)) {
                 $body = $methodsProperties['body'];
             }
             $newMethodCall->setBody($body);
         }
     }
     if ($config->isEnum) {
         $this->currentClass->setAbstract(true);
         $this->addSingleton('Singleton instance for enum', false);
         $this->addParseString();
     }
     if ($config->isSingleton) {
         $this->addSingleton('Singleton instance', true);
     }
 }
開發者ID:yoghi,項目名稱:madda,代碼行數:101,代碼來源:ClassGenerator.php


注:本文中的Nette\PhpGenerator\ClassType::setAbstract方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。