classUserSpecification
final class UserSpecification
implements UserAlteration
uses Snapshot
@visibility public.One account of CREATE USER, ALTER USER or a MySQL 5.x GRANT, with what the statement sets for its authentication.
Mirrors LEX_USER: the account, its first authentication method, the further factors of CREATE USER (AND IDENTIFIED …, 8.0.27+), the initial authentication of a passwordless account (INITIAL AUTHENTICATION …), and the ALTER USER password management words: REPLACE 'current', RETAIN CURRENT PASSWORD, DISCARD OLD PASSWORD. Passwords are operands with their exact values. The constructor accepts only the combinations the grammar can write, so the rendering reads back as the same specification. Source: https://dev.mysql.com/doc/refman/8.4/en/create-user.html, https://dev.mysql.com/doc/refman/8.4/en/alter-user.html, https://dev.mysql.com/doc/refman/8.4/en/multifactor-authentication.html.
$user = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("CREATE USER app IDENTIFIED BY 'secret'")->statement->users[0];
$user->identification?->secret?->value // => 'secret'Properties§
public list<Identification> $factorspublic Account|SessionUser $userpublic Identification|null $identification = nullpublic Identification|null $initial = nullpublic Text|null $replace = nullpublic bool $retainCurrent = falsepublic bool $discardOld = falseMethods§
public function __construct(
public Account|SessionUser $user,
public Identification|null $identification = null,
list<Identification> $factors = [],
public Identification|null $initial = null,
public Text|null $replace = null,
public bool $retainCurrent = false,
public bool $discardOld = false,
)Parameters
$user | Account|SessionUser | The account |
$identification | Identification|null | The first authentication method, when written |
$factors | list<Identification> | The further factors written with AND; at most two |
$initial | Identification|null | The INITIAL AUTHENTICATION method of a passwordless first factor |
$replace | Text|null | The current password REPLACE names |
$retainCurrent | bool | Whether RETAIN CURRENT PASSWORD is written |
$discardOld | bool | Whether DISCARD OLD PASSWORD is written |
Calls 5
- static-call Check::listOf() line 59
- class-const Identification::class() line 59
- static-call Check::input() line 60
- function-call
countline 60 - class-const Credential::None() line 61
public function granted(): boolTells whether a GRANT or REVOKE account list can write the specification: a named account with at most its first method.
Returns
boolTest cases 1
public function created(): boolTells whether CREATE USER can write the specification: a named account without password management words.
Returns
boolTest cases 1
public function altered(): boolTells whether ALTER USER can write the specification: an account without further factors and initial authentication.
Returns
boolTest cases 1
public function render(Output $out): voidWrites the account and its clauses.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 99
- method-call Output::keyword() line 101
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 1
Relations§
Instantiated in 11
- new SqlSemantics\Platform\MySql\Lowering\Account\GrantRule::specifications() packages/sql-semantics-mysql/src/Lowering/Account/GrantRule.php:174
- new SqlSemantics\Platform\MySql\Lowering\Account\UserListRule::create() packages/sql-semantics-mysql/src/Lowering/Account/UserListRule.php:109
- new SqlSemantics\Platform\MySql\Lowering\Account\UserListRule::create() packages/sql-semantics-mysql/src/Lowering/Account/UserListRule.php:110
- new SqlSemantics\Platform\MySql\Lowering\Account\UserListRule::create() packages/sql-semantics-mysql/src/Lowering/Account/UserListRule.php:111
- new SqlSemantics\Platform\MySql\Lowering\Account\UserListRule::alter() packages/sql-semantics-mysql/src/Lowering/Account/UserListRule.php:146
- new SqlSemantics\Platform\MySql\Lowering\Account\UserListRule::alter() packages/sql-semantics-mysql/src/Lowering/Account/UserListRule.php:153
- new SqlSemantics\Platform\MySql\Lowering\Account\UserListRule::alter() packages/sql-semantics-mysql/src/Lowering/Account/UserListRule.php:154
- new SqlSemantics\Platform\MySql\Lowering\Account\UserListRule::grant() packages/sql-semantics-mysql/src/Lowering/Account/UserListRule.php:203
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::definition() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:103
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::alter() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:142
- new SqlSemantics\Platform\MySql\Lowering\Account\UserStatementRule::alter() packages/sql-semantics-mysql/src/Lowering/Account/UserStatementRule.php:150
Constant reads 6
- class-const SqlSemantics\Platform\MySql\Statement\Account\CreateUser::__construct() packages/sql-semantics-mysql/src/Statement/Account/CreateUser.php:77
- class-const SqlSemantics\Platform\MySql\Statement\Account\Privilege\GrantPrivileges::__construct() packages/sql-semantics-mysql/src/Statement/Account/Privilege/GrantPrivileges.php:79
- class-const SqlSemantics\Platform\MySql\Statement\Account\Privilege\GrantProxy::__construct() packages/sql-semantics-mysql/src/Statement/Account/Privilege/GrantProxy.php:44
- class-const SqlSemantics\Platform\MySql\Statement\Account\Privilege\RevokeAll::__construct() packages/sql-semantics-mysql/src/Statement/Account/Privilege/RevokeAll.php:43
- class-const SqlSemantics\Platform\MySql\Statement\Account\Privilege\RevokePrivileges::__construct() packages/sql-semantics-mysql/src/Statement/Account/Privilege/RevokePrivileges.php:66
- class-const SqlSemantics\Platform\MySql\Statement\Account\Privilege\RevokeProxy::__construct() packages/sql-semantics-mysql/src/Statement/Account/Privilege/RevokeProxy.php:42
Type checks 3
- instanceof SqlSemantics\Platform\MySql\Statement\Account\AlterUser::__construct() packages/sql-semantics-mysql/src/Statement/Account/AlterUser.php:81
- instanceof SqlSemantics\Platform\MySql\Statement\Account\AlterUser::__construct() packages/sql-semantics-mysql/src/Statement/Account/AlterUser.php:83
- instanceof SqlSemantics\Platform\MySql\Statement\Account\AlterUser::deriveStatement() packages/sql-semantics-mysql/src/Statement/Account/AlterUser.php:99