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


PHP ReflectionFunction::getModifiers方法代码示例

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


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

示例1: dump

    /**
     * cfdump-style debugging output
     * @param $var    The variable to output.
     * @param $limit  Maximum recursion depth for arrays (default 0 = all)
     * @param $label  text to display in complex data type header
     * @param $depth  Current depth (default 0)
     */
    public function dump(&$var, $limit = 0, $label = '', $depth = 0)
    {
        if ($limit > 0 && $depth >= $limit) {
            return;
        }
        static $seen = array();
        $he = function ($s) {
            return htmlentities($s);
        };
        $self = $this;
        $echoFunction = function ($var, $tabs, $label = '') use($self) {
            if (!is_subclass_of($var, 'ReflectionFunctionAbstract')) {
                $var = new \ReflectionFunction($var);
            }
            echo "{$tabs}<table class=\"dump function\">{$tabs}<thead><tr><th>" . ($label != '' ? $label . ' - ' : '') . (is_callable(array($var, 'getModifiers')) ? htmlentities(implode(' ', \Reflection::getModifierNames($var->getModifiers()))) : '') . " function " . htmlentities($var->getName()) . "</th></tr></thead>{$tabs}<tbody>";
            echo "{$tabs}<tr><td class=\"value\">{$tabs}<table class=\"dump layout\">{$tabs}<tr><th>Parameters:</th><td>";
            $params = $var->getParameters();
            if (count($params) > 0) {
                echo "</td></tr>{$tabs}<tr><td colspan=\"2\">{$tabs}<table class=\"dump param\">{$tabs}<thead><tr><th>Name</th><th>Array/Ref</th><th>Required</th><th>Default</th></tr></thead>{$tabs}<tbody>";
                foreach ($params as $param) {
                    echo "{$tabs}<tr><td>" . htmlentities($param->getName()) . "</td><td>" . ($param->isArray() ? "Array " : "") . ($param->isPassedByReference() ? "Reference" : "") . "</td><td>" . ($param->isOptional() ? "Optional" : "Required") . "</td><td>";
                    if ($param->isOptional()) {
                        $self->dump($param->getDefaultValue());
                    }
                    echo "</td></tr>";
                }
                echo "{$tabs}</tbody>{$tabs}</table>";
            } else {
                echo "none</td></tr>";
            }
            $comment = trim($var->getDocComment());
            if ($comment !== NULL && $comment !== '') {
                echo "{$tabs}<tr><th>Doc Comment:</th><td><kbd>" . str_replace("\n", "<br/>", htmlentities($comment)) . "</kbd></td></tr>";
            }
            echo "</table>{$tabs}</td></tr>";
            echo "{$tabs}</tbody>{$tabs}</table>";
        };
        $tabs = "\n" . str_repeat("\t", $depth);
        $depth++;
        $printCount = 0;
        if (!array_key_exists('fw1dumpstarted', $_REQUEST)) {
            $_REQUEST['fw1dumpstarted'] = TRUE;
            echo <<<DUMPCSS
<style type="text/css">/* fw/1 dump */
table.dump { color: black; background-color: white; font-size: xx-small; font-family: verdana,arial,helvetica,sans-serif; border-spacing: 0; border-collapse: collapse; }
table.dump th { text-indent: -2em; padding: 0.25em 0.25em 0.25em 2.25em; color: #fff; }
table.dump td { padding: 0.25em; }
table.dump th, table.dump td { border-width: 2px; border-style: solid; border-spacing: 0; vertical-align: top; text-align: left; }
table.dump.object, table.dump.object td, table.dump.object th { border-color: #f00; }
table.dump.object th { background-color: #f44; }
table.dump.object .key { background-color: #fcc; }
table.dump.array, table.dump.array td, table.dump.array th { border-color: #060; }
table.dump.array th { background-color: #090; }
table.dump.array .key { background-color: #cfc; }
table.dump.struct, table.dump.struct td, table.dump.struct th { border-color: #00c; }
table.dump.struct th { background-color: #44c; }
table.dump.struct .key { background-color: #cdf; }
table.dump.function, table.dump.function td, table.dump.function th { border-color: #a40; }
table.dump.function th { background-color: #c60; }
table.dump.layout, table.dump.layout td, table.dump.layout th { border-color: #fff; }
table.dump.layout th { font-style: italic; background-color: #fff; color: #000; font-weight: normal; }
table.dump.param, table.dump.param td, table.dump.param th { border-color: #ddd; }
table.dump.param th { background-color: #eee; color: black; font-weight: bold; }
</style>
DUMPCSS;
        }
        if (is_array($var)) {
            $label = $label === '' ? $var === $_POST ? '$_POST' : ($var === $_GET ? '$_GET' : ($var === $_COOKIE ? '$_COOKIE' : ($var === $_ENV ? '$_ENV' : ($var === $_FILES ? '$_FILES' : ($var === $_REQUEST ? '$_REQUEST' : ($var === $_SERVER ? '$_SERVER' : ($var === $_SESSION ? '$_SESSION' : ''))))))) : $label;
            $c = count($var);
            if (isset($var['fw1recursionsentinel'])) {
                echo "(Recursion)";
            }
            $aclass = $c > 0 && array_key_exists(0, $var) && array_key_exists($c - 1, $var) ? 'array' : 'struct';
            $var['fw1recursionsentinel'] = true;
            echo "{$tabs}<table class=\"dump {$aclass}\">{$tabs}<thead><tr><th colspan=\"2\">" . ($label != '' ? $label . ' - ' : '') . "array" . ($c > 0 ? "" : " [empty]") . "</th></tr></thead>{$tabs}<tbody>";
            foreach ($var as $index => $aval) {
                if ($index === 'fw1recursionsentinel') {
                    continue;
                }
                echo "{$tabs}<tr><td class=\"key\">" . $he($index) . "</td><td class=\"value\">";
                $this->dump($aval, $limit, '', $depth);
                echo "</td></tr>";
                $printCount++;
                if ($limit > 0 && $printCount >= $limit && $aclass === 'array') {
                    break;
                }
            }
            echo "{$tabs}</tbody>{$tabs}</table>";
            // unset($var['fw1recursionsentinel']);
        } elseif (is_string($var)) {
            echo $var === '' ? '[EMPTY STRING]' : htmlentities($var);
        } elseif (is_bool($var)) {
            echo $var ? "TRUE" : "FALSE";
//.........这里部分代码省略.........
开发者ID:rickosborne,项目名称:rickosborne,代码行数:101,代码来源:Framework.php

示例2: dump

	/**
	 * cfdump-style debugging output
	 * @param $var    The variable to output.
	 * @param $limit  Maximum recursion depth for arrays (default 0 = all)
	 * @param $label  text to display in complex data type header
	 * @param $depth  Current depth (default 0)
	 */
	public function dump(&$var, $limit = 0, $label = '', $depth = 0) {
		if (!is_int($depth))
			$depth = 0;
		if (!is_int($limit))
			$limit = 0;
		if (($limit > 0) && ($depth >= $limit))
			return;
		static $seen = array();
		$he = function ($s) { return htmlentities($s); };
		$tabs = "\n" . str_repeat("\t", $depth);
		$depth++;
		$printCount = 0;
		$self = $this;
		$echoFunction = function($var, $tabs, $limit = 0, $label = '', $depth = 0) use ($self) {
			if (!is_subclass_of($var, 'ReflectionFunctionAbstract')) {
				$var = new \ReflectionFunction($var);
			}
			echo "$tabs<table class=\"dump function depth${depth}\">$tabs<thead><tr><th>" . ($label != '' ? $label . ' - ' : '') . (is_callable(array($var, 'getModifiers')) ? htmlentities(implode(' ', \Reflection::getModifierNames($var->getModifiers()))) : '') . " function " . htmlentities($var->getName()) . "</th></tr></thead>$tabs<tbody>";
			echo "$tabs<tr><td class=\"value\">$tabs<table class=\"dump layout\">$tabs<tr><th>Parameters:</th><td>";
			$params = $var->getParameters();
			if (count($params) > 0) {
				echo "</td></tr>$tabs<tr><td colspan=\"2\">$tabs<table class=\"dump param\">$tabs<thead><tr><th>Name</th><th>Array/Ref</th><th>Required</th><th>Default</th></tr></thead>$tabs<tbody>";
				foreach ($params as $param) {
					echo "$tabs<tr><td>" . htmlentities($param->getName()) . "</td><td>" . ($param->isArray() ? "Array " : "") . ($param->isPassedByReference() ? "Reference" : "") . "</td><td>" . ($param->isOptional() ? "Optional" : "Required") . "</td><td>";
					if ($param->isOptional() && $param->isDefaultValueAvailable()) {
						$self->dump($param->getDefaultValue(), $limit, $label, $depth);
					}
					echo "</td></tr>";
				}
				echo "$tabs</tbody>$tabs</table>";
			} else {
				echo "none</td></tr>";
			}
			$comment = trim($var->getDocComment());
			if (($comment !== NULL) && ($comment !== '')) {
				echo "$tabs<tr><th>Doc Comment:</th><td><kbd>" . str_replace("\n", "<br/>", htmlentities($comment)) . "</kbd></td></tr>";
			}
			echo "</table>$tabs</td></tr>";
			echo "$tabs</tbody>$tabs</table>";
		};
		if (!array_key_exists('fw1dumpstarted', $_REQUEST)) {
			$_REQUEST['fw1dumpstarted'] = TRUE;
			echo<<<DUMPCSSJS
<style type="text/css">/* fw/1 dump */
table.dump { color: black; background-color: white; font-size: xx-small; font-family: verdana,arial,helvetica,sans-serif; border-spacing: 0; border-collapse: collapse; }
table.dump th { text-indent: -2em; padding: 0.25em 0.25em 0.25em 2.25em; color: #fff; }
table.dump td { padding: 0.25em; }
table.dump .key { cursor: pointer; }
table.dump td.shh { background-color: #ddd; }
table.dump td.shh div { display: none; }
table.dump td.shh:before { content: "..."; }
table.dump th, table.dump td { border-width: 2px; border-style: solid; border-spacing: 0; vertical-align: top; text-align: left; }
table.dump.object, table.dump.object > * > tr > td, table.dump.object > thead > tr > th { border-color: #f00; }
table.dump.object > thead > tr > th { background-color: #f44; }
table.dump.object > tbody > tr > .key { background-color: #fcc; }
table.dump.array, table.dump.array > * > tr > td, table.dump.array > thead > tr > th { border-color: #060; }
table.dump.array > thead > tr > th { background-color: #090; }
table.dump.array > tbody > tr > .key { background-color: #cfc; }
table.dump.struct, table.dump.struct > * > tr > td, table.dump.struct > thead > tr > th { border-color: #00c; }
table.dump.struct > thead > tr > th { background-color: #44c; }
table.dump.struct > tbody > tr > .key { background-color: #cdf; }
table.dump.function, table.dump.function > * > tr > td, table.dump.function > thead > tr > th { border-color: #a40; }
table.dump.function > thead > tr > th { background-color: #c60; }
table.dump.layout, table.dump.layout > * > tr > td, table.dump.layout > thead > tr > th { border-color: #fff; }
table.dump.layout > * > tr > th { font-style: italic; background-color: #fff; color: #000; font-weight: normal; border: none; }
table.dump.param, table.dump.param > * > tr > td, table.dump.param > thead > tr > th { border-color: #ddd; }
table.dump.param > thead > tr > th  { background-color: #eee; color: black; font-weight: bold; }
</style>
<script type="text/javascript" language="JavaScript">
(function(w,d){
	var addEvent = function(o,t,f) {
		if (o.addEventListener) o.addEventListener(t,f,false);
		else if (o.attachEvent) {
			o['e' + t + f] = f;
			o[t + f] = function() { o['e' + t + f](w.event); }
			o.attachEvent('on' + t, o[t + f]);
		}
	}; // addEvent
	var clickCell = function(e) {
		var target = e.target || this;
		var sib = target.nextSibling;
		if (sib && sib.tagName && (sib.tagName.toLowerCase() === 'td')) {
			if (/(^|\s)shh(\s|$)/.test(sib.className)) sib.className = sib.className.replace(/(^|\s)shh(\s|$)/, ' ');
			else sib.className += ' shh';
		}
		if (e && e.stopPropagation) e.stopPropagation();
		else w.event.cancelBubble = true;
		return false;
	}; // clickCell
	var collapsifyDumps = function() {
		setTimeout(function() {
			var tables = document.getElementsByTagName('table');
			for(var t = 0; t < tables.length; t++) {
//.........这里部分代码省略.........
开发者ID:rickosborne,项目名称:php-fw1,代码行数:101,代码来源:Framework.php

示例3: dumpFunction

	private static function dumpFunction($var, $tabs, $limit = 0, $label = '', $depth = 0) {
		if (!is_subclass_of($var, 'ReflectionFunctionAbstract')) {
			$var = new \ReflectionFunction($var);
		}
		echo "$tabs<table class=\"dump function depth${depth}\">$tabs<thead><tr><th>" . ($label != '' ? $label . ' - ' : '') . (is_callable(array($var, 'getModifiers')) ? htmlentities(implode(' ', \Reflection::getModifierNames($var->getModifiers()))) : '') . " function " . htmlentities($var->getName()) . "</th></tr></thead>$tabs<tbody>";
		echo "$tabs<tr><td class=\"value\">$tabs<table class=\"dump layout\">$tabs<tr><th>Parameters:</th><td>";
		$params = $var->getParameters();
		if (count($params) > 0) {
			echo "</td></tr>$tabs<tr><td colspan=\"2\">$tabs<table class=\"dump param\">$tabs<thead><tr><th>Name</th><th>Array/Ref</th><th>Required</th><th>Default</th></tr></thead>$tabs<tbody>";
			foreach ($params as $param) {
				echo "$tabs<tr><td>" . htmlentities($param->getName()) . "</td><td>" . ($param->isArray() ? "Array " : "") . ($param->isPassedByReference() ? "Reference" : "") . "</td><td>" . ($param->isOptional() ? "Optional" : "Required") . "</td><td>";
				if ($param->isOptional() && $param->isDefaultValueAvailable()) {
					$default = $param->getDefaultValue();
					self::dump($default, $limit, $label, $depth);
				}
				echo "</td></tr>";
			}
			echo "$tabs</tbody>$tabs</table>";
		} else {
			echo "none</td></tr>";
		}
		$comment = trim($var->getDocComment());
		if (($comment !== NULL) && ($comment !== '')) {
			echo "$tabs<tr><th>Doc Comment:</th><td><kbd>" . str_replace("\n", "<br/>", htmlentities($comment)) . "</kbd></td></tr>";
		}
		echo "</table>$tabs</td></tr>";
		echo "$tabs</tbody>$tabs</table>";
	} // dumpFunction
开发者ID:rickosborne,项目名称:php-fw1,代码行数:28,代码来源:CFDump.php


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