public function detectFlowPackageFilePath($packageKey, $absolutePackagePath)
    {
        if (!is_dir($absolutePackagePath)) {
            throw new Exception\InvalidPackagePathException(sprintf('The given package path "%s" is not a readable directory.', $absolutePackagePath), 1445904440);
        }

        $composerManifest = ComposerUtility::getComposerManifest($absolutePackagePath);
        if (!ComposerUtility::isFlowPackageType(isset($composerManifest['type']) ? $composerManifest['type'] : '')) {
            return ['className' => GenericPackage::class, 'pathAndFilename' => ''];
        }

        $possiblePackageClassPaths = [
            Files::concatenatePaths(['Classes', 'Package.php']),
            Files::concatenatePaths(['Classes', str_replace('.', '/', $packageKey), 'Package.php'])
        ];

        $foundPackageClassPaths = array_filter($possiblePackageClassPaths, function ($packageClassPathAndFilename) use ($absolutePackagePath) {
            $absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]);
            return is_file($absolutePackageClassPath);
        });

        if ($foundPackageClassPaths === []) {
            return ['className' => Package::class, 'pathAndFilename' => ''];
        }

        if (count($foundPackageClassPaths) > 1) {
            throw new Exception\CorruptPackageException(sprintf('The package "%s" contains multiple possible "Package.php" files. Please make sure that only one "Package.php" exists in the autoload root(s) of your Flow package.', $packageKey), 1457454840);
        }

        $packageClassPathAndFilename = reset($foundPackageClassPaths);
        $absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]);

        $packageClassContents = file_get_contents($absolutePackageClassPath);
        $packageClassName = (new PhpAnalyzer($packageClassContents))->extractFullyQualifiedClassName();
        if ($packageClassName === null) {
            throw new Exception\CorruptPackageException(sprintf('The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class.', $packageKey, $packageClassPathAndFilename), 1327587091);
        }

        return ['className' => $packageClassName, 'pathAndFilename' => $packageClassPathAndFilename];
    }
public function detectFlowPackageFilePath($packageKey, $absolutePackagePath)
    {
        if (!is_dir($absolutePackagePath)) {
            throw new Exception\InvalidPackagePathException(sprintf('The given package path "%s" is not a readable directory.', $absolutePackagePath), 1445904440);
        }

        $composerManifest = ComposerUtility::getComposerManifest($absolutePackagePath);
        if (!ComposerUtility::isFlowPackageType(isset($composerManifest['type']) ? $composerManifest['type'] : '')) {
            return ['className' => GenericPackage::class, 'pathAndFilename' => ''];
        }

        $possiblePackageClassPaths = [
            Files::concatenatePaths(['Classes', 'Package.php']),
            Files::concatenatePaths(['Classes', str_replace('.', '/', $packageKey), 'Package.php'])
        ];

        $foundPackageClassPaths = array_filter($possiblePackageClassPaths, function ($packageClassPathAndFilename) use ($absolutePackagePath) {
            $absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]);
            return is_file($absolutePackageClassPath);
        });

        if ($foundPackageClassPaths === []) {
            return ['className' => Package::class, 'pathAndFilename' => ''];
        }

        if (count($foundPackageClassPaths) > 1) {
            throw new Exception\CorruptPackageException(sprintf('The package "%s" contains multiple possible "Package.php" files. Please make sure that only one "Package.php" exists in the autoload root(s) of your Flow package.', $packageKey), 1457454840);
        }

        $packageClassPathAndFilename = reset($foundPackageClassPaths);
        $absolutePackageClassPath = Files::concatenatePaths([$absolutePackagePath, $packageClassPathAndFilename]);

        $packageClassContents = file_get_contents($absolutePackageClassPath);
        $packageClassName = (new PhpAnalyzer($packageClassContents))->extractFullyQualifiedClassName();
        if ($packageClassName === null) {
            throw new Exception\CorruptPackageException(sprintf('The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class.', $packageKey, $packageClassPathAndFilename), 1327587091);
        }

        return ['className' => $packageClassName, 'pathAndFilename' => $packageClassPathAndFilename];
    }
public function detectFlowPackageFilePath ( $ packageKey , $ absolutePackagePath ) { if ( ! is_dir ( $ absolutePackagePath ) ) { throw new Exception \ InvalidPackagePathException ( sprintf ( 'The given package path "%s" is not a readable directory.' , $ absolutePackagePath ) , 1445904440 ) ; } $ composerManifest = ComposerUtility :: getComposerManifest ( $ absolutePackagePath ) ; if ( ! ComposerUtility :: isFlowPackageType ( isset ( $ composerManifest [ 'type' ] ) ? $ composerManifest [ 'type' ] : '' ) ) { return [ 'className' => GenericPackage :: class , 'pathAndFilename' => '' ] ; } $ possiblePackageClassPaths = [ Files :: concatenatePaths ( [ 'Classes' , 'Package.php' ] ) , Files :: concatenatePaths ( [ 'Classes' , str_replace ( '.' , '/' , $ packageKey ) , 'Package.php' ] ) ] ; $ foundPackageClassPaths = array_filter ( $ possiblePackageClassPaths , function ( $ packageClassPathAndFilename ) use ( $ absolutePackagePath ) { $ absolutePackageClassPath = Files :: concatenatePaths ( [ $ absolutePackagePath , $ packageClassPathAndFilename ] ) ; return is_file ( $ absolutePackageClassPath ) ; } ) ; if ( $ foundPackageClassPaths === [ ] ) { return [ 'className' => Package :: class , 'pathAndFilename' => '' ] ; } if ( count ( $ foundPackageClassPaths ) > 1 ) { throw new Exception \ CorruptPackageException ( sprintf ( 'The package "%s" contains multiple possible "Package.php" files. Please make sure that only one "Package.php" exists in the autoload root(s) of your Flow package.' , $ packageKey ) , 1457454840 ) ; } $ packageClassPathAndFilename = reset ( $ foundPackageClassPaths ) ; $ absolutePackageClassPath = Files :: concatenatePaths ( [ $ absolutePackagePath , $ packageClassPathAndFilename ] ) ; $ packageClassContents = file_get_contents ( $ absolutePackageClassPath ) ; $ packageClassName = ( new PhpAnalyzer ( $ packageClassContents ) ) -> extractFullyQualifiedClassName ( ) ; if ( $ packageClassName === null ) { throw new Exception \ CorruptPackageException ( sprintf ( 'The package "%s" does not contain a valid package class. Check if the file "%s" really contains a class.' , $ packageKey , $ packageClassPathAndFilename ) , 1327587091 ) ; } return [ 'className' => $ packageClassName , 'pathAndFilename' => $ packageClassPathAndFilename ] ; }
Detects if the package contains a package file and returns the path and classname.

@param string $packageKey The package key
@param string $absolutePackagePath Absolute path to the package
@return array The path to the package file and classname for this package or an empty array if none was found.
@throws Exception\CorruptPackageException
@throws Exception\InvalidPackagePathException
Detects if the package contains a package file and returns the path and classname .