Skip to content

Commit

Permalink
#151 - Remove redundant comments and code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Apr 13, 2024
1 parent 3b740e7 commit d253439
Show file tree
Hide file tree
Showing 21 changed files with 228 additions and 471 deletions.
61 changes: 7 additions & 54 deletions src/Console/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ final class Color
public const AT_STRIKE = 9;

/**
* @var array Map of supported foreground colors
* Map of supported foreground colors
*/
private static $fg = [
private static array $fg = [
self::FG_BLACK => '0;30',
self::FG_DARK_GRAY => '1;30',
self::FG_RED => '0;31',
Expand All @@ -89,9 +89,9 @@ final class Color
];

/**
* @var array Map of supported background colors
* Map of supported background colors
*/
private static $bg = [
private static array $bg = [
self::BG_BLACK => '40',
self::BG_RED => '41',
self::BG_GREEN => '42',
Expand All @@ -103,9 +103,9 @@ final class Color
];

/**
* @var array Map of supported attributes
* Map of supported attributes
*/
private static $at = [
private static array $at = [
self::AT_NORMAL => '0',
self::AT_BOLD => '1',
self::AT_ITALIC => '3',
Expand All @@ -119,8 +119,6 @@ final class Color

/**
* Identify if console supports colors
*
* @return bool
*/
public static function isSupportedShell(): bool
{
Expand All @@ -133,15 +131,6 @@ public static function isSupportedShell(): bool

/**
* Colorizes the string using provided colors.
*
* @static
*
* @param string $string
* @param null|integer $fg
* @param null|integer $at
* @param null|integer $bg
*
* @return string
*/
public static function colorize(string $string, int $fg = null, int $at = null, int $bg = null): string
{
Expand Down Expand Up @@ -173,25 +162,13 @@ public static function colorize(string $string, int $fg = null, int $at = null,
return $colored;
}

/**
* @param string $msg
*
* @return string
*/
public static function head(string $msg): string
{
return static::colorize($msg, Color::FG_BROWN);
return Color::colorize($msg, Color::FG_BROWN);
}

/**
* Color style for error messages.
*
* @static
*
* @param string $msg
* @param string $prefix
*
* @return string
*/
public static function error(string $msg, string $prefix = 'Error: '): string
{
Expand All @@ -206,13 +183,6 @@ public static function error(string $msg, string $prefix = 'Error: '): string

/**
* Color style for fatal error messages.
*
* @static
*
* @param string $msg
* @param string $prefix
*
* @return string
*/
public static function fatal(string $msg, string $prefix = 'Fatal Error: '): string
{
Expand All @@ -227,12 +197,6 @@ public static function fatal(string $msg, string $prefix = 'Fatal Error: '): str

/**
* Color style for success messages.
*
* @static
*
* @param string $msg
*
* @return string
*/
public static function success(string $msg): string
{
Expand All @@ -247,12 +211,6 @@ public static function success(string $msg): string

/**
* Color style for info messages.
*
* @static
*
* @param string $msg
*
* @return string
*/
public static function info(string $msg): string
{
Expand All @@ -269,11 +227,6 @@ public static function info(string $msg): string
* Output tab space
*
* Depending on length of string.
*
* @param string $string
* @param int $tabSize
*
* @return int
*/
protected static function tabSpaces(string $string, int $tabSize = 4): int
{
Expand Down
3 changes: 0 additions & 3 deletions src/Console/Commands/CommandsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

use Exception;

/**
* Commands Exception
*/
class CommandsException extends Exception
{
}
8 changes: 1 addition & 7 deletions src/Console/Commands/CommandsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ interface CommandsInterface
{
/**
* Executes the command.
*
* @return mixed
*/
public function run();
public function run(): void;

/**
* Prints help on the usage of the command.
*
* @return void
*/
public function getHelp(): void;

Expand All @@ -40,8 +36,6 @@ public function getHelp(): void;
* This method returns a list of available parameters for the current command.
* The list must be represented as pairs key-value.
* Where key is the parameter name and value is the short description.
*
* @return array
*/
public function getPossibleParams(): array;
}
28 changes: 4 additions & 24 deletions src/Console/Commands/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,10 @@
*/
class Migration implements CommandsInterface
{
/**
* @var Parser
*/
protected $parser;

/**
* @param Parser $parser
*/
final public function __construct(Parser $parser)
final public function __construct(protected Parser $parser)
{
$this->parser = $parser;
}

/**
* @return array
*/
public function getPossibleParams(): array
{
return [
Expand Down Expand Up @@ -208,8 +196,6 @@ public function run(): void

/**
* Print Help information
*
* @return void
*/
public function getHelp(): void
{
Expand All @@ -232,12 +218,7 @@ public function getHelp(): void
$this->printParameters($this->getPossibleParams());
}

/**
* @param mixed $config
*
* @return array
*/
protected function exportFromTables($config): array
protected function exportFromTables(Config $config): array
{
$tables = [];
$application = $config->get('application') ?? [];
Expand All @@ -261,6 +242,7 @@ protected function exportFromTables($config): array
*
* @return Config
* @throws CommandsException
* @throws \Phalcon\Config\Exception
*/
protected function getConfig(string $path): Config
{
Expand All @@ -280,10 +262,8 @@ protected function getConfig(string $path): Config
* Determines correct adapter by file name
* and load config
*
* @param string $fileName Config file name
*
* @return Config
* @throws CommandsException
* @throws \Phalcon\Config\Exception
*/
protected function loadConfig(string $fileName): Config
{
Expand Down
13 changes: 1 addition & 12 deletions src/Console/OptionStack.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,8 @@
*/
class OptionStack implements ArrayAccess
{
/**
* Parameters received by the script.
*
* @var array
*/
protected array $options = [];

/**
* @param array $options
*/
public function __construct(array $options = [])
public function __construct(protected array $options = [])
{
$this->options = $options;
}

/**
Expand Down
12 changes: 1 addition & 11 deletions src/Exception/Db/UnknownColumnTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,8 @@

class UnknownColumnTypeException extends Exception
{
/**
* @var ColumnInterface
*/
protected ColumnInterface $column;

public function __construct(ColumnInterface $column)
public function __construct(protected ColumnInterface $column)
{
$this->column = $column;

$message = sprintf(
'Unrecognized data type "%s" for column "%s".',
$column->getType(),
Expand All @@ -36,9 +29,6 @@ public function __construct(ColumnInterface $column)
parent::__construct($message, 0);
}

/**
* @return ColumnInterface
*/
public function getColumn(): ColumnInterface
{
return $this->column;
Expand Down
56 changes: 5 additions & 51 deletions src/Migration/Action/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
use Phalcon\Db\Enum;
use Phalcon\Db\Exception;
use Phalcon\Db\Index;
use Phalcon\Db\IndexInterface;
use Phalcon\Db\Reference;
use Phalcon\Db\ReferenceInterface;
use Phalcon\Migrations\Exception\Db\UnknownColumnTypeException;
use Phalcon\Migrations\Exception\RuntimeException;
use Phalcon\Migrations\Generator\Snippet;
Expand Down Expand Up @@ -143,31 +141,6 @@ class Generate
*/
private ?ClassType $class = null;

/**
* SQL Adapter Name
*/
private string $adapter;

/**
* Table columns
*/
protected array $columns;

/**
* Table indexes
*/
protected array $indexes;

/**
* Table foreign keys and another references
*/
protected array $references;

/**
* Table options
*/
protected array $options;

protected ?string $primaryColumnName = null;

/**
Expand All @@ -182,27 +155,13 @@ class Generate
*/
protected array $quoteWrappedColumns = [];

/**
* Generate constructor.
*
* @param string $adapter
* @param array|ColumnInterface[] $columns
* @param array|IndexInterface[] $indexes
* @param array|ReferenceInterface[] $references
* @param array $options
*/
public function __construct(
string $adapter,
array $columns = [],
array $indexes = [],
array $references = [],
array $options = []
private string $adapter,
protected array $columns = [],
protected array $indexes = [],
protected array $references = [],
protected array $options = []
) {
$this->adapter = $adapter;
$this->columns = $columns;
$this->indexes = $indexes;
$this->references = $references;
$this->options = $options;
}

public function getEntity(): PhpFile
Expand Down Expand Up @@ -565,11 +524,6 @@ public function getAdapter(): string

/**
* Just wrap string with single quotes
*
* @param string $columnName
* @param string $quote
*
* @return string
*/
public function wrapWithQuotes(string $columnName, string $quote = "'"): string
{
Expand Down
Loading

0 comments on commit d253439

Please sign in to comment.