This file is indexed.

/usr/share/php/Hamcrest/BaseDescription.php is in php-hamcrest 1.2.2-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
namespace Hamcrest;

/*
 Copyright (c) 2009 hamcrest.org
 */
use Hamcrest\Internal\SelfDescribingValue;

/**
 * A {@link Hamcrest\Description} that is stored as a string.
 */
abstract class BaseDescription implements Description
{

    public function appendText($text)
    {
        $this->append($text);

        return $this;
    }

    public function appendDescriptionOf(SelfDescribing $value)
    {
        $value->describeTo($this);

        return $this;
    }

    public function appendValue($value)
    {
        if (is_null($value)) {
            $this->append('null');
        } elseif (is_string($value)) {
            $this->_toPhpSyntax($value);
        } elseif (is_float($value)) {
            $this->append('<');
            $this->append($value);
            $this->append('F>');
        } elseif (is_bool($value)) {
            $this->append('<');
            $this->append($value ? 'true' : 'false');
            $this->append('>');
        } elseif (is_array($value) || $value instanceof \Iterator || $value instanceof \IteratorAggregate) {
            $this->appendValueList('[', ', ', ']', $value);
        } elseif (is_object($value) && !method_exists($value, '__toString')) {
            $this->append('<');
            $this->append(get_class($value));
            $this->append('>');
        } else {
            $this->append('<');
            $this->append($value);
            $this->append('>');
        }

        return $this;
    }

    public function appendValueList($start, $separator, $end, $values)
    {
        $list = array();
        foreach ($values as $v) {
            $list[] = new SelfDescribingValue($v);
        }

        $this->appendList($start, $separator, $end, $list);

        return $this;
    }

    public function appendList($start, $separator, $end, $values)
    {
        $this->append($start);

        $separate = false;

        foreach ($values as $value) {
            /*if (!($value instanceof Hamcrest\SelfDescribing)) {
                $value = new Hamcrest\Internal\SelfDescribingValue($value);
            }*/

            if ($separate) {
                $this->append($separator);
            }

            $this->appendDescriptionOf($value);

            $separate = true;
        }

        $this->append($end);

        return $this;
    }

    // -- Protected Methods

    /**
     * Append the String <var>$str</var> to the description.
     */
    abstract protected function append($str);

    // -- Private Methods

    private function _toPhpSyntax($value)
    {
        $str = '"';
        for ($i = 0, $len = strlen($value); $i < $len; ++$i) {
            switch ($value[$i]) {
                case '"':
                    $str .= '\\"';
                    break;

                case "\t":
                    $str .= '\\t';
                    break;

                case "\r":
                    $str .= '\\r';
                    break;

                case "\n":
                    $str .= '\\n';
                    break;

                default:
                    $str .= $value[$i];
            }
        }
        $str .= '"';
        $this->append($str);
    }
}