Run validation checks for a given module

@param string $module Module name
@return mixed[] Array with errors and warnings
358600
protected function runModuleChecks(string $module) : array
    {
        $result = [
            'errors' => [],
            'warnings' => [],
        ];

        if (!in_array($module, $this->modules)) {
            $result['errors'][] = "$module is not a known module";

            return $result;
        }

        $checks = Check::getList($module);

        if (empty($checks)) {
            $result['warnings'][] = "No checks configured for module [$module]";

            return $result;
        }

        foreach ($checks as $check => $options) {
            $this->out(" - Running $check ... ", 0);

            try {
                $check = Check::getInstance((string)$check);
                $checkResult = $check->run($module, $options);
            } catch (InvalidArgumentException $e) {
                $result['errors'][] = $e->getMessage();
                $this->printCheckStatus(1);
                continue;
            }

            $result['errors'] = array_merge($result['errors'], $check->getErrors());
            $result['warnings'] = array_merge($result['warnings'], $check->getWarnings());

            $this->printCheckStatus($checkResult);
        }

        return $result;
    }
715243
protected function validateModules(array $modules) : int
    {
        $result = 0;

        foreach ($modules as $module) {
            $this->info("Checking module $module", 2);

            $moduleResult = $this->runModuleChecks($module);

            $result += count($moduleResult['errors']);
            if (!$this->skipWarnings) {
                $this->printMessages('warn', $moduleResult['warnings']);
            }

            $this->printMessages('err', $moduleResult['errors']);
            $this->hr();
        }

        return $result;
    }
912058
public function checkPhpVersion(array $module)
    {
        if (!empty($module['php'])) {

            $components = $this->getVersionComponents($module['php']);

            if (empty($components)) {
                throw new UnexpectedValueException($this->translation->text('Failed to read PHP version'));
            }

            list($operator, $number) = $components;

            if (!version_compare(PHP_VERSION, $number, $operator)) {
                $error = $this->translation->text('Requires incompatible version of @name', array('@name' => 'PHP'));
                throw new UnexpectedValueException($error);
            }
        }

        return true;
    }
1216689
public static function validateSchema(\DOMDocument $dom): array
    {
        $xliffVersion = static::getVersionNumber($dom);
        $internalErrors = libxml_use_internal_errors(true);
        $disableEntities = libxml_disable_entity_loader(false);

        $isValid = @$dom->schemaValidateSource(self::getSchema($xliffVersion));
        if (!$isValid) {
            libxml_disable_entity_loader($disableEntities);

            return self::getXmlErrors($internalErrors);
        }

        libxml_disable_entity_loader($disableEntities);

        $dom->normalizeDocument();

        libxml_clear_errors();
        libxml_use_internal_errors($internalErrors);

        return [];
    }
