Skip to content

Commit

Permalink
Merge pull request #1489 from phalcon/4.0.x
Browse files Browse the repository at this point in the history
4.0.5
  • Loading branch information
Jeckerson authored Mar 14, 2021
2 parents a6d8e8a + 94d96c9 commit 8f473bf
Show file tree
Hide file tree
Showing 41 changed files with 215 additions and 169 deletions.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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):
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# [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)


# [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)
Expand Down
7 changes: 1 addition & 6 deletions bootstrap/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}

Expand Down Expand Up @@ -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)
*/
Expand Down
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phalcon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/Builder/Component/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
26 changes: 12 additions & 14 deletions src/Builder/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/Options/OptionsAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/AnnotationsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
2 changes: 1 addition & 1 deletion src/Providers/AssetsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
2 changes: 1 addition & 1 deletion src/Providers/AssetsResourceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
2 changes: 1 addition & 1 deletion src/Providers/DatabaseProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/DbUtilsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
2 changes: 1 addition & 1 deletion src/Providers/DispatcherProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/EventsManagerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/FileSystemProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
2 changes: 1 addition & 1 deletion src/Providers/LoggerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion src/Providers/SessionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/SystemInfoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
}
2 changes: 1 addition & 1 deletion src/Providers/TagProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(' :: ');
Expand Down
14 changes: 7 additions & 7 deletions src/Providers/UrlProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '/';
}

Expand Down
6 changes: 3 additions & 3 deletions src/Providers/ViewProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
12 changes: 6 additions & 6 deletions src/Providers/VoltProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, '\\/');
Expand All @@ -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 = [
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/AssetsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading

0 comments on commit 8f473bf

Please sign in to comment.