Skip to content

Commit

Permalink
Merge pull request #1407 from staabm/parser-pr
Browse files Browse the repository at this point in the history
Kill startLine & endLine mutants
  • Loading branch information
Ocramius authored Mar 18, 2024
2 parents cf4e555 + 452ad36 commit 148b2d1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 37 deletions.
26 changes: 13 additions & 13 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.23.0@005e3184fb6de4350a873b9b8c4dc3cede9db762">
<files psalm-version="5.23.1@8471a896ccea3526b26d082f4461eeea467f10a4">
<file src="src/Reflection/Attribute/ReflectionAttributeHelper.php">
<ImpureMethodCall>
<code><![CDATA[toLowerString]]></code>
Expand Down Expand Up @@ -149,16 +149,12 @@
<code><![CDATA[getStartLine]]></code>
<code><![CDATA[getStmts]]></code>
<code><![CDATA[getSubNodeNames]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[traverse]]></code>
</ImpureMethodCall>
<PropertyTypeCoercion>
<code><![CDATA[$endLine]]></code>
<code><![CDATA[$startLine]]></code>
</PropertyTypeCoercion>
</file>
<file src="src/Reflection/ReflectionMethod.php">
<ImpureFunctionCall>
Expand Down Expand Up @@ -195,10 +191,12 @@
<code><![CDATA[__invoke]]></code>
<code><![CDATA[getEndLine]]></code>
<code><![CDATA[getStartLine]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[toLowerString]]></code>
</ImpureMethodCall>
<PropertyTypeCoercion>
<code><![CDATA[$endLine]]></code>
<code><![CDATA[$startLine]]></code>
</PropertyTypeCoercion>
</file>
<file src="src/Reflection/ReflectionProperty.php">
<ImpureFunctionCall>
Expand All @@ -212,15 +210,17 @@
<code><![CDATA[classExists]]></code>
<code><![CDATA[getEndLine]]></code>
<code><![CDATA[getStartLine]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[hasAttribute]]></code>
<code><![CDATA[isPrivate]]></code>
<code><![CDATA[isProtected]]></code>
<code><![CDATA[isPublic]]></code>
<code><![CDATA[isReadonly]]></code>
<code><![CDATA[isStatic]]></code>
<code><![CDATA[traitExists]]></code>
</ImpureMethodCall>
<PropertyTypeCoercion>
<code><![CDATA[$endLine]]></code>
<code><![CDATA[$startLine]]></code>
</PropertyTypeCoercion>
</file>
<file src="src/Reflection/ReflectionType.php">
<ImpureMethodCall>
Expand Down
14 changes: 6 additions & 8 deletions src/Reflection/ReflectionFunctionAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,14 @@ private function fillFromNode(MethodNode|Node\Stmt\Function_|Node\Expr\Closure|N
$this->docComment = GetLastDocComment::forNode($node);
$this->couldThrow = $this->computeCouldThrow($node);

$startLine = null;
if ($node->hasAttribute('startLine')) {
$startLine = $node->getStartLine();
assert($startLine > 0);
$startLine = $node->getStartLine();
if ($startLine === -1) {
$startLine = null;
}

$endLine = null;
if ($node->hasAttribute('endLine')) {
$endLine = $node->getEndLine();
assert($endLine > 0);
$endLine = $node->getEndLine();
if ($endLine === -1) {
$endLine = null;
}

$this->startLine = $startLine;
Expand Down
12 changes: 4 additions & 8 deletions src/Reflection/ReflectionParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,13 @@ private function __construct(
$this->isPromoted = $node->flags !== 0;
$this->attributes = ReflectionAttributeHelper::createAttributes($reflector, $this, $node->attrGroups);

if ($node->hasAttribute('startLine')) {
$startLine = $node->getStartLine();
assert($startLine > 0);
} else {
$startLine = $node->getStartLine();
if ($startLine === -1) {
$startLine = null;
}

if ($node->hasAttribute('endLine')) {
$endLine = $node->getEndLine();
assert($endLine > 0);
} else {
$endLine = $node->getEndLine();
if ($endLine === -1) {
$endLine = null;
}

Expand Down
14 changes: 6 additions & 8 deletions src/Reflection/ReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,14 @@ private function __construct(
$this->docComment = GetLastDocComment::forNode($node);
$this->attributes = ReflectionAttributeHelper::createAttributes($reflector, $this, $node->attrGroups);

$startLine = null;
if ($node->hasAttribute('startLine')) {
$startLine = $node->getStartLine();
assert($startLine > 0);
$startLine = $node->getStartLine();
if ($startLine === -1) {
$startLine = null;
}

$endLine = null;
if ($node->hasAttribute('endLine')) {
$endLine = $node->getEndLine();
assert($endLine > 0);
$endLine = $node->getEndLine();
if ($endLine === -1) {
$endLine = null;
}

$this->startLine = $startLine;
Expand Down

0 comments on commit 148b2d1

Please sign in to comment.