@param  PhpParser\Node\Expr $first_arg_value

@return null|string
184550
public static function getConstName($first_arg_value, Codebase $codebase, Aliases $aliases)
    {
        $const_name = null;

        if ($first_arg_value instanceof PhpParser\Node\Scalar\String_) {
            $const_name = $first_arg_value->value;
        } elseif (isset($first_arg_value->inferredType)) {
            if ($first_arg_value->inferredType->isSingleStringLiteral()) {
                $const_name = $first_arg_value->inferredType->getSingleStringLiteral()->value;
            }
        } else {
            $simple_type = self::getSimpleType($codebase, $first_arg_value, $aliases);
            if ($simple_type && $simple_type->isSingleStringLiteral()) {
                $const_name = $simple_type->getSingleStringLiteral()->value;
            }
        }

        return $const_name;
    }
1300001
public static function extractArgs(array $args, ?PaginationType $paginationType, ?int $paginateMaxCount): array
    {
        if ($paginationType->isConnection()) {
            /** @var int $first */
            $first = $args['first'];
            $page = self::calculateCurrentPage(
                $first,
                Cursor::decode($args)
            );
        } else {
            /** @var int $first */
            $first = $args[config('lighthouse.pagination_amount_argument')];
            $page = Arr::get($args, 'page', 1);
        }

        if ($first <= 0) {
            throw new Error(
                "Requested pagination amount must be more than 0, got $first"
            );
        }

        // Make sure the maximum pagination count is not exceeded
        if (
            $paginateMaxCount !== null
            && $first > $paginateMaxCount
        ) {
            throw new Error(
                "Maximum number of {$paginateMaxCount} requested items exceeded. Fetch smaller chunks."
            );
        }

        return [$first, $page];
    }
934266
public function getInstance(string $id, $thrErr = true, $forceNew = false)
    {
        if (!$id) {
            throw new \InvalidArgumentException(sprintf(
                'The first parameter must be a non-empty string, %s given',
                \gettype($id)
            ));
        }

        $id = $this->resolveAlias($id);

        if ($service = $this->getService($id, $thrErr)) {
            return $service->get($this, $forceNew);
        }

        return null;
    }
1290325
function parse($args = null)
    {
        if ($args === null) {
            $args = array_slice($_SERVER['argv'], 1);
        }

        foreach ($args as $pos => $arg) {
            // reset value
            $value = null;

            if (substr($arg, 0, 1) === '-') {
                if (preg_match('/^(.+)=(.+)$/', $arg, $matches)) {
                    $arg = $matches[1];
                    $value = $matches[2];
                }

                if (!$flag = @$this->flags[$arg]) {
                    throw new ParseException(sprintf('Flag "%s" is not defined.', $arg));
                }

                unset($args[$pos]);

                if ($flag->hasValue) {
                    if (!isset($value)) {
                        $value = $args[$pos + 1];
                        unset($args[$pos + 1]);
                    }
                } else {
                    $value = true;
                }

                if (null !== $flag->callback) {
                    call_user_func_array($flag->callback, array(&$value));
                }

                # Set the reference given as the flag's 'var'.
                $flag->var = $this->parsedFlags[$flag->name] = $value;
            }
        }

        # TODO: Refactor this so this fits into the above foreach
        foreach ($this->flags as $flag) {
            if (!array_key_exists($flag->name, $this->parsedFlags)) {
                $flag->var = $this->parsedFlags[$flag->name] = $flag->defaultValue;
            }
        }

        $this->parsedArgs = $args = array_values($args);

        $pos = 0;

        foreach ($this->args as $arg) {
            if ($arg->required and !isset($args[$pos])) {
                throw new ArgumentException(sprintf(
                    'Missing required argument "%s"', $arg->name
                ));
            }

            if (isset($args[$pos])) {
                if ($arg->vararg) {
                    $value = array_slice($args, $pos);
                    $pos += count($value);
                } else {
                    $value = $args[$pos];
                    $pos++;
                }
            } else {
                $value = $arg->defaultValue;
            }

            $this->parsedNamedArgs[$arg->name] = $value;
        }
    }
1174900
public function getFirstChild()
	{
		$xpathStr = self::XPATH_THIS . '*[1]';
		$results = $this->xpath($xpathStr);
		if (count($results) >= 1) {
			return $results[0];
		}
		return null;
	}
