Skip to content

Commit

Permalink
Merge pull request #9 from biurad/analysis-qoVl2K
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI

[ci skip] [skip ci]
  • Loading branch information
cyclonecopp authored Jun 22, 2019
2 parents 6254b2b + 308d4b5 commit e1ec899
Show file tree
Hide file tree
Showing 20 changed files with 243 additions and 215 deletions.
40 changes: 23 additions & 17 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
<?php
/**
* This class is used for autocomplete.
* Class _AUTOLOAD_
* Class _AUTOLOAD_.
*
* @noautoload it avoids to index this class
* @generated by AutoLoadOne 1.11 generated 2019/06/11 08:35:03
*
* @copyright Copyright Jorge Castro C - MIT License. https://github.com/EFTEC/AutoLoadOne
* @author Divine Niiquaye <hello@biuhub.net>
*/
const s5cff67b7d578d__debug = true;

/* @var string[] Where $_arrautoloadCustom['namespace\Class']='folder\file.php' */
const s5cff67b7d578d__arrautoloadCustom = [

];

/* @var string[] Where $_arrautoload['namespace']='folder' */
const s5cff67b7d578d__arrautoload = [
'BiuradPHP\Toolbox\ConsoleLite' => '/src',
'BiuradPHP\Toolbox\ConsoleLite\Commands' => '/src/Commands',
'BiuradPHP\Toolbox\ConsoleLite\Compile' => '/src/Compile',
'BiuradPHP\Toolbox\ConsoleLite\Concerns' => '/src/Concerns',
'BiuradPHP\Toolbox\ConsoleLite\Exceptions' => '/src/Exceptions',
'BiuradPHP\Toolbox\ConsoleLite\Interfaces' => '/src/Interfaces',
'BiuradPHP\Toolbox\ConsoleLite\Stuble' => '/src/Stuble',
'BiuradPHP\Toolbox\FilePHP' => 'C:/wamp64/www/biurad-development/Vendor/filephp/src'
'BiuradPHP\Toolbox\ConsoleLite' => '/src',
'BiuradPHP\Toolbox\ConsoleLite\Commands' => '/src/Commands',
'BiuradPHP\Toolbox\ConsoleLite\Compile' => '/src/Compile',
'BiuradPHP\Toolbox\ConsoleLite\Concerns' => '/src/Concerns',
'BiuradPHP\Toolbox\ConsoleLite\Exceptions' => '/src/Exceptions',
'BiuradPHP\Toolbox\ConsoleLite\Interfaces' => '/src/Interfaces',
'BiuradPHP\Toolbox\ConsoleLite\Stuble' => '/src/Stuble',
'BiuradPHP\Toolbox\FilePHP' => 'C:/wamp64/www/biurad-development/Vendor/filephp/src',
];

/* @var boolean[] Where $_arrautoload['namespace' or 'namespace\Class']=true if it's absolute (it uses the full path) */
const s5cff67b7d578d__arrautoloadAbsolute = [
'BiuradPHP\Toolbox\FilePHP' => true
'BiuradPHP\Toolbox\FilePHP' => true,
];

/**
* @param $class_name
*
* @throws Exception
*/
function s5cff67b7d578d__auto($class_name)
Expand All @@ -44,19 +47,23 @@ function s5cff67b7d578d__auto($class_name)
// special cases
if (isset(s5cff67b7d578d__arrautoloadCustom[$class_name])) {
s5cff67b7d578d__loadIfExists(s5cff67b7d578d__arrautoloadCustom[$class_name], $class_name);

return;
}
// normal (folder) cases
if (isset(s5cff67b7d578d__arrautoload[$ns])) {
s5cff67b7d578d__loadIfExists(s5cff67b7d578d__arrautoload[$ns] . '/' . $cls . '.php', $ns);
s5cff67b7d578d__loadIfExists(s5cff67b7d578d__arrautoload[$ns].'/'.$cls.'.php', $ns);

return;
}
}

