Generate the classes

@return string the code or status if -w
170346
public function buildAction() {
		$request = $this->getConsoleRequest();
		
		$types = [
			'datatable' => [
				'DataTable'],
			'abstract' => [
				'EntityAbstract'],
			'entity' => [
				'Entity'],
			'ALL' => [
				'DataTable',
				'EntityAbstract',
				'Entity']];
		
		$class = $request->getParam('class');
		$table = $request->getParam('table');
		$write = $request->getParam('write') || $request->getParam('w');
		
		$body = '';
		$classes = $types[$class];
		foreach ( $classes as $type ) {
			$getFunc = "get{$type}Code";
			$writeFunc = "write{$type}";
			
			$body .= "Generating $type for $table\n";
			
			if ($table == 'ALL') {
				$bm = new BuilderManager($this->getNameManager(true));
				
				while ( $bm->nextTable() ) {
					if ($write) {
						if ($bm->$writeFunc(true)) {
							$body .= "\tWritten {$bm->getTableName()}\n";
						}
					} else {
						$body .= "\n//TODO:NEWCLASS\n" . $bm->$getFunc();
					}
				}
			} else {
				$bm = new BuilderManager($this->getNameManager(true), $table);
				$code = $bm->$getFunc();
				
				if ($write) {
					if ($bm->$writeFunc(true)) {
						$body .= "\tWritten to file\n";
					}
				} else {
					$body .= $code;
				}
			}
			
			$body .= $this->getDeveloperFooter();
		}
		
		return "$body\n";
	}
689683
private function classes(): string
    {
        $classes = '';

        if ($this->style !== null) {
            $classes .= ' btn-' . $this->style;
        }

        if ($this->large === true) {
            $classes .= ' btn-lg';
        }

        if ($this->small === true) {
            $classes .= ' btn-sm';
        }

        if ($this->extra_small === true) {
            $classes .= ' btn-xs';
        }

        if ($this->block === true) {
            $classes .= ' btn-block';
        }

        if ($this->active === true) {
            $classes .= ' active';
        }

        if (count($this->custom_classes) > 0) {
            $classes .= ' ' . implode(' ', $this->custom_classes);
        }

        return $classes;
    }
791775
protected function classMethodsIntoStruct()
    {
        $class = new ReflectionClass($this->classname);
        $methods = $class->getMethods();
        // params
        foreach ($methods as $method) {
            if ($method->isPublic()
                && !in_array($method->getName(), $this->preventMethods)
            ) {
                $docComments = $method->getDocComment();
                $_docComments_Description = trim(
                    str_replace(
                        '/**',
                        '',
                        substr($docComments, 0, strpos($docComments, '@'))
                    )
                );
                $docComments_Description = trim(
                    substr(
                        $_docComments_Description,
                        strpos(
                            $_docComments_Description,
                            '*'
                        ) + 1,
                        strpos($_docComments_Description, '*', 1) - 1
                    )
                );
                $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['description'] = $docComments_Description;
                preg_match_all('~@param\s(\S+)~', $docComments, $param);
                preg_match_all(
                    '~@return\s(\S+)~',
                    $method->getDocComment(),
                    $return
                );
                $params = $method->getParameters();
                for ($i = 0; $i < count($params); ++$i) {
                    $_class = $params[$i]->getClass();
                    $_type  = ($_class) ? $_class->getName() : $param[1][$i];

                    $_cleanType = str_replace('[]', '', $_type, $_length);
                    $_typens    = str_repeat('ArrayOf', $_length);

                    $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['name']
                        = $params[$i]->getName();
                    $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['wsdltype']
                        = $_typens . $_cleanType;
                    $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['type']
                        = $_cleanType;
                    $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['length']
                        = $_length;
                    $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['array']
                        = ($_length > 0 && in_array($_cleanType, $this->simpleTypes)) ? true : false;
                    $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['class']
                        = (!in_array($_cleanType, $this->simpleTypes) && new ReflectionClass($_cleanType)) ? true : false;
                    $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['param']
                        = true;
                }
                // return
                if (isset($return[1][0])) {
                    $_cleanType = str_replace('[]', '', $return[1][0], $_length);
                } else {
                    $_cleanType = 'void';
                    $_length = 0;
                }
                $_typens = str_repeat('ArrayOf', $_length);

                $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['wsdltype']
                    = $_typens.$_cleanType;
                $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['type']
                    = $_cleanType;
                $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['length']
                    = $_length;
                $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['array']
                    = ($_length > 0 && $_cleanType != 'void' && in_array($_cleanType, $this->simpleTypes)) ? true : false;
                $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['class']
                    = ($_cleanType != 'void' && !in_array($_cleanType, $this->simpleTypes) && new ReflectionClass($_cleanType)) ? true : false;
                $this->wsdlStruct[$this->wsdlclassname]['method'][$method->getName()]['var'][$i]['return']
                    = true;
            }
        }
    }
