From 4c8b445c5d65225acb1ca730b80dbf551f47f3c8 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 15 May 2016 01:38:29 +0300 Subject: [PATCH 1/5] Fixed issue #665 --- scripts/Phalcon/Utils.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/Phalcon/Utils.php b/scripts/Phalcon/Utils.php index 744f0584e..19cbe76d7 100644 --- a/scripts/Phalcon/Utils.php +++ b/scripts/Phalcon/Utils.php @@ -27,6 +27,14 @@ class Utils { const DB_ADAPTER_POSTGRESQL = 'Postgresql'; + const DB_ADAPTER_SQLITE = 'Sqlite'; + + /** + * Converts the underscore_notation to the UpperCamelCase + * + * @param string $string + * @return string + */ public static function camelize($string) { $stringParts = explode('_', $string); @@ -35,6 +43,17 @@ public static function camelize($string) return implode('', $stringParts); } + /** + * Converts the underscore_notation to the lowerCamelCase + * + * @param string $string + * @return string + */ + public static function lowerCamelize($string) + { + return lcfirst(self::camelize($string)); + } + /** * Resolves the DB Schema * @@ -48,7 +67,13 @@ public static function resolveDbSchema(Config $config) } if (self::DB_ADAPTER_POSTGRESQL == $config->get('adapter')) { - return 'public'; + return 'public'; + } + + if (self::DB_ADAPTER_SQLITE == $config->get('adapter')) { + // SQLite only supports the current database, unless one is + // attached. This is not the case, so don't return a schema. + return null; } if ($config->offsetExists('dbname')) { From 81bddccace9469d1f754594c23d848c482dd5140 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 15 May 2016 18:45:20 +0300 Subject: [PATCH 2/5] Improved process to creating module --- scripts/Phalcon/Builder/Module.php | 39 +++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/scripts/Phalcon/Builder/Module.php b/scripts/Phalcon/Builder/Module.php index b452e5436..c5faf07ae 100644 --- a/scripts/Phalcon/Builder/Module.php +++ b/scripts/Phalcon/Builder/Module.php @@ -19,6 +19,8 @@ namespace Phalcon\Builder; +use SplFileInfo; + /** * Module Builder * @@ -88,7 +90,7 @@ public function build() $modulesDir = $this->path->getRootPath($modulesDir); } - $this->options->offsetSet('modulesDir', realpath($modulesDir)); + $this->options->offsetSet('modulesDir', $modulesDir); $this->options->offsetSet('templatePath', realpath($templatePath)); $this->options->offsetSet('projectPath', $this->path->getRootPath()); @@ -122,10 +124,39 @@ public function buildDirectories() )); } - mkdir($modulesDir . DIRECTORY_SEPARATOR . $moduleName, 0777, true); + $modulesPath = new SplFileInfo($modulesDir); + $modulePath = $modulesDir. DIRECTORY_SEPARATOR . $moduleName; + + try { + if ($modulesPath->isFile() && !$modulesPath->isDir()) { + throw new BuilderException( + sprintf( + "Builder expects a directory for 'modulesDir'. But %s is a file.", + $modulesPath->getPathname() + ) + ); + } elseif ($modulesPath->isReadable() && !mkdir($modulePath, 0777, true)) { + throw new BuilderException("Unable to create module directory. Check permissions."); + } + + foreach ($this->moduleDirectories as $dir) { + $path = $modulePath . DIRECTORY_SEPARATOR . $dir; + if (!mkdir($path, 0777, true)) { + throw new BuilderException( + sprintf( + "Unable to create %s directory. Check permissions.", + $path + ) + ); + } + } - foreach ($this->moduleDirectories as $dir) { - mkdir($modulesDir . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR . $dir, 0777, true); + } catch (\Exception $e) { + throw new BuilderException( + $e->getMessage(), + $e->getCode(), + ($e instanceof BuilderException ? null : $e) + ); } return $this; From 41445b5b7a4baec76416cc9fc2d9cbf82d8bb1b2 Mon Sep 17 00:00:00 2001 From: Eugene Matvejev Date: Mon, 16 May 2016 17:11:08 +0100 Subject: [PATCH 3/5] Update Model.php --- ide/stubs/Phalcon/mvc/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ide/stubs/Phalcon/mvc/Model.php b/ide/stubs/Phalcon/mvc/Model.php index c57db9bac..78ac7d73f 100644 --- a/ide/stubs/Phalcon/mvc/Model.php +++ b/ide/stubs/Phalcon/mvc/Model.php @@ -305,7 +305,7 @@ public function assign($data, $dataColumnMap = null, $whiteList = null) {} * )); * * - * @param \Phalcon\Mvc\ModelInterface|Phalcon\Mvc\Model\Row $base + * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base * @param array $data * @param array $columnMap * @param int $dirtyState From 969b20720170f117703e10e0b6e7404dd2914377 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 17 May 2016 00:24:30 +0300 Subject: [PATCH 4/5] Amended IDE stubs --- ide/stubs/Phalcon/Crypt.php | 8 +++++--- ide/stubs/Phalcon/Flash.php | 2 +- ide/stubs/Phalcon/mvc/Model.php | 2 +- ide/stubs/Phalcon/mvc/view/engine/Volt.php | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ide/stubs/Phalcon/Crypt.php b/ide/stubs/Phalcon/Crypt.php index 366acaaf0..0e2467cd7 100644 --- a/ide/stubs/Phalcon/Crypt.php +++ b/ide/stubs/Phalcon/Crypt.php @@ -105,22 +105,24 @@ public function getKey() {} /** * Pads texts before encryption * - * @see http://www.di-mgt.com.au/cryptopad.html + * @link http://www.di-mgt.com.au/cryptopad.html * @param string $text * @param string $mode * @param int $blockSize * @param int $paddingType + * @return string */ protected function _cryptPadText($text, $mode, $blockSize, $paddingType) {} /** - * Removes padding @a padding_type from @a text - * If the function detects that the text was not padded, it will return it unmodified + * Removes $paddingType padding from text + * If the method detects that the text was not padded, it will return it unmodified * * @param string $text Message to be unpadded * @param string $mode Encryption mode; unpadding is applied only in CBC or ECB mode * @param int $blockSize Cipher block size * @param int $paddingType Padding scheme + * @return string */ protected function _cryptUnpadText($text, $mode, $blockSize, $paddingType) {} diff --git a/ide/stubs/Phalcon/Flash.php b/ide/stubs/Phalcon/Flash.php index 725673109..951cb4bbf 100644 --- a/ide/stubs/Phalcon/Flash.php +++ b/ide/stubs/Phalcon/Flash.php @@ -84,7 +84,7 @@ public function notice($message) {} * $flash->success('The process was finished successfully'); * * - * @param string $message + * @param mixed $message * @return string */ public function success($message) {} diff --git a/ide/stubs/Phalcon/mvc/Model.php b/ide/stubs/Phalcon/mvc/Model.php index c57db9bac..78ac7d73f 100644 --- a/ide/stubs/Phalcon/mvc/Model.php +++ b/ide/stubs/Phalcon/mvc/Model.php @@ -305,7 +305,7 @@ public function assign($data, $dataColumnMap = null, $whiteList = null) {} * )); * * - * @param \Phalcon\Mvc\ModelInterface|Phalcon\Mvc\Model\Row $base + * @param \Phalcon\Mvc\ModelInterface|\Phalcon\Mvc\Model\Row $base * @param array $data * @param array $columnMap * @param int $dirtyState diff --git a/ide/stubs/Phalcon/mvc/view/engine/Volt.php b/ide/stubs/Phalcon/mvc/view/engine/Volt.php index 2dea86bf7..498b7a2e9 100644 --- a/ide/stubs/Phalcon/mvc/view/engine/Volt.php +++ b/ide/stubs/Phalcon/mvc/view/engine/Volt.php @@ -97,7 +97,8 @@ public function sort($value) {} * * @param string $name * @param array $arguments + * @return mixed */ - public function callMacro($name, $arguments) {} + public function callMacro($name, $arguments = array()) {} } From 8b9c33879e1b86de2b5e4dd18d13588203699257 Mon Sep 17 00:00:00 2001 From: Eugene Matvejev Date: Tue, 17 May 2016 10:30:40 +0100 Subject: [PATCH 5/5] Update Model.php --- ide/stubs/Phalcon/mvc/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ide/stubs/Phalcon/mvc/Model.php b/ide/stubs/Phalcon/mvc/Model.php index c57db9bac..4f7ec5e2c 100644 --- a/ide/stubs/Phalcon/mvc/Model.php +++ b/ide/stubs/Phalcon/mvc/Model.php @@ -605,7 +605,7 @@ public function validationHasFailed() {} * * * @param mixed $filter - * @return MessageInterface[] + * @return \Phalcon\Mvc\Model\Message\MessageInterface[] */ public function getMessages($filter = null) {}