Skip to content

Commit 950b451

Browse files
committed
Fix #242
1 parent d4bdbcd commit 950b451

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

src/Application.php

+7
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,13 @@ public function runCollector(CollectorConfig $config) {
153153
$this->logger->log(' - ' . $class . ' (missing ' . $missing . ')');
154154
}
155155
}
156+
157+
if ($resolver->hasErrors()) {
158+
$this->logger->log('The following unit(s) caused errors during inheritance resolution:');
159+
foreach($resolver->getErrors() as $class => $error) {
160+
$this->logger->log(' - ' . $class . ': ' . implode(', ', $error));
161+
}
162+
}
156163
}
157164
$this->logger->log("Collector process completed\n");
158165
}

src/collector/InheritanceResolver.php

+33-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
namespace TheSeer\phpDox\Collector {
3838

3939
use TheSeer\fDOM\fDOMDocument;
40-
use TheSeer\phpDox\ProgressLogger;
4140
use TheSeer\phpDox\InheritanceConfig;
41+
use TheSeer\phpDox\ProgressLogger;
4242

4343
/**
4444
* Inheritance resolving class
@@ -67,6 +67,11 @@ class InheritanceResolver {
6767
*/
6868
private $unresolved = array();
6969

70+
/**
71+
* @var array
72+
*/
73+
private $errors = array();
74+
7075
/**
7176
* @param ProgressLogger $logger
7277
*/
@@ -153,6 +158,22 @@ public function getUnresolved() {
153158
return $this->unresolved;
154159
}
155160

161+
public function hasErrors() {
162+
return count($this->errors) > 0;
163+
}
164+
165+
public function getErrors() {
166+
return $this->errors;
167+
}
168+
169+
private function addError(AbstractUnitObject $unit, $errorInfo) {
170+
$unitName = $unit->getName();
171+
if (!isset($this->errors[$unitName])) {
172+
$this->errors[$unitName] = array();
173+
}
174+
$this->errors[$unitName][] = $errorInfo;
175+
}
176+
156177
private function addUnresolved(AbstractUnitObject $unit, $missingUnit) {
157178
$unitName = $unit->getName();
158179
if (!isset($this->unresolved[$unitName])) {
@@ -212,6 +233,17 @@ private function processImplements(AbstractUnitObject $unit, AbstractUnitObject
212233
$this->project->registerForSaving($unit);
213234
$this->project->registerForSaving($implements);
214235

236+
if (!$implements instanceof InterfaceObject) {
237+
$this->addError(
238+
$unit,
239+
sprintf(
240+
'Trying to implement "%s" which is a %s',
241+
$implements->getName(),
242+
$implements->getType()
243+
)
244+
);
245+
return;
246+
}
215247
$implements->addImplementor($unit);
216248
$unit->importExports($implements, 'interface');
217249

tests/data/issue242/src/test.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
class test { }
4+
5+
class foo implements test {}

tests/data/issue242/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-issue" 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)