734097
protected function _classNode()
    {
        if (substr($this->_states['body'], -2) === '::') { // Bails out on `::class`
            $this->_states['body'] .= 'class';
            return;
        }

        $this->_codeNode();
        $token = $this->_stream->current(true);
        $body = $token[1];
        $body .= $this->_stream->skipWhitespaces();
        $body .= $name = $this->_stream->current();
        if ($name !== '{') {
            $body .= $this->_stream->next(['{', T_EXTENDS, T_IMPLEMENTS]);
        } else {
            $name = '';
        }
        $token = $this->_stream->current(true);
        $extends = '';
        $implements = '';
        if ($token[0] === T_EXTENDS) {
            $body .= $this->_stream->skipWhitespaces();
            $body .= $extends = $this->_stream->skipWhile([T_STRING, T_NS_SEPARATOR]);
            $body .= $this->_stream->current();
            if ($this->_stream->current() !== '{') {
                $body .= $this->_stream->next('{');
            }
        } elseif ($token[0] === T_IMPLEMENTS) {
            $body .= $implements = $this->_stream->next('{');
            $implements = substr($implements, 0, -1);
        }
        $node = new BlockDef($body, 'class');
        $node->name = $name;
        $node->extends = $this->_normalizeClass($extends);
        $node->implements = $this->_normalizeImplements($implements);

        $this->_states['body'] .= $body;
        return $this->_states['current'] = $this->_contextualize($node);
    }
1109791
public function classes()
    {
        if (is_null($this->classRequests)) {
            $this->classRequests = new ClassRequests($this->client);
        }

        return $this->classRequests;
    }
145427
protected function generate_wsdl() {
        // Initialise WSDL.
        $this->wsdl = new wsdl($this->serviceclass, $this->serverurl);
        // Register service struct classes as complex types.
        foreach ($this->servicestructs as $structinfo) {
            $this->wsdl->add_complex_type($structinfo->classname, $structinfo->properties);
        }
        // Register the method for the WSDL generation.
        foreach ($this->servicemethods as $methodinfo) {
            $this->wsdl->register($methodinfo->name, $methodinfo->inputparams, $methodinfo->outputparams, $methodinfo->description);
        }
    }
1220166
protected static function get_extractor_classes()
    {
        // Check cache
        if (self::$sorted_extractor_classes) {
            return self::$sorted_extractor_classes;
        }

        // Generate the sorted list of extractors on demand.
        $classes = ClassInfo::subclassesFor(__CLASS__);
        array_shift($classes);
        $classPriorities = [];

        foreach ($classes as $class) {
            $classPriorities[$class] = Config::inst()->get($class, 'priority');
        }
        arsort($classPriorities);

        // Save classes
        $sortedClasses = array_keys($classPriorities);
        return self::$sorted_extractor_classes = $sortedClasses;
    }
67890
public static function renderClasses()
    {
        if (!empty(self::$views['classes'])) {
            self::render(self::$views['classes'], array(
                'classes' => self::classes()
            ));
        }
    }
26311
private function classes(): string
    {
        $classes = '';

        if ($this->style !== null) {
            $classes .= ' label-' . $this->style;
        }

        return $classes;
    }
760978
public function CMSTreeClasses()
    {
        $classes = parent::CMSTreeClasses();
        
        if (!$this->canEdit()) {
            $classes .= ' hidden';
        }
        
        $this->extend('updateCMSTreeClasses', $classes);
        
        return $classes;
    }
176149
private function generateWrapperClass(): void
  {
    $this->io->title('Wrapper');

    /** @var NameMangler $mangler */
    $mangler  = new $this->nameMangler();
    $routines = $this->readRoutineMetadata();

    if (!empty($routines))
    {
      // Sort routines by their wrapper method name.
      $sorted_routines = [];
      foreach ($routines as $routine)
      {
        $method_name                   = $mangler->getMethodName($routine['routine_name']);
        $sorted_routines[$method_name] = $routine;
      }
      ksort($sorted_routines);

      // Write methods for each stored routine.
      foreach ($sorted_routines as $method_name => $routine)
      {
        // If routine type is hidden don't create routine wrapper.
        if ($routine['designation']!='hidden')
        {
          $this->writeRoutineFunction($routine, $mangler);
        }
      }
    }
    else
    {
      echo "No files with stored routines found.\n";
    }

    $wrappers        = $this->codeStore->getRawCode();
    $this->codeStore = new PhpCodeStore();

    // Write the header of the wrapper class.
    $this->writeClassHeader();

    // Write methods of the wrapper calls.
    $this->codeStore->append($wrappers, false);

    // Write the trailer of the wrapper class.
    $this->writeClassTrailer();

    // Write the wrapper class to the filesystem.
    $this->storeWrapperClass();
  }
52460
protected function getClassFiles()
	{
		$app = $this->flyphp;

		$core = require __DIR__.'/Optimize/config.php';

		return array_merge($core, $this->flyphp['config']['compile']);
	}
114025
public function getClasses()
    {
        if (!isset($this->fileClasses)) {
            $this->fileClasses = $this->findClasses();
        }

        return $this->fileClasses;
    }
