public function testGetGlobalFileNamespace()
 {
     $fileName = stream_resolve_include_path(__DIR__ . self::STUB_GLOBAL_FILE);
     $reflectionFile = new ReflectionFile($fileName);
     $reflectionFileNamespace = $reflectionFile->getFileNamespace('\\');
     $this->assertInstanceOf('Go\\ParserReflection\\ReflectionFileNamespace', $reflectionFileNamespace);
 }
 protected function setUp()
 {
     $this->originalRefClass = $refClass = new \ReflectionClass(self::STUB_CLASS);
     $fileName = $refClass->getFileName();
     $reflectionFile = new ReflectionFile($fileName);
     $parsedClass = $reflectionFile->getFileNamespace($refClass->getNamespaceName())->getClass($refClass->getName());
     $this->parsedRefClass = $parsedClass;
 }
 protected function setUp()
 {
     $fileName = stream_resolve_include_path(__DIR__ . self::STUB_FILE);
     $fileNode = ReflectionEngine::parseFile($fileName);
     $reflectionFile = new ReflectionFile($fileName, $fileNode);
     $parsedFileNamespace = $reflectionFile->getFileNamespace('Go\\ParserReflection\\Stub');
     $this->parsedRefFileNamespace = $parsedFileNamespace;
     include_once $fileName;
 }
 public function testGetReturnTypeMethod()
 {
     if (PHP_VERSION_ID < 70000) {
         $this->markTestSkipped('Test available only for PHP7.0 and newer');
     }
     $fileName = stream_resolve_include_path(__DIR__ . self::STUB_FILE70);
     $reflectionFile = new ReflectionFile($fileName);
     include $fileName;
     foreach ($reflectionFile->getFileNamespaces() as $fileNamespace) {
         foreach ($fileNamespace->getFunctions() as $refFunction) {
             $functionName = $refFunction->getName();
             $originalRefFunction = new \ReflectionFunction($functionName);
             $hasReturnType = $refFunction->hasReturnType();
             $this->assertSame($originalRefFunction->hasReturnType(), $hasReturnType, "Presence of return type for function {$functionName} should be equal");
             if ($hasReturnType) {
                 $parsedReturnType = $refFunction->getReturnType();
                 $originalReturnType = $originalRefFunction->getReturnType();
                 $this->assertSame($originalReturnType->allowsNull(), $parsedReturnType->allowsNull());
                 $this->assertSame($originalReturnType->isBuiltin(), $parsedReturnType->isBuiltin());
                 $this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString());
             } else {
                 $this->assertSame($originalRefFunction->getReturnType(), $refFunction->getReturnType());
             }
         }
     }
 }
 public function testGetTypeMethod()
 {
     if (PHP_VERSION_ID < 70000) {
         $this->markTestSkipped('Test available only for PHP7.0 and newer');
     }
     foreach ($this->parsedRefFile->getFileNamespaces() as $fileNamespace) {
         foreach ($fileNamespace->getFunctions() as $refFunction) {
             $functionName = $refFunction->getName();
             foreach ($refFunction->getParameters() as $refParameter) {
                 $parameterName = $refParameter->getName();
                 $originalRefParameter = new \ReflectionParameter($functionName, $parameterName);
                 $hasType = $refParameter->hasType();
                 $this->assertSame($originalRefParameter->hasType(), $hasType, "Presence of type for parameter {$functionName}:{$parameterName} should be equal");
                 if ($hasType) {
                     $parsedReturnType = $refParameter->getType();
                     $originalReturnType = $originalRefParameter->getType();
                     $this->assertSame($originalReturnType->allowsNull(), $parsedReturnType->allowsNull());
                     $this->assertSame($originalReturnType->isBuiltin(), $parsedReturnType->isBuiltin());
                     $this->assertSame($originalReturnType->__toString(), $parsedReturnType->__toString());
                 } else {
                     $this->assertSame($originalRefParameter->getType(), $refParameter->getType());
                 }
             }
         }
     }
 }
 /**
  * Tests specific features of PHP5.6 and newer, for example, array constants, etc
  */
 public function testGettersPHP56()
 {
     if (PHP_VERSION_ID < 50600) {
         $this->markTestSkipped("Can not test new features on old version of PHP");
     }
     $fileName = stream_resolve_include_path(__DIR__ . self::STUB_FILE56);
     $fileNode = ReflectionEngine::parseFile($fileName);
     $reflectionFile = new ReflectionFile($fileName, $fileNode);
     include_once $fileName;
     $parsedFileNamespace = $reflectionFile->getFileNamespace('Go\\ParserReflection\\Stub');
     foreach ($parsedFileNamespace->getClasses() as $parsedRefClass) {
         $this->performGeneralMethodComparison($parsedRefClass);
     }
 }