Skip to content

Commit 148b2d1

Browse files
authored
Merge pull request #1407 from staabm/parser-pr
Kill startLine & endLine mutants
2 parents cf4e555 + 452ad36 commit 148b2d1

4 files changed

+29
-37
lines changed

psalm-baseline.xml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.23.0@005e3184fb6de4350a873b9b8c4dc3cede9db762">
2+
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
33
<file src="src/Reflection/Attribute/ReflectionAttributeHelper.php">
44
<ImpureMethodCall>
55
<code><![CDATA[toLowerString]]></code>
@@ -149,16 +149,12 @@
149149
<code><![CDATA[getStartLine]]></code>
150150
<code><![CDATA[getStmts]]></code>
151151
<code><![CDATA[getSubNodeNames]]></code>
152-
<code><![CDATA[hasAttribute]]></code>
153-
<code><![CDATA[hasAttribute]]></code>
154-
<code><![CDATA[hasAttribute]]></code>
155-
<code><![CDATA[hasAttribute]]></code>
156-
<code><![CDATA[hasAttribute]]></code>
157-
<code><![CDATA[hasAttribute]]></code>
158-
<code><![CDATA[hasAttribute]]></code>
159-
<code><![CDATA[hasAttribute]]></code>
160152
<code><![CDATA[traverse]]></code>
161153
</ImpureMethodCall>
154+
<PropertyTypeCoercion>
155+
<code><![CDATA[$endLine]]></code>
156+
<code><![CDATA[$startLine]]></code>
157+
</PropertyTypeCoercion>
162158
</file>
163159
<file src="src/Reflection/ReflectionMethod.php">
164160
<ImpureFunctionCall>
@@ -195,10 +191,12 @@
195191
<code><![CDATA[__invoke]]></code>
196192
<code><![CDATA[getEndLine]]></code>
197193
<code><![CDATA[getStartLine]]></code>
198-
<code><![CDATA[hasAttribute]]></code>
199-
<code><![CDATA[hasAttribute]]></code>
200194
<code><![CDATA[toLowerString]]></code>
201195
</ImpureMethodCall>
196+
<PropertyTypeCoercion>
197+
<code><![CDATA[$endLine]]></code>
198+
<code><![CDATA[$startLine]]></code>
199+
</PropertyTypeCoercion>
202200
</file>
203201
<file src="src/Reflection/ReflectionProperty.php">
204202
<ImpureFunctionCall>
@@ -212,15 +210,17 @@
212210
<code><![CDATA[classExists]]></code>
213211
<code><![CDATA[getEndLine]]></code>
214212
<code><![CDATA[getStartLine]]></code>
215-
<code><![CDATA[hasAttribute]]></code>
216-
<code><![CDATA[hasAttribute]]></code>
217213
<code><![CDATA[isPrivate]]></code>
218214
<code><![CDATA[isProtected]]></code>
219215
<code><![CDATA[isPublic]]></code>
220216
<code><![CDATA[isReadonly]]></code>
221217
<code><![CDATA[isStatic]]></code>
222218
<code><![CDATA[traitExists]]></code>
223219
</ImpureMethodCall>
220+
<PropertyTypeCoercion>
221+
<code><![CDATA[$endLine]]></code>
222+
<code><![CDATA[$startLine]]></code>
223+
</PropertyTypeCoercion>
224224
</file>
225225
<file src="src/Reflection/ReflectionType.php">
226226
<ImpureMethodCall>

src/Reflection/ReflectionFunctionAbstract.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,14 @@ private function fillFromNode(MethodNode|Node\Stmt\Function_|Node\Expr\Closure|N
106106
$this->docComment = GetLastDocComment::forNode($node);
107107
$this->couldThrow = $this->computeCouldThrow($node);
108108

109-
$startLine = null;
110-
if ($node->hasAttribute('startLine')) {
111-
$startLine = $node->getStartLine();
112-
assert($startLine > 0);
109+
$startLine = $node->getStartLine();
110+
if ($startLine === -1) {
111+
$startLine = null;
113112
}
114113

115-
$endLine = null;
116-
if ($node->hasAttribute('endLine')) {
117-
$endLine = $node->getEndLine();
118-
assert($endLine > 0);
114+
$endLine = $node->getEndLine();
115+
if ($endLine === -1) {
116+
$endLine = null;
119117
}
120118

121119
$this->startLine = $startLine;

src/Reflection/ReflectionParameter.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,13 @@ private function __construct(
8585
$this->isPromoted = $node->flags !== 0;
8686
$this->attributes = ReflectionAttributeHelper::createAttributes($reflector, $this, $node->attrGroups);
8787

88-
if ($node->hasAttribute('startLine')) {
89-
$startLine = $node->getStartLine();
90-
assert($startLine > 0);
91-
} else {
88+
$startLine = $node->getStartLine();
89+
if ($startLine === -1) {
9290
$startLine = null;
9391
}
9492

95-
if ($node->hasAttribute('endLine')) {
96-
$endLine = $node->getEndLine();
97-
assert($endLine > 0);
98-
} else {
93+
$endLine = $node->getEndLine();
94+
if ($endLine === -1) {
9995
$endLine = null;
10096
}
10197

src/Reflection/ReflectionProperty.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,14 @@ private function __construct(
9090
$this->docComment = GetLastDocComment::forNode($node);
9191
$this->attributes = ReflectionAttributeHelper::createAttributes($reflector, $this, $node->attrGroups);
9292

93-
$startLine = null;
94-
if ($node->hasAttribute('startLine')) {
95-
$startLine = $node->getStartLine();
96-
assert($startLine > 0);
93+
$startLine = $node->getStartLine();
94+
if ($startLine === -1) {
95+
$startLine = null;
9796
}
9897

99-
$endLine = null;
100-
if ($node->hasAttribute('endLine')) {
101-
$endLine = $node->getEndLine();
102-
assert($endLine > 0);
98+
$endLine = $node->getEndLine();
99+
if ($endLine === -1) {
100+
$endLine = null;
103101
}
104102

105103
$this->startLine = $startLine;

0 commit comments

Comments
 (0)