Page MenuHomePhorge

PHP 8.2: creation of dynamic property is deprecated
Closed, ResolvedPublic

Description

This specific error was raised when using PHP 8.2 and arc unit --everything in Phorge:

Creation of dynamic property PhabricatorAuthPasswordException::$confirmError is deprecated

Stack trace:

FAIL  PhabricatorAuthPasswordTestCase::testPasswordBlocklisting
EXCEPTION (RuntimeException): Creation of dynamic property PhabricatorAuthPasswordException::$confirmError is deprecated
#0 /var/www/phorge/src/applications/auth/password/PhabricatorAuthPasswordException.php(15): PhutilErrorHandler::handleError(8192, '...', '...', 15)
#1 /var/www/phorge/src/applications/auth/engine/PhabricatorAuthPasswordEngine.php(70): PhabricatorAuthPasswordException->__construct('...', '...')
#2 /var/www/phorge/src/applications/auth/__tests__/PhabricatorAuthPasswordTestCase.php(166): PhabricatorAuthPasswordEngine->checkNewPassword(Object(PhutilOpaqueEnvelope), Object(PhutilOpaqueEnvelope))
#3 /var/www/phorge/src/applications/auth/__tests__/PhabricatorAuthPasswordTestCase.php(152): PhabricatorAuthPasswordTestCase->assertBlocklistedPassword(Object(PhabricatorAuthPasswordEngine), '', false)
#4 /var/www/arcanist/src/unit/engine/phutil/PhutilTestCase.php(634): PhabricatorAuthPasswordTestCase->testPasswordBlocklisting()
#5 /var/www/arcanist/src/unit/engine/PhutilUnitTestEngine.php(69): PhutilTestCase->run()
#6 /var/www/arcanist/src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php(148): PhutilUnitTestEngine->run()
#7 /var/www/arcanist/src/workflow/ArcanistUnitWorkflow.php(170): ArcanistConfigurationDrivenUnitTestEngine->run()
#8 /var/www/arcanist/scripts/arcanist.php(427): ArcanistUnitWorkflow->run()
#9 {main}

Official reference:

https://www.php.net/manual/en/migration82.deprecated.php

Additional resources:

https://php.watch/versions/8.2/dynamic-properties-deprecated

Basic example that does not work anymore:

<?php
error_reporting(E_ALL);

class User {
    public function __construct() {
        $this->name = 'test';
    }
}

new User();

Requested change:

<?php
error_reporting(E_ALL);

class User {

+   private $name;

    public function __construct() {
        $this->name = 'test';
    }
}

new User();

Event Timeline

valerio.bozzolan triaged this task as High priority.
valerio.bozzolan created this object in space S1 Public.