diff --git a/src/Common/AbstractCommand.php b/src/Commands/AbstractCommand.php similarity index 76% rename from src/Common/AbstractCommand.php rename to src/Commands/AbstractCommand.php index 2a4604f..e9724e6 100644 --- a/src/Common/AbstractCommand.php +++ b/src/Commands/AbstractCommand.php @@ -16,12 +16,19 @@ */ abstract class AbstractCommand extends Command { + /** + * @var \Rougin\Describe\Describe + */ protected $describe; + + /** + * @var \Twig_Environment + */ protected $renderer; /** - * @param Twig_Environment $renderer - * @param Describe $describe + * @param \Twig_Environment $renderer + * @param \Rougin\Describe\Describe $describe */ public function __construct(Describe $describe, Twig_Environment $renderer) { diff --git a/src/Commands/CreateControllerCommand.php b/src/Commands/CreateControllerCommand.php index 14f9bb9..c59402a 100644 --- a/src/Commands/CreateControllerCommand.php +++ b/src/Commands/CreateControllerCommand.php @@ -6,7 +6,6 @@ use Rougin\Combustor\Common\File; use Rougin\Combustor\Common\Tools; use Rougin\Combustor\Validator\Validator; -use Rougin\Combustor\Common\AbstractCommand; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Commands/CreateLayoutCommand.php b/src/Commands/CreateLayoutCommand.php index 4ff1fd2..9b03dba 100644 --- a/src/Commands/CreateLayoutCommand.php +++ b/src/Commands/CreateLayoutCommand.php @@ -3,7 +3,6 @@ namespace Rougin\Combustor\Commands; use Rougin\Combustor\Common\Tools; -use Rougin\Combustor\Common\AbstractCommand; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -106,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output) array_push($data['scripts'], $bootstrapJs); } - if ( ! @mkdir($filePath, 0777, TRUE)) { + if ( ! @mkdir($filePath, 0777, true)) { $message = 'The layout directory already exists!'; return $output->writeln(''.$message.''); diff --git a/src/Commands/CreateModelCommand.php b/src/Commands/CreateModelCommand.php index 0c21038..effbedd 100644 --- a/src/Commands/CreateModelCommand.php +++ b/src/Commands/CreateModelCommand.php @@ -6,7 +6,6 @@ use Rougin\Combustor\Common\File; use Rougin\Combustor\Common\Tools; use Rougin\Combustor\Validator\Validator; -use Rougin\Combustor\Common\AbstractCommand; use Rougin\Combustor\Generator\ModelGenerator; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; diff --git a/src/Commands/CreateScaffoldCommand.php b/src/Commands/CreateScaffoldCommand.php index 4fb711a..59615b8 100644 --- a/src/Commands/CreateScaffoldCommand.php +++ b/src/Commands/CreateScaffoldCommand.php @@ -2,7 +2,6 @@ namespace Rougin\Combustor\Commands; -use Rougin\Combustor\Common\AbstractCommand; use Rougin\Combustor\Common\Tools; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputArgument; diff --git a/src/Commands/CreateViewCommand.php b/src/Commands/CreateViewCommand.php index 56b598d..56ddded 100644 --- a/src/Commands/CreateViewCommand.php +++ b/src/Commands/CreateViewCommand.php @@ -6,7 +6,6 @@ use Rougin\Combustor\Common\File; use Rougin\Combustor\Common\Tools; use Rougin\Combustor\Common\FileCollection; -use Rougin\Combustor\Common\AbstractCommand; use Rougin\Combustor\Generator\ViewGenerator; use Rougin\Combustor\Validator\ViewValidator; use Symfony\Component\Console\Command\Command; @@ -36,10 +35,10 @@ class CreateViewCommand extends AbstractCommand public function isEnabled() { if ( ! Tools::isCommandEnabled() && ! Tools::hasLayout()) { - return FALSE; + return false; } - return TRUE; + return true; } /** diff --git a/src/Commands/InstallDoctrineCommand.php b/src/Commands/InstallDoctrineCommand.php index 27272d0..0f8c8b6 100644 --- a/src/Commands/InstallDoctrineCommand.php +++ b/src/Commands/InstallDoctrineCommand.php @@ -3,7 +3,6 @@ namespace Rougin\Combustor\Commands; use Rougin\Combustor\Common\Tools; -use Rougin\Combustor\Common\AbstractCommand; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -30,10 +29,10 @@ class InstallDoctrineCommand extends AbstractCommand public function isEnabled() { if (file_exists(APPPATH.'libraries/Doctrine.php')) { - return FALSE; + return false; } - return TRUE; + return true; } /** @@ -133,8 +132,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $schemaTool = 'use Doctrine\ORM\Tools\SchemaTool;'; $coreModel = 'include BASEPATH . \'core/Model.php\';'; - if (strpos($abstractCommand, $schemaTool) !== FALSE) { - if (strpos($abstractCommand, $coreModel) === FALSE) { + if (strpos($abstractCommand, $schemaTool) !== false) { + if (strpos($abstractCommand, $coreModel) === false) { $contents = str_replace($search, $replace, $abstractCommand); } } diff --git a/src/Commands/InstallWildfireCommand.php b/src/Commands/InstallWildfireCommand.php index c4cb351..94709ce 100644 --- a/src/Commands/InstallWildfireCommand.php +++ b/src/Commands/InstallWildfireCommand.php @@ -3,7 +3,6 @@ namespace Rougin\Combustor\Commands; use Rougin\Combustor\Common\Tools; -use Rougin\Combustor\Common\AbstractCommand; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -30,10 +29,10 @@ class InstallWildfireCommand extends AbstractCommand public function isEnabled() { if (file_exists(APPPATH.'libraries/Wildfire.php')) { - return FALSE; + return false; } - return TRUE; + return true; } /** diff --git a/src/Commands/RemoveDoctrineCommand.php b/src/Commands/RemoveDoctrineCommand.php index f1b42eb..c1ade4a 100644 --- a/src/Commands/RemoveDoctrineCommand.php +++ b/src/Commands/RemoveDoctrineCommand.php @@ -3,7 +3,6 @@ namespace Rougin\Combustor\Commands; use Rougin\Combustor\Common\Tools; -use Rougin\Combustor\Common\AbstractCommand; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Commands/RemoveWildfireCommand.php b/src/Commands/RemoveWildfireCommand.php index 08c6b82..0377660 100644 --- a/src/Commands/RemoveWildfireCommand.php +++ b/src/Commands/RemoveWildfireCommand.php @@ -3,7 +3,6 @@ namespace Rougin\Combustor\Commands; use Rougin\Combustor\Common\Tools; -use Rougin\Combustor\Common\AbstractCommand; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; diff --git a/src/Common/File.php b/src/Common/File.php index 063318a..369af2d 100644 --- a/src/Common/File.php +++ b/src/Common/File.php @@ -12,7 +12,14 @@ */ class File { + /** + * @var File pointer + */ protected $file; + + /** + * @var string + */ protected $path; /** diff --git a/src/Common/FileCollection.php b/src/Common/FileCollection.php index 5f2e225..9401d47 100644 --- a/src/Common/FileCollection.php +++ b/src/Common/FileCollection.php @@ -14,7 +14,10 @@ */ class FileCollection { - protected $files; + /** + * @var array + */ + protected $files = []; /** * Adds a File object to the listing of files. @@ -38,11 +41,11 @@ public function close() { foreach ($this->files as $file) { if ( ! $file->close()) { - return FALSE; + return false; } } - return TRUE; + return true; } /** diff --git a/src/Common/Tools.php b/src/Common/Tools.php index 497e964..29bdb37 100644 --- a/src/Common/Tools.php +++ b/src/Common/Tools.php @@ -25,7 +25,7 @@ public static function ignite() $config = new File(APPPATH.'config/config.php', 'wb'); $search = [ - '$config[\'composer_autoload\'] = FALSE;' + '$config[\'composer_autoload\'] = false;' ]; $replace = [ @@ -33,13 +33,13 @@ public static function ignite() ]; // Removes the index.php from $config['index_page']. - if (strpos($config->getContents(), '$config[\'index_page\'] = \'index.php\';') !== FALSE) { + if (strpos($config->getContents(), '$config[\'index_page\'] = \'index.php\';') !== false) { array_push($search, '$config[\'index_page\'] = \'index.php\';'); array_push($replace, '$config[\'index_page\'] = \'\';'); } // Adds an encryption key from the configuration. - if (strpos($config->getContents(), '$config[\'encryption_key\'] = \'\';') !== FALSE) { + if (strpos($config->getContents(), '$config[\'encryption_key\'] = \'\';') !== false) { array_push($search, '$config[\'encryption_key\'] = \'\';'); array_push($replace, '$config[\'encryption_key\'] = \''.md5('rougin').'\';'); } @@ -149,11 +149,7 @@ public static function ignite() */ public static function isCommandEnabled() { - if ( ! self::isWildfireEnabled() && ! self::isDoctrineEnabled()) { - return FALSE; - } - - return TRUE; + return self::isWildfireEnabled() || self::isDoctrineEnabled(); } /** @@ -163,11 +159,7 @@ public static function isCommandEnabled() */ public static function isDoctrineEnabled() { - if ( ! file_exists(APPPATH.'libraries/Doctrine.php')) { - return FALSE; - } - - return TRUE; + return file_exists(APPPATH.'libraries/Doctrine.php'); } /** @@ -177,14 +169,8 @@ public static function isDoctrineEnabled() */ public static function hasLayout() { - if ( - ! file_exists(APPPATH.'views/layout/header.php') || - ! file_exists(APPPATH.'views/layout/footer.php') - ) { - return FALSE; - } - - return TRUE; + return file_exists(APPPATH.'views/layout/header.php') + && file_exists(APPPATH.'views/layout/footer.php'); } /** @@ -194,11 +180,7 @@ public static function hasLayout() */ public static function isWildfireEnabled() { - if ( ! file_exists(APPPATH.'libraries/Wildfire.php')) { - return FALSE; - } - - return TRUE; + return file_exists(APPPATH.'libraries/Wildfire.php'); } /** @@ -209,11 +191,9 @@ public static function isWildfireEnabled() */ public static function stripTableSchema($table) { - if (strpos($table, '.') !== FALSE) { - return substr($table, strpos($table, '.') + 1); - } - - return $table; + return (strpos($table, '.') !== false) + ? substr($table, strpos($table, '.') + 1) + : $table; } /** diff --git a/src/Generator/ControllerGenerator.php b/src/Generator/ControllerGenerator.php index cfd9fe2..c6a7f83 100644 --- a/src/Generator/ControllerGenerator.php +++ b/src/Generator/ControllerGenerator.php @@ -16,12 +16,19 @@ */ class ControllerGenerator implements GeneratorInterface { + /** + * @var \Rougin\Describe\Describe + */ protected $describe; - protected $data; /** - * @param Describe $describe - * @param array $data + * @var array + */ + protected $data = []; + + /** + * @param \Rougin\Describe\Describe $describe + * @param array $data */ public function __construct(Describe $describe, array $data) { @@ -100,4 +107,4 @@ public function generate() return $this->data; } -} \ No newline at end of file +} diff --git a/src/Generator/GeneratorInterface.php b/src/Generator/GeneratorInterface.php index 04da75e..8b96063 100644 --- a/src/Generator/GeneratorInterface.php +++ b/src/Generator/GeneratorInterface.php @@ -18,4 +18,4 @@ interface GeneratorInterface * @return array */ public function generate(); -} \ No newline at end of file +} diff --git a/src/Generator/ModelGenerator.php b/src/Generator/ModelGenerator.php index d3f37ed..781dac4 100644 --- a/src/Generator/ModelGenerator.php +++ b/src/Generator/ModelGenerator.php @@ -16,12 +16,19 @@ */ class ModelGenerator implements GeneratorInterface { + /** + * @var \Rougin\Describe\Describe + */ protected $describe; - protected $data; /** - * @param Describe $describe - * @param array $data + * @var array + */ + protected $data = []; + + /** + * @param \Rougin\Describe\Describe $describe + * @param array $data */ public function __construct(Describe $describe, array $data) { @@ -96,4 +103,4 @@ public function generate() return $this->data; } -} \ No newline at end of file +} diff --git a/src/Generator/ViewGenerator.php b/src/Generator/ViewGenerator.php index ed6e6ca..2574c2c 100644 --- a/src/Generator/ViewGenerator.php +++ b/src/Generator/ViewGenerator.php @@ -16,12 +16,19 @@ */ class ViewGenerator implements GeneratorInterface { + /** + * @var \Rougin\Describe\Describe + */ protected $describe; - protected $data; /** - * @param Describe $describe - * @param array $data + * @var array + */ + protected $data = []; + + /** + * @param \Rougin\Describe\Describe $describe + * @param array $data */ public function __construct(Describe $describe, array $data) { @@ -139,4 +146,4 @@ public function generate() return $this->data; } -} \ No newline at end of file +} diff --git a/src/Validator/Validator.php b/src/Validator/Validator.php index 628aae5..d546900 100644 --- a/src/Validator/Validator.php +++ b/src/Validator/Validator.php @@ -15,12 +15,35 @@ */ class Validator implements ValidatorInterface { - protected $file; - protected $isCamel; - protected $isDoctrine; - protected $isWildfire; - protected $library; - protected $message; + /** + * @var array + */ + protected $file = []; + + /** + * @var boolean + */ + protected $isCamel = false; + + /** + * @var boolean + */ + protected $isDoctrine = false; + + /** + * @var boolean + */ + protected $isWildfire = false; + + /** + * @var string + */ + protected $library = ''; + + /** + * @var string + */ + protected $message = ''; /** * @param string $isDoctrine @@ -30,10 +53,10 @@ class Validator implements ValidatorInterface */ public function __construct($isDoctrine, $isWildfire, $isCamel, $file) { + $this->file = $file; + $this->isCamel = $isCamel; $this->isWildfire = $isWildfire; $this->isDoctrine = $isDoctrine; - $this->isCamel = $isCamel; - $this->file = $file; } /** @@ -49,41 +72,41 @@ public function fails() if ( ! $hasWildfire && ! $hasDoctrine) { $this->message = 'Please install Wildfire or Doctrine!'; - return TRUE; + return true; } if ($hasWildfire && $hasDoctrine) { $this->message = 'Please select "--wildfire" or "--doctrine"!'; - return TRUE; + return true; } if ($this->isDoctrine || $hasDoctrine) { $this->library = 'doctrine'; - return FALSE; + return false; } if ($this->isWildfire || $hasWildfire) { if ($this->isCamel) { $this->message = 'Wildfire does not support camel casing!'; - return TRUE; + return true; } $this->library = 'wildfire'; - return FALSE; + return false; } if (file_exists($this->file['path'])) { $this->message = 'The "'.$this->file['name'].'" '. $this->file['type'].' already exists!'; - return TRUE; + return true; } - return FALSE; + return false; } /** diff --git a/src/Validator/ViewValidator.php b/src/Validator/ViewValidator.php index 114c5e6..57363b8 100644 --- a/src/Validator/ViewValidator.php +++ b/src/Validator/ViewValidator.php @@ -15,8 +15,15 @@ */ class ViewValidator implements ValidatorInterface { - protected $name; - protected $message; + /** + * @var string + */ + protected $name = ''; + + /** + * @var string + */ + protected $message = ''; public function __construct($name) { @@ -32,12 +39,14 @@ public function fails() { $filePath = APPPATH.'views/'.$this->name; - if ( ! @mkdir($filePath, 0775, TRUE)) { + if ( ! @mkdir($filePath, 0775, true)) { $this->message = 'The "'.$this->name. '" views folder already exists!'; - return TRUE; + return true; } + + return false; } /**