本文整理汇总了PHP中Strings::indent方法的典型用法代码示例。如果您正苦于以下问题:PHP Strings::indent方法的具体用法?PHP Strings::indent怎么用?PHP Strings::indent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Strings
的用法示例。
在下文中一共展示了Strings::indent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __toString
/** @return string PHP code */
public function __toString()
{
$consts = array();
foreach ($this->consts as $name => $value) {
$consts[] = "const {$name} = " . PhpHelpers::dump($value) . ";\n";
}
$properties = array();
foreach ($this->properties as $property) {
$properties[] = ($property->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $property->documents)) . "\n */\n" : '') . $property->visibility . ($property->static ? ' static' : '') . ' $' . $property->name . ($property->value === NULL ? '' : ' = ' . PhpHelpers::dump($property->value)) . ";\n";
}
return Strings::normalize(($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $this->documents)) . "\n */\n" : '') . ($this->abstract ? 'abstract ' : '') . ($this->final ? 'final ' : '') . $this->type . ' ' . $this->name . ' ' . ($this->extends ? 'extends ' . implode(', ', (array) $this->extends) . ' ' : '') . ($this->implements ? 'implements ' . implode(', ', (array) $this->implements) . ' ' : '') . "\n{\n\n" . Strings::indent(($this->traits ? "use " . implode(', ', (array) $this->traits) . ";\n\n" : '') . ($this->consts ? implode('', $consts) . "\n\n" : '') . ($this->properties ? implode("\n", $properties) . "\n\n" : '') . implode("\n\n\n", $this->methods), 1) . "\n\n}") . "\n";
}
示例2: __toString
/** @return string PHP code */
public function __toString()
{
$parameters = array();
foreach ($this->parameters as $param) {
$parameters[] = ($param->typeHint ? $param->typeHint . ' ' : '') . ($param->reference ? '&' : '') . '$' . $param->name . ($param->optional ? ' = ' . PhpHelpers::dump($param->defaultValue) : '');
}
$uses = array();
foreach ($this->uses as $param) {
$uses[] = ($param->reference ? '&' : '') . '$' . $param->name;
}
return ($this->documents ? str_replace("\n", "\n * ", "/**\n" . implode("\n", (array) $this->documents)) . "\n */\n" : '') . ($this->abstract ? 'abstract ' : '') . ($this->final ? 'final ' : '') . ($this->visibility ? $this->visibility . ' ' : '') . ($this->static ? 'static ' : '') . 'function' . ($this->returnReference ? ' &' : '') . ($this->name ? ' ' . $this->name : '') . '(' . implode(', ', $parameters) . ')' . ($this->uses ? ' use (' . implode(', ', $uses) . ')' : '') . ($this->abstract || $this->body === FALSE ? ';' : ($this->name ? "\n" : ' ') . "{\n" . Strings::indent(trim($this->body), 1) . "\n}");
}
示例3: indent
/**
* Indents the HTML content from the left.
* @param string UTF-8 encoding or 8-bit
* @param int
* @param string
* @return string
*/
public static function indent($s, $level = 1, $chars = "\t")
{
if ($level >= 1) {
$s = Strings::replace($s, '#<(textarea|pre).*?</\\1#si', new Callback(create_function('$m', '
return strtr($m[0], " \\t\\r\\n", "\\x1F\\x1E\\x1D\\x1A");
')));
$s = Strings::indent($s, $level, $chars);
$s = strtr($s, "", " \t\r\n");
}
return $s;
}