@param string $content
@param string $path
@param string $class

@return Compiler
964670
protected function createCompiler(string $content, string $path, string $class): Compiler
    {
        return new Compiler($this->createParser($content)->parse($path, $class));
    }
1351283
public function dump($input, $path = null)
    {
        $element = $this->compileDocument($input, $path);

        return $element instanceof ElementInterface
            ? $element->dump()
            : var_export($element, true);
    }
529434
protected function _write($path, $content)
    {
        $File = new File($path);
        $File->write($content);
        $File->exists();
    }
887140
protected function putIntoCache($class, $path, XType $type)
    {
        if (!isset($this->pathCache[$class])) {
            $this->pathCache[$class] = [];
        }

        $this->pathCache[$class][$path] = $type;

        return $type;
    }
745326
public function register($class, string $path = '')
    {
        if (empty($class->slug)) {
            return;
        }

        if (!is_multisite() && $class->multisiteOnly) {
            return;
        }

        // Get post type slug
        $postTypeSlug = self::prefixSlug($class->slug);
        self::$classes[$postTypeSlug] = $class;

        // Set labels
        $labels = array(
            'name'               => _x($class->nameSingular, 'post type general name', 'modularity'),
            'singular_name'      => _x($class->nameSingular, 'post type singular name', 'modularity'),
            'menu_name'          => _x($class->namePlural, 'admin menu', 'modularity'),
            'name_admin_bar'     => _x($class->nameSingular, 'add new on admin bar', 'modularity'),
            'add_new'            => _x('Add New', 'add new button', 'modularity'),
            'add_new_item'       => sprintf(__('Add new %s', 'modularity'), $class->nameSingular),
            'new_item'           => sprintf(__('New %s', 'modularity'), $class->nameSingular),
            'edit_item'          => sprintf(__('Edit %s', 'modularity'), $class->nameSingular),
            'view_item'          => sprintf(__('View %s', 'modularity'), $class->nameSingular),
            'all_items'          => sprintf(__('Edit %s', 'modularity'), $class->namePlural),
            'search_items'       => sprintf(__('Search %s', 'modularity'), $class->namePlural),
            'parent_item_colon'  => sprintf(__('Parent %s', 'modularity'), $class->namePlural),
            'not_found'          => sprintf(__('No %s', 'modularity'), $class->namePlural),
            'not_found_in_trash' => sprintf(__('No %s in trash', 'modularity'), $class->namePlural)
        );

        // Set args
        $args = array(
            'labels'               => $labels,
            'description'          => __($class->description, 'modularity'),
            'public'               => false,
            'publicly_queryable'   => false,
            'exclude_from_search'  => false,
            'show_ui'              => true,
            'show_in_nav_menus'    => false,
            'show_in_menu'         => ($this->showInAdminMenu()) ? 'modularity' : false,
            'has_archive'          => false,
            'rewrite'              => false,
            'hierarchical'         => false,
            'menu_position'        => 100,
            'menu_icon'            => $class->icon,
            'supports'             => array_merge($class->supports, array('title', 'revisions', 'author')),
            'capabilities'         => array(
                'edit_post'          => 'edit_module',
                'edit_posts'         => 'edit_modules',
                'edit_others_posts'  => 'edit_other_modules',
                'publish_posts'      => 'publish_modules',
                'read_post'          => 'read_module',
                'read_private_posts' => 'read_private_posts',
                'delete_post'        => 'delete_module'
            ),
            'map_meta_cap'         => true
        );

        //Disable from search search pages (someone did a huge mistake designing this feature)
        if (is_search()) {
            $args['exclude_from_search'] = true;
        }

        // Get menu icon
        if (empty($args['menu_icon']) && $icon = $this->getIcon($path, $class)) {
            $args['menu_icon'] = $icon;
            $args['menu_icon_auto_import'] = true;
        }

        // Register the post type if module is enabled
        if (in_array($postTypeSlug, self::$enabled)) {

            register_post_type($postTypeSlug, $args);
            $this->setupListTableField($postTypeSlug);

            $class->plugin = (array) $class->plugin;

            if (!empty($class->plugin)) {
                // Fallback to enable old modules to register their plugins
                if (!is_array($class->plugin)) {
                    $class->plugin = array($class->plugin);
                }

                // Ability to filter path
                $class->plugin = apply_filters('Modularity/Register/Plugin', $class->plugin, $postTypeSlug);

                // Include
                foreach ($class->plugin as $plugin) {
                    /**
                     * Deprecated
                     * @todo  Remove……
                     */
                    trigger_error('Deprecation message: Modularity module "' . $postTypeSlug . '" is using a deprecated way of including plugins. Use the wp action "Modularity/Plugins" to load plugins instead.', E_USER_WARNING);

                    if (file_exists($plugin)) {
                        require_once $plugin;
                    } elseif (file_exists(MODULARITY_PATH . 'plugins/'. $plugin)) {
                        require_once MODULARITY_PATH . 'plugins/'. $plugin;
                    }
                }
            }
        }

        // Check if module is deprecated
        if ($class->isDeprecated) {
            \Modularity\ModuleManager::$deprecated[] = $postTypeSlug;
        }

        // Add to list of available modules
        \Modularity\ModuleManager::$available[$postTypeSlug] = $args;

        // Store settings of each module in static var
        self::$moduleSettings[$postTypeSlug] = array(
            'moduleSlug'    => $postTypeSlug,
            'slug'          => $class->slug,
            'singular_name' => $class->nameSingular,
            'plural_name'   => $class->namePlural,
            'description'   => $class->description,
            'supports'      => $class->supports,
            'icon'          => $class->icon,
            'plugin'        => $class->plugin,
            'cache_ttl'     => $class->cacheTtl,
            'hide_title'    => $class->hideTitle
        );

        $class->moduleSlug = $postTypeSlug;

        return $postTypeSlug;
    }
