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


PHP InputDefinition::getArguments方法代码示例

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


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

示例1: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
     foreach ($definition->getArguments() as $argument) {
         $totalWidth = max($totalWidth, strlen($argument->getName()));
     }
     if ($definition->getArguments()) {
         $this->writeText('<comment>Arguments:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getArguments() as $argument) {
             $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
             $this->writeText("\n");
         }
     }
     if ($definition->getArguments() && $definition->getOptions()) {
         $this->writeText("\n");
     }
     if ($definition->getOptions()) {
         $laterOptions = array();
         $this->writeText('<comment>Options:</comment>', $options);
         foreach ($definition->getOptions() as $option) {
             if (strlen($option->getShortcut()) > 1) {
                 $laterOptions[] = $option;
                 continue;
             }
             $this->writeText("\n");
             $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
         }
         foreach ($laterOptions as $option) {
             $this->writeText("\n");
             $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
         }
     }
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:37,代码来源:TextDescriptor.php

示例2: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $nameWidth = 0;
     foreach ($definition->getOptions() as $option) {
         $nameLength = strlen($option->getName()) + 2;
         if ($option->getShortcut()) {
             $nameLength += strlen($option->getShortcut()) + 3;
         }
         $nameWidth = max($nameWidth, $nameLength);
     }
     foreach ($definition->getArguments() as $argument) {
         $nameWidth = max($nameWidth, strlen($argument->getName()));
     }
     ++$nameWidth;
     if ($definition->getArguments()) {
         $this->writeText('<comment>Arguments:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getArguments() as $argument) {
             $this->describeInputArgument($argument, array_merge($options, array('name_width' => $nameWidth)));
             $this->writeText("\n");
         }
     }
     if ($definition->getArguments() && $definition->getOptions()) {
         $this->writeText("\n");
     }
     if ($definition->getOptions()) {
         $this->writeText('<comment>Options:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getOptions() as $option) {
             $this->describeInputOption($option, array_merge($options, array('name_width' => $nameWidth)));
             $this->writeText("\n");
         }
     }
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:37,代码来源:TextDescriptor.php

示例3: testAddArgument

 public function testAddArgument()
 {
     $this->initializeArguments();
     $definition = new InputDefinition();
     $definition->addArgument($this->foo);
     $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->addArgument() adds a InputArgument object');
     $definition->addArgument($this->bar);
     $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '->addArgument() adds a InputArgument object');
 }
开发者ID:exDron,项目名称:AndrewBlog,代码行数:9,代码来源:InputDefinitionTest.php

示例4: startWorkers

 /**
  * Start workers, put master port, server name to run on, and options stuff.
  */
 public function startWorkers()
 {
     // Get verbosity.
     $verbosity = new VerbosityString($this->output);
     // Get current deploy.php file.
     $deployPhpFile = $this->input->getOption('file');
     // User input.
     $input = '';
     // Get user arguments.
     foreach ($this->userDefinition->getArguments() as $argument) {
         $value = $this->input->getArgument($argument->getName());
         if ($value) {
             $input .= " {$value}";
         }
     }
     // Get user options.
     foreach ($this->userDefinition->getOptions() as $option) {
         $value = $this->input->getOption($option->getName());
         if ($value) {
             $input .= " --{$option->getName()} {$value}";
         }
     }
     foreach ($this->servers as $serverName => $server) {
         $process = new Process("php " . DEPLOYER_BIN . (null === $deployPhpFile ? "" : " --file={$deployPhpFile}") . " worker " . " --master 127.0.0.1:{$this->port}" . " --server {$serverName}" . " {$input} " . " {$verbosity}" . " &");
         $process->disableOutput();
         $process->start();
     }
 }
开发者ID:elfet,项目名称:deployer,代码行数:31,代码来源:ParallelExecutor.php

示例5: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $blocks = array();
     if (count($definition->getArguments()) > 0) {
         $blocks[] = '### Arguments:';
         foreach ($definition->getArguments() as $argument) {
             $blocks[] = $this->describeInputArgument($argument);
         }
     }
     if (count($definition->getOptions()) > 0) {
         $blocks[] = '### Options:';
         foreach ($definition->getOptions() as $option) {
             $blocks[] = $this->describeInputOption($option);
         }
     }
     return implode("\n\n", $blocks);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:20,代码来源:MarkdownDescriptor.php

示例6: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     if ($showArguments = count($definition->getArguments()) > 0) {
         $this->write('### Arguments:');
         foreach ($definition->getArguments() as $argument) {
             $this->write("\n\n");
             $this->write($this->describeInputArgument($argument));
         }
     }
     if (count($definition->getOptions()) > 0) {
         if ($showArguments) {
             $this->write("\n\n");
         }
         $this->write('### Options:');
         foreach ($definition->getOptions() as $option) {
             $this->write("\n\n");
             $this->write($this->describeInputOption($option));
         }
     }
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:23,代码来源:MarkdownDescriptor.php

示例7: testAddArgument

    public function testAddArgument()
    {
        $this->initializeArguments();

        $definition = new InputDefinition();
        $definition->addArgument($this->foo);
        $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->addArgument() adds a InputArgument object');
        $definition->addArgument($this->bar);
        $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '->addArgument() adds a InputArgument object');

        // arguments must have different names
        try {
            $definition->addArgument($this->foo1);
            $this->fail('->addArgument() throws a Exception if another argument is already registered with the same name');
        } catch (\Exception $e) {
            $this->assertInstanceOf('\Exception', $e, '->addArgument() throws a Exception if another argument is already registered with the same name');
            $this->assertEquals('An argument with name "foo" already exist.', $e->getMessage());
        }

        // cannot add a parameter after an array parameter
        $definition->addArgument(new InputArgument('fooarray', InputArgument::IS_ARRAY));
        try {
            $definition->addArgument(new InputArgument('anotherbar'));
            $this->fail('->addArgument() throws a Exception if there is an array parameter already registered');
        } catch (\Exception $e) {
            $this->assertInstanceOf('\Exception', $e, '->addArgument() throws a Exception if there is an array parameter already registered');
            $this->assertEquals('Cannot add an argument after an array argument.', $e->getMessage());
        }


        // cannot add a required argument after an optional one
        $definition = new InputDefinition();
        $definition->addArgument($this->foo);
        try {
            $definition->addArgument($this->foo2);
            $this->fail('->addArgument() throws an exception if you try to add a required argument after an optional one');
        } catch (\Exception $e) {
            $this->assertInstanceOf('\Exception', $e, '->addArgument() throws an exception if you try to add a required argument after an optional one');
            $this->assertEquals('Cannot add a required argument after an optional one.', $e->getMessage());
        }
    }
开发者ID:usefulthink,项目名称:symfony,代码行数:41,代码来源:InputDefinitionTest.php

示例8: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $inputArguments = array();
     foreach ($definition->getArguments() as $name => $argument) {
         $inputArguments[$name] = $this->describeInputArgument($argument, array('as_array' => true));
     }
     $inputOptions = array();
     foreach ($definition->getOptions() as $name => $option) {
         $inputOptions[$name] = $this->describeInputOption($option, array('as_array' => true));
     }
     return $this->output(array('arguments' => $inputArguments, 'options' => $inputOptions), $options);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:15,代码来源:JsonDescriptor.php

示例9: getInputDefinitionData

 private function getInputDefinitionData(InputDefinition $definition)
 {
     $inputArguments = array();
     foreach ($definition->getArguments() as $name => $argument) {
         $inputArguments[$name] = $this->getInputArgumentData($argument);
     }
     $inputOptions = array();
     foreach ($definition->getOptions() as $name => $option) {
         $inputOptions[$name] = $this->getInputOptionData($option);
     }
     return array('arguments' => $inputArguments, 'options' => $inputOptions);
 }
