src/ExcludeFilePlugin.php
private function filterAutoloads(array $packageMap, PackageInterface $mainPackage, array $blacklist = null)
    {
        $type = self::INCLUDE_FILES_PROPERTY;

        $blacklist = array_flip($blacklist);

        foreach ($packageMap as $item) {
            list($package, $installPath) = $item;

            // Skip root package
            if ($package === $mainPackage) {
                continue;
            }

            $autoload = $package->getAutoload();

            // Skip misconfigured packages
            if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
                continue;
            }

            if (null !== $package->getTargetDir()) {
                $installPath = substr($installPath, 0, -strlen('/' . $package->getTargetDir()));
            }

            foreach ($autoload[$type] as $key => $path) {
                if ($package->getTargetDir() && !is_readable($installPath.'/'.$path)) {
                    // add target-dir from file paths that don't have it
                    $path = $package->getTargetDir() . '/' . $path;
                }

                $resolvedPath = $installPath . '/' . $path;
                $resolvedPath = strtr($resolvedPath, '\\', '/');

                if (isset($blacklist[$resolvedPath])) {
                    unset($autoload[$type][$key]);
                }
            }

            $package->setAutoload($autoload);
        }
    }
private function filterAutoloads(array $packageMap, PackageInterface $mainPackage, array $blacklist = null)
    {
        $type = self::INCLUDE_FILES_PROPERTY;

        $blacklist = array_flip($blacklist);

        foreach ($packageMap as $item) {
            list($package, $installPath) = $item;

            // Skip root package
            if ($package === $mainPackage) {
                continue;
            }

            $autoload = $package->getAutoload();

            // Skip misconfigured packages
            if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
                continue;
            }

            if (null !== $package->getTargetDir()) {
                $installPath = substr($installPath, 0, -strlen('/' . $package->getTargetDir()));
            }

            foreach ($autoload[$type] as $key => $path) {
                if ($package->getTargetDir() && !is_readable($installPath.'/'.$path)) {
                    // add target-dir from file paths that don't have it
                    $path = $package->getTargetDir() . '/' . $path;
                }

                $resolvedPath = $installPath . '/' . $path;
                $resolvedPath = strtr($resolvedPath, '\\', '/');

                if (isset($blacklist[$resolvedPath])) {
                    unset($autoload[$type][$key]);
                }
            }

            $package->setAutoload($autoload);
        }
    }
private function filterAutoloads ( array $ packageMap , PackageInterface $ mainPackage , array $ blacklist = null ) { $ type = self :: INCLUDE_FILES_PROPERTY ; $ blacklist = array_flip ( $ blacklist ) ; foreach ( $ packageMap as $ item ) { list ( $ package , $ installPath ) = $ item ; // Skip root package if ( $ package === $ mainPackage ) { continue ; } $ autoload = $ package -> getAutoload ( ) ; // Skip misconfigured packages if ( ! isset ( $ autoload [ $ type ] ) || ! is_array ( $ autoload [ $ type ] ) ) { continue ; } if ( null !== $ package -> getTargetDir ( ) ) { $ installPath = substr ( $ installPath , 0 , - strlen ( '/' . $ package -> getTargetDir ( ) ) ) ; } foreach ( $ autoload [ $ type ] as $ key => $ path ) { if ( $ package -> getTargetDir ( ) && ! is_readable ( $ installPath . '/' . $ path ) ) { // add target-dir from file paths that don't have it $ path = $ package -> getTargetDir ( ) . '/' . $ path ; } $ resolvedPath = $ installPath . '/' . $ path ; $ resolvedPath = strtr ( $ resolvedPath , '\\' , '/' ) ; if ( isset ( $ blacklist [ $ resolvedPath ] ) ) { unset ( $ autoload [ $ type ] [ $ key ] ) ; } } $ package -> setAutoload ( $ autoload ) ; } }
Alters packages to exclude files required in "autoload.files" by "extra.exclude-from-files".

@param  array            $packageMap  Array of `[ package, installDir-relative-to-composer.json) ]`.
@param  PackageInterface $mainPackage Root package instance.
@param  string[]         $blacklist   The files to exclude from the "files" autoload mechanism.
@return void
Alters packages to exclude files required in autoload . files by extra . exclude - from - files .