* Add native property types Includes TypeHints.UnionTypeHintFormat Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Set some default values for properties Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Format and promote properties Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove redundant asserts Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant cast Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $tmanager->theme is never null Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant variable Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix empty on $statementInfo bool Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant casts Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant issets Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * getPacked() returns nullable string Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Redundant if Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $this->content can be null Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Simplify ThemeManager::getInstance() Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use isset for checking if property is initialized Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use nullable instead of uninitialized property Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * password is no longer nullable I can't verify that none of the globals ever tried to set it to null, but the variable should never be nullable. Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Update baselines Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * $same_wide_width param can be float or int Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Update Message.php Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Cast Sub_part to int Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix one line doc comments Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
76 lines
2.3 KiB
PHP
76 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Display;
|
|
|
|
/** @psalm-immutable */
|
|
final class DisplayParts
|
|
{
|
|
public const NO_DELETE = 0;
|
|
public const DELETE_ROW = 1;
|
|
public const KILL_PROCESS = 2;
|
|
|
|
/** @psalm-param self::NO_DELETE|self::DELETE_ROW|self::KILL_PROCESS $deleteLink */
|
|
private function __construct(
|
|
public bool $hasEditLink,
|
|
public int $deleteLink,
|
|
public bool $hasSortLink,
|
|
public bool $hasNavigationBar,
|
|
public bool $hasBookmarkForm,
|
|
public bool $hasTextButton,
|
|
public bool $hasPrintLink,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @param array<string, bool|int> $parts
|
|
* @psalm-param array{
|
|
* hasEditLink?: bool,
|
|
* deleteLink?: self::NO_DELETE|self::DELETE_ROW|self::KILL_PROCESS,
|
|
* hasSortLink?: bool,
|
|
* hasNavigationBar?: bool,
|
|
* hasBookmarkForm?: bool,
|
|
* hasTextButton?: bool,
|
|
* hasPrintLink?: bool
|
|
* } $parts
|
|
*/
|
|
public static function fromArray(array $parts): self
|
|
{
|
|
return new self(
|
|
$parts['hasEditLink'] ?? false,
|
|
$parts['deleteLink'] ?? self::NO_DELETE,
|
|
$parts['hasSortLink'] ?? false,
|
|
$parts['hasNavigationBar'] ?? false,
|
|
$parts['hasBookmarkForm'] ?? false,
|
|
$parts['hasTextButton'] ?? false,
|
|
$parts['hasPrintLink'] ?? false,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, bool|int> $parts
|
|
* @psalm-param array{
|
|
* hasEditLink?: bool,
|
|
* deleteLink?: self::NO_DELETE|self::DELETE_ROW|self::KILL_PROCESS,
|
|
* hasSortLink?: bool,
|
|
* hasNavigationBar?: bool,
|
|
* hasBookmarkForm?: bool,
|
|
* hasTextButton?: bool,
|
|
* hasPrintLink?: bool
|
|
* } $parts
|
|
*/
|
|
public function with(array $parts): self
|
|
{
|
|
return new self(
|
|
$parts['hasEditLink'] ?? $this->hasEditLink,
|
|
$parts['deleteLink'] ?? $this->deleteLink,
|
|
$parts['hasSortLink'] ?? $this->hasSortLink,
|
|
$parts['hasNavigationBar'] ?? $this->hasNavigationBar,
|
|
$parts['hasBookmarkForm'] ?? $this->hasBookmarkForm,
|
|
$parts['hasTextButton'] ?? $this->hasTextButton,
|
|
$parts['hasPrintLink'] ?? $this->hasPrintLink,
|
|
);
|
|
}
|
|
}
|