<NME> PropertyReflectionTest.php
<BEF> <?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace ZendTest\Code\Reflection;

use PHPUnit\Framework\TestCase;
use Zend\Code\Annotation\AnnotationCollection;
use Zend\Code\Annotation\AnnotationManager;
use Zend\Code\Annotation\Parser\GenericAnnotationParser;
use Zend\Code\Reflection\ClassReflection;
use Zend\Code\Reflection\PropertyReflection;
use Zend\Code\Scanner\CachingFileScanner;
use ZendTest\Code\Reflection\TestAsset\InjectablePropertyReflection;

use function get_class;

/**
 * @group      Zend_Reflection
 * @group      Zend_Reflection_Property
 */
class PropertyReflectionTest extends TestCase
{
    public function testDeclaringClassReturn()
    {
        $property = new PropertyReflection(TestAsset\TestSampleClass2::class, '_prop1');
        self::assertInstanceOf(ClassReflection::class, $property->getDeclaringClass());
 * @group      Zend_Reflection
 * @group      Zend_Reflection_Property
 */
class ReflectionPropertyTest extends \PHPUnit_Framework_TestCase
{
    public function testDeclaringClassReturn()
    {
        $property = new \Zend\Code\Reflection\ReflectionProperty('ZendTest\Code\Reflection\TestAsset\TestSampleClass2', '_prop1');
        $this->assertEquals(get_class($property->getDeclaringClass()), 'Zend\Code\Reflection\ReflectionClass');
    }
}
        self::assertInstanceOf(AnnotationCollection::class, $annotations);
        self::assertTrue($annotations->hasAnnotation(TestAsset\SampleAnnotation::class));
        $found = false;
        foreach ($annotations as $key => $annotation) {
            if (! $annotation instanceof TestAsset\SampleAnnotation) {
                continue;
            }
            self::assertEquals(get_class($annotation) . ': {"foo":"bar"}', $annotation->content);
            $found = true;
            break;
        }
        self::assertTrue($found);
    }

    public function testGetAnnotationsWithNoNameInformations()
    {
        $reflectionProperty = new InjectablePropertyReflection(
            // TestSampleClass5 has the annotations required to get to the
            // right point in the getAnnotations method.
            TestAsset\TestSampleClass2::class,
            '_prop2'
        );

        $annotationManager = new AnnotationManager();

        $fileScanner = $this->getMockBuilder(CachingFileScanner::class)
                            ->disableOriginalConstructor()
                            ->getMock();

        $reflectionProperty->setFileScanner($fileScanner);

        $fileScanner->method('getClassNameInformation')
                    ->willReturn(false);

        self::assertFalse($reflectionProperty->getAnnotations($annotationManager));
    }
}

<MSG> Zend\Code refactorings:
* Scanner now supports docblocks, scanners use better algorithm for gathering information
* Reflection renamings from Reflection_ to _Reflection for better consistency
* Tested update to run (still has some failures)

<DFF> @@ -33,11 +33,12 @@ namespace ZendTest\Code\Reflection;
  * @group      Zend_Reflection
  * @group      Zend_Reflection_Property
  */
-class ReflectionPropertyTest extends \PHPUnit_Framework_TestCase
+class PropertyReflectionTest extends \PHPUnit_Framework_TestCase
 {
     public function testDeclaringClassReturn()
     {
-        $property = new \Zend\Code\Reflection\ReflectionProperty('ZendTest\Code\Reflection\TestAsset\TestSampleClass2', '_prop1');
-        $this->assertEquals(get_class($property->getDeclaringClass()), 'Zend\Code\Reflection\ReflectionClass');
+        $property = new \Zend\Code\Reflection\PropertyReflection('ZendTest\Code\Reflection\TestAsset\TestSampleClass2', '_prop1');
+        $this->assertInstanceOf('Zend\Code\Reflection\ClassReflection', $property->getDeclaringClass());
+        $this->assertEquals('ZendTest\Code\Reflection\TestAsset\TestSampleClass2', $property->getDeclaringClass()->getName());
     }
 }

Zend\Code refactorings: * Scanner now supports docblocks, scanners use better algorithm for gathering information * Reflection renamings from Reflection_ to _Reflection for better consistency * Tested update to run (still has some failures)