Ejemplo n.º 1
3
 /**
  * @param \Exception $exception
  * @return string
  * @todo Fix this to get full stack trace
  */
 public static function getExceptionTraceAsString(\Exception $exception)
 {
     $ret = "";
     $count = 0;
     foreach ($exception->getTrace() as $trace) {
         $args = "";
         if (isset($trace['args'])) {
             $args = array();
             foreach ($trace['args'] as $arg) {
                 if (is_string($arg)) {
                     $args[] = "'" . $arg . "'";
                 } elseif (is_array($arg)) {
                     $args[] = "Array";
                 } elseif (is_null($arg)) {
                     $args[] = 'NULL';
                 } elseif (is_bool($arg)) {
                     $args[] = $arg ? "true" : "false";
                 } elseif (is_object($arg)) {
                     $args[] = get_class($arg);
                 } elseif (is_resource($arg)) {
                     $args[] = get_resource_type($arg);
                 } else {
                     $args[] = $arg;
                 }
             }
             $args = join(", ", $args);
         }
         $ret .= sprintf("#%s %s(%s): %s(%s)\n", $count, isset($trace['file']) ? $trace['file'] : 'unknown file', isset($trace['line']) ? $trace['line'] : 'unknown line', isset($trace['class']) ? $trace['class'] . $trace['type'] . $trace['function'] : $trace['function'], $args);
         $count++;
     }
     return $ret;
 }
