-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14986 from phalcon/fix/config-factory-load
Fixed incorrect return type hints for ConfigFactory
- Loading branch information
Showing
5 changed files
with
43 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,20 +4,14 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\Config; | ||
|
||
use Phalcon\Config; | ||
use Phalcon\Config\Adapter\Grouped; | ||
use Phalcon\Config\Adapter\Ini; | ||
use Phalcon\Config\Adapter\Json; | ||
use Phalcon\Config\Adapter\Php; | ||
use Phalcon\Config\Adapter\Yaml; | ||
use Phalcon\Factory\AbstractFactory; | ||
use Phalcon\Factory\Exception as FactoryException; | ||
use Phalcon\Helper\Arr; | ||
|
||
/** | ||
|
@@ -55,7 +49,7 @@ class ConfigFactory extends AbstractFactory | |
* 'callbacks' => null | ||
* ] | ||
*/ | ||
public function load(config) -> object | ||
public function load(config) -> <Config> | ||
{ | ||
var adapter, extension, first, oldConfig, second; | ||
|
||
|
@@ -117,7 +111,7 @@ class ConfigFactory extends AbstractFactory | |
/** | ||
* Returns a new Config instance | ||
*/ | ||
public function newInstance(string name, string fileName, var params = null) -> object | ||
public function newInstance(string name, string fileName, var params = null) -> <Config> | ||
{ | ||
var definition, options; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
@@ -15,6 +15,7 @@ | |
|
||
use Phalcon\Config; | ||
use Phalcon\Config\Adapter\Ini; | ||
|
||
use function dataDir; | ||
use function outputDir; | ||
|
||
|
@@ -35,8 +36,10 @@ trait FactoryTrait | |
|
||
/** | ||
* Initializes the main config | ||
* | ||
* @return void | ||
*/ | ||
protected function init() | ||
protected function init(): void | ||
{ | ||
$configFile = dataDir('assets/config/factory.ini'); | ||
|
||
|
@@ -47,8 +50,10 @@ protected function init() | |
|
||
/** | ||
* Initializes the logger config - this is special because it is nested | ||
* | ||
* @return void | ||
*/ | ||
protected function initLogger() | ||
protected function initLogger(): void | ||
{ | ||
$options = [ | ||
'logger' => [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
@@ -29,22 +29,30 @@ class LoadCest | |
{ | ||
use FactoryTrait; | ||
|
||
public function _before(UnitTester $I) | ||
/** | ||
* Executed before each test | ||
* | ||
* @param UnitTester $I | ||
* @return void | ||
*/ | ||
public function _before(UnitTester $I): void | ||
{ | ||
$this->init(); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Config\ConfigFactory :: load() - Config | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Wojciech Ślawski <[email protected]> | ||
* @since 2017-03-02 | ||
*/ | ||
public function configFactoryLoadConfig(UnitTester $I) | ||
{ | ||
$I->wantToTest('Config\ConfigFactory - load() - Config'); | ||
|
||
$options = $this->config->config; | ||
$options = $this->config->get('config'); | ||
|
||
/** @var Ini $ini */ | ||
$ini = (new ConfigFactory())->load($options); | ||
|
@@ -63,7 +71,7 @@ public function configFactoryLoadConfig(UnitTester $I) | |
); | ||
|
||
/** @var Ini $ini */ | ||
$ini = (new ConfigFactory())->load($ini->config->toArray()); | ||
$ini = (new ConfigFactory())->load($ini->get('config')->toArray()); | ||
|
||
$I->assertInstanceOf( | ||
Ini::class, | ||
|
@@ -74,6 +82,8 @@ public function configFactoryLoadConfig(UnitTester $I) | |
/** | ||
* Tests Phalcon\Config\ConfigFactory :: load() - array | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Wojciech Ślawski <[email protected]> | ||
* @since 2017-03-02 | ||
*/ | ||
|
@@ -95,6 +105,8 @@ public function configFactoryLoadArray(UnitTester $I) | |
/** | ||
* Tests Phalcon\Config\ConfigFactory :: load() - string | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Wojciech Ślawski <[email protected]> | ||
* @since 2017-11-24 | ||
*/ | ||
|
@@ -116,6 +128,8 @@ public function configFactoryLoadString(UnitTester $I) | |
/** | ||
* Tests Phalcon\Config\ConfigFactory :: load() - exception | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-06-19 | ||
*/ | ||
|
@@ -169,6 +183,8 @@ function () { | |
/** | ||
* Tests Phalcon\Config\ConfigFactory :: load() - yaml callback | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-06-19 | ||
*/ | ||
|
@@ -198,6 +214,8 @@ public function configFactoryLoadYamlCallback(UnitTester $I) | |
/** | ||
* Tests Phalcon\Config\ConfigFactory :: load() - two calls new instances | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-12-07 | ||
* @issue 14584 | ||
|
@@ -211,11 +229,11 @@ public function configFactoryLoadTwoCallsNewInstances(UnitTester $I) | |
$configFile1 = dataDir('assets/config/config.php'); | ||
$config = $factory->load($configFile1); | ||
|
||
$I->assertEquals("/phalcon/", $config->phalcon->baseUri); | ||
$I->assertEquals("/phalcon/", $config->get('phalcon')->baseUri); | ||
|
||
$configFile2 = dataDir('assets/config/config-2.php'); | ||
$config2 = $factory->load($configFile2); | ||
|
||
$I->assertEquals("/phalcon4/", $config2->phalcon->baseUri); | ||
$I->assertEquals("/phalcon4/", $config2->get('phalcon')->baseUri); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
* | ||
* (c) Phalcon Team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE.txt | ||
* file that was distributed with this source code. | ||
* For the full copyright and license information, please view the | ||
* LICENSE.txt file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
@@ -27,6 +27,8 @@ class NewInstanceCest | |
/** | ||
* Tests Phalcon\Logger\LoggerFactory :: newInstance() | ||
* | ||
* @param UnitTester $I | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2019-05-03 | ||
*/ | ||
|