PHP-Auth
PHP-Auth copied to clipboard
PHP 8.4 Deprecation?
I get the following when testing a pretty basic setup on PHP 8.4.3. It looks like it's this deprecation (https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated) and I'm wondering if there's a roadmap to make this PHP 8.4 compatible, or if I've done something wrong. Thanks.
Deprecated: Delight\Db\PdoDatabase::__construct(): Implicitly marking parameter $pdoInstance as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 49
Deprecated: Delight\Db\PdoDatabase::__construct(): Implicitly marking parameter $pdoDsn as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 49
Deprecated: Delight\Db\PdoDatabase::select(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 117
Deprecated: Delight\Db\PdoDatabase::selectValue(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 124
Deprecated: Delight\Db\PdoDatabase::selectRow(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 131
Deprecated: Delight\Db\PdoDatabase::selectColumn(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 138
Deprecated: Delight\Db\PdoDatabase::exec(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 246
Deprecated: Delight\Db\PdoDatabase::setProfiler(): Implicitly marking parameter $profiler as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 364
Deprecated: Delight\Db\PdoDatabase::configureConnection(): Implicitly marking parameter $newAttributes as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 514
Deprecated: Delight\Db\PdoDatabase::configureConnection(): Implicitly marking parameter $oldAttributes as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 514
Deprecated: Delight\Db\PdoDatabase::selectInternal(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\PdoDatabase.php on line 567
Deprecated: Delight\Db\Database::select(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\Database.php on line 31
Deprecated: Delight\Db\Database::selectValue(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\Database.php on line 44
Deprecated: Delight\Db\Database::selectRow(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\Database.php on line 57
Deprecated: Delight\Db\Database::selectColumn(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\Database.php on line 70
Deprecated: Delight\Db\Database::exec(): Implicitly marking parameter $bindValues as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\Database.php on line 117
Deprecated: Delight\Db\Database::setProfiler(): Implicitly marking parameter $profiler as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\db\src\Database.php on line 183
Deprecated: Delight\Auth\Auth::register(): Implicitly marking parameter $callback as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\auth\src\Auth.php on line 228
Deprecated: Delight\Auth\Auth::registerWithUniqueUsername(): Implicitly marking parameter $callback as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\auth\src\Auth.php on line 269
Deprecated: Delight\Auth\Auth::login(): Implicitly marking parameter $onBeforeSuccess as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\auth\src\Auth.php on line 294
Deprecated: Delight\Auth\Auth::loginWithUsername(): Implicitly marking parameter $onBeforeSuccess as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\auth\src\Auth.php on line 319
Deprecated: Delight\Auth\Auth::authenticateUserInternal(): Implicitly marking parameter $onBeforeSuccess as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\auth\src\Auth.php on line 1035
Deprecated: Delight\Auth\UserManager::createUserInternal(): Implicitly marking parameter $callback as nullable is deprecated, the explicit nullable type must be used instead in \php-auth\vendor\delight-im\auth\src\UserManager.php on line 125
Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in \php-auth\vendor\delight-im\auth\src\Auth.php on line 61
Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in \php-auth\vendor\delight-im\auth\src\Auth.php on line 63
Warning: ini_set(): Session ini settings cannot be changed after headers have already been sent in \php-auth\vendor\delight-im\auth\src\Auth.php on line 65
Thanks!
Yes, the fix is very easy. But unfortunately, we still have to support PHP 7.0, for example for clients on Ubuntu with Ubuntu Expanded Security Maintenance (ESM).
In production, you should obviously disable deprecation warnings. But for development environments, our only choice right now may be to drop the type annotations (turning SomeClass $someParam = null into just $someParam = null) to get rid of the implicit null in the annotation, until we can drop PHP 7.0 support.
So for now, to keep PHP 7.0 support, we won’t be able to avoid this deprecation warning just yet.
But there is no reason you should be bothered by the messages, as it’s not an error, doesn’t break logic or behavior, and it’s not even in your own code where you need to care about it. So if you are distracted by the deprecation warnings, maybe consider suppressing them for this library.
For example, where you include the dependencies from Composer with
require __DIR__ . '/vendor/autoload.php';
consider adding a custom PHP error handler that suppresses only deprecation warnings that come from this library here, using the same base for the vendor directory with __DIR__ . '/vendor/:
\set_error_handler(function ($errno, $errstr, $errfile, $errline) {
// if the error is a deprecation warning
if ($errno & (\E_DEPRECATED | \E_USER_DEPRECATED)) {
// if the error is a warning from third-party dependency 'PHP-Auth'
if (\strpos(\str_replace('\\', '/', $errfile), \str_replace('\\', '/', (__DIR__ . '/vendor/delight-im/auth/'))) === 0) {
// suppress the error
return true;
}
}
// let PHP's standard error handler handle the error
return false;
});