Add a class entry.

@param string $class The class name.

@param string $file  The file containing the class.

@return ClassMap

@throws ClassAlreadyRegisteredException When the class has already been registered.
171787
public function add($class, $file)
    {
        $class = $this->normalizeClassName($class);

        if ($this->has($class)) {
            if (($localFile = $this->getFileFor($class)) !== $file) {
                throw new ClassAlreadyRegisteredException($class, $localFile);
            }
        }

        $this->classes[$class] = $file;

        return $this;
    }
399897
protected function loadMetadataFromFile(\ReflectionClass $class, $file)
    {
        $config = Yaml::parse(file_get_contents($file));

        if (!isset($config[$name = $class->name])) {
            throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file));
        }

        $config                         = $config[$name];
        $classMetadata                  = new MergeableClassMetadata($name);
        $classMetadata->fileResources[] = $file;
        $classMetadata->fileResources[] = $class->getFileName();

        $propertiesMetadata = [];

        foreach ($class->getProperties() as $property) {
            $pName                      = $property->getName();
            $propertiesMetadata[$pName] = new PropertyMetadata($name, $pName);
        }

        foreach ($config as $pName => $pConfig) {
            $propertyMetadata = $propertiesMetadata[$pName];

            if (isset($pConfig['data'])) {
                $propertyMetadata->staticData = $pConfig['data'];
            } elseif (isset($pConfig['faker'])) {
                $fConfig = $pConfig['faker'];

                if (is_string($fConfig)) {
                    $propertyMetadata->fakerName = $fConfig;
                } elseif (is_array($fConfig)) {
                    if (isset($fConfig['name'])) {
                        $propertyMetadata->fakerName = (string)$fConfig['name'];
                    }
                    if (isset($fConfig['type'])) {
                        $propertyMetadata->fakerResolverType = (string)$fConfig['type'];
                    }
                    if (isset($fConfig['arguments'])) {
                        $propertyMetadata->fakerResolverArgs = (array)$fConfig['arguments'];
                    }
                }
            } elseif (isset($pConfig['ignore'])) {
                $propertyMetadata->ignore = (Boolean)$pConfig['ignore'];
            }
        }

        foreach ($propertiesMetadata as $propertyMetadata) {
            $classMetadata->addPropertyMetadata($propertyMetadata);
        }

        return $classMetadata;
    }
256095
public function addClass($class)
    {
        if (! $this->hasClass($class)) {
            $this->set('class', trim((string) $this->get('class') . ' ' . $class));
        }

        return $this;
    }
1188945
public function addClassDefinition(CompilerFileAnonymous $file, ClassDefinition $classDefinition)
    {
        $this->definitions[$classDefinition->getCompleteName()] = $classDefinition;
        $this->anonymousFiles[$classDefinition->getCompleteName()] = $file;
    }
1047321
public static function loadClassFile($file) {
		$before = array_merge(get_declared_classes(), get_declared_interfaces());
		require_once $file;
		$after = array_merge(get_declared_classes(), get_declared_interfaces());

		$diff = array_diff($after, $before);

		#class was maybe already loaded
		if(!$diff) {
			foreach(array_merge(get_declared_classes(), get_declared_interfaces()) as $class) {
				$reflector = new \ReflectionClass($class);
				if($reflector->getFileName() == realpath($file)) {
					$result = $class;
					break;
				}
			}
			if(!isset($result))
				throw new \Exception('File '.$file.' does not contain any class.');
		}
		else
			$result = array_values($diff)[count($diff)-1];

		return $result;
	}
226679
public function addClass( string $class ): Tag
    {

        if ( ! isset( $this->attributes['class'] ) ) {
            $this->attributes['class'] = $class;
        } else {
            $this->attributes['class'] .= " $class";
        }

        return $this;
    }
502770
public function setClass($identifier, $class)
    {
        $class      = trim($class);
        $identifier = (string) $identifier;

        $this->_classes[$identifier] = $class;

        return $this;
    }
270575
public static function register($class, $priority = 0)
    {
        if (! in_array($class, self::$modules)) {
            $priority = str_pad($priority, 4, '0', STR_PAD_LEFT);
            $key = sprintf('%s:%s', $priority, $class);
            self::$modules[$key] = $class;
        }
    }
375459
public function addListenerByClass(string $class, $listener)
    {
        $class = trim($class, '\\');

        if (!isset($this->classListeners[$class])) {
            $this->classListeners[$class] = [];
        }
        $this->classListeners[$class][] = $listener;
    }
692786
public function registerType($class) {
    $name = str_replace('\\','',$class);
    \Doctrine\DBAL\Types\Type::addType($name, $class);
    return $this;
  }
441468
protected function registerObserver($class)
    {
        $className = is_string($class) ? $class : get_class($class);

        foreach ($this->getObservableEvents() as $event) {
            if (method_exists($class, $event)) {
                static::registerModelEvent($event, $className . '@' . $event);
            }
        }
    }
790362
public function registerClass(string $class, string $name)
    {
        if (isset($this->classes[$name]))
            throw new Exception("Cannot register the same name twice");
        if (!is_a($class, ACLModel::class, true))
            throw new TypeError("Class must be subclass of ACLModel");
    
        $this->classes[$name] = $class;
        $this->classes_names[$class] = $name;
        return $this;
    }
1162203
public function addClass ($class)
    {
        $targetArray = &$this->customClasses;
        if (!is_array($class))
            $targetArray[] = $class;
        else
            $targetArray = array_merge($targetArray, $class);
        return $this;
    }
970662
public function addClassResource(\ReflectionClass $class)
    {
        if (!$this->trackResources) {
            return $this;
        }

        do {
            if (is_file($class->getFileName())) {
                $this->addResource(new FileResource($class->getFileName()));
            }
        } while ($class = $class->getParentClass());

        return $this;
    }
1359299
public function autoload($class) {
        $classKey = strtolower($class);

        if (isset($this->classes[$classKey])) {
            list($_, $path) = $this->classes[$classKey];
            include_once $path;
        }
    }
246948
public function add($file)
    {
        if ($file instanceof File) {
            throw InvalidArgumentException::create(
                sprintf(
                    '%1$s/FileBag|SplFileInfo[]|SplFileInfo',
                    __NAMESPACE__
                ),
                $file
            );
        }

        return parent::add($file);
    }
480229
protected function define(ClassDefinition $class)
    {
        $class->property($this->name)->asString();

        $class->property($this->file)->asObject(File::class);
    }