scan all classes inside one defined unit test file

@param string $file

@return array
353791
public function analyseClassesInFile($file)
    {
        $ts = new PHP_Token_Stream($file);
        $this->phpUnitFile = new CoverFishPHPUnitFile();

        foreach ($ts->getClasses() as $className => $classData) {
            $fqnClass = sprintf('%s\\%s',
                $this->coverFishHelper->getAttributeByKey('namespace', $classData['package']),
                $className
            );

            if (false === $this->coverFishHelper->isValidTestClass($fqnClass)) {
                continue;
            }

            $classData['className'] = $className;
            $classData['classFile'] = $file;
            $this->analyseClass($classData);
        }
    }
558508
protected function getFileFinder($file) {
    return new class($file) implements ClassFinderInterface {

      protected $file;

      public function __construct($file) {
        $this->file = $file;
      }

      public function findFile($class) {
        return $this->file;
      }
    };
  }
748804
private function processFile($file)
	{
		// var to hold output
		$output = array();

		require_once $file;

		$className = $this->parseClassFromFile($file);
		$component = $this->parseClassFromFile($file, true)['component'];
		$version   = $this->parseClassFromFile($file, true)['version'];

		// Push file to files array
		$this->output['files'][] = $file;

		// Push version to versions array
		$this->output['versions']['available'][] = $version;

		if (!class_exists($className))
		{
			return $output;
		}

		$classReflector = new ReflectionClass($className);

		foreach ($classReflector->getMethods() as $method)
		{
			// Create docblock object & make sure we have something
			$phpdoc = new DocBlock($method);

			// Skip methods we don't want processed
			if (substr($method->getName(), -4) != 'Task' || in_array($method->getName(), array('registerTask', 'unregisterTask', 'indexTask')))
			{
				continue;
			}

			// Skip method in the parent class (already processed), 
			if ($className != $method->getDeclaringClass()->getName())
			{
				//continue;
			}

			// Skip if we dont have a short desc
			// but put in error
			if (!$phpdoc->getShortDescription())
			{
				$this->output['errors'][] = sprintf('Missing docblock for method "%s" in "%s"', $method->getName(), $file);
				continue;
			}

			$controller = basename($file);
			$controller = preg_replace('#\.[^.]*$#', '', $controller);
			$parts = explode('v', $controller);
			$v = array_pop($parts);
			$controller = implode('v', $parts);

			// Create endpoint data array
			$endpoint = array(
				//'name'        => substr($method->getName(), 0, -4),
				//'description' => preg_replace('/\s+/', ' ', $phpdoc->getShortDescription()), // $phpdoc->getLongDescription()->getContents()
				'name'        => $phpdoc->getShortDescription(),
				'description' => $phpdoc->getLongDescription()->getContents(),
				'method'      => '',
				'uri'         => '',
				'parameters'  => array(),
				'_metadata'   => array(
					'controller' => $controller,
					'component' => $component,
					'version'   => $version,
					'method'    => $method->getName()
				)
			);

			// Loop through each tag
			foreach ($phpdoc->getTags() as $tag)
			{
				$name    = strtolower(str_replace('api', '', $tag->getName()));
				$content = $tag->getContent();

				// Handle parameters separately
				// json decode param input
				if ($name == 'parameter')
				{
					$parameter = json_decode($content);

					if (json_last_error() != JSON_ERROR_NONE)
					{
						$this->output['errors'][] = sprintf('Unable to parse parameter info for method "%s" in "%s"', $method->getName(), $file);
						continue;
					}

					$endpoint['parameters'][] = (array) $parameter;
					continue;
				}

				if ($name == 'uri')
				{
					$content = str_replace(['{component}', '{controller}'], [$component, $controller], $content);

					if ($controller == $component)
					{
						$content = str_replace($component . '/' . $controller, $component, $content);
					}
				}

				if ($name == 'uri' && $method->getName() == 'indexTask')
				{
					$content .= $component;
				}

				// Add data to endpoint data
				$endpoint[$name] = $content;
			}

			// Add endpoint to output
			// We always want indexTask to be first in the list
			if ($method->getName() == 'indexTask')
			{
				array_unshift($output, $endpoint);
			}
			else
			{
				$output[] = $endpoint;
			}
		}

		return $output;
	}
600740
private function parseJsonFile(string $file): array
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException("$file is not a file");
        }

        $json = json_decode(file_get_contents($file), true);

        if (null === $json) {
            throw new \RuntimeException("File $file cannot be decoded");
        }

        return $json;
    }
1198301
protected function loader($file)
    {
        foreach ($this->folders as $folder)
        {
            foreach (FileLoader::extensions() as $ext)
            {
                try
                {
                    return FileLoader::load($folder . '/' . $file . '.' . $ext);
                }
                catch (\Throwable $throwable)
                {
                    // skip...
                }
            }
        }

        return null;
    }
815297
protected function readFile(string $file) : array
    {
        if (!file_exists($file)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Configuration %s is not exists',
                    $file
                ),
                E_WARNING
            );
        }

        if (!is_array(($configs = $this->parseFromFile($file)))) {
            throw new \RuntimeException(
                sprintf(
                    'Invalid %s configuration from file: %s',
                    ltrim(strrchr(get_class($this), '\\'), '\\'),
                    $file
                ),
                E_NOTICE
            );
        }

        return $configs;
    }