开发者ID:VicDeo,项目名称:poc,代码行数:12,代码来源:JsonDescriptor.php

示例10: getInputDefinitionDocument

 /**
  * @param InputDefinition $definition
  *
  * @return \DOMDocument
  */
 public function getInputDefinitionDocument(InputDefinition $definition)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($definitionXML = $dom->createElement('definition'));
     $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
     foreach ($definition->getArguments() as $argument) {
         $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
     }
     $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
     foreach ($definition->getOptions() as $option) {
         $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
     }
     return $dom;
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:19,代码来源:XmlDescriptor.php

示例11: describeInputDefinition

 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($definitionXML = $dom->createElement('definition'));
     $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
     foreach ($definition->getArguments() as $argument) {
         $this->appendDocument($argumentsXML, $this->describeInputArgument($argument, array('as_dom' => true)));
     }
     $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
     foreach ($definition->getOptions() as $option) {
         $this->appendDocument($optionsXML, $this->describeInputOption($option, array('as_dom' => true)));
     }
     return $this->output($dom, $options);
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:17,代码来源:XmlDescriptor.php

示例12: resolveInputDefinition

 /**
  * @return array Values for given InputDefinition, optionally filtered
  */
 public function resolveInputDefinition(InputDefinition $inputDefinition, array $filter = [])
 {
     $values = [];
     $arguments = array_filter($inputDefinition->getArguments(), function (InputArgument $argument) use($filter) {
         return !count($filter) || in_array($argument->getName(), $filter);
     });
     $options = array_filter($inputDefinition->getOptions(), function (InputOption $option) use($filter) {
         return !count($filter) || in_array($option->getName(), $filter);
     });
     foreach ($arguments as $argument) {
         $values[$argument->getName()] = $this->input->getArgument($argument->getName());
     }
     foreach ($options as $option) {
         $values[$option->getName()] = $this->getOptionValue($option);
     }
     return $values;
 }
开发者ID:Karttrend,项目名称:console-input-resolver,代码行数:20,代码来源:Resolver.php

示例13: startWorkers

 /**
  * Start workers, put master port, server name to run on, and options stuff.
  */
 public function startWorkers()
 {
     $input = ['--master' => '127.0.0.1:' . $this->port, '--server' => ''];
     // Get verbosity.
     $verbosity = new VerbosityString($this->output);
     // Get current deploy.php file.
     $deployPhpFile = $this->input->getOption('file');
     // Get user arguments.
     foreach ($this->userDefinition->getArguments() as $argument) {
         $input[$argument->getName()] = $this->input->getArgument($argument->getName());
     }
     // Get user options.
     foreach ($this->userDefinition->getOptions() as $option) {
         $input["--" . $option->getName()] = $this->input->getOption($option->getName());
     }
     foreach ($this->servers as $serverName => $server) {
         $input['--server'] = $serverName;
         $process = new Process("php " . DEPLOYER_BIN . (null === $deployPhpFile ? "" : " --file={$deployPhpFile}") . " worker " . new ArrayInput($input) . " {$verbosity}" . " &");
         $process->disableOutput();
         $process->run();
     }
 }
开发者ID:acorncom,项目名称:deployer,代码行数:25,代码来源:ParallelExecutor.php

示例14: getArguments

 /**
  * @param InputDefinition $definition
  * @return array
  */
 private function getArguments(InputDefinition $definition) : array
 {
     $arguments = [];
     foreach ($definition->getArguments() as $argument) {
         $mode = $this->getArgumentMode($argument);
         $arguments[] = new Definition(InputArgument::class, [$argument->getName(), $mode, $argument->getDescription(), $argument->getDefault()]);
     }
     return $arguments;
 }
开发者ID:brainexe,项目名称:core,代码行数:13,代码来源:ConsoleCompilerPass.php


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