Skip to content

Commit 403ca2f

Browse files
committed
Fix #313
1 parent 08e7dc3 commit 403ca2f

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/collector/backend/parser/UnitCollectingVisitor.php

+10
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,16 @@ private function resolveExpressionValue(Expr $expr) {
482482
);
483483
}
484484

485+
if ($expr instanceof BinaryOp) {
486+
$code = (new \PhpParser\PrettyPrinter\Standard)->prettyPrint([$expr]);
487+
488+
return array(
489+
'type' => 'expression',
490+
'value' => substr($code,0,-1)
491+
);
492+
493+
}
494+
485495
$type = get_class($expr);
486496
$line = $expr->getLine();
487497
$file = $this->result->getFileName();

tests/data/issue313/src/bug.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php declare(strict_types=1);
2+
3+
class bug {
4+
const FOO = 'a' . 'b' . 'c' . 'd';
5+
const BAZ = ((5 - 1) / 2) . 'em';
6+
const BAR = 1 + 2 + 3;
7+
}

tests/data/issue313/test.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<phpdox xmlns="http://xml.phpdox.net/config" silent="false">
3+
4+
<project name="phpDox-issue300" source="${basedir}/src" workdir="${basedir}/xml">
5+
6+
<collector publiconly="false" backend="parser" />
7+
8+
<generator output="${basedir}/docs">
9+
<build engine="html" enabled="true" output="html" />
10+
<build engine="xml" enabled="true" output="xml" />
11+
</generator>
12+
13+
</project>
14+
15+
</phpdox>

0 commit comments

Comments
 (0)