1174627
public function filter(\SplFileInfo $file)
    {
        try {
            $class = $this->getClassName($file->getPathname());
        } catch (\Exception $e){
            return false;
        }

        if (! @include_once($file->getPathname())) {
            return false;
        }

        $ReflectionClass = new \ReflectionClass($class);

        foreach ($this->instances as $instance) {
            if ($ReflectionClass->isSubclassOf($instance)) {
                return true;
            }

            if ($class === $instance) {
                return true;
            }
        }

        return false;
    }
674980
private static function getLinks(string $file): array
    {
        $links    = [];
        $contents = (string)file_get_contents($file);
        if (false !== preg_match_all(
            '/\[(.+?)\].*?\((.+?)\)/',
            $contents,
            $matches,
            PREG_SET_ORDER
        )) {
            $links = array_merge($links, $matches);
        }

        return $links;
    }
266056
private function getFileContents($file)
    {
        if (!isset($this->filesContent[$file])) {
            $this->filesContent[$file] = file_exists($file) ? file($file) : [];
        }

        return $this->filesContent[$file];
    }
53263
protected static function getMaps($file)
    {
        $maps = json_decode(File::get($file), true);

        if (is_null($maps)) {
            throw new Exception('The existing mapping file contains invalid json string. Please fix the file then try again');
        }

        return $maps;
    }
203613
protected function getExtensions($file)
    {
        $basename = strtolower(pathinfo($file, PATHINFO_BASENAME));

        // normalize
        foreach ($this->composedExtensions as $composedExtension => $canonicalExtension) {
            $basename = preg_replace('/\.'.preg_quote($composedExtension).'(\.|$)/', '.'.$canonicalExtension.'\\1', $basename);
        }

        $extensions = explode('.', $basename);
        $extensions = array_reverse(array_slice($extensions, 1));

        $recognizedExtensions = [];

        $i = 0;
        $extensionsNumber = count($extensions);

        while ($i < $extensionsNumber && array_key_exists($extensions[$i], $this->extensionMap)) {
            $recognizedExtensions[] = $extensions[$i];
            $i++;
        }

        return array_reverse($recognizedExtensions);
    }
49976
protected function getTranslations(string $file) : array
    {
        return $this->files->exists($file) ? (array) json_decode($this->files->get($file)) : [];
    }
75152
private static function getIgnoredFiles($file) {
    if (file_exists($file) === FALSE) {
      return array();
    }

    $contents = file_get_contents($file);
    if ($contents === FALSE) {
      return array();
    }

    return preg_split('/\s+/', $contents);
  }
514357
public function run(string $file, Node $node): array
    {
        // This inspection only works to top level statements in each file.
        if ($this->inspectedFile === $file) {
            return [];
        }

        $found = false;
        foreach ($node->children as $child) {
            if (!$child instanceof Node) {
                continue;
            }

            if ($child->kind !== \ast\AST_DECLARE) {
                continue;
            }

            $declares = $child->children["declares"];
            if ($declares->kind !== \ast\AST_CONST_DECL) {
                continue;
            }

            foreach ($declares->children as $declare) {
                if ($declare->kind === \ast\AST_CONST_ELEM && $declare->children["name"] === "strict_types") {
                    $found = true;
                }
            }
        }
        $this->inspectedFile = $file;

        if (!$found) {
            return [new Hint(
                self::HINT_TYPE,
                self::HINT_MESSAGE,
                $file,
                $node->lineno,
                self::HINT_LINK
            )];
        }

        return [];
    }
852008
public static function get(String $file) : stdClass
    {
        $file = self::rpath($file);

        if( ! is_file($file) )
        {
            throw new Exception\FileNotFoundException(NULL, $file);
        }

        return (object)
        [
            'basename'   => self::pathInfo($file, 'basename'),
            'size'       => filesize($file),
            'date'       => filemtime($file),
            'readable'   => is_readable($file),
            'writable'   => is_writable($file),
            'executable' => is_executable($file),
            'permission' => fileperms($file)
        ];
    }
24315
protected function _read($file) {
		$text = file_get_contents($file);
		if (empty($text)) {
			return [];
		}
		$pieces = explode(NL, $text);
		return $pieces;
	}
1076028
protected function _coverage($file, $coverage)
    {
        $result = [];
        $root = $this->parse($file);
        foreach ($root->lines['content'] as $num => $content) {
            $coverable = null;
            foreach ($content['nodes'] as $node) {
                if ($node->coverable && $node->lines['stop'] === $num) {
                    $coverable = $node;
                    break;
                }
            }
            if (!$coverable) {
                continue;
            }
            if (isset($coverage[$num])) {
                $result[$num] = $coverage[$num];
            } elseif (isset($coverable->lines['begin'])) {
                for ($i = $coverable->lines['begin']; $i <= $num; $i++) {
                    if (isset($coverage[$i])) {
                        $result[$num] = $coverage[$i];
                        break;
                    }
                }
                if (!isset($result[$num])) {
                    $result[$num] = 0;
                }
            } else {
                $result[$num] = 0;
            }
        }
        return $result;
    }