|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
15
|
|
|
* |
|
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
17
|
|
|
* and is licensed under the LGPL. For more information please see |
|
18
|
|
|
* <http://phing.info>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace Phing\Parser; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Stores the file name and line number of a XML file. |
|
25
|
|
|
* |
|
26
|
|
|
* @author Andreas Aderhold <[email protected]> |
|
27
|
|
|
* @copyright 2001,2002 THYRELL. All rights reserved |
|
28
|
|
|
*/ |
|
29
|
|
|
class Location |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @var null|string |
|
33
|
|
|
*/ |
|
34
|
|
|
private $fileName; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var null|int |
|
38
|
|
|
*/ |
|
39
|
|
|
private $lineNumber; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var null|int |
|
43
|
|
|
*/ |
|
44
|
|
|
private $columnNumber; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Constructs the location consisting of a file name and line number. |
|
48
|
|
|
* |
|
49
|
|
|
* @param string $fileName the filename |
|
50
|
|
|
* @param int $lineNumber the line number |
|
51
|
|
|
* @param int $columnNumber the column number |
|
52
|
|
|
*/ |
|
53
|
940 |
|
public function __construct($fileName = null, $lineNumber = null, $columnNumber = null) |
|
54
|
|
|
{ |
|
55
|
940 |
|
$this->fileName = $fileName; |
|
56
|
940 |
|
$this->lineNumber = $lineNumber; |
|
57
|
940 |
|
$this->columnNumber = $columnNumber; |
|
58
|
940 |
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Returns the file name, line number and a trailing space. |
|
62
|
|
|
* |
|
63
|
|
|
* An error message can be appended easily. For unknown locations, |
|
64
|
|
|
* returns empty string. |
|
65
|
|
|
* |
|
66
|
|
|
* @return string the string representation of this Location object |
|
67
|
|
|
*/ |
|
68
|
19 |
|
public function __toString(): string |
|
69
|
|
|
{ |
|
70
|
19 |
|
$buf = ''; |
|
71
|
19 |
|
if (null !== $this->getFileName()) { |
|
72
|
19 |
|
$buf .= $this->getFileName(); |
|
73
|
19 |
|
if (null !== $this->getLineNumber()) { |
|
74
|
19 |
|
$buf .= ':' . $this->getLineNumber(); |
|
75
|
|
|
} |
|
76
|
19 |
|
$buf .= ':' . $this->getColumnNumber(); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
19 |
|
return $buf; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return null|string |
|
84
|
|
|
*/ |
|
85
|
119 |
|
public function getFileName(): ?string |
|
86
|
|
|
{ |
|
87
|
119 |
|
return $this->fileName; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @return null|int |
|
92
|
|
|
*/ |
|
93
|
19 |
|
public function getLineNumber(): ?int |
|
94
|
|
|
{ |
|
95
|
19 |
|
return $this->lineNumber; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return null|int |
|
100
|
|
|
*/ |
|
101
|
19 |
|
public function getColumnNumber(): ?int |
|
102
|
|
|
{ |
|
103
|
19 |
|
return $this->columnNumber; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|