Ejemplo n.º 2
1
 /**
  * Append any supported $content to $parent
  *
  * @param  DOMNode $parent  Node to append to
  * @param  mixed   $content Content to append
  * @return self
  */
 protected function XMLAppend(\DOMNode &$parent = null, $content = null)
 {
     if (is_null($parent)) {
         $parent = $this->root;
     }
     if (is_string($content) or is_numeric($content) or is_object($content) and method_exists($content, '__toString')) {
         $parent->appendChild($this->createTextNode("{$content}"));
     } elseif (is_object($content) and is_subclass_of($content, '\\DOMNode')) {
         $parent->appendChild($content);
     } elseif (is_array($content) or is_object($content) and $content = get_object_vars($content)) {
         array_map(function ($node, $value) use(&$parent) {
             if (is_string($node)) {
                 if (substr($node, 0, 1) === '@') {
                     $parent->setAttribute(substr($node, 1), $value);
                 } else {
                     $node = $parent->appendChild($this->createElement($node));
                     if (is_string($value)) {
                         $this->XMLAppend($node, $this->createTextNode($value));
                     } else {
                         $this->XMLAppend($node, $value);
                     }
                 }
             } else {
                 $this->XMLAppend($parent, $value);
             }
         }, array_keys($content), array_values($content));
     } elseif (is_bool($content)) {
         $parent->appendChild($this->createTextNode($content ? 'true' : 'false'));
     } else {
         throw new \InvalidArgumentException(sprintf('Unable to append unknown content [%s] to %s', get_class($content), get_class($this)));
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * __call() test
  *
  * Call as method call
  *
  * Expects:
  * - method:
  * - args:
  *
  * Returns: mixed
  */
 public function test__call()
 {
     $r = new Zend_Server_Reflection_Parameter($this->_getParameter());
     // just test a few call proxies...
     $this->assertTrue(is_bool($r->allowsNull()));
     $this->assertTrue(is_bool($r->isOptional()));
 }
Ejemplo n.º 4
0
 public function monopolized($monopolized = true)
 {
     if (is_bool($monopolized)) {
         return $this->andWhere(['monopolized' => $monopolized == true ? 1 : 0]);
     }
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Returns `true` if value is of the specified type
  *
  * @param string $type
  * @param mixed $value
  * @return bool
  */
 protected function checkType($type, $value)
 {
     switch ($type) {
         case 'array':
             return is_array($value);
         case 'bool':
         case 'boolean':
             return is_bool($value);
         case 'callable':
             return is_callable($value);
         case 'float':
         case 'double':
             return is_float($value);
         case 'int':
         case 'integer':
             return is_int($value);
         case 'null':
             return is_null($value);
         case 'numeric':
             return is_numeric($value);
         case 'object':
             return is_object($value);
         case 'resource':
             return is_resource($value);
         case 'scalar':
             return is_scalar($value);
         case 'string':
             return is_string($value);
         case 'mixed':
             return true;
         default:
             return $value instanceof $type;
     }
 }
Ejemplo n.º 6
0
 /**
  * Query database
  *
  * @param   string        $sql          SQL Query
  * @param   array|string  $replacement  Replacement
  * @return  mixed
  */
 public function query()
 {
     $args = func_get_args();
     $sql = array_shift($args);
     // Menerapkan $replacement ke pernyataan $sql
     if (!empty($args)) {
         $sql = vsprintf($sql, $args);
     }
     try {
         // Return 'false' kalo belum ada koneksi
         if (!$this->_db) {
             $this->connect();
         }
         $this->_sql = $sql;
         // Eksekusi SQL Query
         if ($results = $this->_db->query($sql)) {
             if (is_bool($results)) {
                 return $results;
             }
             $this->_results = $results;
             $this->_num_rows = $this->_results->num_rows;
             return $this;
         } else {
             App::error($this->_db->error . '<br>' . $this->_sql);
         }
     } catch (Exception $e) {
         setAlert('error', $e->getMessage());
         return false;
     }
 }
Ejemplo n.º 7
0
 public function useAlias($bVal = null)
 {
     if (is_bool($bVal)) {
         $this->bAlias = $bVal;
     }
     return $this->bAlias;
 }
Ejemplo n.º 8
0
 public function setConfirmed($confirmed)
 {
     if (!is_bool($confirmed)) {
         throw new InvalidArgumentException('Invalid peer link confirmed value "' . $confirmed . '"');
     }
     $this->confirmed = $confirmed;
 }
Ejemplo n.º 9
0
 public static function varExport($var)
 {
     $value = 'n/a';
     $preview = '';
     if (is_bool($var)) {
         $value = $var ? 'true' : 'false';
     } elseif (null === $var) {
         //return 'null';
     } elseif (is_numeric($var)) {
         $value = $var;
     } elseif (is_array($var)) {
         $value = count($var);
         $preview = sprintf('[%s]', preg_replace('/\\n\\s*|^array \\(|\\)$/', '', var_export($var, true)));
     } elseif (is_string($var)) {
         $value = strlen($var);
         $preview = sprintf('"%s"', $var);
     } elseif (is_object($var)) {
         $value = get_class($var);
         if (method_exists($var, '__toString')) {
             $preview = $var->__toString();
         }
     }
     if ($preview && self::$varExportPreviewMaxLength < strlen($preview)) {
         $preview = substr($preview, 0, self::$varExportPreviewMaxLength) . '...';
     }
     return sprintf('%s(%s)%s', gettype($var), $value, $preview ? ' ' . $preview : '');
 }
Ejemplo n.º 10
0
 public function Start($string, $language, $count, $F)
 {
     $snippets = array();
     $query = urlencode(mb_strtolower($string, 'UTF-8'));
     $url = "http://www.mysearch.com/search/GGmain.jhtml?searchfor={$query}&lr=lang_{$language}&ie=utf-8&oe=utf-8";
     $html = $F->GetHTML($url, 'www.mysearch.com');
     if (!is_bool($html)) {
         $i = 0;
         foreach ($html->find('div[class="algoLinkBox"]') as $e) {
             $t = 'a[class="pseudolink"]';
             $d = 'span[class="nDesc"]';
             if (isset($e->find($t, 0)->plaintext)) {
                 $title = $e->find($t, 0)->plaintext;
             }
             if (isset($e->find($d, 0)->plaintext)) {
                 $description = $e->find($d, 0)->plaintext;
             }
             if ($i < $count) {
                 if (!empty($title) and !empty($description)) {
                     $snippets[$i]['title'] = trim($title);
                     $snippets[$i]['description'] = trim($description);
                     $i++;
                 }
             }
         }
         $html->clear();
         $html = null;
         $e = null;
         unset($html, $e);
     } else {
         $F->Error("Can't create outgoing request. Please check MySearch snippets plugin.");
     }
     return $snippets;
 }
Ejemplo n.º 11
0
 public function validate($value)
 {
     if ($this->options['type'] == 'boolean' && !is_bool($value)) {
         throw new \InvalidArgumentException('Must be a boolean');
     }
     if ($this->options['type'] == 'choice' && !in_array($value, $this->options['choices'])) {
         throw new \InvalidArgumentException('Must be on of ' . json_encode($this->options['choices']));
     }
     if ($this->options['type'] == 'text') {
         if (!is_string($value) || strlen($value) < 1) {
             throw new \InvalidArgumentException('Text must be provided');
         }
     }
     if ($this->options['type'] == 'yes-no') {
         if ($value === 'yes') {
             $value = 'y';
         }
         if ($value === 'no') {
             $value = 'n';
         }
         if ($value !== 'y' && $value !== 'n') {
             throw new \InvalidArgumentException('Value should be [y] or [n]');
         }
     }
     return $value;
 }
Ejemplo n.º 12
0
 /**
  * Generates the configuration tree builder.
  *
  * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
  */
 public function getConfigTreeBuilder()
 {
     $treeBuilder = new TreeBuilder();
     $rootNode = $treeBuilder->root('framework');
     $rootNode->children()->scalarNode('charset')->defaultNull()->beforeNormalization()->ifTrue(function ($v) {
         return null !== $v;
     })->then(function ($v) {
         $message = 'The charset setting is deprecated. Just remove it from your configuration file.';
         if ('UTF-8' !== $v) {
             $message .= sprintf(' You need to define a getCharset() method in your Application Kernel class that returns "%s".', $v);
         }
         throw new \RuntimeException($message);
     })->end()->end()->scalarNode('trust_proxy_headers')->defaultFalse()->end()->arrayNode('trusted_proxies')->beforeNormalization()->ifTrue(function ($v) {
         return !is_array($v) && !is_null($v);
     })->then(function ($v) {
         return is_bool($v) ? array() : preg_split('/\\s*,\\s*/', $v);
     })->end()->prototype('scalar')->validate()->ifTrue(function ($v) {
         return !empty($v) && !filter_var($v, FILTER_VALIDATE_IP);
     })->thenInvalid('Invalid proxy IP "%s"')->end()->end()->end()->scalarNode('secret')->isRequired()->end()->scalarNode('ide')->defaultNull()->end()->booleanNode('test')->end()->scalarNode('default_locale')->defaultValue('en')->end()->arrayNode('trusted_hosts')->beforeNormalization()->ifTrue(function ($v) {
         return is_string($v);
     })->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->end();
     $this->addFormSection($rootNode);
     $this->addEsiSection($rootNode);
     $this->addProfilerSection($rootNode);
     $this->addRouterSection($rootNode);
     $this->addSessionSection($rootNode);
     $this->addTemplatingSection($rootNode);
     $this->addTranslatorSection($rootNode);
     $this->addValidationSection($rootNode);
     $this->addAnnotationsSection($rootNode);
     return $treeBuilder;
 }
Ejemplo n.º 13
0
 public function Start($string, $language, $count, $F)
 {
     $snippets = array();
     $query = urlencode(mb_strtolower($string, 'UTF-8'));
     $url = "http://www.nigma.ru/?s={$query}&lang={$language}&ie=utf-8&oe=utf-8";
     $html = $F->GetHTML($url, 'www.nigma.ru');
     if (!is_bool($html)) {
         $i = 0;
         foreach ($html->find('div[id="results"] ol li') as $e) {
             $t = 'div[class="snippet_title"] a';
             $d = 'div[class="snippet_text"]';
             if (isset($e->find($t, 0)->plaintext)) {
                 $title = $e->find($t, 0)->plaintext;
             }
             if (isset($e->find($d, 0)->plaintext)) {
                 $description = $e->find($d, 0)->plaintext;
             }
             if ($i < $count) {
                 if (!empty($title) and !empty($description)) {
                     $snippets[$i]['title'] = trim($title);
                     $snippets[$i]['description'] = trim($description);
                     $i++;
                 }
             }
         }
         $html->clear();
         $html = null;
         $e = null;
         unset($html, $e);
     } else {
         $F->Error("Can't create outgoing request. Please check Nigma snippets plugin.");
     }
     return $snippets;
 }
Ejemplo n.º 14
0
 /**
  * @throws \Exception
  */
 public function update()
 {
     try {
         $ts = time();
         $this->model->setModificationDate($ts);
         $type = get_object_vars($this->model);
         foreach ($type as $key => $value) {
             if (in_array($key, $this->getValidTableColumns(self::TABLE_NAME_KEYS))) {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 }
                 if (is_array($value) || is_object($value)) {
                     if ($this->model->getType() == 'select') {
                         $value = \Zend_Json::encode($value);
                     } else {
                         $value = \Pimcore\Tool\Serialize::serialize($value);
                     }
                 }
                 $data[$key] = $value;
             }
         }
         $this->db->update(self::TABLE_NAME_KEYS, $data, $this->db->quoteInto("id = ?", $this->model->getId()));
         return $this->model;
     } catch (\Exception $e) {
         throw $e;
     }
 }
 function json_encode($data)
 {
     if (is_array($data)) {
         $ret = array();
         // OBJECT
         if (array_keys($data) !== range(0, count($data) - 1)) {
             foreach ($data as $key => $val) {
                 $ret[] = kcfinder_json_string_encode($key) . ':' . json_encode($val);
             }
             return "{" . implode(",", $ret) . "}";
             // ARRAY
         } else {
             foreach ($data as $val) {
                 $ret[] = json_encode($val);
             }
             return "[" . implode(",", $ret) . "]";
         }
         // BOOLEAN OR NULL
     } elseif (is_bool($data) || $data === null) {
         return $data === null ? "null" : ($data ? "true" : "false");
     } elseif (is_float($data)) {
         return rtrim(rtrim(number_format($data, 14, ".", ""), "0"), ".");
     } elseif (is_int($data)) {
         return $data;
     }
     // STRING
     return kcfinder_json_string_encode($data);
 }
Ejemplo n.º 16
0
 public function escape(array $values)
 {
     if (extension_loaded("mbstring")) {
         $toEnc = defined("SDB_MSSQL_ENCODING") ? SDB_MSSQL_ENCODING : "SJIS";
         $fromEnc = mb_internal_encoding();
         $currentRegexEnc = mb_regex_encoding();
         mb_regex_encoding($fromEnc);
         foreach ($values as $k => &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . mb_convert_encoding(mb_ereg_replace("'", "''", $val), $toEnc, $fromEnc) . "'";
             }
         }
         mb_regex_encoding($currentRegexEnc);
     } else {
         foreach ($values as &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . str_replace("'", "''", $val) . "'";
             }
         }
     }
     return $values;
 }
