Call to private method Phalcon\Config\Adapter\Ini::_cast() Error thrown when calling parent::__construct() from child class #12230

Closed
Yogarine opened this Issue Sep 18, 2016 · 1 comment

Projects

None yet

2 participants

@Yogarine
Yogarine commented Sep 18, 2016 edited

Expected and Actual Behavior

I'm extending Phalcon\Config\Adapter\Ini like this:

use Phalcon\Config\Adapter\Ini as IniConfig;

/**
 * Special Ini Config that merges all the supplied files into one.
 *
 * @author Alwin Garside <alwin@garsi.de>
 * @copyright Copyright © 2015 Alwin Garside
 */
class CascadedConfig extends IniConfig
{
    /**
     * CascadedConfig constructor.
     *
     * @param string $filePath
     * @param string $_
     * @throws ConfigException
     */
    public function __construct($filePath, $_)
    {
        $args = func_get_args();
        $firstConfigFound = false;
        foreach($args as $arg)
        {
            if(file_exists($arg))
            {
                if(!$firstConfigFound)
                {
                    $firstConfigFound = true;
                    parent::__construct($arg);
                }
                else
                {
                    $this->merge(new IniConfig($arg));
                }
            }
        }

        if(!$firstConfigFound)
        {
            throw new ConfigException("Unable to find any of these config files: '" . implode("', '", $args) . "'");
        }
    }
}

In Phalcon 2 on PHP 5.6 this used to work just fine, but in PHP 7 with Phalcon 3 this gives the following error:

Error: Call to private method Phalcon\Config\Adapter\Ini::_cast() from context 'CascadedConfig' in CascadedConfig.php on line 30

Details

  • Phalcon version: 3.0.1
  • PHP Version: 7.0.11
  • Operating System: macOS 10.12 Sierra
  • Installation type: installing via package manager
  • Server: PHP built in web server
@sergeyklay sergeyklay added this to the 3.0.2 milestone Sep 18, 2016
@sergeyklay sergeyklay self-assigned this Sep 18, 2016
@sergeyklay
Collaborator

Fixed in the 3.0.x branch.

@sergeyklay sergeyklay closed this Sep 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment