From c5fdf17177fd529d1108a5f1b843097f0a207d50 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 12 Mar 2021 09:16:28 +0000 Subject: [PATCH 1/9] Change domain name --- .github/ISSUE_TEMPLATE.md | 5 ++--- bootstrap/autoload.php | 2 +- phalcon.sh | 2 +- tests/_support/Module/UnitTest.php | 8 ++++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 811a701e5..9dd80274b 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,4 +1,4 @@ -> Questions should go to https://forum.phalconphp.com +> Questions should go to https://forum.phalcon.io > Documentation issues should go to https://github.com/phalcon/docs/issues ### Expected and Actual Behavior @@ -23,5 +23,4 @@ * PHP Version: (`php -v`) * Operating System: * Server: Nginx | Apache | Other -* Other related info (Database, table schema): - +* Other related info (Database, table schema): diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index e5e67b91e..694df6960 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -14,7 +14,7 @@ if (!extension_loaded('phalcon')) { throw new Exception( "Phalcon extension isn't installed, follow these instructions to install it: " . - 'https://docs.phalconphp.com/en/latest/installation' + 'https://docs.phalcon.io/en/latest/installation' ); } diff --git a/phalcon.sh b/phalcon.sh index efd091809..6f234fdb0 100755 --- a/phalcon.sh +++ b/phalcon.sh @@ -110,7 +110,7 @@ check_install(){ printf "\n" printf "\nIn case of problems: " printf "${YELLOW}https://github.com/phalcon/phalcon-devtools/issues${NC} " - printf "\n and: ${YELLOW}https://forum.phalconphp.com${NC}" + printf "\n and: ${YELLOW}https://forum.phalcon.io${NC}" printf "\n" check_bash diff --git a/tests/_support/Module/UnitTest.php b/tests/_support/Module/UnitTest.php index 57de0e7db..4c0b2f409 100644 --- a/tests/_support/Module/UnitTest.php +++ b/tests/_support/Module/UnitTest.php @@ -11,16 +11,16 @@ * Base class for all Unit tests * * @copyright (c) 2011-2017 Phalcon Team - * @link http://www.phalconphp.com - * @author Andres Gutierrez - * @author Nikolaos Dimopoulos + * @link http://www.phalcon.io + * @author Andres Gutierrez + * @author Nikolaos Dimopoulos * @package Phalcon\Test\Module * * The contents of this file are subject to the New BSD License that is * bundled with this package in the file LICENSE.txt * * If you did not receive a copy of the license and are unable to obtain it - * through the world-wide-web, please send an email to license@phalconphp.com + * through the world-wide-web, please send an email to license@phalcon.io * so that we can send you a copy immediately. */ class UnitTest extends Unit From ce5c318cc912dc2bb1bb33af9b2de67da0d2d10f Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 12 Mar 2021 09:19:12 +0000 Subject: [PATCH 2/9] Update AdminLTE Version information --- src/Utils/SystemInfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils/SystemInfo.php b/src/Utils/SystemInfo.php index f242405bf..9da2b293a 100644 --- a/src/Utils/SystemInfo.php +++ b/src/Utils/SystemInfo.php @@ -58,7 +58,7 @@ public function getVersions(): array return [ 'Phalcon DevTools Version' => Version::get(), 'Phalcon Version' => PhVersion::get(), - 'AdminLTE Version' => ADMIN_LTE_VERSION, + 'AdminLTE Version' => '3.0.1', ]; } From 4c7d97b9e03f94a176142080c8d6d8225e52b5e3 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Fri, 12 Mar 2021 09:19:49 +0000 Subject: [PATCH 3/9] Remove ADMIN_LTE_VERSION constant --- bootstrap/autoload.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php index 694df6960..ae52a5866 100644 --- a/bootstrap/autoload.php +++ b/bootstrap/autoload.php @@ -87,11 +87,6 @@ */ defined('HOSTNAME') || define('HOSTNAME', explode('.', gethostname())[0]); -/** - * @const ADMIN_LTE_VERSION The AdminLTE version. - */ -defined('ADMIN_LTE_VERSION') || define('ADMIN_LTE_VERSION', '2.3.6'); - /** * Register the Composer autoloader (if any) */ From 0917f32b7b7a85b03d276439a496603d0a503250 Mon Sep 17 00:00:00 2001 From: Aziz Date: Sun, 14 Mar 2021 18:50:21 +0300 Subject: [PATCH 4/9] ISSUE-1415: Removed breaking model creation change --- CHANGELOG.md | 10 +++++++++- src/Builder/Component/Model.php | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7451a252a..6c41ce9d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ -# [4.0.4](https://github.com/phalcon/cphalcon/releases/tag/v4.0.4) (2021-03-11) +# [4.0.5](https://github.com/phalcon/cphalcon/releases/tag/v4.0.5) +## Added + +## Fixed +- Fixed model creation failure in webtools due to wrong variable mutation [#1415](https://github.com/phalcon/phalcon-devtools/issues/1415) + +## Changed + +[4.0.4](https://github.com/phalcon/cphalcon/releases/tag/v4.0.4) (2021-03-11) ## Added - Added support for PHP `7.4` [#1482](https://github.com/phalcon/phalcon-devtools/pull/1482) diff --git a/src/Builder/Component/Model.php b/src/Builder/Component/Model.php index f43774f1e..e43177aa2 100644 --- a/src/Builder/Component/Model.php +++ b/src/Builder/Component/Model.php @@ -139,9 +139,7 @@ public function build(): void $adapterName = 'Phalcon\Db\Adapter\Pdo\\' . $adapter; unset($configArray['adapter']); - if (isset($configArray['options'])) { - $configArray = $configArray['options']; - } + /** @var AbstractPdo $db */ $db = new $adapterName($configArray); From b8ddd9c1ece6d852ea77b3e82aed0b2e04ed12dd Mon Sep 17 00:00:00 2001 From: Aziz Date: Sun, 14 Mar 2021 19:30:21 +0300 Subject: [PATCH 5/9] ISSUE-1426: Replaced regex config path matching by strpos --- CHANGELOG.md | 1 + src/Builder/Path.php | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c41ce9d6..8125a8062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Fixed - Fixed model creation failure in webtools due to wrong variable mutation [#1415](https://github.com/phalcon/phalcon-devtools/issues/1415) +- Fixed config path detection to platform independent [#1426](https://github.com/phalcon/phalcon-devtools/issues/1426) ## Changed diff --git a/src/Builder/Path.php b/src/Builder/Path.php index acca94682..d79d8a2bd 100644 --- a/src/Builder/Path.php +++ b/src/Builder/Path.php @@ -43,34 +43,32 @@ public function getConfig($type = null): Config $type = isset($types[$type]) ? $type : 'ini'; foreach (['app/config/', 'config/', 'apps/config/', 'apps/frontend/config/'] as $configPath) { - if ('ini' == $type && file_exists($this->rootPath . $configPath . 'config.ini')) { + if ('ini' === $type && file_exists($this->rootPath . $configPath . 'config.ini')) { return new ConfigIni($this->rootPath . $configPath . 'config.ini'); - } else { - if (file_exists($this->rootPath . $configPath. 'config.php')) { - $config = include($this->rootPath . $configPath . 'config.php'); - if (is_array($config)) { - $config = new Config($config); - } - - return $config; + } + if (file_exists($this->rootPath . $configPath. 'config.php')) { + $config = include($this->rootPath . $configPath . 'config.php'); + if (is_array($config)) { + $config = new Config($config); } + + return $config; } } $directory = new RecursiveDirectoryIterator('.'); $iterator = new RecursiveIteratorIterator($directory); foreach ($iterator as $f) { - if (preg_match('/\/config\.php$/i', $f->getPathName())) { + if (false !== strpos($f->getPathName(), 'config.php')) { $config = include $f->getPathName(); if (is_array($config)) { $config = new Config($config); } return $config; - } else { - if (preg_match('/config\.ini$/i', $f->getPathName())) { - return new ConfigIni($f->getPathName()); - } + } + if (false !== strpos($f->getPathName(), 'config.ini')) { + return new ConfigIni($f->getPathName()); } } From b85e7522975c9723b83476b153ff495e6bf88960 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Sun, 14 Mar 2021 17:35:21 +0000 Subject: [PATCH 6/9] Partial code reformat --- src/Options/OptionsAware.php | 8 +++----- src/Providers/AnnotationsProvider.php | 2 +- src/Providers/AssetsProvider.php | 2 +- src/Providers/AssetsResourceProvider.php | 2 +- src/Providers/DatabaseProvider.php | 2 +- src/Providers/DbUtilsProvider.php | 2 +- src/Providers/DispatcherProvider.php | 2 +- src/Providers/EventsManagerProvider.php | 2 +- src/Providers/FileSystemProvider.php | 2 +- src/Providers/LoggerProvider.php | 2 +- src/Providers/SessionProvider.php | 3 ++- src/Providers/SystemInfoProvider.php | 2 +- src/Providers/TagProvider.php | 2 +- src/Providers/UrlProvider.php | 14 +++++++------- src/Providers/ViewProvider.php | 6 +++--- src/Providers/VoltProvider.php | 12 ++++++------ src/Resources/AssetsResource.php | 2 +- src/Scanners/Config.php | 6 +++--- src/Utils/DbUtils.php | 4 ++-- src/Validation/Validator/Namespaces.php | 2 +- src/Web/Tools.php | 22 +++++++++++----------- 21 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/Options/OptionsAware.php b/src/Options/OptionsAware.php index bfa96766c..a84932050 100644 --- a/src/Options/OptionsAware.php +++ b/src/Options/OptionsAware.php @@ -30,11 +30,9 @@ class OptionsAware implements FactoryOptions /** * @param array $options */ - public function __construct(array $options = null) + public function __construct(array $options = []) { - if (!empty($options)) { - $this->options = $options; - } + $this->options = $options; } /** @@ -110,7 +108,7 @@ public function getOptions(): array public function getOption($key) { if (!isset($this->options[$key])) { - throw new InvalidArgumentException("Option " . $key . " has't been defined"); + throw new InvalidArgumentException("Option " . $key . " hasn't been defined"); } return $this->options[$key]; diff --git a/src/Providers/AnnotationsProvider.php b/src/Providers/AnnotationsProvider.php index 46ce02600..fcfdde90a 100644 --- a/src/Providers/AnnotationsProvider.php +++ b/src/Providers/AnnotationsProvider.php @@ -31,7 +31,7 @@ class AnnotationsProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new AnnotationsMemory; + return new AnnotationsMemory(); }); } } diff --git a/src/Providers/AssetsProvider.php b/src/Providers/AssetsProvider.php index 30003bdbe..61999abf5 100644 --- a/src/Providers/AssetsProvider.php +++ b/src/Providers/AssetsProvider.php @@ -31,7 +31,7 @@ class AssetsProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new AssetsManager; + return new AssetsManager(); }); } } diff --git a/src/Providers/AssetsResourceProvider.php b/src/Providers/AssetsResourceProvider.php index e1204b339..c31e3a8be 100644 --- a/src/Providers/AssetsResourceProvider.php +++ b/src/Providers/AssetsResourceProvider.php @@ -31,7 +31,7 @@ class AssetsResourceProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new AssetsResource; + return new AssetsResource(); }); } } diff --git a/src/Providers/DatabaseProvider.php b/src/Providers/DatabaseProvider.php index 0ff14899b..5ec089e16 100644 --- a/src/Providers/DatabaseProvider.php +++ b/src/Providers/DatabaseProvider.php @@ -38,7 +38,7 @@ public function register(DiInterface $di): void if ($this->getShared('config')->offsetExists('database')) { $config = $this->getShared('config')->get('database')->toArray(); } else { - $dbname = sys_get_temp_dir() . DS . 'phalcon.sqlite'; + $dbname = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phalcon.sqlite'; $this->getShared('logger')->warning( 'Unable to initialize "db" service. Used Sqlite adapter at path: {path}', ['path' => $dbname] diff --git a/src/Providers/DbUtilsProvider.php b/src/Providers/DbUtilsProvider.php index 3665689ba..25976efb8 100644 --- a/src/Providers/DbUtilsProvider.php +++ b/src/Providers/DbUtilsProvider.php @@ -31,7 +31,7 @@ class DbUtilsProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new DbUtils; + return new DbUtils(); }); } } diff --git a/src/Providers/DispatcherProvider.php b/src/Providers/DispatcherProvider.php index 6da904187..533c9ed65 100644 --- a/src/Providers/DispatcherProvider.php +++ b/src/Providers/DispatcherProvider.php @@ -37,7 +37,7 @@ public function register(DiInterface $di): void $access = $di->getShared('access'); $di->setShared($this->providerName, function () use ($eventsManager, $access) { - $dispatcher = new MvcDispatcher; + $dispatcher = new MvcDispatcher(); $dispatcher->setDefaultNamespace('Phalcon\DevTools\Web\Tools\Controllers'); $eventsManager->attach('dispatch', $access, 1000); diff --git a/src/Providers/EventsManagerProvider.php b/src/Providers/EventsManagerProvider.php index 2c72d62ab..5a3f08871 100644 --- a/src/Providers/EventsManagerProvider.php +++ b/src/Providers/EventsManagerProvider.php @@ -31,7 +31,7 @@ class EventsManagerProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - $em = new EventsManager; + $em = new EventsManager(); $em->enablePriorities(true); return $em; diff --git a/src/Providers/FileSystemProvider.php b/src/Providers/FileSystemProvider.php index 962faf64f..5873abde2 100644 --- a/src/Providers/FileSystemProvider.php +++ b/src/Providers/FileSystemProvider.php @@ -31,7 +31,7 @@ class FileSystemProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new FsUtils; + return new FsUtils(); }); } } diff --git a/src/Providers/LoggerProvider.php b/src/Providers/LoggerProvider.php index 00b4a8708..65f3528c8 100644 --- a/src/Providers/LoggerProvider.php +++ b/src/Providers/LoggerProvider.php @@ -38,7 +38,7 @@ public function register(DiInterface $di): void $basePath = $application->getBasePath(); $di->setShared($this->providerName, function () use ($hostName, $basePath) { - $ptoolsPath = $basePath . DS . '.phalcon' . DS; + $ptoolsPath = $basePath . DIRECTORY_SEPARATOR . '.phalcon' . DIRECTORY_SEPARATOR; if (is_dir($ptoolsPath) && is_writable($ptoolsPath)) { $formatter = new LineFormatter("%date% {$hostName} php: [%type%] %message%", 'D j H:i:s'); $adapter = new FileLogger($ptoolsPath . 'devtools.log'); diff --git a/src/Providers/SessionProvider.php b/src/Providers/SessionProvider.php index 4685c034d..095ac496b 100644 --- a/src/Providers/SessionProvider.php +++ b/src/Providers/SessionProvider.php @@ -32,10 +32,11 @@ class SessionProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - $session = new Manager(); $files = new SessionStream([ 'savePath' => sys_get_temp_dir(), ]); + + $session = new Manager(); $session->setAdapter($files); $session->start(); diff --git a/src/Providers/SystemInfoProvider.php b/src/Providers/SystemInfoProvider.php index 06d9455c9..d488f7946 100644 --- a/src/Providers/SystemInfoProvider.php +++ b/src/Providers/SystemInfoProvider.php @@ -31,7 +31,7 @@ class SystemInfoProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - return new SystemInfo; + return new SystemInfo(); }); } } diff --git a/src/Providers/TagProvider.php b/src/Providers/TagProvider.php index 1f6f7b444..92ef90555 100644 --- a/src/Providers/TagProvider.php +++ b/src/Providers/TagProvider.php @@ -31,7 +31,7 @@ class TagProvider implements ServiceProviderInterface public function register(DiInterface $di): void { $di->setShared($this->providerName, function () { - $tag = new Tag; + $tag = new Tag(); $tag->setDocType(Tag::HTML5); $tag->setTitleSeparator(' :: '); diff --git a/src/Providers/UrlProvider.php b/src/Providers/UrlProvider.php index 051c671f7..3c8ac3e62 100644 --- a/src/Providers/UrlProvider.php +++ b/src/Providers/UrlProvider.php @@ -35,23 +35,23 @@ public function register(DiInterface $di): void /** @var DiInterface $this */ $config = $this->getShared('config'); - $url = new UrlResolver; + $url = new UrlResolver(); - if ($config->get('application', new Config)->offsetExists('baseUri')) { - $baseUri = $config->get('application', new Config)->get('baseUri'); + if ($config->get('application', new Config())->offsetExists('baseUri')) { + $baseUri = $config->get('application', new Config())->get('baseUri'); } elseif ($config->offsetExists('baseUri')) { $baseUri = $config->get('baseUri'); } else { - // @todo Log notice here + // TODO: Log notice here $baseUri = '/'; } - if ($config->get('application', new Config)->offsetExists('staticUri')) { - $staticUri = $config->get('application', new Config)->get('staticUri'); + if ($config->get('application', new Config())->offsetExists('staticUri')) { + $staticUri = $config->get('application', new Config())->get('staticUri'); } elseif ($config->offsetExists('staticUri')) { $staticUri = $config->get('staticUri'); } else { - // @todo Log notice here + // TODO: Log notice here $staticUri = '/'; } diff --git a/src/Providers/ViewProvider.php b/src/Providers/ViewProvider.php index 662a3a3a9..03e74468f 100644 --- a/src/Providers/ViewProvider.php +++ b/src/Providers/ViewProvider.php @@ -44,11 +44,11 @@ public function register(DiInterface $di): void $view->registerEngines([ '.volt' => $this->getShared('volt', [$view, $this]), - '.phtml' => Php::class + '.phtml' => Php::class, ]); - $view->setViewsDir($registry->offsetGet('directories')->webToolsViews . DS) - ->setLayoutsDir('layouts' . DS) + $view->setViewsDir($registry->offsetGet('directories')->webToolsViews . DIRECTORY_SEPARATOR) + ->setLayoutsDir('layouts' . DIRECTORY_SEPARATOR) ->setRenderLevel(View::LEVEL_AFTER_TEMPLATE); $em = $this->getShared('eventsManager'); diff --git a/src/Providers/VoltProvider.php b/src/Providers/VoltProvider.php index fe77df2a9..5ce210b5b 100644 --- a/src/Providers/VoltProvider.php +++ b/src/Providers/VoltProvider.php @@ -49,7 +49,7 @@ public function register(DiInterface $di): void $config = $this->getShared('config'); $appCacheDir = $config->get('application', new Config)->get('cacheDir'); - $defaultCacheDir = sys_get_temp_dir() . DS . 'phalcon' . DS . 'volt'; + $defaultCacheDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phalcon' . DIRECTORY_SEPARATOR . 'volt'; /** @var Config $voltConfig */ $voltConfig = null; @@ -80,8 +80,8 @@ public function register(DiInterface $di): void */ if (0 === strpos($templatePath, $basePath)) { $templatePath = substr($templatePath, strlen($basePath)); - } elseif (0 === strpos($templatePath, $ptoolsPath . DS . 'src')) { - $templatePath = substr($templatePath, strlen($ptoolsPath . DS . 'src')); + } elseif (0 === strpos($templatePath, $ptoolsPath . DIRECTORY_SEPARATOR . 'src')) { + $templatePath = substr($templatePath, strlen($ptoolsPath . DIRECTORY_SEPARATOR . 'src')); } $templatePath = trim($templatePath, '\\/'); @@ -90,7 +90,7 @@ public function register(DiInterface $di): void $cacheDir = $that->getCacheDir($voltConfig); - return rtrim($cacheDir, '\\/') . DS . $filename; + return rtrim($cacheDir, '\\/') . DIRECTORY_SEPARATOR . $filename; }; $options = [ @@ -112,11 +112,11 @@ public function register(DiInterface $di): void * * @return string */ - protected function getCacheDir(Config $voltConfig) + protected function getCacheDir(Config $voltConfig): string { $appCacheDir = $this->di->getShared('config')->path('application.cacheDir'); $cacheDir = $voltConfig->get('cacheDir', $appCacheDir); - $defaultCacheDir = sys_get_temp_dir() . DS . 'phalcon' . DS . 'volt'; + $defaultCacheDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'phalcon' . DIRECTORY_SEPARATOR . 'volt'; if ($cacheDir && is_dir($cacheDir) && is_writable($cacheDir)) { return $cacheDir; diff --git a/src/Resources/AssetsResource.php b/src/Resources/AssetsResource.php index 8d56a7224..c0ee48930 100644 --- a/src/Resources/AssetsResource.php +++ b/src/Resources/AssetsResource.php @@ -28,6 +28,6 @@ class AssetsResource extends Injectable */ public function path(string $path): string { - return PTOOLSPATH . DS . 'resources' . DS . $this->fs->normalize($path); + return PTOOLSPATH . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . $this->fs->normalize($path); } } diff --git a/src/Scanners/Config.php b/src/Scanners/Config.php index 3a8dbeba3..eefcaf0d4 100644 --- a/src/Scanners/Config.php +++ b/src/Scanners/Config.php @@ -66,14 +66,14 @@ public function __construct($basePath) * @param string $filename The config basename. * @return null|PhConfig */ - public function scan($filename): ?PhConfig + public function scan(string $filename): ?PhConfig { $config = null; $filename = pathinfo($filename, PATHINFO_FILENAME); foreach ($this->getConfigPaths() as $probablyPath) { foreach ($this->configAdapters as $ext => $adapter) { - $probablyConfig = $probablyPath . DS . "{$filename}.{$ext}"; + $probablyConfig = $probablyPath . DIRECTORY_SEPARATOR . "{$filename}.{$ext}"; if (is_file($probablyConfig) && is_readable($probablyConfig)) { if (in_array($ext, ['php', 'php5', 'inc'])) { @@ -102,7 +102,7 @@ public function scan($filename): ?PhConfig * @return PhConfig * @throws Exception */ - public function load($filename): PhConfig + public function load(string $filename): PhConfig { $config = $this->scan($filename); diff --git a/src/Utils/DbUtils.php b/src/Utils/DbUtils.php index b7d1e2fb1..f2b026f6c 100644 --- a/src/Utils/DbUtils.php +++ b/src/Utils/DbUtils.php @@ -60,11 +60,11 @@ public function resolveDbSchema(): ?string return $config->get('schema'); } - if ('Postgresql' == $config->get('adapter')) { + if ('Postgresql' === $config->get('adapter')) { return 'public'; } - if ('Sqlite' == $config->get('adapter')) { + if ('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; diff --git a/src/Validation/Validator/Namespaces.php b/src/Validation/Validator/Namespaces.php index fcbea73eb..1feb84371 100644 --- a/src/Validation/Validator/Namespaces.php +++ b/src/Validation/Validator/Namespaces.php @@ -48,7 +48,7 @@ public function validate(Validation $validation, $field): bool $re = '#^(?:(?:\\\)?[a-z](?:[a-z0-9_]+)?)+(?:\\\\(?:[a-z](?:[a-z0-9_]+)?)+)*$#i'; - if (false === (bool)preg_match($re, $value)) { + if (!preg_match($re, $value)) { $label = $this->getOption('label') ?: $validation->getLabel($field); $message = $this->getOption('message') ?: 'Invalid namespace syntax!'; $replacePairs = array(':field' => $label); diff --git a/src/Web/Tools.php b/src/Web/Tools.php index e4c172846..da2877ff8 100644 --- a/src/Web/Tools.php +++ b/src/Web/Tools.php @@ -34,18 +34,18 @@ class Tools public static function install(string $path): void { $fsUtils = new FsUtils(); - $path = $fsUtils->normalize(realpath($path)) . DS; - $publicPath = $path . self::PROJECT_PUBLIC_FOLDER . DS; + $path = $fsUtils->normalize(realpath($path)) . DIRECTORY_SEPARATOR; + $publicPath = $path . self::PROJECT_PUBLIC_FOLDER . DIRECTORY_SEPARATOR; $root = new SplFileInfo($publicPath); $fsUtils->setDirectoryPermission($root, ['js' => 0777, 'css' => 0777]); - $tools = rtrim(str_replace(["\\", '/'], DS, PTOOLSPATH), DS); + $tools = rtrim(str_replace(["\\", '/'], DIRECTORY_SEPARATOR, PTOOLSPATH), DIRECTORY_SEPARATOR); - copy($tools . DS . self::WEB_TOOLS_FILE, $publicPath . self::WEB_TOOLS_FILE); + copy($tools . DIRECTORY_SEPARATOR . self::WEB_TOOLS_FILE, $publicPath . self::WEB_TOOLS_FILE); if (!file_exists($configPath = $publicPath . self::WEB_TOOLS_CONFIG_FILE)) { - $template = file_get_contents(TEMPLATE_PATH . DS . self::WEB_TOOLS_CONFIG_FILE); + $template = file_get_contents(TEMPLATE_PATH . DIRECTORY_SEPARATOR . self::WEB_TOOLS_CONFIG_FILE); $code = str_replace('@@PATH@@', $tools, $template); file_put_contents($configPath, $code); @@ -59,16 +59,16 @@ public static function install(string $path): void * @return void * @throws Exception */ - public static function uninstall($path): void + public static function uninstall(string $path): void { $fsUtils = new FsUtils(); - $path = $fsUtils->normalize(realpath($path)) . DS; + $path = $fsUtils->normalize(realpath($path)) . DIRECTORY_SEPARATOR; - $root = new SplFileInfo($path . self::PROJECT_PUBLIC_FOLDER . DS); + $root = new SplFileInfo($path . self::PROJECT_PUBLIC_FOLDER . DIRECTORY_SEPARATOR); $fsUtils->deleteFilesFromDirectory($root, [ - 'css' . DS . 'webtools.css', - 'js' . DS . 'webtools.js', - 'js' . DS . 'webtools-ie.js', + 'css' . DIRECTORY_SEPARATOR . 'webtools.css', + 'js' . DIRECTORY_SEPARATOR . 'webtools.js', + 'js' . DIRECTORY_SEPARATOR . 'webtools-ie.js', self::WEB_TOOLS_CONFIG_FILE, self::WEB_TOOLS_FILE, ]); From 56c27d908d300e4d384701f11ef1fc0efc23fdc9 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Sun, 14 Mar 2021 17:35:49 +0000 Subject: [PATCH 7/9] Correct namespaces in tests --- composer.json | 8 ++- composer.lock | 12 ++-- tests/_support/Module/UnitTest.php | 2 +- .../{phtml => }/ScaffoldPhtmlCest.php | 55 +++++++------------ .../Template/{volt => }/ScaffoldVoltCest.php | 43 +++++++-------- tests/console/GenerateMultyModelsCept.php | 18 +++++- tests/console/GenerateProjectCept.php | 22 ++++++-- tests/console/GenerateScaffoldCept.php | 18 +++++- tests/console/GenerateSingleModelCept.php | 18 +++++- .../functional/Commands/Builtin/ServeTest.php | 7 ++- tests/unit/Generator/SnippetTest.php | 2 +- tests/unit/UtilsTest.php | 16 +++--- 12 files changed, 136 insertions(+), 85 deletions(-) rename tests/acceptance/Web/Template/{phtml => }/ScaffoldPhtmlCest.php (82%) rename tests/acceptance/Web/Template/{volt => }/ScaffoldVoltCest.php (84%) diff --git a/composer.json b/composer.json index 2a5d0b84e..f3efb9a50 100644 --- a/composer.json +++ b/composer.json @@ -52,9 +52,11 @@ }, "autoload-dev": { "psr-4": { - "Phalcon\\Test\\": "tests/unit", - "Phalcon\\Test\\Models\\": "tests/_data/models", - "Phalcon\\Test\\Module\\": "tests/_support/Module" + "Phalcon\\DevTools\\Tests\\Acceptance\\": "tests/acceptance/", + "Phalcon\\DevTools\\Tests\\Console\\": "tests/console/", + "Phalcon\\DevTools\\Tests\\Functional\\": "tests/functional/", + "Phalcon\\DevTools\\Tests\\Unit\\": "tests/unit/", + "Phalcon\\DevTools\\Tests\\Support\\Module\\": "tests/_support/Module" }, "files": [ "tests/_support/helpers.php" diff --git a/composer.lock b/composer.lock index 0f3ed06b3..8692e107d 100644 --- a/composer.lock +++ b/composer.lock @@ -362,16 +362,16 @@ }, { "name": "psy/psysh", - "version": "v0.10.6", + "version": "v0.10.7", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "6f990c19f91729de8b31e639d6e204ea59f19cf3" + "reference": "a395af46999a12006213c0c8346c9445eb31640c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/6f990c19f91729de8b31e639d6e204ea59f19cf3", - "reference": "6f990c19f91729de8b31e639d6e204ea59f19cf3", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/a395af46999a12006213c0c8346c9445eb31640c", + "reference": "a395af46999a12006213c0c8346c9445eb31640c", "shasum": "" }, "require": { @@ -432,9 +432,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.10.6" + "source": "https://github.com/bobthecow/psysh/tree/v0.10.7" }, - "time": "2021-01-18T15:53:43+00:00" + "time": "2021-03-14T02:14:56+00:00" }, { "name": "symfony/console", diff --git a/tests/_support/Module/UnitTest.php b/tests/_support/Module/UnitTest.php index 4c0b2f409..ab7fbafcd 100644 --- a/tests/_support/Module/UnitTest.php +++ b/tests/_support/Module/UnitTest.php @@ -1,6 +1,6 @@ registerNamespaces(' . - $returnLine . '[ '. - '"'.$namespace.'" => $config->application->modelsDir' . - $returnLine . ' ]' . + $returnLine . '[ ' . + '"' . $namespace . '" => $config->application->modelsDir' . + $returnLine . ' ]' . $returnLine . ');'; file_put_contents($loaderFile, $content); @@ -55,6 +55,7 @@ public function before(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testGenScaffoldFileExist(AcceptanceTester $I): void { @@ -115,12 +116,13 @@ public function testGenScaffoldFileExist(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testSearchAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename')); + $I->amOnPage('/' . Fixtures::get('tablename')); $I->see(Fixtures::get('tablename')); - $I->see('Search '.Fixtures::get('tablename')); + $I->see('Search ' . Fixtures::get('tablename')); $I->see('Dateofbirth'); $I->fillField('dateofbirth', '2019-04-17'); $I->click('input[type=submit]'); @@ -130,37 +132,34 @@ public function testSearchAction(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testSearchButtonAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename').'/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click("#next"); - $I->see("K1S6X"); $I->click("#previous"); - $I->see("U7B0Q"); $I->click("#last"); - $I->see("N2Z7T"); $I->click("#first"); - $I->see("U7B0Q"); } - /** * @group mysql + * @param AcceptanceTester $I */ public function testNewAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename').'/new'); - $I->see('Create '.Fixtures::get('tablename')); + $I->amOnPage('/' . Fixtures::get('tablename') . '/new'); + $I->see('Create ' . Fixtures::get('tablename')); $I->fillField('firstname', 'jeremy'); $I->fillField('surname', 'jenovateurs'); $I->fillField('membertype', 'aaa'); @@ -170,47 +169,35 @@ public function testNewAction(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testEditAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click(['link' => 'Edit']); $I->seeInField('firstname', 'Hedley'); $I->fillField('firstname', 'samedi'); $I->click('input[type=submit]'); - $I->amOnPage('/'.Fixtures::get('tablename'). + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); //Check if edit work - // $I->see('samedi'); + // $I->see('samedi'); } /** * @group mysql + * @param AcceptanceTester $I */ public function testDeleteAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click(['link' => 'Delete']); $I->see('customer was deleted successfully'); - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->cantSee('Hedley'); } - - /** - * @group mysql - */ - public function after(AcceptanceTester $I): void - { - /*$I->deleteFile(Fixtures::get('controller')); - $I->deleteFile(Fixtures::get('model')); - $I->deleteFile(Fixtures::get('layout')); - $I->deleteDir(Fixtures::get('views'));*/ - } } diff --git a/tests/acceptance/Web/Template/volt/ScaffoldVoltCest.php b/tests/acceptance/Web/Template/ScaffoldVoltCest.php similarity index 84% rename from tests/acceptance/Web/Template/volt/ScaffoldVoltCest.php rename to tests/acceptance/Web/Template/ScaffoldVoltCest.php index 63c78430b..07c0d3331 100644 --- a/tests/acceptance/Web/Template/volt/ScaffoldVoltCest.php +++ b/tests/acceptance/Web/Template/ScaffoldVoltCest.php @@ -5,12 +5,12 @@ use AcceptanceTester; use Codeception\Util\Fixtures; -use Codeception\Util\Locator; final class ScaffoldVoltCest { /** * @group mysql + * @param AcceptanceTester $I */ public function before(AcceptanceTester $I): void { @@ -45,9 +45,9 @@ public function before(AcceptanceTester $I): void $content .= $returnLine . '$loader->registerNamespaces(' . - $returnLine . '[ '. - '"'.$namespace.'" => $config->application->modelsDir' . - $returnLine . ' ]' . + $returnLine . '[ ' . + '"' . $namespace . '" => $config->application->modelsDir' . + $returnLine . ' ]' . $returnLine . ');'; file_put_contents($loaderFile, $content); @@ -55,6 +55,7 @@ public function before(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testGenScaffoldFileExist(AcceptanceTester $I): void { @@ -115,12 +116,13 @@ public function testGenScaffoldFileExist(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testSearchAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename')); + $I->amOnPage('/' . Fixtures::get('tablename')); $I->see(Fixtures::get('tablename')); - $I->see('Search '.Fixtures::get('tablename')); + $I->see('Search ' . Fixtures::get('tablename')); $I->see('Dateofbirth'); $I->fillField('dateofbirth', '2019-04-17'); $I->click('input[type=submit]'); @@ -130,37 +132,34 @@ public function testSearchAction(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testSearchButtonAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename').'/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click("#next"); - $I->see("K1S6X"); $I->click("#previous"); - $I->see("W2Q7K"); $I->click("#last"); - $I->see("N2Z7T"); $I->click("#first"); - $I->see("W2Q7K"); } - /** * @group mysql + * @param AcceptanceTester $I */ public function testNewAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename').'/new'); - $I->see('Create '.Fixtures::get('tablename')); + $I->amOnPage('/' . Fixtures::get('tablename') . '/new'); + $I->see('Create ' . Fixtures::get('tablename')); $I->fillField('firstname', 'jeremy'); $I->fillField('surname', 'jenovateurs'); $I->fillField('membertype', 'aaa'); @@ -170,41 +169,41 @@ public function testNewAction(AcceptanceTester $I): void /** * @group mysql + * @param AcceptanceTester $I */ public function testEditAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename'). + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click(['link' => 'Edit']); $I->seeInField('firstname', 'Lillian'); $I->fillField('firstname', 'samedi'); $I->click('input[type=submit]'); - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); //Check if edit work - // $I->see('samedi'); + // $I->see('samedi'); } /** * @group mysql + * @param AcceptanceTester $I */ public function testDeleteAction(AcceptanceTester $I): void { - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->see('Search result'); $I->click(['link' => 'Delete']); $I->see('customer was deleted successfully'); - $I->amOnPage('/'.Fixtures::get('tablename'). - '/search'); + $I->amOnPage('/' . Fixtures::get('tablename') . '/search'); $I->cantSee('samedi'); } /** * @group mysql + * @param AcceptanceTester $I */ public function after(AcceptanceTester $I): void { diff --git a/tests/console/GenerateMultyModelsCept.php b/tests/console/GenerateMultyModelsCept.php index 36533d7aa..db283c4d6 100644 --- a/tests/console/GenerateMultyModelsCept.php +++ b/tests/console/GenerateMultyModelsCept.php @@ -1,7 +1,23 @@ + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\DevTools\Tests\Console; + +use Codeception\Scenario; +use ConsoleTester; + +/** + * @var Scenario $scenario */ $I = new ConsoleTester($scenario); diff --git a/tests/console/GenerateProjectCept.php b/tests/console/GenerateProjectCept.php index 0bb930fba..4ffa73a71 100644 --- a/tests/console/GenerateProjectCept.php +++ b/tests/console/GenerateProjectCept.php @@ -1,16 +1,28 @@ + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\DevTools\Tests\Console; + +use Codeception\Scenario; +use ConsoleTester; + +/** + * @var Scenario $scenario */ $I = new ConsoleTester($scenario); $I->wantToTest('Generating project'); -$output=<< + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\DevTools\Tests\Console; + +use Codeception\Scenario; +use ConsoleTester; + +/** + * @var Scenario $scenario */ $I = new ConsoleTester($scenario); diff --git a/tests/console/GenerateSingleModelCept.php b/tests/console/GenerateSingleModelCept.php index 80288c321..7b0e3a2d6 100644 --- a/tests/console/GenerateSingleModelCept.php +++ b/tests/console/GenerateSingleModelCept.php @@ -1,7 +1,23 @@ + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\DevTools\Tests\Console; + +use Codeception\Scenario; +use ConsoleTester; + +/** + * @var Scenario $scenario */ $I = new ConsoleTester($scenario); diff --git a/tests/functional/Commands/Builtin/ServeTest.php b/tests/functional/Commands/Builtin/ServeTest.php index 64080d3e0..c7c49c25a 100644 --- a/tests/functional/Commands/Builtin/ServeTest.php +++ b/tests/functional/Commands/Builtin/ServeTest.php @@ -1,7 +1,4 @@ Date: Sun, 14 Mar 2021 18:17:43 +0000 Subject: [PATCH 8/9] Bump version to 4.0.5 --- src/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Version.php b/src/Version.php index d3fcaf39d..81c8f0688 100644 --- a/src/Version.php +++ b/src/Version.php @@ -27,7 +27,7 @@ class Version extends PhVersion // phpcs:disable protected static function _getVersion(): array { - return [4, 0, 4, 0, 0]; + return [4, 0, 5, 0, 0]; } // phpcs:enable } From bb1c795467c03c8678dd23624419173954a9be93 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev Date: Sun, 14 Mar 2021 18:20:29 +0000 Subject: [PATCH 9/9] Update CHANGELOG.md --- CHANGELOG.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8125a8062..e9e07c17d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,10 @@ -# [4.0.5](https://github.com/phalcon/cphalcon/releases/tag/v4.0.5) -## Added - +# [4.0.5](https://github.com/phalcon/cphalcon/releases/tag/v4.0.5) (2021-03-14) ## Fixed - Fixed model creation failure in webtools due to wrong variable mutation [#1415](https://github.com/phalcon/phalcon-devtools/issues/1415) - Fixed config path detection to platform independent [#1426](https://github.com/phalcon/phalcon-devtools/issues/1426) -## Changed -[4.0.4](https://github.com/phalcon/cphalcon/releases/tag/v4.0.4) (2021-03-11) +# [4.0.4](https://github.com/phalcon/cphalcon/releases/tag/v4.0.4) (2021-03-11) ## Added - Added support for PHP `7.4` [#1482](https://github.com/phalcon/phalcon-devtools/pull/1482)