This file is indexed.

/usr/share/php/TokenReflection/Exception/ParseException.php is in php-tokenreflection 1.4.0-2build1.

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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
<?php
/**
 * PHP Token Reflection
 *
 * Version 1.4.0
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this library in the file LICENSE.md.
 *
 * @author Ondřej Nešpor
 * @author Jaroslav Hanslík
 */

namespace TokenReflection\Exception;

use TokenReflection\Stream\StreamBase;
use TokenReflection\IReflection;

/**
 * Parse exception.
 *
 * Thrown while parsing source codes.
 */
class ParseException extends StreamException
{
	/**
	 * An unexpected  token was encountered.
	 *
	 * @var integer
	 */
	const UNEXPECTED_TOKEN = 1101;

	/**
	 * A logical error was encountered.
	 *
	 * @var integer
	 */
	const LOGICAL_ERROR = 1102;

	/**
	 * An invalid reflection parent was provided.
	 *
	 * @var integer
	 */
	const INVALID_PARENT = 1103;

	/**
	 * Minimal number of source code lines around the token.
	 *
	 * @var integer
	 */
	const SOURCE_LINES_AROUND = 5;

	/**
	 * The token that caused the expection to be thrown.
	 *
	 * @var array|null
	 */
	private $token;

	/**
	 * The name of the token that caused the exception to be thrown.
	 *
	 * @var string|null
	 */
	private $tokenName;

	/**
	 * The line where the exception was thrown.
	 *
	 * @var integer
	 */
	private $exceptionLine;

	/**
	 * Boundaries of the token substream around the token.
	 *
	 * @var array
	 */
	private $scopeBoundaries = array();

	/**
	 * The reflection element that caused this exception to be raised.
	 *
	 * @var \TokenReflection\IReflection
	 */
	private $sender;

	/**
	 * Constructor.
	 *
	 * @param \TokenReflection\IReflection $sender Reflection element
	 * @param \TokenReflection\Stream\StreamBase $tokenStream Token stream
	 * @param string $message Exception message
	 * @param integer $code Exception code
	 */
	public function __construct(IReflection $sender, StreamBase $tokenStream, $message, $code)
	{
		parent::__construct($tokenStream, $message, $code);

		$this->sender = $sender;

		$token = $tokenStream->current();
		$position = $tokenStream->key();

		if (!empty($token) && !empty($position)) {
			$this->token = $token;
			$this->tokenName = $tokenStream->getTokenName();

			$line = $this->token[2];
			$min = $max = $position;
		} else {
			$min = $max = $tokenStream->count() - 1;
			$line = $tokenStream[$min][2];
		}

		$this->exceptionLine = $line;

		static $skip = array(T_WHITESPACE => true, T_COMMENT => true, T_DOC_COMMENT => true);

		$significant = array();
		while (isset($tokenStream[$min - 1])) {
			if (!isset($significant[$tokenStream[$min][2]])) {
				if (self::SOURCE_LINES_AROUND <= array_sum($significant)) {
					break;
				}

				$significant[$tokenStream[$min][2]] = !isset($skip[$tokenStream[$min][0]]);
			} else {
				$significant[$tokenStream[$min][2]] |= !isset($skip[$tokenStream[$min][0]]);
			}

			$min--;
		}

		$significant = array();
		while (isset($tokenStream[$max + 1])) {
			if (!isset($significant[$tokenStream[$max][2]])) {
				if (self::SOURCE_LINES_AROUND <= array_sum($significant)) {
					break;
				}

				$significant[$tokenStream[$max][2]] = !isset($skip[$tokenStream[$max][0]]);
			} else {
				$significant[$tokenStream[$max][2]] |= !isset($skip[$tokenStream[$max][0]]);
			}

			$max++;
		}

		$this->scopeBoundaries = array($min, $max);
	}

	/**
	 * Returns the token where the problem was detected or NULL if the token stream was empty or an end was reached.
	 *
	 * @return array|null
	 */
	public function getToken()
	{
		return $this->token;
	}

	/**
	 * Returns the name of the token where the problem was detected or NULL if the token stream was empty or an end was reached.
	 *
	 * @return string|null
	 */
	public function getTokenName()
	{
		return $this->tokenName;
	}

	/**
	 * Returns the line where the exception was thrown.
	 *
	 * @return integer
	 */
	public function getExceptionLine()
	{
		return $this->exceptionLine;
	}

	/**
	 * Returns the file line with the token or null.
	 *
	 * @return integer|null
	 */
	public function getTokenLine()
	{
		return null === $this->token ? null : $this->token[2];
	}

	/**
	 * Returns the source code part around the token.
	 *
	 * @param boolean $lineNumbers Returns the source code part with line numbers
	 * @return string|null
	 */
	public function getSourcePart($lineNumbers = false)
	{
		if (empty($this->scopeBoundaries)) {
			return null;
		}

		list($lo, $hi) = $this->scopeBoundaries;
		$stream = $this->getStream();

		$code = $stream->getSourcePart($lo, $hi);

		if ($lineNumbers) {
			$lines = explode("\n", $code);

			$startLine = $stream[$lo][2];
			$width = strlen($startLine + count($lines) - 1);
			$errorLine = $this->token[2];
			$actualLine = $startLine;

			$code = implode(
				"\n",
				array_map(function($line) use (&$actualLine, $width, $errorLine) {
					return ($actualLine === $errorLine ? '*' : ' ') . str_pad($actualLine++, $width, ' ', STR_PAD_LEFT) . ': ' . $line;
				}, $lines)
			);
		}

		return $code;
	}

	/**
	 * Returns the reflection element that caused the exception to be raised.
	 *
	 * @return \TokenReflection\IReflection
	 */
	public function getSender()
	{
		return $this->sender;
	}

	/**
	 * Returns an exception description detail.
	 *
	 * @return string
	 */
	public function getDetail()
	{
		if (0 === $this->getStream()->count()) {
			return parent::getDetail() . 'The token stream was empty.';
		} elseif (empty($this->token)) {
			return parent::getDetail() . 'The token stream was read out of its bounds.';
		} else {
			return parent::getDetail() .
				sprintf(
					"\nThe cause of the exception was the %s token (line %s) in following part of %s source code:\n\n%s",
					$this->tokenName,
					$this->token[2],
					$this->sender && $this->sender->getName() ? $this->sender->getPrettyName() : 'the',
					$this->getSourcePart(true)
				);
		}
	}
}