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


PHP ConsoleOptionParser::buildFromArray方法代碼示例

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


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

示例1: __construct

 /**
  * Make a new Subcommand
  *
  * @param string|array $name The long name of the subcommand, or an array with all the properties.
  * @param string $help The help text for this option.
  * @param \Cake\Console\ConsoleOptionParser|array|null $parser A parser for this subcommand. Either a ConsoleOptionParser, or an
  *   array that can be used with ConsoleOptionParser::buildFromArray().
  */
 public function __construct($name, $help = '', $parser = null)
 {
     if (is_array($name) && isset($name['name'])) {
         foreach ($name as $key => $value) {
             $this->{'_' . $key} = $value;
         }
     } else {
         $this->_name = $name;
         $this->_help = $help;
         $this->_parser = $parser;
     }
     if (is_array($this->_parser)) {
         $this->_parser['command'] = $this->_name;
         $this->_parser = ConsoleOptionParser::buildFromArray($this->_parser);
     }
 }
開發者ID:rederlo,項目名稱:cakephp,代碼行數:24,代碼來源:ConsoleInputSubcommand.php

示例2: testToArray

 /**
  * Tests toArray()
  *
  * @return void
  */
 public function testToArray()
 {
     $spec = ['command' => 'test', 'arguments' => ['name' => ['help' => 'The name'], 'other' => ['help' => 'The other arg']], 'options' => ['name' => ['help' => 'The name'], 'other' => ['help' => 'The other arg']], 'subcommands' => ['initdb' => ['help' => 'make database']], 'description' => 'description text', 'epilog' => 'epilog text'];
     $parser = ConsoleOptionParser::buildFromArray($spec);
     $result = $parser->toArray();
     $this->assertEquals($spec['description'], $result['description']);
     $this->assertEquals($spec['epilog'], $result['epilog']);
     $options = $result['options'];
     $this->assertTrue(isset($options['name']));
     $this->assertTrue(isset($options['other']));
     $this->assertEquals(2, count($result['arguments']));
     $this->assertEquals(1, count($result['subcommands']));
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:18,代碼來源:ConsoleOptionParserTest.php

示例3: testBuildFromArray

 /**
  * test building a parser from an array.
  *
  * @return void
  */
 public function testBuildFromArray()
 {
     $spec = array('command' => 'test', 'arguments' => array('name' => array('help' => 'The name'), 'other' => array('help' => 'The other arg')), 'options' => array('name' => array('help' => 'The name'), 'other' => array('help' => 'The other arg')), 'subcommands' => array('initdb' => array('help' => 'make database')), 'description' => 'description text', 'epilog' => 'epilog text');
     $parser = ConsoleOptionParser::buildFromArray($spec);
     $this->assertEquals($spec['description'], $parser->description());
     $this->assertEquals($spec['epilog'], $parser->epilog());
     $options = $parser->options();
     $this->assertTrue(isset($options['name']));
     $this->assertTrue(isset($options['other']));
     $args = $parser->arguments();
     $this->assertEquals(2, count($args));
     $commands = $parser->subcommands();
     $this->assertEquals(1, count($commands));
 }
開發者ID:maitrepylos,項目名稱:nazeweb,代碼行數:19,代碼來源:ConsoleOptionParserTest.php


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