Ejemplo n.º 17
0
 /**
  * @param string $sortField
  * @param bool   $isAscending
  */
 public function __construct($sortField, $isAscending)
 {
     is_string($sortField) === true ?: Exceptions::throwInvalidArgument('sortField', $sortField);
     is_bool($isAscending) === true ?: Exceptions::throwInvalidArgument('isAscending', $isAscending);
     $this->sortField = $sortField;
     $this->isAscending = $isAscending;
 }
Ejemplo n.º 18
0
function debugPrint($var, $file = '')
{
    $more_info = '';
    if (is_string($var)) {
        $more_info = 'size: ' . strlen($var);
    } elseif (is_bool($var)) {
        $more_info = 'val: ' . ($var ? 'true' : 'false');
    } elseif (is_null($var)) {
        $more_info = 'is null';
    } elseif (is_array($var)) {
        $more_info = count($var);
    }
    if ($file === true) {
        $file = '/tmp/logDebug';
    }
    if (strlen($file) > 0) {
        $f = fopen($file, "a");
        ob_start();
        echo date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info . "\n";
        print_r($var);
        echo "\n\n";
        $output = ob_get_clean();
        fprintf($f, "%s", $output);
        fclose($f);
    } else {
        echo "<pre>" . date("Y/m/d H:i:s") . " (" . gettype($var) . ") " . $more_info . "</pre>";
        echo "<pre>";
        print_r($var);
        echo "</pre>";
    }
}
Ejemplo n.º 19
0
 public function init()
 {
     SWFUpload::$threadId++;
     if (is_string($this->imgUrlList)) {
         $this->imgUrlList = array($this->imgUrlList);
     }
     if ($this->uploadUrl === '') {
         $this->uploadUrl = $this->controller->createUrl('upload');
         //上传路径默认action为upload ,可以使用SWFUploadAction
     }
     if (!is_bool($this->debug)) {
         throw new Exception('debug参数需要一个bool值(false/true)');
     }
     $this->postParams['SWFUpload'] = SWFUpload::$threadId;
     //标识是SWFUpload上传请求
     $this->postParams['callbackJS'] = $this->callbackJS;
     $this->postParams['SessionID'] = Yii::app()->session->getSessionID();
     $this->postParams['fileQuenueLimit'] = $this->fileQuenueLimit;
     $this->postParams['companyId'] = $this->companyId;
     $this->postParams['folder'] = $this->folder;
     $assets = dirname(__FILE__) . '/assets';
     $this->baseUrl = Yii::app()->assetManager->publish($assets);
     if (is_dir($assets)) {
         Yii::app()->clientScript->registerCoreScript('jquery');
         Yii::app()->clientScript->registerScriptFile($this->baseUrl . '/swfupload.js', CClientScript::POS_HEAD);
         Yii::app()->clientScript->registerScriptFile($this->baseUrl . '/handlers.js', CClientScript::POS_HEAD);
     } else {
         throw new Exception('SWFUpload - Error: Couldn\'t find assets to publish.');
     }
 }