/**
* We load the file.
*
* @param string $filename
* @param string $key key of the class it could be the full class name or only the namespace
* @param string $key key of the class it could be the full class name or only the namespace
*
* @throws Exception
*/
function s5cff67b7d578d__loadIfExists($filename, $key)
Expand All @@ -68,13 +75,13 @@ function s5cff67b7d578d__loadIfExists($filename, $key)
chdir(__DIR__);
}
} else {
$fullFile = __DIR__ . "/" . $filename; // its relative to this path
$fullFile = __DIR__.'/'.$filename; // its relative to this path
}
if ((@include $fullFile) === false) {
if (s5cff67b7d578d__debug) {
throw new Exception("AutoLoadOne Error: Loading file [" . __DIR__ . "/" . $filename . "] for class [" . basename($filename) . "]");
throw new Exception('AutoLoadOne Error: Loading file ['.__DIR__.'/'.$filename.'] for class ['.basename($filename).']');
} else {
throw new Exception("AutoLoadOne Error: No file found.");
throw new Exception('AutoLoadOne Error: No file found.');
}
} else {
if (isset($oldDir)) {
Expand All @@ -88,4 +95,3 @@ function s5cff67b7d578d__loadIfExists($filename, $key)
});
// autorun
@include __DIR__.'/vendor/autoload.php';

8 changes: 4 additions & 4 deletions docs/tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

namespace BiuradPHP\Toolbox\ConsoleLiteTest;

use PHPUnit\Framework\TestCase;
use BiuradPHP\Toolbox\ConsoleLite\Application;
use BiuradPHP\Toolbox\ConsoleLiteTest\fixtures\FooCommand;
use PHPUnit\Framework\TestCase;

class ApplicationTest extends TestCase
{
Expand All @@ -39,7 +39,7 @@ public function testSetGetVersion()
public function testRegister()
{
$application = new Application();
$application->register(new FooCommand);
$application->register(new FooCommand());
$command = $application->hasCommand('foo:bar1') ? 'foo:bar1' : null;

$this->assertEquals('foo:bar1', $command, '->register() registers a new command');
Expand Down Expand Up @@ -76,9 +76,9 @@ public function testSetIsDecorated()

public function testDisableDecorated()
{
$output = new Application();
$output = new Application();
$output->getColors()->disable();

$this->assertFalse($output->getColors()->isEnabled(), 'disableDecorated() sets the un-decorated flag --no-ansi');
}
}
}
5 changes: 2 additions & 3 deletions docs/tests/TerminalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

namespace BiuradPHP\Toolbox\ConsoleLiteTest;

use PHPUnit\Framework\TestCase;
use BiuradPHP\Toolbox\ConsoleLite\Terminal;

use PHPUnit\Framework\TestCase;

class TerminalTest extends TestCase
{
Expand Down Expand Up @@ -64,7 +63,7 @@ public function testZeroValues()
public function testCliteLoad()
{
$terminal = new Terminal();
$file = __DIR__. '/fixtures/clite.json';
$file = __DIR__.'/fixtures/clite.json';

$expected = $terminal->loadFile($file);
$actual = $terminal->decodeFile($file);
Expand Down
2 changes: 1 addition & 1 deletion docs/tests/fixtures/FooCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public function handle()
{
//code...
}
}
}
42 changes: 21 additions & 21 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

namespace BiuradPHP\Toolbox\ConsoleLite;

