diff --git a/src/ReflectionTrait.php b/src/ReflectionTrait.php index 24c71ae..2d1bf40 100644 --- a/src/ReflectionTrait.php +++ b/src/ReflectionTrait.php @@ -47,7 +47,7 @@ public static function getClassFromDocComment($comment, $includeNamespaces = tru } return $matches[1]; } - return join('', array_slice(explode('\\', $matches[1]), -1)); + return implode('', array_slice(explode('\\', $matches[1]), -1)); } return false; diff --git a/tests/ReflectionTest.php b/tests/ReflectionTest.php new file mode 100644 index 0000000..c6e53c6 --- /dev/null +++ b/tests/ReflectionTest.php @@ -0,0 +1,39 @@ +testClass = new ReflectionStub(); + } + + public function testExceptionOnClassNotFound() + { + $className = "thisClassDoesNotExist"; + + $this->expectExceptionMessage(sprintf("%s not found or does not exist", $className)); + + $this->testClass->getClassFromClassProperty($className, 'foo'); + } + + public function testExceptionOnPropertyNotFound() + { + $propertyName = "NonExistingProperty"; + $className = ReflectionStub::class; + + $this->expectExceptionMessage(sprintf("%s has no property with the name %s", $className, $propertyName)); + + $this->testClass->getClassFromClassProperty($className, $propertyName); + } + + //public function testGetClassNameWithoutNamespaceFromComment() + //{ + // + //} +} diff --git a/tests/stubs/ReflectionStub.php b/tests/stubs/ReflectionStub.php new file mode 100644 index 0000000..1e9e8bc --- /dev/null +++ b/tests/stubs/ReflectionStub.php @@ -0,0 +1,18 @@ +