1059087
private function createContextFile($path, $content)
    {
        file_put_contents($path, $content);

        if ($this->logger) {
            $this->logger->fileCreated($path, 'place your definitions, transformations and hooks here');
        }
    }
883092
protected function save($content, $path)
    {
        $handler = $this->openFileForWriting($path);

        $this->writeToFile($handler, $content);

        @fclose($handler);
    }
828853
@Override
    public Class<?> compile(String className, String code, ClassLoader classLoader, OutputStream os, long timestamp) {
        Class<?> cls = null;
        try {
            cls = ClassHelper.forName(className, classLoader);
        } catch (ClassNotFoundException e) {
            // ignore this exception
        } catch (LinkageError e) {
            // ignore this exception
        }
        if (cls != null) {
            return cls;
        }

        // to check cache
        byte[] bytes = cached(className, timestamp);
        // if has cached and timestamp is not changed will return a not null byte array
        if (bytes != null) {
            LoadableClassLoader loadableClassLoader = new LoadableClassLoader(classLoader);
            loadableClassLoader.defineNewClass(className, bytes, 0, bytes.length);

            try {
                return loadableClassLoader.loadClass(className);
            } catch (ClassNotFoundException e) {
                // ignore this exception
            }
        }

        cls = compiler.compile(className, code, classLoader, os, timestamp);

        cache(className, compiler.loadBytes(className), timestamp);
        return cls;
    }
1199735
public final <T> T getImplementation(Class<T> type, String... path)
    {
        return getImplementation(getClass().getClassLoader(), type, path);
    }
1343318
public function write( $path, $content )
	{
		try {
			$this->fs->put( $path, $content );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
1185576
protected function filePutClassContent($file, $content, $chmod)
    {
        $from = [
            "/[\n]+(\n +const )/",
            "/}\n([\n]*[ ]*protected)/",
            "/}\n[\n]+}/",
            "/array\([ \n]+\)/",
            "/'SCHEMAS::([^']+)'/"
        ];
        $to = [
            '$1',
            '}$1',
            "}\n}",
            '[]',
            "DB_SCHEMAS['$1']"
        ];
        foreach ($this->getSchemaKeys() as $db => $key) {
            $from[] = '/`' . $db . '`/';
            $to[] = "`' . DB_SCHEMAS['" . $key . "'] . '`";
        }
        $content = preg_replace($from, $to, $content);
        file_put_contents($file, trim($content));
        chmod($file, $chmod);
    }
646237
public function addMap($class, $path = null)
    {
        if (is_array($class)) {
            foreach ($class as $ns => $path) {
                $this->files->addMap($ns, $path);
            }
        } else {
            $this->files->addMap($class, $path);
        }

        return $this;
    }
1320114
protected static function selectClasses(string $path, string $classOrInterface): iterable
    {
        $selectedFiles = [];

        $flags = GlobIterator::SKIP_DOTS | GlobIterator::CURRENT_AS_PATHNAME;
        foreach (new GlobIterator($path, $flags) as $filePath) {
            if (is_file($filePath) === true) {
                $filePath = realpath($filePath);
                try {
                    /** @noinspection PhpIncludeInspection */
                    require_once $filePath;
                } catch (Exception $ex) {
                    // Files might have syntax errors and etc.
                    // For the purposes of this method it doesn't matter so just skip it.
                    continue;
                }
                $selectedFiles[$filePath] = true;
            }
        }

        foreach (get_declared_classes() as $class) {
            // if class actually implements requested one and ...
            if ($class === $classOrInterface || static::classInherits($class, $classOrInterface) === true) {
                // ... it was loaded from a file we've selected then...
                $reflectionClass = new ReflectionClass($class);
                if ($reflectionClass->isInstantiable() === true &&
                    ($classFileName = $reflectionClass->getFileName()) !== false &&
                    array_key_exists($classFileName, $selectedFiles) === true
                ) {
                    // ... that's what we need.
                    yield $class;
                }
            }
        }
    }
1080909
public function storeModel($class, $path = null)
    {
        $result = $this->traitStoreModel($class, $path);

        if ($this->request->is_active == 1) {
            $this->activationComplete();
            return $result;
        }

        $this->activationRemove();
        return $result;
    }
851466
protected function transformXML( $content, $path_to_xsl ) {

		libxml_use_internal_errors( true );
		$content = iconv( 'UTF-8', 'UTF-8//IGNORE', $content );

		$xsl = new \DOMDocument();
		$xsl->load( $path_to_xsl );

		$proc = new \XSLTProcessor();
		$proc->importStyleSheet( $xsl );

		$old_value = libxml_disable_entity_loader( true );
		$xml = new \DOMDocument();
		$xml->loadXML( $content );
		libxml_disable_entity_loader( $old_value );

		$content = $proc->transformToXML( $xml );

		$errors = libxml_get_errors(); // TODO: Handle errors gracefully
		libxml_clear_errors();

		return $content;
	}
1354495
public function compile($path)
	{
		switch (pathinfo($path, PATHINFO_EXTENSION)) {
			case 'less':
				$less = new Less_Parser;
				$content = '/*' . md5(File::get($path)) . "*/\n" . $less->parseFile($path)->getCss();
				
				break;
				
			default:
				$content = File::get($path);
		}
		
		return $content;
	}
311476
public function a_class( $name, $content, $extends = null, $implements = null )
	{
		return $this->add( $this->closure( "class ".$name.
			( $extends ? ' extends '.$extends : '' ).
			( $implements ? ' implements '.$implements : '' ), $content ) );
	}