615306
public function parseModules($modules, $moduleType)
    {
        // distinguish between 'modules' command-line argument
        // which has module data in colon-separated format
        // and properly-formatted 'modules' array
        // generated through previous methods
        if (is_array($modules)) {
            if (isset($modules[0]['module_name'])) {
                return $modules;
            }
        }

        $newModules = array();

        foreach ($modules as $module) {
            $data = explode(':', $module);

            if (count($newModules) == 0) {
                $moduleName = Validators::validateModuleName($data[0], false);
                $moduleNameSuffix = Validators::validateModuleNameSuffix($data[1], false);
            } else {
                $moduleName = $newModules[0]['module_name'];
                $moduleNameSuffix = Validators::validateModuleNameSuffix($data[1], $newModules, true, false);
            }
            $moduleNameUnderscore = strtolower(str_replace(' ', '_', $moduleName));
            $moduleNameHyphen = strtolower(str_replace(' ', '-', $moduleName));
            $moduleNameSuffixUnderscore = strtolower(str_replace(' ', '_', $moduleNameSuffix));
            $moduleNameSuffixHyphen = strtolower(str_replace(' ', '-', $moduleNameSuffix));
            $moduleDisplayName = Validators::validateDisplayName($data[2], false);
            $moduleDescription = Validators::validateDescription($data[3], false);
            $derivedClassName = implode('', array_map('ucwords', explode('-', $moduleNameHyphen . '-' . $moduleNameSuffix)));
            if ($moduleType == 'operation') {
                $operationOwnsLocation = Validators::validateOperationOwnsLocation($data[4], false);
                $metricsForOperation = Validators::validateMetricsForOperation($data[5], false);
            }
            if ($moduleType == 'activity') {
                $channelsForActivity = Validators::validateChannelsForActivity($data[4], false);
                $hooksForActivity = Validators::validateHooksForActivity($data[5], false);
            }

            $newModules[] = array(
                'module_name'                   => $moduleName,
                'module_name_underscore'        => $moduleNameUnderscore,
                'module_name_hyphen'            => $moduleNameHyphen,
                'module_name_suffix'            => $moduleNameSuffix,
                'module_name_suffix_underscore' => $moduleNameSuffixUnderscore,
                'module_name_suffix_hyphen'     => $moduleNameSuffixHyphen,
                'module_display_name'           => $moduleDisplayName,
                'module_description'            => $moduleDescription,
                'operation_owns_location'       => !empty($operationOwnsLocation) ? $operationOwnsLocation : null,
                'channels_for_activity'         => !empty($channelsForActivity) ? explode(',', $channelsForActivity) : null,
                'hooks_for_activity'            => !empty($hooksForActivity) ? explode(',', $hooksForActivity) : null,
                'metrics_for_operation'         => !empty($metricsForOperation) ? explode(',', $metricsForOperation) : null,
                'class_name'                    => $derivedClassName
            );
        }
        return $newModules;
    }
540344
public function getInstance($module)
    {
        if ( ! $this->isLoaded($module))
        {
            $this->load($module);
        }

        return $this->instances[$module];
    }
504991
public function validateModule($module) {
        $missing_modules = $this->validator->getMissingModules([$module]);
        if ($missing_modules) {
            throw new \Exception(
                sprintf(
                    $this->trans(
                        'commands.module.download.messages.no-releases'
                    ),
                    $module
                )
            );
        }
        return $module;
    }
517157
public function checkDependenciesExtensions(array $module)
    {
        if (!empty($module['extensions'])) {

            $missing = array();

            foreach ($module['extensions'] as $extension) {
                if (!extension_loaded($extension)) {
                    $missing[] = $extension;
                }
            }

            if (!empty($missing)) {
                $error = $this->translation->text("Missing PHP extensions: @list", array('@list' => implode(',', $missing)));
                throw new UnexpectedValueException($error);
            }
        }

        return true;
    }
749176
protected function showModules(Collection $modules)
    {
        $table = [];
        $i     = 0;

        /** @var BaseModuleServiceProvider $module */
        foreach ($modules as $module) {
            $i++;

            $table[] = [
                'no'        => sprintf('%d.', $i),
                'name'      => $module->getManifest()->getName(),
                'kind'      => $module->getKind()->label(),
                'version'   => $module->getManifest()->getVersion(),
                'id'        => $module->getId(),
                'namespace' => $module->getNamespaceRoot()
            ];
        }

        $this->table($this->headers, $table);
    }
