src/PatchCollector.php
protected function resolveExplicitList(PackageInterface $package, $patches)
    {
        $collectedPatches = new PatchCollection();
        if (!is_array($patches)) {
            $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches', $patches, 'The extra.patches configuration must be an array.'));
        } else {
            $packageDirectory = $this->installationManager->getInstallPath($package);
            foreach ($patches as $forPackageHandle => $patchList) {
                if (!is_array($patchList)) {
                    $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches', $package, "The \"{$forPackageHandle}\" value must be an array."));
                    continue;
                }
                foreach ($patchList as $patchDescription => $patchData) {
                    try {
                        list($path, $levels) = $this->extractPatchData($package, $patchData);
                        $localFile = $this->pathResolver->resolve($path, $packageDirectory);
                        if ($localFile === '') {
                            $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches', $package, "The path of the \"{$patchDescription}\" patch is empty or is not a string."));
                        }
                        $collectedPatches->addPatch(
                            new Patch($package, $forPackageHandle, $path, $localFile, $patchDescription, $levels)
                        );
                    } catch (BaseException $x) {
                        $this->handleException($x);
                    }
                }
            }
        }

        return $collectedPatches;
    }
protected function resolveExplicitList(PackageInterface $package, $patches)
    {
        $collectedPatches = new PatchCollection();
        if (!is_array($patches)) {
            $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches', $patches, 'The extra.patches configuration must be an array.'));
        } else {
            $packageDirectory = $this->installationManager->getInstallPath($package);
            foreach ($patches as $forPackageHandle => $patchList) {
                if (!is_array($patchList)) {
                    $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches', $package, "The \"{$forPackageHandle}\" value must be an array."));
                    continue;
                }
                foreach ($patchList as $patchDescription => $patchData) {
                    try {
                        list($path, $levels) = $this->extractPatchData($package, $patchData);
                        $localFile = $this->pathResolver->resolve($path, $packageDirectory);
                        if ($localFile === '') {
                            $this->handleException(Exception\InvalidPackageConfigurationValue($package, 'extra.patches', $package, "The path of the \"{$patchDescription}\" patch is empty or is not a string."));
                        }
                        $collectedPatches->addPatch(
                            new Patch($package, $forPackageHandle, $path, $localFile, $patchDescription, $levels)
                        );
                    } catch (BaseException $x) {
                        $this->handleException($x);
                    }
                }
            }
        }

        return $collectedPatches;
    }
protected function resolveExplicitList ( PackageInterface $ package , $ patches ) { $ collectedPatches = new PatchCollection ( ) ; if ( ! is_array ( $ patches ) ) { $ this -> handleException ( Exception \ InvalidPackageConfigurationValue ( $ package , 'extra.patches' , $ patches , 'The extra.patches configuration must be an array.' ) ) ; } else { $ packageDirectory = $ this -> installationManager -> getInstallPath ( $ package ) ; foreach ( $ patches as $ forPackageHandle => $ patchList ) { if ( ! is_array ( $ patchList ) ) { $ this -> handleException ( Exception \ InvalidPackageConfigurationValue ( $ package , 'extra.patches' , $ package , "The \"{$forPackageHandle}\" value must be an array." ) ) ; continue ; } foreach ( $ patchList as $ patchDescription => $ patchData ) { try { list ( $ path , $ levels ) = $ this -> extractPatchData ( $ package , $ patchData ) ; $ localFile = $ this -> pathResolver -> resolve ( $ path , $ packageDirectory ) ; if ( $ localFile === '' ) { $ this -> handleException ( Exception \ InvalidPackageConfigurationValue ( $ package , 'extra.patches' , $ package , "The path of the \"{$patchDescription}\" patch is empty or is not a string." ) ) ; } $ collectedPatches -> addPatch ( new Patch ( $ package , $ forPackageHandle , $ path , $ localFile , $ patchDescription , $ levels ) ) ; } catch ( BaseException $ x ) { $ this -> handleException ( $ x ) ; } } } } return $ collectedPatches ; }
Collect the patches from the "patches" configuration key.

@param \Composer\Package\PackageInterface $package the package being inspected
@param array|mixed $patches the extra.patches configuration provided by the package

@throws \ComposerPatcher\Exception\InvalidPackageConfigurationValue when $patches is not valid

@return \ComposerPatcher\PatchCollection
Collect the patches from the patches configuration key .