Ejemplo n.º 20
0
 public function parseOptions()
 {
     $shortopts = '';
     $longopts = array();
     $defaults = array();
     foreach (self::$optionDefs as $name => $def) {
         $def += array('default' => '', 'short' => false);
         $defaults[$name] = $def['default'];
         $postfix = is_bool($defaults[$name]) ? '' : ':';
         $longopts[] = $name . $postfix;
         if ($def['short']) {
             $shortmap[$def['short']] = $name;
             $shortopts .= $def['short'] . $postfix;
         }
     }
     $received = getopt($shortopts, $longopts);
     foreach (array_keys($received) as $key) {
         if (strlen($key) === 1) {
             $received[$shortmap[$key]] = $received[$key];
             unset($received[$key]);
         }
     }
     // getopt is odd ... it returns false for received args with no options allowed
     foreach (array_keys($received) as $key) {
         if (false === $received[$key]) {
             $received[$key] = true;
         }
     }
     $received += $defaults;
     if ($received['help']) {
         $this->usage();
         exit(0);
     }
     return $received;
 }
Ejemplo n.º 21
0
 public static function doConvert(array $data, array $parent = array())
 {
     $output = '';
     foreach ($data as $k => $v) {
         $index = str_replace(' ', '-', $k);
         if (is_array($v)) {
             $sec = array_merge((array) $parent, (array) $index);
             $output .= PHP_EOL . '[' . join('.', $sec) . ']' . PHP_EOL;
             $output .= self::doConvert($v, $sec);
         } else {
             $output .= "{$index}=";
             if (is_numeric($v) || is_float($v)) {
                 $output .= "{$v}";
             } elseif (is_bool($v)) {
                 $output .= $v === true ? 1 : 0;
             } elseif (is_string($v)) {
                 $output .= "'" . addcslashes($v, "'") . "'";
             } else {
                 $output .= "{$v}";
             }
             $output .= PHP_EOL;
         }
     }
     return $output;
 }
