Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump requirement checker #449

Merged
merged 1 commit into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .requirement-checker/bin/check-requirements.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

require __DIR__ . '/../vendor/autoload.php';
if (\false === \in_array(\PHP_SAPI, array('cli', 'phpdbg', 'embed'), \true)) {
echo \PHP_EOL . 'The application may only be invoked from a command line, got "' . \PHP_SAPI . '"' . \PHP_EOL;
exit(1);
}
if ((\false === isset($_SERVER['BOX_REQUIREMENT_CHECKER']) || \true === (bool) $_SERVER['BOX_REQUIREMENT_CHECKER']) && \false === \HumbugBox380\KevinGH\RequirementChecker\Checker::checkRequirements()) {
if ((\false === isset($_SERVER['BOX_REQUIREMENT_CHECKER']) || \true === (bool) $_SERVER['BOX_REQUIREMENT_CHECKER']) && \false === \HumbugBox383\KevinGH\RequirementChecker\Checker::checkRequirements()) {
exit(1);
}
32 changes: 16 additions & 16 deletions .requirement-checker/src/Checker.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

/**
@symfony
Expand All @@ -12,16 +12,16 @@ public static function checkRequirements()
{
$requirements = self::retrieveRequirements();
$checkPassed = $requirements->evaluateRequirements();
$io = new \HumbugBox380\KevinGH\RequirementChecker\IO();
self::printCheck($checkPassed, new \HumbugBox380\KevinGH\RequirementChecker\Printer($io->getVerbosity(), $io->hasColorSupport()), $requirements);
$io = new \HumbugBox383\KevinGH\RequirementChecker\IO();
self::printCheck($checkPassed, new \HumbugBox383\KevinGH\RequirementChecker\Printer($io->getVerbosity(), $io->hasColorSupport()), $requirements);
return $checkPassed;
}
public static function printCheck($checkPassed, \HumbugBox380\KevinGH\RequirementChecker\Printer $printer, \HumbugBox380\KevinGH\RequirementChecker\RequirementCollection $requirements)
public static function printCheck($checkPassed, \HumbugBox383\KevinGH\RequirementChecker\Printer $printer, \HumbugBox383\KevinGH\RequirementChecker\RequirementCollection $requirements)
{
if (\false === $checkPassed && \HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_VERY_VERBOSE > $printer->getVerbosity()) {
$printer->setVerbosity(\HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_VERY_VERBOSE);
if (\false === $checkPassed && \HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_VERY_VERBOSE > $printer->getVerbosity()) {
$printer->setVerbosity(\HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_VERY_VERBOSE);
}
$verbosity = \HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_VERY_VERBOSE;
$verbosity = \HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_VERY_VERBOSE;
$iniPath = $requirements->getPhpIniPath();
$printer->title('Box Requirements Checker', $verbosity);
$printer->printv('> Using PHP ', $verbosity);
Expand All @@ -42,24 +42,24 @@ public static function printCheck($checkPassed, \HumbugBox380\KevinGH\Requiremen
$errorMessages = array();
foreach ($requirements->getRequirements() as $requirement) {
if ($errorMessage = $printer->getRequirementErrorMessage($requirement)) {
if (\HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG === $printer->getVerbosity()) {
$printer->printvln('✘ ' . $requirement->getTestMessage(), \HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG, 'red');
$printer->printv(' ', \HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG);
if (\HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG === $printer->getVerbosity()) {
$printer->printvln('✘ ' . $requirement->getTestMessage(), \HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG, 'red');
$printer->printv(' ', \HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG);
$errorMessages[] = $errorMessage;
} else {
$printer->printv('E', $verbosity, 'red');
$errorMessages[] = $errorMessage;
}
continue;
}
if (\HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG === $printer->getVerbosity()) {
$printer->printvln('✔ ' . $requirement->getHelpText(), \HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG, 'green');
$printer->printv(' ', \HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG);
if (\HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG === $printer->getVerbosity()) {
$printer->printvln('✔ ' . $requirement->getHelpText(), \HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG, 'green');
$printer->printv(' ', \HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG);
} else {
$printer->printv('.', $verbosity, 'green');
}
}
if (\HumbugBox380\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG !== $printer->getVerbosity() && \count($requirements) > 0) {
if (\HumbugBox383\KevinGH\RequirementChecker\IO::VERBOSITY_DEBUG !== $printer->getVerbosity() && \count($requirements) > 0) {
$printer->printvln('', $verbosity);
}
if ($requirements->evaluateRequirements()) {
Expand All @@ -79,9 +79,9 @@ private static function retrieveRequirements()
self::$requirementsConfig = __DIR__ . '/../.requirements.php';
}
$config = (require self::$requirementsConfig);
$requirements = new \HumbugBox380\KevinGH\RequirementChecker\RequirementCollection();
$requirements = new \HumbugBox383\KevinGH\RequirementChecker\RequirementCollection();
foreach ($config as $constraint) {
$requirements->addRequirement('php' === $constraint['type'] ? new \HumbugBox380\KevinGH\RequirementChecker\IsPhpVersionFulfilled($constraint['condition']) : new \HumbugBox380\KevinGH\RequirementChecker\IsExtensionFulfilled($constraint['condition']), $constraint['message'], $constraint['helpMessage']);
$requirements->addRequirement('php' === $constraint['type'] ? new \HumbugBox383\KevinGH\RequirementChecker\IsPhpVersionFulfilled($constraint['condition']) : new \HumbugBox383\KevinGH\RequirementChecker\IsExtensionFulfilled($constraint['condition']), $constraint['message'], $constraint['helpMessage']);
}
return $requirements;
}
Expand Down
2 changes: 1 addition & 1 deletion .requirement-checker/src/IO.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

final class IO
{
Expand Down
4 changes: 2 additions & 2 deletions .requirement-checker/src/IsExtensionFulfilled.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

final class IsExtensionFulfilled implements \HumbugBox380\KevinGH\RequirementChecker\IsFulfilled
final class IsExtensionFulfilled implements \HumbugBox383\KevinGH\RequirementChecker\IsFulfilled
{
private $requiredExtension;
public function __construct($requiredExtension)
Expand Down
2 changes: 1 addition & 1 deletion .requirement-checker/src/IsFulfilled.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

interface IsFulfilled
{
Expand Down
8 changes: 4 additions & 4 deletions .requirement-checker/src/IsPhpVersionFulfilled.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

use HumbugBox380\Composer\Semver\Semver;
final class IsPhpVersionFulfilled implements \HumbugBox380\KevinGH\RequirementChecker\IsFulfilled
use HumbugBox383\Composer\Semver\Semver;
final class IsPhpVersionFulfilled implements \HumbugBox383\KevinGH\RequirementChecker\IsFulfilled
{
private $requiredPhpVersion;
public function __construct($requiredPhpVersion)
Expand All @@ -12,6 +12,6 @@ public function __construct($requiredPhpVersion)
}
public function __invoke()
{
return \HumbugBox380\Composer\Semver\Semver::satisfies(\sprintf('%d.%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, \PHP_RELEASE_VERSION), $this->requiredPhpVersion);
return \HumbugBox383\Composer\Semver\Semver::satisfies(\sprintf('%d.%d.%d', \PHP_MAJOR_VERSION, \PHP_MINOR_VERSION, \PHP_RELEASE_VERSION), $this->requiredPhpVersion);
}
}
6 changes: 3 additions & 3 deletions .requirement-checker/src/Printer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

final class Printer
{
Expand All @@ -11,7 +11,7 @@ final class Printer
public function __construct($verbosity, $supportColors, $width = null)
{
if (null === $width) {
$terminal = new \HumbugBox380\KevinGH\RequirementChecker\Terminal();
$terminal = new \HumbugBox383\KevinGH\RequirementChecker\Terminal();
$width = \min($terminal->getWidth(), 80);
}
$this->verbosity = $verbosity;
Expand All @@ -36,7 +36,7 @@ public function title($title, $verbosity, $style = null)
$this->printvln(\str_repeat('=', \min(\strlen($title), $this->width)), $verbosity, $style);
$this->printvln('', $verbosity, $style);
}
public function getRequirementErrorMessage(\HumbugBox380\KevinGH\RequirementChecker\Requirement $requirement)
public function getRequirementErrorMessage(\HumbugBox383\KevinGH\RequirementChecker\Requirement $requirement)
{
if ($requirement->isFulfilled()) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion .requirement-checker/src/Requirement.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

/**
@symfony
Expand Down
8 changes: 4 additions & 4 deletions .requirement-checker/src/RequirementCollection.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

use ArrayIterator;
use Countable;
Expand All @@ -20,13 +20,13 @@ public function count()
{
return \count($this->requirements);
}
public function add(\HumbugBox380\KevinGH\RequirementChecker\Requirement $requirement)
public function add(\HumbugBox383\KevinGH\RequirementChecker\Requirement $requirement)
{
$this->requirements[] = $requirement;
}
public function addRequirement($checkIsFulfilled, $testMessage, $helpText)
{
$this->add(new \HumbugBox380\KevinGH\RequirementChecker\Requirement($checkIsFulfilled, $testMessage, $helpText));
$this->add(new \HumbugBox383\KevinGH\RequirementChecker\Requirement($checkIsFulfilled, $testMessage, $helpText));
}
public function getRequirements()
{
Expand All @@ -38,7 +38,7 @@ public function getPhpIniPath()
}
public function evaluateRequirements()
{
return \array_reduce($this->requirements, function ($checkPassed, \HumbugBox380\KevinGH\RequirementChecker\Requirement $requirement) {
return \array_reduce($this->requirements, function ($checkPassed, \HumbugBox383\KevinGH\RequirementChecker\Requirement $requirement) {
return $checkPassed && $requirement->isFulfilled();
}, \true);
}
Expand Down
25 changes: 23 additions & 2 deletions .requirement-checker/src/Terminal.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace HumbugBox380\KevinGH\RequirementChecker;
namespace HumbugBox383\KevinGH\RequirementChecker;

/**
@symfony
Expand All @@ -9,6 +9,7 @@ class Terminal
{
private static $width;
private static $height;
private static $stty;
public function getWidth()
{
$width = \getenv('COLUMNS');
Expand All @@ -31,17 +32,37 @@ public function getHeight()
}
return self::$height ?: 50;
}
public static function hasSttyAvailable()
{
if (null !== self::$stty) {
return self::$stty;
}
\exec('stty 2>&1', $output, $exitcode);
return self::$stty = 0 === $exitcode;
}
private static function initDimensions()
{
if ('\\' === \DIRECTORY_SEPARATOR) {
if (\preg_match('/^(\\d+)x(\\d+)(?: \\((\\d+)x(\\d+)\\))?$/', \trim(\getenv('ANSICON')), $matches)) {
self::$width = (int) $matches[1];
self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
} elseif (!self::hasVt100Support() && self::hasSttyAvailable()) {
self::initDimensionsUsingStty();
} elseif (null !== ($dimensions = self::getConsoleMode())) {
self::$width = (int) $dimensions[0];
self::$height = (int) $dimensions[1];
}
} elseif ($sttyString = self::getSttyColumns()) {
} else {
self::initDimensionsUsingStty();
}
}
private static function hasVt100Support()
{
return \function_exists('sapi_windows_vt100_support') && \sapi_windows_vt100_support(\fopen('php://stdout', 'wb'));
}
private static function initDimensionsUsingStty()
{
if ($sttyString = self::getSttyColumns()) {
if (\preg_match('/rows.(\\d+);.columns.(\\d+);/i', $sttyString, $matches)) {
self::$width = (int) $matches[2];
self::$height = (int) $matches[1];
Expand Down
2 changes: 1 addition & 1 deletion .requirement-checker/vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit0d96cc2add98eaac9c2cac2d900e67fe::getLoader();
return ComposerAutoloaderInit4dcc0e1d4584ae7b8040cfa1b3dfe9e3::getLoader();
34 changes: 17 additions & 17 deletions .requirement-checker/vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
$baseDir = dirname($vendorDir);

return array(
'HumbugBox380\\Composer\\Semver\\Comparator' => $vendorDir . '/composer/semver/src/Comparator.php',
'HumbugBox380\\Composer\\Semver\\Constraint\\AbstractConstraint' => $vendorDir . '/composer/semver/src/Constraint/AbstractConstraint.php',
'HumbugBox380\\Composer\\Semver\\Constraint\\Constraint' => $vendorDir . '/composer/semver/src/Constraint/Constraint.php',
'HumbugBox380\\Composer\\Semver\\Constraint\\ConstraintInterface' => $vendorDir . '/composer/semver/src/Constraint/ConstraintInterface.php',
'HumbugBox380\\Composer\\Semver\\Constraint\\EmptyConstraint' => $vendorDir . '/composer/semver/src/Constraint/EmptyConstraint.php',
'HumbugBox380\\Composer\\Semver\\Constraint\\MultiConstraint' => $vendorDir . '/composer/semver/src/Constraint/MultiConstraint.php',
'HumbugBox380\\Composer\\Semver\\Semver' => $vendorDir . '/composer/semver/src/Semver.php',
'HumbugBox380\\Composer\\Semver\\VersionParser' => $vendorDir . '/composer/semver/src/VersionParser.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\Checker' => $baseDir . '/src/Checker.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\IO' => $baseDir . '/src/IO.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\IsExtensionFulfilled' => $baseDir . '/src/IsExtensionFulfilled.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\IsFulfilled' => $baseDir . '/src/IsFulfilled.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\IsPhpVersionFulfilled' => $baseDir . '/src/IsPhpVersionFulfilled.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\Printer' => $baseDir . '/src/Printer.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\Requirement' => $baseDir . '/src/Requirement.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\RequirementCollection' => $baseDir . '/src/RequirementCollection.php',
'HumbugBox380\\KevinGH\\RequirementChecker\\Terminal' => $baseDir . '/src/Terminal.php',
'HumbugBox383\\Composer\\Semver\\Comparator' => $vendorDir . '/composer/semver/src/Comparator.php',
'HumbugBox383\\Composer\\Semver\\Constraint\\AbstractConstraint' => $vendorDir . '/composer/semver/src/Constraint/AbstractConstraint.php',
'HumbugBox383\\Composer\\Semver\\Constraint\\Constraint' => $vendorDir . '/composer/semver/src/Constraint/Constraint.php',
'HumbugBox383\\Composer\\Semver\\Constraint\\ConstraintInterface' => $vendorDir . '/composer/semver/src/Constraint/ConstraintInterface.php',
'HumbugBox383\\Composer\\Semver\\Constraint\\EmptyConstraint' => $vendorDir . '/composer/semver/src/Constraint/EmptyConstraint.php',
'HumbugBox383\\Composer\\Semver\\Constraint\\MultiConstraint' => $vendorDir . '/composer/semver/src/Constraint/MultiConstraint.php',
'HumbugBox383\\Composer\\Semver\\Semver' => $vendorDir . '/composer/semver/src/Semver.php',
'HumbugBox383\\Composer\\Semver\\VersionParser' => $vendorDir . '/composer/semver/src/VersionParser.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\Checker' => $baseDir . '/src/Checker.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\IO' => $baseDir . '/src/IO.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\IsExtensionFulfilled' => $baseDir . '/src/IsExtensionFulfilled.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\IsFulfilled' => $baseDir . '/src/IsFulfilled.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\IsPhpVersionFulfilled' => $baseDir . '/src/IsPhpVersionFulfilled.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\Printer' => $baseDir . '/src/Printer.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\Requirement' => $baseDir . '/src/Requirement.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\RequirementCollection' => $baseDir . '/src/RequirementCollection.php',
'HumbugBox383\\KevinGH\\RequirementChecker\\Terminal' => $baseDir . '/src/Terminal.php',
);
4 changes: 2 additions & 2 deletions .requirement-checker/vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
$baseDir = dirname($vendorDir);

return array(
'HumbugBox380\\KevinGH\\RequirementChecker\\' => array($baseDir . '/src'),
'HumbugBox380\\Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
'HumbugBox383\\KevinGH\\RequirementChecker\\' => array($baseDir . '/src'),
'HumbugBox383\\Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
);
8 changes: 4 additions & 4 deletions .requirement-checker/vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit0d96cc2add98eaac9c2cac2d900e67fe
class ComposerAutoloaderInit4dcc0e1d4584ae7b8040cfa1b3dfe9e3
{
private static $loader;

Expand All @@ -19,15 +19,15 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit0d96cc2add98eaac9c2cac2d900e67fe', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit4dcc0e1d4584ae7b8040cfa1b3dfe9e3', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit0d96cc2add98eaac9c2cac2d900e67fe', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit4dcc0e1d4584ae7b8040cfa1b3dfe9e3', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInit0d96cc2add98eaac9c2cac2d900e67fe::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit4dcc0e1d4584ae7b8040cfa1b3dfe9e3::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
Expand Down
Loading