use InvalidArgumentException;
use BiuradPHP\Toolbox\ConsoleLite\Commands\CommandAbout;
use BiuradPHP\Toolbox\ConsoleLite\Commands\CommandList;
use BiuradPHP\Toolbox\ConsoleLite\Commands\CommandPhar;
use BiuradPHP\Toolbox\ConsoleLite\Commands\CommandStub;
use BiuradPHP\Toolbox\ConsoleLite\Concerns\Highlighter;
use BiuradPHP\Toolbox\ConsoleLite\Commands\CommandAbout;
use BiuradPHP\Toolbox\ConsoleLite\Exceptions\ExpectedException;
use BiuradPHP\Toolbox\ConsoleLite\Exceptions\DeprecatedException;
use BiuradPHP\Toolbox\ConsoleLite\Exceptions\ConsoleLiteException;
use BiuradPHP\Toolbox\ConsoleLite\Exceptions\DeprecatedException;
use BiuradPHP\Toolbox\ConsoleLite\Exceptions\ExpectedException;
use InvalidArgumentException;

/**
* ConsoleLite Application.
Expand Down Expand Up @@ -213,10 +213,10 @@ public function register(Command $command)
$command->defineApp($this);

$this->commands[$commandName] = [
'handler' => [$command, 'handle'],
'handler' => [$command, 'handle'],
'description' => $command->getDescription(),
'args' => $args,
'options' => $options,
'args' => $args,
'options' => $options,
];
} catch (ExpectedException $e) {
$class = get_class($command);
Expand All @@ -237,10 +237,10 @@ public function command($signature, $description, \Closure $handler)
list($commandName, $args, $options) = $this->_parseCommand($signature);

$this->commands[$commandName] = [
'handler' => $handler,
'handler' => $handler,
'description' => $description,
'args' => $args,
'options' => $options,
'args' => $args,
'options' => $options,
];
}

Expand All @@ -259,9 +259,9 @@ public function getRegisteredCommands()
*
* @param string $name The command name or alias
*
* @return Command A Command object
*
* @throws ExpectedException When given command name does not exist
*
* @return Command A Command object
*/
public function getCommand($name)
{
Expand Down Expand Up @@ -425,9 +425,9 @@ public function getArguments()
*
* @param string|int $name The Argument name or position
*
* @return mixed
*
* @throws InvalidArgumentException When argument given doesn't exist
*
* @return mixed
*/
public function getArgument($name)
{
Expand Down Expand Up @@ -752,7 +752,7 @@ public function writeDebug(string $message, bool $line = true)
public function newLine(int $num = 1, $line = false, $format = '+')
{
// Do it once or more, write with empty string gives us a new line
for ($i = 0; $i < $num; ++$i) {
for ($i = 0; $i < $num; $i++) {
if (false === $line) {
$this->write(PHP_EOL, null);
} else {
Expand Down Expand Up @@ -917,7 +917,7 @@ public function wait(int $seconds = 0, bool $countdown = false)
//$this->write($time.'...');
$this->showProgress($time);
sleep(1);
--$time;
$time--;
}
$this->newLine();
} else {
Expand Down Expand Up @@ -1006,7 +1006,7 @@ public function showSpinner(string $msg = '', $ended = false)
$lastTime = $now;
// echo $chars[$counter];
$this->getSilencer()->call('printf', $tpl, $chars[$counter].$msg);
++$counter;
$counter++;

if ($counter > \strlen($chars) - 1) {
$counter = 0;
Expand Down Expand Up @@ -1043,9 +1043,9 @@ protected function _parseCommand($command)
}

$args[$argName] = [
'is_array' => !empty($matchArgs['arr'][$i]),
'is_array' => !empty($matchArgs['arr'][$i]),
'is_optional' => !empty($matchArgs['optional'][$i]) || !empty($default),
'default' => $default ?: null,
'default' => $default ?: null,
'description' => $description,
];
}
Expand All @@ -1062,9 +1062,9 @@ protected function _parseCommand($command)
}
$options[$optName] = [
'is_valuable' => !empty($matchOptions['valuable'][$i]),
'default' => $default ?: null,
'default' => $default ?: null,
'description' => $description,
'alias' => $matchOptions['alias'][$i] ?: null,
'alias' => $matchOptions['alias'][$i] ?: null,
];
}
}
Expand Down
Loading

0 comments on commit e1ec899

Please sign in to comment.