Ejemplo n.º 22
0
 public function setDisabled($isDisabled)
 {
     if (!is_bool($isDisabled)) {
         throw new InvalidArgumentException('Invalid user disabled value "' . $isDisabled . '"');
     }
     $this->disabled = $isDisabled;
 }
Ejemplo n.º 23
0
 /**
  * @param bool|null $val
  * @return bool
  */
 public function poweredBy($val = null)
 {
     if (is_bool($val)) {
         $this->__poweredBy = $val;
     }
     return $this->__poweredBy;
 }
Ejemplo n.º 24
0
function osd_val($key, $value)
{
    $nums = array("Version", "LeftNode", "RightNode");
    $out = "";
    if (is_null($value)) {
        $out .= "\"\"";
    } else {
        if (is_array($value)) {
        } else {
            if (is_numeric($value)) {
                if (in_array($value, $nums)) {
                    $out .= $value;
                } else {
                    $out .= js_escape_string($value);
                }
            } else {
                if ($key == "ExtraData") {
                    $out .= !empty($value) ? $value : '{}';
                } else {
                    if (is_string($value)) {
                        $out .= js_escape_string($value);
                    } else {
                        if (is_bool($value)) {
                            $out .= $value ? "true" : "false";
                        } else {
                            $out .= sprintf("?%s?", js_escape_string($value));
                        }
                    }
                }
            }
        }
    }
    return $out;
}
Ejemplo n.º 25
0
 public function setAdminAuthenticated($authenticated = true)
 {
     if (!is_bool($authenticated)) {
         throw new InvalidArgumentException('Le valeur spécifié à la méthode User::setAdminAuthenticated() doit être un boolean');
     }
     $_SESSION['admin-auth'] = $authenticated;
 }