852676
protected function getModuleCommands($module)
    {
        $prefix = $module instanceof Application ? '' : $module->getUniqueId() . '/';

        $commands = [];
        foreach (array_keys($module->controllerMap) as $id) {
            $commands[] = $prefix . $id;
        }

        foreach ($module->getModules() as $id => $child) {
            if (($child = $module->getModule($id)) === null) {
                continue;
            }
            foreach ($this->getModuleCommands($child) as $command) {
                $commands[] = $command;
            }
        }

        $controllerPath = $module->getControllerPath();
        if (is_dir($controllerPath)) {
            $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($controllerPath, \RecursiveDirectoryIterator::KEY_AS_PATHNAME));
            $iterator = new \RegexIterator($iterator, '/.*Controller\.php$/', \RecursiveRegexIterator::GET_MATCH);
            foreach ($iterator as $matches) {
                $file = $matches[0];
                $relativePath = str_replace($controllerPath, '', $file);
                $class = strtr($relativePath, [
                    '/' => '\\',
                    '.php' => '',
                ]);
                $controllerClass = $module->controllerNamespace . $class;
                if ($this->validateControllerClass($controllerClass)) {
                    $dir = ltrim(pathinfo($relativePath, PATHINFO_DIRNAME), '\\/');

                    $command = InflectorHelper::camel2id(substr(basename($file), 0, -14), '-', true);
                    if (!empty($dir)) {
                        $command = $dir . '/' . $command;
                    }
                    $commands[] = $prefix . $command;
                }
            }
        }

        return $commands;
    }
249972
public static function getPosts($module)
    {
        $fields = json_decode(json_encode(get_fields($module->ID)));
        if ($fields->posts_data_source == 'input') {
            return self::getManualInputPosts($fields->data);
        }

        return get_posts(self::getPostArgs($module->ID));
    }
994162
public function checkModuleExtensionsForIncorrectNamespaceClasses(\OxidEsales\Eshop\Core\Module\Module $module)
    {
        $incorrect = $this->getIncorrectExtensions($module);
        if (!empty($incorrect)) {
            $message = $this->prepareMessage('MODULE_METADATA_PROBLEMATIC_DATA_IN_EXTEND', $incorrect);
            throw new \OxidEsales\Eshop\Core\Exception\ModuleValidationException($message);
        }
    }
634856
protected function loadMigrationFiles($module)
    {
        $path = $this->laravel['modules']->getModulePath($module) . $this->getMigrationGeneratorPath();

        $files = $this->laravel['files']->glob($path . '/*_*.php');

        foreach ($files as $file) {
            $this->laravel['files']->requireOnce($file);
        }
    }
21363
def _validate(self):
        

        v_mod = utils.import_string('.'.join([
            'pyswagger',
            'scanner',
            'v' + self.version.replace('.', '_'),
            'validate'
        ]))

        if not v_mod:
            # there is no validation module
            # for this version of spec
            return []

        s = Scanner(self)
        v = v_mod.Validate()

        s.scan(route=[v], root=self.__raw)
        return v.errs
406128
public static function isValidList(string $list, string $module = '') : bool
    {
        if (strpos($list, '.') !== false) {
            list($module, $list) = explode('.', $list, 2);
        }

        $listItems = null;
        try {
            $mc = new ModuleConfig(ConfigType::LISTS(), $module, $list, ['cacheSkip' => true]);
            $config = $mc->parse();
            $listItems = property_exists($config, 'items') ? $config->items : null;
        } catch (InvalidArgumentException $e) {
            return false;
        }

        if (null === $listItems) {
            return false;
        }

        return true;
    }
1355852
public function update($module)
    {
        $module = $this->module->findOrFail($module);

        $packages = $module->get('require', []);

        chdir(base_path());

        foreach ($packages as $name => $version) {
            $package = "\"{$name}:{$version}\"";

            $this->run("composer require {$package}");
        }
    }
141679
public function getAppRoutes(string $module = null): array
    {
        if ($module === null) {
            $module = Yii::$app;
        } else {
            $module = Yii::$app->getModule($module);
        }

        $key = [__METHOD__, $module->getUniqueId()];
        $result = (($this->cache !== null) ? $this->cache->get($key) : false);

        if ($result === false) {
            $result = [];
            $this->getRouteRecursive($module, $result);
            if ($this->cache !== null) {
                $this->cache->set($key, $result, $this->cacheDuration, new TagDependency([
                    'tags' => self::CACHE_TAG,
                ]));
            }
        }

        return $result;
    }