Console_CommandLine
[ class tree: Console_CommandLine ] [ index: Console_CommandLine ] [ all elements ]

Source for file Callback.php

Documentation is available at Callback.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * This file is part of the PEAR Console_CommandLine package.
  7.  *
  8.  * PHP version 5
  9.  *
  10.  * LICENSE: This source file is subject to the MIT license that is available
  11.  * through the world-wide-web at the following URI:
  12.  * http://opensource.org/licenses/mit-license.php
  13.  *
  14.  * @category  Console
  15.  * @package   Console_CommandLine
  16.  * @author    David JEAN LOUIS <izimobil@gmail.com>
  17.  * @copyright 2007 David JEAN LOUIS
  18.  * @license   http://opensource.org/licenses/mit-license.php MIT License
  19.  * @version   CVS: $Id$
  20.  * @link      http://pear.php.net/package/Console_CommandLine
  21.  * @since     File available since release 0.1.0
  22.  * @filesource
  23.  */
  24.  
  25. /**
  26.  * Required by this class.
  27.  */
  28. require_once 'Console/CommandLine/Action.php';
  29.  
  30. /**
  31.  * Class that represent the Callback action.
  32.  *
  33.  * The result option array entry value is set to the return value of the
  34.  * callback defined in the option.
  35.  *
  36.  * There are two steps to defining a callback option:
  37.  *   - define the option itself using the callback action
  38.  *   - write the callback; this is a function (or method) that takes five
  39.  *     arguments, as described below.
  40.  *
  41.  * All callbacks are called as follows:
  42.  * <code>
  43.  * callable_func(
  44.  *     $value,           // the value of the option
  45.  *     $option_instance, // the option instance
  46.  *     $result_instance, // the result instance
  47.  *     $parser_instance, // the parser instance
  48.  *     $params           // an array of params as specified in the option
  49.  * );
  50.  * </code>
  51.  * and *must* return the option value.
  52.  *
  53.  * @category  Console
  54.  * @package   Console_CommandLine
  55.  * @author    David JEAN LOUIS <izimobil@gmail.com>
  56.  * @copyright 2007 David JEAN LOUIS
  57.  * @license   http://opensource.org/licenses/mit-license.php MIT License
  58.  * @version   Release: 1.2.0
  59.  * @link      http://pear.php.net/package/Console_CommandLine
  60.  * @since     Class available since release 0.1.0
  61.  */
  62. {
  63.     // execute() {{{
  64.  
  65.     /**
  66.      * Executes the action with the value entered by the user.
  67.      *
  68.      * @param mixed $value  The value of the option
  69.      * @param array $params An optional array of parameters
  70.      *
  71.      * @return string 
  72.      */
  73.     public function execute($value = false$params = array())
  74.     {
  75.         $this->setResult(call_user_func($this->option->callback$value,
  76.             $this->option$this->result$this->parser$params));
  77.     }
  78.     // }}}
  79. }

Documentation generated on Mon, 11 Mar 2019 15:51:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.