Ejemplo n.º 26
0
 /**
  * @param mixed            $value
  * @param AbstractPlatform $platform
  *
  * @return string
  * @throws \InvalidArgumentException
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (empty($value)) {
         return '';
     }
     if ($value instanceof \stdClass) {
         $value = get_object_vars($value);
     }
     if (!is_array($value)) {
         throw new \InvalidArgumentException("Hstore value must be off array or \\stdClass.");
     }
     $hstoreString = '';
     foreach ($value as $k => $v) {
         if (!is_string($v) && !is_numeric($v) && !is_bool($v)) {
             throw new \InvalidArgumentException("Cannot save 'nested arrays' into hstore.");
         }
         $v = trim($v);
         if (!is_numeric($v) && false !== strpos($v, ' ')) {
             $v = sprintf('"%s"', $v);
         }
         $hstoreString .= "{$k} => {$v}," . "\n";
     }
     $hstoreString = substr(trim($hstoreString), 0, -1) . "\n";
     return $hstoreString;
 }
Ejemplo n.º 27
0
 private function setupMocks($mocks = array(), $inject = false)
 {
     if (is_bool($mocks) || is_array($mocks) && empty($mocks)) {
         $inject = $mocks;
         $mocks = array('emailValidator', 'translator', 'userRepository', 'userTokenGenerator', 'mailerPlugin');
     }
     if (!is_array($mocks)) {
         $mocks = array($mocks);
     }
     if (in_array('emailValidator', $mocks)) {
         $this->emailValidatorMock = new EmailAddress();
     }
     if (in_array('translator', $mocks)) {
         $this->translatorMock = $this->getMockBuilder('\\Zend\\I18n\\Translator\\Translator')->getMock();
     }
     if (in_array('userRepository', $mocks)) {
         $this->userRepositoryMock = $this->getMockBuilder('\\Auth\\Repository\\User')->disableOriginalConstructor()->getMock();
     }
     if (in_array('userTokenGenerator', $mocks)) {
         $this->userTokenGeneratorMock = $this->getMockBuilder('\\Auth\\Service\\UserUniqueTokenGenerator')->disableOriginalConstructor()->getMock();
     }
     if (in_array('mailerPlugin', $mocks)) {
         $this->mailerPluginMock = $this->getMockBuilder('\\Core\\Controller\\Plugin\\Mailer')->disableOriginalConstructor()->getMock();
     }
     if ($inject) {
         foreach ($mocks as $key) {
             $setter = 'set' . $key;
             $this->target->{$setter}($this->{$key . 'Mock'});
         }
     }
 }
Ejemplo n.º 28
0
 public function createCommand(TaskInfo $taskInfo)
 {
     $task = new Command($taskInfo->getName());
     $task->setDescription($taskInfo->getDescription());
     $task->setHelp($taskInfo->getHelp());
     $args = $taskInfo->getArguments();
     foreach ($args as $name => $val) {
         $description = $taskInfo->getArgumentDescription($name);
         if ($val === TaskInfo::PARAM_IS_REQUIRED) {
             $task->addArgument($name, InputArgument::REQUIRED, $description);
         } elseif (is_array($val)) {
             $task->addArgument($name, InputArgument::IS_ARRAY, $description, $val);
         } else {
             $task->addArgument($name, InputArgument::OPTIONAL, $description, $val);
         }
     }
     $opts = $taskInfo->getOptions();
     foreach ($opts as $name => $val) {
         $description = $taskInfo->getOptionDescription($name);
         $fullName = $name;
         $shortcut = '';
         if (strpos($name, '|')) {
             list($fullName, $shortcut) = explode('|', $name, 2);
         }
         if (is_bool($val)) {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_NONE, $description);
         } else {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_OPTIONAL, $description, $val);
         }
     }
     return $task;
 }
Ejemplo n.º 29
0
function is_empty($var, $allow_false = false, $allow_ws = false)
{
    if (!isset($var) || is_null($var)) {
        return true;
    }
    if (is_array($var)) {
        if (empty($var)) {
            return true;
        } else {
            return false;
        }
    }
    if (is_bool($var)) {
        if ($allow_false === false && $var === false) {
            return true;
        } else {
            return false;
        }
    } else {
        if ($allow_ws == false && trim($var) == "") {
            return true;
        } else {
            return false;
        }
    }
    return false;
}
Ejemplo n.º 30
-1
 public function cleanValueForGetting($value)
 {
     if (is_bool($value)) {
         return $value;
     }
     return $value == '1' ? true : false;
 }