function PhpassHashedPasswordBase::__construct

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Password/PhpassHashedPasswordBase.php \Drupal\Core\Password\PhpassHashedPasswordBase::__construct()

Constructs a new password hashing instance.

Parameters

\Drupal\Core\Password\PasswordInterface|int $corePassword: The core PHP password interface (or the countLog2 value for BC).

File

core/lib/Drupal/Core/Password/PhpassHashedPasswordBase.php, line 66

Class

PhpassHashedPasswordBase
Legacy password hashing framework.

Namespace

Drupal\Core\Password

Code

public function __construct(PasswordInterface|int $corePassword) {
    if ($corePassword instanceof PasswordInterface) {
        // Note: If $corePassword is set, $countLog2 isn't used anywhere in the
        // code path of this class. Still, set it to the default value for BC
        // reasons.
        // @phpstan-ignore-next-line
        $this->countLog2 = 16;
        $this->corePassword = $corePassword;
    }
    else {
        $countLog2 = $corePassword;
        @trigger_error('Calling ' . __METHOD__ . '() with numeric $countLog2 as the first parameter is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use PhpassHashedPasswordInterface::__construct() with $corePassword parameter set to an instance of Drupal\\Core\\Password\\PhpPassword instead. See https://www.drupal.org/node/3322420', E_USER_DEPRECATED);
        // Ensure that $countLog2 is within set bounds.
        // @phpstan-ignore-next-line
        $this->countLog2 = $this->enforceLog2Boundaries($countLog2);
        $this->corePassword = NULL;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.