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

Breadcrumb

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

function ClassMap::getAmbiguousClasses

A map of class names to their list of ambiguous paths

This occurs when the same class can be found in several files

To get the path the class is being mapped to, call getClassPath

By default, paths that contain test(s), fixture(s), example(s) or stub(s) are ignored as those are typically not problematic when they're dummy classes in the tests folder. If you want to get these back as well you can pass false to $duplicatesFilter. Or you can pass your own pattern to exclude if you need to change the default.

Parameters

non-empty-string|false $duplicatesFilter:

Return value

array<class-string, array<non-empty-string>>

File

vendor/composer/class-map-generator/src/ClassMap.php, line 85

Class

ClassMap
@author Jordi Boggiano <j.boggiano@seld.be>

Namespace

Composer\ClassMapGenerator

Code

public function getAmbiguousClasses($duplicatesFilter = '{/(test|fixture|example|stub)s?/}i') : array {
    if (false === $duplicatesFilter) {
        return $this->ambiguousClasses;
    }
    if (true === $duplicatesFilter) {
        throw new \InvalidArgumentException('$duplicatesFilter should be false or a string with a valid regex, got true.');
    }
    $ambiguousClasses = [];
    foreach ($this->ambiguousClasses as $class => $paths) {
        $paths = array_filter($paths, function ($path) use ($duplicatesFilter) {
            return !Preg::isMatch($duplicatesFilter, strtr($path, '\\', '/'));
        });
        if (\count($paths) > 0) {
            $ambiguousClasses[$class] = array_values($paths);
        }
    }
    return $ambiguousClasses;
}

API Navigation

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