Llevo poco más de un día con este problema, revisé la posible similaridad de mi pregunta con otras, pero la verdad, ninguna me ha funcionado.
Estoy teniendo el siguiente error en PHP:
Fatal error: Uncaught Error: Call to a member function get() on null
Archivo Url.php, línea 28.
Url.php:
<?php
class Url extends App {
private $db;
private static $alias = null;
private static $mcpe_list = null;
private static $url2 = null;
private static $clicks = 0;
private static $name = null;
private static $password = null;
public function __construct() {
$this->db = json_decode(file_get_contents('/../' . $this->config->get('DB_PATH')), true);
}
}
App.php:
<?php
class App {
protected $error;
protected $url;
protected $config;
const CFG_PATH = 'private/config.json';
const VAL_ERRORS = [400, 401, 403, 404, 500];
public function __construct() {
$this->error = new Error();
$this->url = new Url();
$this->config = new Config(self::CFG_PATH);
}
}
En el constructor de la clase Url ocurre el error, $this->config->get('DB_PATH')
.
En la clase App se crean las instancias y como Url extiende a App, se heredan las propiedades protegidas.
Gracias por sus respuestas.