상속: extends Nette\Object
예제 #1
0
    }
    public function color($color = NULL, $s = NULL)
    {
        static $colors = array('black' => '0;30', 'gray' => '1;30', 'silver' => '0;37', 'white' => '1;37', 'navy' => '0;34', 'blue' => '1;34', 'green' => '0;32', 'lime' => '1;32', 'teal' => '0;36', 'aqua' => '1;36', 'maroon' => '0;31', 'red' => '1;31', 'purple' => '0;35', 'fuchsia' => '1;35', 'olive' => '0;33', 'yellow' => '1;33', NULL => '0');
        if ($this->useColors) {
            $c = explode('/', $color);
            $s = "[" . ($c[0] ? $colors[$c[0]] : '') . (empty($c[1]) ? '' : ';4' . substr($colors[$c[1]], -1)) . 'm' . $s . ($s === NULL ? '' : "");
        }
        return $s;
    }
    public function is($extensions)
    {
        return in_array(pathinfo($this->file, PATHINFO_EXTENSION), explode(',', $extensions));
    }
}
$checker = new CodeChecker();
foreach ($options['--ignore'] as $ignore) {
    $checker->ignore[] = $ignore;
}
$checker->readOnly = !isset($options['--fix']);
// control characters checker
$checker->tasks[] = function (CodeChecker $checker, $s) {
    if (!Strings::match($s, '#^[^\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]*+$#')) {
        $checker->error('Contains control characters');
    }
};
// BOM remover
$checker->tasks[] = function (CodeChecker $checker, $s) {
    if (substr($s, 0, 3) === "") {
        $checker->fix('contains BOM');
        return substr($s, 3);
예제 #2
0
    }
    public function color($color = NULL, $s = NULL)
    {
        static $colors = ['black' => '0;30', 'gray' => '1;30', 'silver' => '0;37', 'white' => '1;37', 'navy' => '0;34', 'blue' => '1;34', 'green' => '0;32', 'lime' => '1;32', 'teal' => '0;36', 'aqua' => '1;36', 'maroon' => '0;31', 'red' => '1;31', 'purple' => '0;35', 'fuchsia' => '1;35', 'olive' => '0;33', 'yellow' => '1;33', NULL => '0'];
        if ($this->useColors) {
            $c = explode('/', $color);
            $s = "[" . ($c[0] ? $colors[$c[0]] : '') . (empty($c[1]) ? '' : ';4' . substr($colors[$c[1]], -1)) . 'm' . $s . ($s === NULL ? '' : "");
        }
        return $s;
    }
    public function is($extensions)
    {
        return in_array(pathinfo($this->file, PATHINFO_EXTENSION), explode(',', $extensions));
    }
}
$checker = new CodeChecker();
foreach ($options['--ignore'] as $ignore) {
    $checker->ignore[] = $ignore;
}
$checker->readOnly = !isset($options['--fix']);
// control characters checker
$checker->tasks[] = function ($s) {
    if (!Strings::match($s, '#^[^\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]*+$#')) {
        $this->error('Contains control characters');
    }
};
// BOM remover
$checker->tasks[] = function ($s) {
    if (substr($s, 0, 3) === "") {
        $this->fix('contains BOM');
        return substr($s, 3);