}
}
- /**
- * Validates specific php requirements.
- *
- * @param array $requirements
- * @return mixed[][]
- */
- public static function validatePHPRequirements(array $requirements)
- {
- $errors = [];
-
- // validate php version
- if (isset($requirements['version'])) {
- $passed = false;
- if (\version_compare(\PHP_VERSION, $requirements['version'], '>=')) {
- $passed = true;
- }
-
- if (!$passed) {
- $errors['version'] = [
- 'required' => $requirements['version'],
- 'installed' => \PHP_VERSION,
- ];
- }
- }
-
- // validate extensions
- if (isset($requirements['extensions'])) {
- foreach ($requirements['extensions'] as $extension) {
- $passed = \extension_loaded($extension) ? true : false;
-
- if (!$passed) {
- $errors['extension'][] = [
- 'extension' => $extension,
- ];
- }
- }
- }
-
- // validate settings
- if (isset($requirements['settings'])) {
- foreach ($requirements['settings'] as $setting => $value) {
- $iniValue = \ini_get($setting);
-
- $passed = self::compareSetting($setting, $value, $iniValue);
- if (!$passed) {
- $errors['setting'][] = [
- 'setting' => $setting,
- 'required' => $value,
- 'installed' => ($iniValue === false) ? '(unknown)' : $iniValue,
- ];
- }
- }
- }
-
- // validate functions
- if (isset($requirements['functions'])) {
- foreach ($requirements['functions'] as $function) {
- $function = \mb_strtolower($function);
-
- $passed = \function_exists($function);
- if (!$passed) {
- $errors['function'][] = [
- 'function' => $function,
- ];
- }
- }
- }
-
- // validate classes
- if (isset($requirements['classes'])) {
- foreach ($requirements['classes'] as $class) {
- $passed = false;
-
- // see: http://de.php.net/manual/en/language.oop5.basic.php
- if (\preg_match('~[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.~', $class)) {
- $globalClass = '\\' . $class;
-
- if (\class_exists($globalClass, false)) {
- $passed = true;
- }
- }
-
- if (!$passed) {
- $errors['class'][] = [
- 'class' => $class,
- ];
- }
- }
- }
-
- return $errors;
- }
-
/**
* Compares settings, converting values into compareable ones.
*