Skip to content

Commit 2c4cdac

Browse files
Initial work on issue sebastianbergmann#37.
1 parent 8a535bd commit 2c4cdac

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

PHP/CodeCoverage/Report/HTML/Renderer/File.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,35 @@ protected function renderFunctionItems(array $functions, Text_Template $template
291291
protected function renderFunctionOrMethodItem(Text_Template $template, array $item, $indent = '')
292292
{
293293
$numTestedItems = $item['executedLines'] == $item['executableLines'] ? 1 : 0;
294+
$visibility = '';
295+
296+
if (isset($item['visibility'])) {
297+
switch ($item['visibility']) {
298+
case 'public': {
299+
$visibility = '+ ';
300+
}
301+
break;
302+
303+
case 'protected': {
304+
$visibility = '# ';
305+
}
306+
break;
307+
308+
case 'private': {
309+
$visibility = '- ';
310+
}
311+
break;
312+
}
313+
}
294314

295315
return $this->renderItemTemplate(
296316
$template,
297317
array(
298318
'name' => sprintf(
299-
'%s<a href="#%d">%s</a>',
319+
'%s<a href="#%d">%s%s</a>',
300320
$indent,
301321
$item['startLine'],
322+
$visibility,
302323
htmlspecialchars($item['signature'])
303324
),
304325
'numMethods' => 1,

PHP/CodeCoverage/Report/Node/File.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,8 @@ protected function processClasses(PHP_Token_Stream $tokens)
571571
'ccn' => $method['ccn'],
572572
'coverage' => 0,
573573
'crap' => 0,
574-
'link' => $link . $method['startLine']
574+
'link' => $link . $method['startLine'],
575+
'visibility' => $method['visibility']
575576
);
576577

577578
$this->startLines[$method['startLine']] = &$this->classes[$className]['methods'][$methodName];

Tests/PHP/CodeCoverage/Report/FactoryTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ public function testSomething()
111111
'ccn' => 1,
112112
'coverage' => 100,
113113
'crap' => '1',
114-
'link' => 'BankAccount.php.html#6'
114+
'link' => 'BankAccount.php.html#6',
115+
'visibility' => 'public'
115116
),
116117
'setBalance' => array(
117118
'signature' => 'setBalance($balance)',
@@ -122,7 +123,8 @@ public function testSomething()
122123
'ccn' => 2,
123124
'coverage' => 0,
124125
'crap' => 6,
125-
'link' => 'BankAccount.php.html#11'
126+
'link' => 'BankAccount.php.html#11',
127+
'visibility' => 'protected'
126128
),
127129
'depositMoney' => array(
128130
'signature' => 'depositMoney($balance)',
@@ -133,7 +135,8 @@ public function testSomething()
133135
'ccn' => 1,
134136
'coverage' => 100,
135137
'crap' => '1',
136-
'link' => 'BankAccount.php.html#20'
138+
'link' => 'BankAccount.php.html#20',
139+
'visibility' => 'public'
137140
),
138141
'withdrawMoney' => array(
139142
'signature' => 'withdrawMoney($balance)',
@@ -144,7 +147,8 @@ public function testSomething()
144147
'ccn' => 1,
145148
'coverage' => 100,
146149
'crap' => '1',
147-
'link' => 'BankAccount.php.html#27'
150+
'link' => 'BankAccount.php.html#27',
151+
'visibility' => 'public'
148152
),
149153
),
150154
'startLine' => 2,

0 commit comments

Comments
 (0)