Why is it not possible to hide the constructor in a child class?
I am getting the following Exception:
Fatal error: Access level to CIS\Logger\WPLogger::__construct() must be public (as in class Katzgrau\KLogger\Logger) in /builds/r2o/website/wp-content/mu-plugins/toolsets/lib/cis-logger/src/WPLogger.php on line 12
Code of superclass (from external library):
public function __construct($logDirectory, $logLevelThreshold = LogLevel::DEBUG, array $options = array()) { // ...
}
Code of WPLogger.php (subclass):
private function __construct(string $logDirectory, string $logLevelThreshold = LogLevel::DEBUG, array $options = array()) {
parent::__construct($logDirectory, $logLevelThreshold, $options);
// ... some actions
}
}
public static function getInstance(string $logFileRelative = self::DEFAULT_LOG_NAME, string $logLevelThreshold = LogLevel::DEBUG, array $options = array()) {
// ...
}
I do not want this special subclass to be instantiated with new. I want it to be created statically with getInstance() instead for some reasons. How can I achieve this?