CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 企业解决方案
  • 周边商品
  • 旅行
  • 团队
  • 社区
    • 社区
    • 参与进来
    • 问题 (Github)
    • Bakery
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • 缓存
    • 集合
    • 命令
    • 控制台
      • 命令
      • 异常
      • 测试套件
        • 约束
    • 控制器
    • 核心
    • 数据库
    • 数据源
    • 错误
    • 事件
    • 表单
    • HTTP
    • 国际化
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 工具
    • 验证
    • 视图

类 StubConsoleOutput

StubOutput 使测试 shell 命令/shell 助手变得更容易。

您可以通过将它注入到命令/任务/助手使用的 ConsoleIo 实例中来使用此类。

use Cake\Console\ConsoleIo;
use Cake\Console\TestSuite\StubConsoleOutput;

$output = new StubConsoleOutput();
$io = new ConsoleIo($output);
命名空间: Cake\Console\TestSuite

常量

  • int
    COLOR ¶
    2

    彩色输出 - 将已知的标签转换为 ANSI 颜色转义码。

  • string
    LF ¶
    PHP_EOL

    换行的常量。

  • int
    PLAIN ¶
    1

    普通输出 - 标签将被剥离。

  • int
    RAW ¶
    0

    原始输出常量 - 不修改输出文本。

属性摘要

  • $_backgroundColors protected static
    array<string, int>

    彩色输出中使用的背景颜色。

  • $_foregroundColors protected static
    array<string, int>

    彩色输出中使用的文本颜色。

  • $_options protected static
    array<string, int>

    彩色输出的格式选项。

  • $_out protected
    list<string>

    缓冲的消息。

  • $_output protected
    resource

    输出的文件句柄。

  • $_outputAs protected
    int

    当前输出类型。

  • $_styles protected static
    array<string, array>

    在控制台输出中可作为标签使用的样式。您可以使用 ConsoleOutput::styles() 修改这些样式。

方法摘要

  • __construct() public

    构造输出对象。

  • __destruct() public

    清理并关闭句柄

  • _replaceTags() protected

    用颜色代码替换标签。

  • _write() protected

    将消息写入输出流。

  • clear() public

    清除缓冲的输出

  • getOutputAs() public

    获取如何处理格式化标签的输出类型。

  • getStyle() public

    获取当前提供的样式

  • messages() public

    获取缓冲的输出。

  • output() public

    将输出作为字符串获取

  • setOutputAs() public

    设置如何处理格式化标签的输出类型。

  • setStyle() public

    设置样式。

  • styleText() public

    将样式应用于文本。

  • styles() public

    获取所有样式定义。

  • write() public

    将输出写入缓冲区。

方法详情

__construct() ¶ public

__construct(resource|string $stream = 'php://stdout')

构造输出对象。

检查是否为漂亮的控制台环境。Ansicon 和 ConEmu 允许在 Windows 上使用漂亮的控制台,并且受支持。

参数
resource|string $stream optional

要写入输出的流的标识符。

抛出
Cake\Console\Exception\ConsoleException
如果给定的流不是有效的资源。

__destruct() ¶ public

__destruct()

清理并关闭句柄

_replaceTags() ¶ protected

_replaceTags(array<string, string> $matches): string

用颜色代码替换标签。

参数
array<string, string> $matches

要替换的匹配项数组。

返回值
string

_write() ¶ protected

_write(string $message): int

将消息写入输出流。

参数
string $message

要写入的消息。

返回值
int

clear() ¶ public

clear(): void

清除缓冲的输出

返回值
void

getOutputAs() ¶ public

getOutputAs(): int

获取如何处理格式化标签的输出类型。

返回值
int

getStyle() ¶ public

getStyle(string $style): array

获取当前提供的样式

参数
string $style

要获取的样式。

返回值
array

messages() ¶ public

messages(): list<string>

获取缓冲的输出。

返回值
list<string>

output() ¶ public

output(): string

将输出作为字符串获取

返回值
string

setOutputAs() ¶ public

setOutputAs(int $type): void

设置如何处理格式化标签的输出类型。

参数
int $type

要使用的输出类型。应为类常量之一。

返回值
void
抛出
InvalidArgumentException
在不支持的输出类型的情况下。

setStyle() ¶ public

setStyle(string $style, array $definition): void

设置样式。

创建或修改现有样式。

$output->setStyle('annoy', ['text' => 'purple', 'background' => 'yellow', 'blink' => true]);

删除样式

$this->output->setStyle('annoy', []);
参数
string $style

要设置的样式。

array $definition

要更改或创建的样式的数组定义。

返回值
void

styleText() ¶ public

styleText(string $text): string

将样式应用于文本。

参数
string $text

带有样式标签的文本。

返回值
string

styles() ¶ public

styles(): array<string, mixed>

获取所有样式定义。

返回值
array<string, mixed>

write() ¶ public

write(list<string>|string $message, int $newlines = 1): int

将输出写入缓冲区。

参数
list<string>|string $message

要输出的字符串或字符串数组

int $newlines optional

要追加的换行符数量

返回值
int

属性详情

$_backgroundColors ¶ protected static

彩色输出中使用的背景颜色。

类型
array<string, int>

$_foregroundColors ¶ protected static

彩色输出中使用的文本颜色。

类型
array<string, int>

$_options ¶ protected static

彩色输出的格式选项。

类型
array<string, int>

$_out ¶ protected

缓冲的消息。

类型
list<string>

$_output ¶ 受保护的

输出的文件句柄。

类型
resource

$_outputAs ¶ 受保护的

当前输出类型。

类型
int

$_styles ¶ 受保护的 静态的

在控制台输出中可作为标签使用的样式。您可以使用 ConsoleOutput::styles() 修改这些样式。

类型
array<string, array>
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与进来
  • 问题 (Github)
  • Bakery
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成