349299
public static function PrintValue($arg1, $arg2 = null)
	{
		if (self::$_logger == null)
			self::$_logger = new LogWrapper('debug.output');

		for ($i = 0, $numArgs = func_num_args(); $i < $numArgs ; $i++)
		{
			$var = func_get_arg($i);
			ErrorHandler::getInstance()->addExtraInfo('DEBUG_' . (Debug::$count++), $var);

			if (array_key_exists("raw", $_REQUEST))
			{
				continue;
			}

			if (is_array($var))
			{
				self::writeLog(null, print_r($var, true), true);
			}
			elseif ($var instanceof SingleRow)
			{
				self::writeLog('SingleRow', print_r($var->toArray(), true), true);
			}
			elseif ($var instanceof AnyDataset)
			{
				Debug::PrintValue($var->getIterator());
			}
			elseif ( ($var instanceof IteratorInterface) || ($var instanceof AnyIterator) )
			{
				$it = $var;
				if (!$it->hasNext())
				{
					self::writeLog('IteratorInterface', "Não trouxe registros.", false);
				}
				else
				{
					$result = "<style>.devdebug {border: 1px solid silver; padding: 2px;} table.devdebug {border-collapse:collapse;} th.devdebug {background-color: silver}</style>"
							. "<table class='devdebug'>";
					$arr = null;
					while ($it->hasNext())
					{
						$i++;
						$sr = $it->moveNext();
						if ($i>100)
							break;

						if (is_null($arr))
						{
							$arr = $sr->getFieldNames();
							$result .= '<tr><th class="devdebug">' . implode('</b></th><th class="devdebug">', $arr) . '</th></tr>';
						}

						$raw = $sr->toArray();
						$result .= '<tr>';
						foreach($raw as $item)
						{
							$result .= '<td class="devdebug">';
							if (is_array($item))
							{
								$result .= implode(',', $item);
							}
							else
							{
								$result .= $item;
							}
							$result .= '</td>';
						}
						$result .= '</tr>';
					}
					$result .= "</table>";
					self::writeLog('IteratorInterface', $result, false);
				}
			}
			elseif ($var instanceof IteratorFilter)
			{
				$filter = $var->getSql("ANYTABLE", $param, "*");
				$filter = substr($filter, strpos($filter, "where") + 6);
				$result = array(
					"XPath" => $var->getXPath(),
					"Filter" => $filter
				) + $param;

				self::writeLog(get_class($var), print_r($result, true), true);
			}
			elseif ($var instanceof FilenameProcessor)
			{
				$result = array(
					"PathSuggested()" => $var->PathSuggested(),
					"PrivatePath()" => $var->PrivatePath(),
					"SharedPath()" => $var->SharedPath(),
					"Name" => $var->ToString(),
					"Extension()" => $var->Extension(),
					"FullQualifiedName()" => $var->FullQualifiedName(),
					"FullQualifiedNameAndPath()" => $var->FullQualifiedNameAndPath(),
					"getFilenameLocation()" =>  $var->getFilenameLocation(),
					"File Exists?" => file_exists($var->FullQualifiedNameAndPath()) ? "yes" : "no"
				);

				self::writeLog(get_class($var), print_r($result, true), true);
			}
			elseif ($var instanceof LanguageCollection)
			{
				self::writeLog("", get_class($var) . ": Is Loaded? " . ($var->loadedFromFile() ? 'yes' : 'no'), false);
				$var->Debug();
			}
			elseif (is_object($var))
			{
				if ($var instanceof DOMDocument)
				{
					$var->formatOutput = true;
					self::writeLog(get_class($var), htmlentities($var->saveXML()), true);
				}
				elseif ( ($var instanceof DOMElement) || ($var instanceof DOMNode) )
				{
					$doc = $var->ownerDocument;
					$doc->formatOutput = true;
					echo htmlentities($doc->saveXML($var)) . "</pre>";
					self::writeLog(get_class($var), htmlentities('[' . $var->nodeName . "]") . "\n" . htmlentities($doc->saveXML()), true);
				}
				else
				{
					self::writeLog(get_class($var), print_r($var, true), true);
				}
			}
			elseif (gettype($var) == "boolean")
			{
				self::writeLog("", '(boolean) ' . ($var ? "true":"false"), true);
			}
			else
			{
				self::writeLog("", gettype($var) . ": ". $var, true);
			}
		}
	}
740474
def p_arg1(p):
    
    # a hack to support "clear global"
    p[0] = node.string(value=str(p[1]), lineno=p.lineno(1), lexpos=p.lexpos(1))
30010
public function parse($arguments = null)
    {
        $this->_options = [];
        $this->_values = [];

        if ($arguments === null) {
            if (isset($GLOBALS['argv'][1]) && $GLOBALS['argv'][1][0] === '/') {
                $arguments = [$GLOBALS['argv'][1]];
            } else {
                /** @noinspection CallableParameterUseCaseInTypeContextInspection */
                $arguments = array_slice($GLOBALS['argv'], 3);
            }
        }

        if (count($arguments) === 1 && $arguments[0][0] === '/') {
            $query = parse_url($arguments[0], PHP_URL_QUERY);
            parse_str($query, $this->_options);
            if (($fragment = parse_url($arguments[0], PHP_URL_FRAGMENT)) !== null) {
                $this->_values[] = $fragment;
            }
        } else {
            $this->_parse($arguments);
        }

        return $this;
    }
530862
private function _getParagraph($first = false)
    {
        $words = $this->_dictionary;
        shuffle($words);
        if ($first) {
            $pre = array('lorem', 'ipsum');
            $words = array_merge($pre, $words);
        }
        $nbrWordsPerParagraph = $this->_nbrWordsPerParagraph + mt_rand(-20, 20);
        $nbrWordsPerSentence = $this->_nbrWordsPerSentence + mt_rand(-8, 8);
        $words = array_slice($words, 0, $nbrWordsPerParagraph);
        $sentences = array_chunk($words, $nbrWordsPerSentence);
        $result = array();
        foreach ($sentences as &$sentence) {
            $this->_punctuate($sentence);
            $result[] = ucfirst(implode(' ', $sentence));
        }
        return ('<p>' . implode(' ', $result) . '</p>');
    }
82262
public function getFirstArgument()
    {
        foreach ($this->argv as $value) {
            if ($value && '-' === $value[0]) {
                continue;
            }

            return $value;
        }

        return isset($this->definition->getDefaultInputArguments()[0]) ?
            $this->definition->getDefaultInputArguments()[0]->getDefault() : false;
    }
354274
public function first()
    {
        $tmpArray = $this->getArray();

        $key_first = array_key_first($tmpArray);
        if ($key_first === null) {
            return null;
        }

        return $tmpArray[$key_first];
    }
1085138
public static function fetchArguments($_class = null, $_method = null, $args = null)
    {
        if (empty($_class) || empty($_method)) {
            return null;
        }
        $args_def = array();
        if (!empty($args)) {
            $analyze = new ReflectionMethod($_class, $_method);
            foreach($analyze->getParameters() as $_param) {
                $arg_index = $_param->getName();
                $args_def[$_param->getPosition()] = isset($args[$arg_index]) ?
                    $args[$arg_index] : ( $_param->isOptional() ? $_param->getDefaultValue() : null );
            }
        }
        return call_user_func_array( array($_class, $_method), $args_def );
    }
886633
function uc( $str, $first = false ) {
		if ( function_exists( 'mb_strtoupper' ) ) {
			if ( $first ) {
				if ( $this->isMultibyte( $str ) ) {
					return mb_strtoupper( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 );
				} else {
					return ucfirst( $str );
				}
			} else {
				return $this->isMultibyte( $str ) ? mb_strtoupper( $str ) : strtoupper( $str );
			}
		} else {
			if ( $this->isMultibyte( $str ) ) {
				$x = $first ? '^' : '';
				return preg_replace_callback(
					"/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/",
					array( $this, 'ucCallback' ),
					$str
				);
			} else {
				return $first ? ucfirst( $str ) : strtoupper( $str );
			}
		}
	}
