diff --git a/src/Rule/DependencyIsUsedRule.php b/src/Rule/DependencyIsUsedRule.php index 55c7cad..517c2a8 100644 --- a/src/Rule/DependencyIsUsedRule.php +++ b/src/Rule/DependencyIsUsedRule.php @@ -42,7 +42,7 @@ protected function doCheck() "new {$name}\(", "{$name}::", "\({$name} \\$", - "instanceof {$name}(:|\))", + "instanceof {$name}(;|:|\))", "extends {$name}", "implements {$name}" ); diff --git a/tests/Rule/DependencyIsUsedRule.php b/tests/Rule/DependencyIsUsedRule.php index 75f4f5a..62f3d11 100644 --- a/tests/Rule/DependencyIsUsedRule.php +++ b/tests/Rule/DependencyIsUsedRule.php @@ -30,5 +30,20 @@ public function testDetect() $this->assertTrue($this->result->hasViolations()); $this->assertEquals(1, $this->result->getNumberOfViolations()); } + + /** + * @covers \spriebsch\PHPca\Rule\DependencyIsUsedRule + */ + public function testDetectInstanceof() + { + $this->init(__DIR__ . '/../_testdata/DependencyIsUsedRule/instanceof.php'); + + $rule = new DependencyIsUsedRule(); + + $rule->check($this->file, $this->result); + + $this->assertFalse($this->result->hasViolations()); + $this->assertEquals(0, $this->result->getNumberOfViolations()); + } } ?> \ No newline at end of file diff --git a/tests/_testdata/DependencyIsUsedRule/instanceof.php b/tests/_testdata/DependencyIsUsedRule/instanceof.php new file mode 100644 index 0000000..820b8a4 --- /dev/null +++ b/tests/_testdata/DependencyIsUsedRule/instanceof.php @@ -0,0 +1,31 @@ + 'Foo Gallery' + ); + + public function skip() { + $isDatabase = Connections::get('test') instanceof Database; + } + + public function testCreateData() { + $gallery = Galleries::create($this->gallery); + } + + public function testManyToOne() { + $query = new Query(); + $images = Images::find('all', $opts + array('with' => 'Galleries'))->data(); + } +} + +?> \ No newline at end of file