765679
private function getClasses()
    {
        $r = '';

        // Inside classes
        foreach ($this->modules as $module) {
            $classes = (array)$this->xml->xpath('/draggy/module[@name=\'' . $module . '\']/class');

            foreach ($classes as $class) {
                $classAttributes = (array)$class;
                $classAttributes = (array)$classAttributes['@attributes'];

                $this->checkMandatoryAttributes('Class in module ' . $module, $classAttributes, ['name']);

                $className = $classAttributes['name'];

                $this->insideClasses[$module][] = $className;

                $this->checkMandatoryAttributes(
                    'Class ' . $className . ' in module ' . $module,
                    $classAttributes,
                    ['left', 'top']
                );

                $r .= 'var c = new Class(\'' . $classAttributes['name'] . '\',\'' . str_replace(
                    '\\',
                    '\\\\',
                    $module
                ) . '\');' . PHP_EOL;
                $r .= 'c.moveTo(\'' . ( $classAttributes['left'] /*- 1*/ ) . 'px\',\'' . ( $classAttributes['top'] /*- 1*/ ) . 'px\');' . PHP_EOL;

                $r .= $this->getClassLikeProperties($classAttributes, 'c');

                $r .= 'c.setModule(Container.prototype.getContainerByName(\'' . str_replace(
                    '\\',
                    '\\\\',
                    $module
                ) . '\').getId());' . PHP_EOL;
            }
        }

        // Outside classes
        $classes = (array)$this->xml->xpath('/draggy/loose/class');

        foreach ($classes as $class) {
            $classAttributes = (array)$class;
            $classAttributes = $classAttributes['@attributes'];

            $this->checkMandatoryAttributes('Loose class', $classAttributes, ['name']);

            $className = $classAttributes['name'];

            $this->outsideClasses[] = $className;

            $this->checkMandatoryAttributes('Loose class ' . $className, $classAttributes, ['left', 'top']);

            $r .= 'var c = new Class(\'' . $className . '\');' . PHP_EOL;
            $r .= 'c.moveTo(\'' . ( $classAttributes['left'] ) . 'px\',\'' . ( $classAttributes['top'] ) . 'px\');' . PHP_EOL;

            $r .= $this->getClassLikeProperties($classAttributes, 'c');
        }

        return $r;
    }
362820
public function generatePropertyMapClass()
    {
        $classMap = array();

        foreach($this->elementClassFinder as $classFile)
        {
            /** @var \Symfony\Component\Finder\SplFileInfo $classFile */
            $className = str_replace(array('\\', 'src/', '/', '.php'), array('/', '', '\\', ''), $classFile->getRelativePathname());

            if (false !== strpos($className, 'Abstract') || false !== strpos($className, 'Interface'))
                continue;

            $namespacedClassName = $this->elementClassNamespace.$className;
            $reflectionClass = new \ReflectionClass($namespacedClassName);
            $classMap[$namespacedClassName] = $this->createMapEntry($reflectionClass);
        }

        foreach($this->resourceClassFinder as $classFile)
        {
            /** @var \Symfony\Component\Finder\SplFileInfo $classFile */
            $className = str_replace(array('\\', 'src/', '/', '.php'), array('/', '', '\\', ''), $classFile->getRelativePathname());

            if (false !== strpos($className, 'Abstract') || false !== strpos($className, 'Interface'))
                continue;

            $namespacedClassName = $this->resourceClassNamespace.$className;
            $reflectionClass = new \ReflectionClass($namespacedClassName);
            $classMap[$namespacedClassName] = $this->createMapEntry($reflectionClass);
        }

        $outputFile = $this->outputDir.$this->outputClassName.'.php';

        $data = str_replace("\n  ", "\n        ", var_export($classMap, true));
        $now = date('Y-m-d e');
        $outputString = <<<PHP
<?php

/**
 * This class is automatically generated by php-fhir-object-mapper, do not edit!
 *
 * Created: {$now}
 */
class {$this->outputClassName} implements \\ArrayAccess {

    /** @var array */
    private \$_classMap = {$data};

    public function offsetSet(\$offset, \$value) {
        throw new \\BadMethodCallException('You may not add objects to this map post-creation.');
    }

    public function offsetExists(\$offset) {
        return isset(\$this->_classMap[\$offset]);
    }

    public function offsetUnset(\$offset) {
        throw new \\BadMethodCallException('You may not remove objects from this map post-creation.');
    }

    public function offsetGet(\$offset) {
        if (isset(\$this->_classMap[\$offset]))
            return \$this->_classMap[\$offset];

        throw new \OutOfRangeException('No FHIR class named "'.\$offset.'" exists in this map.');
    }
}
PHP;
        return (bool)file_put_contents($outputFile, $outputString);
    }
337288
private function generateClasses()
    {
        foreach($this->ref->getClasses() as $class)
        {
            if($class->isInterface())
            {
                $this->generateInterface($class);
            }
            else if($class->isTrait())
            {
                $this->generateTrait($class);
            }
            else
            {
                $this->generateClass($class);
            }
        }
    }
1364196
def generate_classes(self, items):
        ""
        classes = set()
        for c in items: classes = classes.union(set(c))
        classes = list(classes)
        classes.sort()
        return classes