231553
protected function parseArgument($arg)
    {
        //if it's a literal string value
        if (strpos($arg, '"') === 0
            || strpos($arg, "'") === 0
        ) {
            return "'" . str_replace("'", '\\\'', substr($arg, 1, -1)) . "'";
        }
        
        //if it's null
        if (strtolower($arg) === 'null'
            || strtolower($arg) === 'true'
            || strtolower($arg) === 'false'
            || is_numeric($arg)
        ) {
            return $arg;
        }
        
        $arg = str_replace(array('[', ']', '(', ')'), '', $arg);
        $arg = str_replace("'", '\\\'', $arg);
        return sprintf(self::BLOCK_ARGUMENT_VALUE, $arg);
    }
853285
public static function toCamelCase($p_str, $p_first = false, $p_glue = '_')
    {
        if (trim($p_str) == '') {
            return $p_str;
        }
        if ($p_first) {
            $p_str[0] = strtoupper($p_str[0]);
        }
        return preg_replace_callback(
            "|{$p_glue}([a-z])|",
            function ($matches) use ($p_glue) {
                return str_replace($p_glue, '', strtoupper($matches[0]));
            },
            $p_str
        );
    }
1374464
public static function getFirst($arg) {
        $str = iconv('UTF-8', 'gb2312', $arg);//如果程序是gbk的，此行就要注释掉
        if (!preg_match('/^[\x7f-\xff]/', $str)) {
            return strtoupper($str[0]);
        }
        $firstChar=ord($str{0});
        if($firstChar >= ord('A') && $firstChar <= ord('z')) {
            return strtoupper($str{0});
        }
        $a = $str;
        $val = ord($a{0}) * 256 + ord($a{1}) - 65536;
        if ($val >= -20319 && $val <= -20284)  {
            return 'A';
        }
        if ($val >= -20283 && $val <= -19776) {
            return 'B';
        }
        if ($val >= -19775 && $val <= -19219) {
            return 'C';
        }
        if ($val >= -19218 && $val <= -18711) {
            return 'D';
        }
        if ($val >= -18710 && $val <= -18527) {
            return 'E';
        }
        if ($val >= -18526 && $val <= -18240) {
            return 'F';
        }
        if ($val >= -18239 && $val <= -17923) {
            return 'G';
        }
        if ($val >= -17922 && $val <= -17418) {
            return 'H';
        }
        if ($val >= -17417 && $val <= -16475) {
            return 'J';
        }
        if ($val >= -16474 && $val <= -16213) {
            return 'K';
        }
        if ($val >= -16212 && $val <= -15641) {
            return 'L';
        }
        if ($val >= -15640 && $val <= -15166) {
            return 'M';
        }
        if ($val >= -15165 && $val <= -14923) {
            return 'N';
        }
        if ($val >= -14922 && $val <= -14915) {
            return 'O';
        }
        if ($val >= -14914 && $val <= -14631) {
            return 'P';
        }
        if ($val >= -14630 && $val <= -14150) {
            return 'Q';
        }
        if ($val >= -14149 && $val <= -14091) {
            return 'R';
        }
        if ($val >= -14090 && $val <= -13319) {
            return 'S';
        }
        if ($val >= -13318 && $val <= -12839) {
            return 'T';
        }
        if ($val >= -12838 && $val <= -12557) {
            return 'W';
        }
        if ($val >= -12556 && $val <= -11848) {
            return 'X';
        }
        if ($val >= -11847 && $val <= -11056) {
            return 'Y';
        }
        if ($val >= -11055 && $val <= -10247) {
            return 'Z';
        }
        return strtoupper($str[0]);
    }
635147
public function set($arg1 = null, $arg2 = null)
    {
        if (is_string($arg1) && $arg2 !== null) {

            // must be initialized
            $this->template->set($arg1, $arg2);

            return $this;
        }

        if ($arg2 !== null) {
            throw new Exception([
                'Second argument to set() can be only passed if the first one is a string',
                'arg1' => $arg1,
                'arg2' => $arg2,
            ]);
        }

        if (is_scalar($arg1)) {
            $this->content = $arg1;

            return $this;
        }

        if (is_array($arg1)) {
            if (isset($arg1[0])) {
                $this->content = $arg1[0];
            }
            $this->setDefaults($arg1);

            return $this;
        }

        throw new Exception([
            'Not sure what to do with argument',
            'this' => $this,
            'arg1' => $arg1,
            'arg2' => $arg2,
        ]);
    }