Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AutoloadGenerator.php

function AutoloadGenerator::validatePackage

Return value

void

Throws

\InvalidArgumentException Throws an exception, if the package has illegal settings.

1 call to AutoloadGenerator::validatePackage()
AutoloadGenerator::buildPackageMap in vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php

File

vendor/composer/composer/src/Composer/Autoload/AutoloadGenerator.php, line 537

Class

AutoloadGenerator
@author Igor Wiedler <igor@wiedler.ch> @author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\Autoload

Code

protected function validatePackage(PackageInterface $package) {
    $autoload = $package->getAutoload();
    if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
        $name = $package->getName();
        $package->getTargetDir();
        throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '{$name}'.");
    }
    if (!empty($autoload['psr-4'])) {
        foreach ($autoload['psr-4'] as $namespace => $dirs) {
            if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
                throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '{$namespace}' does not, use '{$namespace}\\'.");
            }
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal