diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8ccbb2e18..e69a6094b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+### 12.2.0 (2026-??-??)
+
+#### Deprecations
+
+* All enum cases have been converted from `UPPER_SNAKE_CASE` to `PascalCase`. A compatibility layer is available until Mako 13.
+
+--------------------------------------------------------
+
### 12.0.3, 12.1.1 (2026-03-01)
#### Bugfixes
diff --git a/src/mako/cli/input/Key.php b/src/mako/cli/input/Key.php
index afa35c8b5..6fe674eb8 100644
--- a/src/mako/cli/input/Key.php
+++ b/src/mako/cli/input/Key.php
@@ -7,27 +7,68 @@
namespace mako\cli\input;
+use Deprecated;
+
/**
* Keyboard keys.
*/
enum Key: string
{
- case UP = "\x1b[A";
- case DOWN = "\x1b[B";
- case LEFT = "\x1b[D";
- case RIGHT = "\x1b[C";
- case ENTER = "\n";
- case SPACE = ' ';
- case TAB = "\t";
- case CTRL_A = "\x01";
- case CTRL_B = "\x02";
- case CTRL_C = "\x03";
- case CTRL_D = "\x04";
- case BACKSPACE = "\x7F";
- case DELETE = "\x1b[3~";
- case HOME = "\x1b[H";
- case END = "\x1b[F";
- case PAGE_UP = "\x1b[5~";
- case PAGE_DOWN = "\x1b[6~";
- case ESCAPE = "\x1b";
+ /* Start compatibility */
+ #[Deprecated('use Key::Up instead', 'Mako 12.2.0')]
+ public const UP = self::Up;
+ #[Deprecated('use Key::Down instead', 'Mako 12.2.0')]
+ public const DOWN = self::Down;
+ #[Deprecated('use Key::Left instead', 'Mako 12.2.0')]
+ public const LEFT = self::Left;
+ #[Deprecated('use Key::Right instead', 'Mako 12.2.0')]
+ public const RIGHT = self::Right;
+ #[Deprecated('use Key::Enter instead', 'Mako 12.2.0')]
+ public const ENTER = self::Enter;
+ #[Deprecated('use Key::Space instead', 'Mako 12.2.0')]
+ public const SPACE = self::Space;
+ #[Deprecated('use Key::Tab instead', 'Mako 12.2.0')]
+ public const TAB = self::Tab;
+ #[Deprecated('use Key::CtrlA instead', 'Mako 12.2.0')]
+ public const CTRL_A = self::CtrlA;
+ #[Deprecated('use Key::CtrlB instead', 'Mako 12.2.0')]
+ public const CTRL_B = self::CtrlB;
+ #[Deprecated('use Key::CtrlC instead', 'Mako 12.2.0')]
+ public const CTRL_C = self::CtrlC;
+ #[Deprecated('use Key::CtrlD instead', 'Mako 12.2.0')]
+ public const CTRL_D = self::CtrlD;
+ #[Deprecated('use Key::Backspace instead', 'Mako 12.2.0')]
+ public const BACKSPACE = self::Backspace;
+ #[Deprecated('use Key::Delete instead', 'Mako 12.2.0')]
+ public const DELETE = self::Delete;
+ #[Deprecated('use Key::Home instead', 'Mako 12.2.0')]
+ public const HOME = self::Home;
+ #[Deprecated('use Key::End instead', 'Mako 12.2.0')]
+ public const END = self::End;
+ #[Deprecated('use Key::PageUp instead', 'Mako 12.2.0')]
+ public const PAGE_UP = self::PageUp;
+ #[Deprecated('use Key::PageDown instead', 'Mako 12.2.0')]
+ public const PAGE_DOWN = self::PageDown;
+ #[Deprecated('use Key::Escape instead', 'Mako 12.2.0')]
+ public const ESCAPE = self::Escape;
+ /* End compatibility */
+
+ case Up = "\x1b[A";
+ case Down = "\x1b[B";
+ case Left = "\x1b[D";
+ case Right = "\x1b[C";
+ case Enter = "\n";
+ case Space = ' ';
+ case Tab = "\t";
+ case CtrlA = "\x01";
+ case CtrlB = "\x02";
+ case CtrlC = "\x03";
+ case CtrlD = "\x04";
+ case Backspace = "\x7F";
+ case Delete = "\x1b[3~";
+ case Home = "\x1b[H";
+ case End = "\x1b[F";
+ case PageUp = "\x1b[5~";
+ case PageDown = "\x1b[6~";
+ case Escape = "\x1b";
}
diff --git a/src/mako/cli/input/components/Confirmation.php b/src/mako/cli/input/components/Confirmation.php
index ecfe26193..3500e7ba9 100644
--- a/src/mako/cli/input/components/Confirmation.php
+++ b/src/mako/cli/input/components/Confirmation.php
@@ -104,10 +104,10 @@ protected function interactiveConfirmation(): bool
$key = Key::tryFrom($this->input->readBytes(3));
- if ($key === Key::SPACE || $key === Key::LEFT || $key === Key::RIGHT) {
+ if ($key === Key::Space || $key === Key::Left || $key === Key::Right) {
$this->toggleSelection();
}
- elseif ($key === Key::ENTER) {
+ elseif ($key === Key::Enter) {
return $this->currentSelection;
}
}
diff --git a/src/mako/cli/input/components/Select.php b/src/mako/cli/input/components/Select.php
index ad20da3c7..96ddb4c29 100644
--- a/src/mako/cli/input/components/Select.php
+++ b/src/mako/cli/input/components/Select.php
@@ -268,16 +268,16 @@ protected function interactiveSelect(array $options, callable $optionFormatter):
$key = Key::tryFrom($this->input->readBytes(3));
- if ($key === Key::UP) {
+ if ($key === Key::Up) {
$this->moveCursorUp();
}
- elseif ($key === Key::DOWN) {
+ elseif ($key === Key::Down) {
$this->moveCursorDown();
}
- elseif ($key === Key::SPACE || $key === Key::LEFT || $key === Key::RIGHT) {
+ elseif ($key === Key::Space || $key === Key::Left || $key === Key::Right) {
$this->toggleSelection();
}
- elseif ($key === Key::ENTER) {
+ elseif ($key === Key::Enter) {
$selection = $this->getSelection();
if ($this->allowEmptySelection || $selection !== null) {
diff --git a/src/mako/database/query/Query.php b/src/mako/database/query/Query.php
index c32c04bce..a7451d284 100644
--- a/src/mako/database/query/Query.php
+++ b/src/mako/database/query/Query.php
@@ -647,7 +647,7 @@ public function orWhereColumn(array|string $column1, string $operator, array|str
*
* @return $this
*/
- public function whereVectorDistance(string $column, array|string|Subquery $vector, float $maxDistance, VectorDistance $vectorDistance = VectorDistance::COSINE, string $separator = 'AND'): static
+ public function whereVectorDistance(string $column, array|string|Subquery $vector, float $maxDistance, VectorDistance $vectorDistance = VectorDistance::Cosine, string $separator = 'AND'): static
{
$this->wheres[] = [
'type' => 'whereVectorDistance',
@@ -666,7 +666,7 @@ public function whereVectorDistance(string $column, array|string|Subquery $vecto
*
* @return $this
*/
- public function orWhereVectorDistance(string $column, array|string|Subquery $vector, float $maxDistance, VectorDistance $vectorDistance = VectorDistance::COSINE): static
+ public function orWhereVectorDistance(string $column, array|string|Subquery $vector, float $maxDistance, VectorDistance $vectorDistance = VectorDistance::Cosine): static
{
return $this->whereVectorDistance($column, $vector, $maxDistance, $vectorDistance, 'OR');
}
@@ -1130,7 +1130,7 @@ public function descendingRaw(string $raw, array $parameters = []): static
/**
* Adds a vector ORDER BY clause.
*/
- public function orderByVectorDistance(string $column, array|string|Subquery $vector, VectorDistance $vectorDistance = VectorDistance::COSINE, string $order = 'ASC'): static
+ public function orderByVectorDistance(string $column, array|string|Subquery $vector, VectorDistance $vectorDistance = VectorDistance::Cosine, string $order = 'ASC'): static
{
$this->orderings[] = [
'type' => 'vectorDistanceOrdering',
@@ -1146,7 +1146,7 @@ public function orderByVectorDistance(string $column, array|string|Subquery $vec
/**
* Adds a ascending vector ORDER BY clause.
*/
- public function ascendingVectorDistance(string $column, array|string|Subquery $vector, VectorDistance $vectorDistance = VectorDistance::COSINE): static
+ public function ascendingVectorDistance(string $column, array|string|Subquery $vector, VectorDistance $vectorDistance = VectorDistance::Cosine): static
{
return $this->orderByVectorDistance($column, $vector, $vectorDistance, 'ASC');
}
@@ -1154,7 +1154,7 @@ public function ascendingVectorDistance(string $column, array|string|Subquery $v
/**
* Adds a descending vector ORDER BY clause.
*/
- public function descendingVectorDistance(string $column, array|string|Subquery $vector, VectorDistance $vectorDistance = VectorDistance::COSINE): static
+ public function descendingVectorDistance(string $column, array|string|Subquery $vector, VectorDistance $vectorDistance = VectorDistance::Cosine): static
{
return $this->orderByVectorDistance($column, $vector, $vectorDistance, 'DESC');
}
diff --git a/src/mako/database/query/VectorDistance.php b/src/mako/database/query/VectorDistance.php
index 52a23b6dd..fc9fec8f5 100644
--- a/src/mako/database/query/VectorDistance.php
+++ b/src/mako/database/query/VectorDistance.php
@@ -7,11 +7,20 @@
namespace mako\database\query;
+use Deprecated;
+
/**
* Vector distance.
*/
enum VectorDistance
{
- case COSINE;
- case EUCLIDEAN;
+ /* Start compatibility */
+ #[Deprecated('use VectorDistance::Cosine instead', 'Mako 12.2.0')]
+ public const COSINE = self::Cosine;
+ #[Deprecated('use VectorDistance::Euclidean instead', 'Mako 12.2.0')]
+ public const EUCLIDEAN = self::Euclidean;
+ /* End compatibility */
+
+ case Cosine;
+ case Euclidean;
}
diff --git a/src/mako/database/query/compilers/MariaDB.php b/src/mako/database/query/compilers/MariaDB.php
index bc9074f54..4f399712c 100644
--- a/src/mako/database/query/compilers/MariaDB.php
+++ b/src/mako/database/query/compilers/MariaDB.php
@@ -38,8 +38,8 @@ protected function vectorDistance(array $vectorDistance): string
}
$function = match ($vectorDistance['vectorDistance']) {
- VectorDistance::COSINE => 'VEC_DISTANCE_COSINE',
- VectorDistance::EUCLIDEAN => 'VEC_DISTANCE_EUCLIDEAN',
+ VectorDistance::Cosine => 'VEC_DISTANCE_COSINE',
+ VectorDistance::Euclidean => 'VEC_DISTANCE_EUCLIDEAN',
};
return "{$function}({$this->column($vectorDistance['column'], false)}, {$vector})";
diff --git a/src/mako/database/query/compilers/MySQL.php b/src/mako/database/query/compilers/MySQL.php
index 8cc81fde5..064deb65f 100644
--- a/src/mako/database/query/compilers/MySQL.php
+++ b/src/mako/database/query/compilers/MySQL.php
@@ -75,8 +75,8 @@ protected function vectorDistance(array $vectorDistance): string
}
$function = match ($vectorDistance['vectorDistance']) {
- VectorDistance::COSINE => 'COSINE',
- VectorDistance::EUCLIDEAN => 'EUCLIDEAN',
+ VectorDistance::Cosine => 'COSINE',
+ VectorDistance::Euclidean => 'EUCLIDEAN',
};
return "DISTANCE({$this->column($vectorDistance['column'], false)}, {$vector}, '{$function}')";
diff --git a/src/mako/database/query/compilers/Postgres.php b/src/mako/database/query/compilers/Postgres.php
index 39e73b51b..b6f4bbac1 100644
--- a/src/mako/database/query/compilers/Postgres.php
+++ b/src/mako/database/query/compilers/Postgres.php
@@ -78,8 +78,8 @@ protected function vectorDistance(array $vectorDistance): string
}
$function = match ($vectorDistance['vectorDistance']) {
- VectorDistance::COSINE => '<=>',
- VectorDistance::EUCLIDEAN => '<->',
+ VectorDistance::Cosine => '<=>',
+ VectorDistance::Euclidean => '<->',
};
return "{$this->column($vectorDistance['column'], false)} {$function} {$vector}";
diff --git a/src/mako/database/query/values/out/VectorDistance.php b/src/mako/database/query/values/out/VectorDistance.php
index 62636674d..33c38c7f1 100644
--- a/src/mako/database/query/values/out/VectorDistance.php
+++ b/src/mako/database/query/values/out/VectorDistance.php
@@ -30,7 +30,7 @@ class VectorDistance extends Value
public function __construct(
protected string $column,
protected array|string $vector,
- protected VectorDistanceType $vectorDistance = VectorDistanceType::COSINE,
+ protected VectorDistanceType $vectorDistance = VectorDistanceType::Cosine,
protected ?string $alias = null
) {
}
@@ -41,8 +41,8 @@ public function __construct(
protected function getMariaDbDistance(Compiler $compiler): string
{
$function = match ($this->vectorDistance) {
- VectorDistanceType::COSINE => 'VEC_DISTANCE_COSINE',
- VectorDistanceType::EUCLIDEAN => 'VEC_DISTANCE_EUCLIDEAN',
+ VectorDistanceType::Cosine => 'VEC_DISTANCE_COSINE',
+ VectorDistanceType::Euclidean => 'VEC_DISTANCE_EUCLIDEAN',
};
return "{$function}({$compiler->escapeColumnName($this->column)}, VEC_FromText(?))";
@@ -54,8 +54,8 @@ protected function getMariaDbDistance(Compiler $compiler): string
protected function getMySqlDistance(Compiler $compiler): string
{
$function = match ($this->vectorDistance) {
- VectorDistanceType::COSINE => 'COSINE',
- VectorDistanceType::EUCLIDEAN => 'EUCLIDEAN',
+ VectorDistanceType::Cosine => 'COSINE',
+ VectorDistanceType::Euclidean => 'EUCLIDEAN',
};
return "DISTANCE({$compiler->escapeColumnName($this->column)}, STRING_TO_VECTOR(?), '{$function}')";
@@ -67,8 +67,8 @@ protected function getMySqlDistance(Compiler $compiler): string
protected function getPostgresDistance(Compiler $compiler): string
{
$function = match ($this->vectorDistance) {
- VectorDistanceType::COSINE => '<=>',
- VectorDistanceType::EUCLIDEAN => '<->',
+ VectorDistanceType::Cosine => '<=>',
+ VectorDistanceType::Euclidean => '<->',
};
return "{$compiler->columnName($this->column)} {$function} ?";
diff --git a/src/mako/env/Type.php b/src/mako/env/Type.php
index e3d146349..40ad702cb 100644
--- a/src/mako/env/Type.php
+++ b/src/mako/env/Type.php
@@ -7,14 +7,29 @@
namespace mako\env;
+use Deprecated;
+
/**
* Type.
*/
enum Type
{
- case BOOL;
- case INT;
- case FLOAT;
- case JSON_AS_OBJECT;
- case JSON_AS_ARRAY;
+ /* Start compatibility */
+ #[Deprecated('use Type::Bool instead', 'Mako 12.2.0')]
+ public const BOOL = self::Bool;
+ #[Deprecated('use Type::Int instead', 'Mako 12.2.0')]
+ public const INT = self::Int;
+ #[Deprecated('use Type::Float instead', 'Mako 12.2.0')]
+ public const FLOAT = self::Float;
+ #[Deprecated('use Type::JsonAsObject instead', 'Mako 12.2.0')]
+ public const JSON_AS_OBJECT = self::JsonAsObject;
+ #[Deprecated('use Type::JsonAsArray instead', 'Mako 12.2.0')]
+ public const JSON_AS_ARRAY = self::JsonAsArray;
+ /* End compatibility */
+
+ case Bool;
+ case Int;
+ case Float;
+ case JsonAsObject;
+ case JsonAsArray;
}
diff --git a/src/mako/error/handlers/web/Handler.php b/src/mako/error/handlers/web/Handler.php
index babd14521..04e8ad514 100644
--- a/src/mako/error/handlers/web/Handler.php
+++ b/src/mako/error/handlers/web/Handler.php
@@ -51,7 +51,7 @@ public function getExceptionId(): string
*/
protected function getHttpStatus(Throwable $exception): Status
{
- return ($exception instanceof HttpStatusException) ? $exception->getStatus() : Status::INTERNAL_SERVER_ERROR;
+ return ($exception instanceof HttpStatusException) ? $exception->getStatus() : Status::InternalServerError;
}
/**
diff --git a/src/mako/file/FileInfo.php b/src/mako/file/FileInfo.php
index 85495ce5f..be5d6582f 100644
--- a/src/mako/file/FileInfo.php
+++ b/src/mako/file/FileInfo.php
@@ -82,7 +82,7 @@ public function validateHmac(string $hmac, #[SensitiveParameter] string $key, st
*/
public function getPermissions(): Permissions
{
- return Permissions::fromInt($this->getPerms() & Permission::FULL->value);
+ return Permissions::fromInt($this->getPerms() & Permission::FullWithAllSpecial->value);
}
/**
diff --git a/src/mako/file/FileSystem.php b/src/mako/file/FileSystem.php
index 17b4dd393..a9f6a6454 100644
--- a/src/mako/file/FileSystem.php
+++ b/src/mako/file/FileSystem.php
@@ -102,7 +102,7 @@ public function setPermissions(string $path, int|Permissions $permissions): bool
*/
public function getPermissions(string $path): Permissions
{
- return Permissions::fromInt(fileperms($path) & Permission::FULL->value);
+ return Permissions::fromInt(fileperms($path) & Permission::FullWithAllSpecial->value);
}
/**
diff --git a/src/mako/file/Permission.php b/src/mako/file/Permission.php
index c85e50105..f40e85766 100644
--- a/src/mako/file/Permission.php
+++ b/src/mako/file/Permission.php
@@ -7,6 +7,7 @@
namespace mako\file;
+use Deprecated;
use InvalidArgumentException;
use function sprintf;
@@ -16,53 +17,110 @@
*/
enum Permission: int
{
+ /* Start compatibility */
+ #[Deprecated('use Permission::None instead', 'Mako 12.2.0')]
+ public const NONE = self::None;
+ #[Deprecated('use Permission::OwnerExecute instead', 'Mako 12.2.0')]
+ public const OWNER_EXECUTE = self::OwnerExecute;
+ #[Deprecated('use Permission::OwnerWrite instead', 'Mako 12.2.0')]
+ public const OWNER_WRITE = self::OwnerWrite;
+ #[Deprecated('use Permission::OwnerExecuteWrite instead', 'Mako 12.2.0')]
+ public const OWNER_EXECUTE_WRITE = self::OwnerExecuteWrite;
+ #[Deprecated('use Permission::OwnerRead instead', 'Mako 12.2.0')]
+ public const OWNER_READ = self::OwnerRead;
+ #[Deprecated('use Permission::OwnerExecuteRead instead', 'Mako 12.2.0')]
+ public const OWNER_EXECUTE_READ = self::OwnerExecuteRead;
+ #[Deprecated('use Permission::OwnerWriteRead instead', 'Mako 12.2.0')]
+ public const OWNER_WRITE_READ = self::OwnerWriteRead;
+ #[Deprecated('use Permission::OwnerFull instead', 'Mako 12.2.0')]
+ public const OWNER_FULL = self::OwnerFull;
+ #[Deprecated('use Permission::GroupExecute instead', 'Mako 12.2.0')]
+ public const GROUP_EXECUTE = self::GroupExecute;
+ #[Deprecated('use Permission::GroupWrite instead', 'Mako 12.2.0')]
+ public const GROUP_WRITE = self::GroupWrite;
+ #[Deprecated('use Permission::GroupExecuteWrite instead', 'Mako 12.2.0')]
+ public const GROUP_EXECUTE_WRITE = self::GroupExecuteWrite;
+ #[Deprecated('use Permission::GroupRead instead', 'Mako 12.2.0')]
+ public const GROUP_READ = self::GroupRead;
+ #[Deprecated('use Permission::GroupExecuteRead instead', 'Mako 12.2.0')]
+ public const GROUP_EXECUTE_READ = self::GroupExecuteRead;
+ #[Deprecated('use Permission::GroupWriteRead instead', 'Mako 12.2.0')]
+ public const GROUP_WRITE_READ = self::GroupWriteRead;
+ #[Deprecated('use Permission::GroupFull instead', 'Mako 12.2.0')]
+ public const GROUP_FULL = self::GroupFull;
+ #[Deprecated('use Permission::PublicExecute instead', 'Mako 12.2.0')]
+ public const PUBLIC_EXECUTE = self::PublicExecute;
+ #[Deprecated('use Permission::PublicWrite instead', 'Mako 12.2.0')]
+ public const PUBLIC_WRITE = self::PublicWrite;
+ #[Deprecated('use Permission::PublicExecuteWrite instead', 'Mako 12.2.0')]
+ public const PUBLIC_EXECUTE_WRITE = self::PublicExecuteWrite;
+ #[Deprecated('use Permission::PublicRead instead', 'Mako 12.2.0')]
+ public const PUBLIC_READ = self::PublicRead;
+ #[Deprecated('use Permission::PublicExecuteRead instead', 'Mako 12.2.0')]
+ public const PUBLIC_EXECUTE_READ = self::PublicExecuteRead;
+ #[Deprecated('use Permission::PublicWriteRead instead', 'Mako 12.2.0')]
+ public const PUBLIC_WRITE_READ = self::PublicWriteRead;
+ #[Deprecated('use Permission::PublicFull instead', 'Mako 12.2.0')]
+ public const PUBLIC_FULL = self::PublicFull;
+ #[Deprecated('use Permission::Full instead', 'Mako 12.2.0')]
+ public const FULL = self::Full;
+ #[Deprecated('use Permission::SpecialSticky instead', 'Mako 12.2.0')]
+ public const SPECIAL_STICKY = self::SpecialSticky;
+ #[Deprecated('use Permission::SpecialSetGid instead', 'Mako 12.2.0')]
+ public const SPECIAL_SETGID = self::SpecialSetGid;
+ #[Deprecated('use Permission::SpecialSetUid instead', 'Mako 12.2.0')]
+ public const SPECIAL_SETUID = self::SpecialSetUid;
+ #[Deprecated('use Permission::FullWithAllSpecial instead', 'Mako 12.2.0')]
+ public const FULL_WITH_ALL_SPECIAL = self::FullWithAllSpecial;
+ /* End compatibility */
+
// No permissions
- case NONE = 0o0000;
+ case None = 0o0000;
// Owner permissions
- case OWNER_EXECUTE = 0o0100;
- case OWNER_WRITE = 0o0200;
- case OWNER_EXECUTE_WRITE = 0o0300;
- case OWNER_READ = 0o0400;
- case OWNER_EXECUTE_READ = 0o0500;
- case OWNER_WRITE_READ = 0o0600;
- case OWNER_FULL = 0o0700;
+ case OwnerExecute = 0o0100;
+ case OwnerWrite = 0o0200;
+ case OwnerExecuteWrite = 0o0300;
+ case OwnerRead = 0o0400;
+ case OwnerExecuteRead = 0o0500;
+ case OwnerWriteRead = 0o0600;
+ case OwnerFull = 0o0700;
// Group permissions
- case GROUP_EXECUTE = 0o0010;
- case GROUP_WRITE = 0o0020;
- case GROUP_EXECUTE_WRITE = 0o0030;
- case GROUP_READ = 0o0040;
- case GROUP_EXECUTE_READ = 0o0050;
- case GROUP_WRITE_READ = 0o0060;
- case GROUP_FULL = 0o0070;
+ case GroupExecute = 0o0010;
+ case GroupWrite = 0o0020;
+ case GroupExecuteWrite = 0o0030;
+ case GroupRead = 0o0040;
+ case GroupExecuteRead = 0o0050;
+ case GroupWriteRead = 0o0060;
+ case GroupFull = 0o0070;
// Public permissions
- case PUBLIC_EXECUTE = 0o0001;
- case PUBLIC_WRITE = 0o0002;
- case PUBLIC_EXECUTE_WRITE = 0o0003;
- case PUBLIC_READ = 0o0004;
- case PUBLIC_EXECUTE_READ = 0o0005;
- case PUBLIC_WRITE_READ = 0o0006;
- case PUBLIC_FULL = 0o0007;
+ case PublicExecute = 0o0001;
+ case PublicWrite = 0o0002;
+ case PublicExecuteWrite = 0o0003;
+ case PublicRead = 0o0004;
+ case PublicExecuteRead = 0o0005;
+ case PublicWriteRead = 0o0006;
+ case PublicFull = 0o0007;
// Full permissions (owner, group, and public)
- case FULL = 0o0777;
+ case Full = 0o0777;
// Special bits
- case SPECIAL_STICKY = 0o1000;
- case SPECIAL_SETGID = 0o2000;
- case SPECIAL_SETUID = 0o4000;
+ case SpecialSticky = 0o1000;
+ case SpecialSetGid = 0o2000;
+ case SpecialSetUid = 0o4000;
// Full permissions (owner, group, and public) with all special bits
- case FULL_WITH_ALL_SPECIAL = 0o7777;
+ case FullWithAllSpecial = 0o7777;
/**
* Calculates sum of the specified permissions.
diff --git a/src/mako/file/Permissions.php b/src/mako/file/Permissions.php
index a25d1684a..c2b293368 100644
--- a/src/mako/file/Permissions.php
+++ b/src/mako/file/Permissions.php
@@ -32,7 +32,7 @@ class Permissions
*/
final public function __construct(Permission ...$permissions)
{
- $this->permissions = empty($permissions) ? [Permission::NONE] : $permissions;
+ $this->permissions = empty($permissions) ? [Permission::None] : $permissions;
}
/**
@@ -40,27 +40,27 @@ final public function __construct(Permission ...$permissions)
*/
public static function fromInt(int $permissions): static
{
- if ($permissions < Permission::NONE->value || $permissions > (Permission::FULL_WITH_ALL_SPECIAL->value)) {
+ if ($permissions < Permission::None->value || $permissions > (Permission::FullWithAllSpecial->value)) {
throw new InvalidArgumentException(sprintf('The integer [ %s ] does not represent a valid octal between 0o0000 and 0o7777.', $permissions));
}
- if ($permissions === Permission::NONE->value) {
+ if ($permissions === Permission::None->value) {
return new static;
}
$basePermissions = [
- Permission::OWNER_READ,
- Permission::OWNER_WRITE,
- Permission::OWNER_EXECUTE,
- Permission::GROUP_READ,
- Permission::GROUP_WRITE,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_WRITE,
- Permission::PUBLIC_EXECUTE,
- Permission::SPECIAL_SETUID,
- Permission::SPECIAL_SETGID,
- Permission::SPECIAL_STICKY,
+ Permission::OwnerRead,
+ Permission::OwnerWrite,
+ Permission::OwnerExecute,
+ Permission::GroupRead,
+ Permission::GroupWrite,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicWrite,
+ Permission::PublicExecute,
+ Permission::SpecialSetUid,
+ Permission::SpecialSetGid,
+ Permission::SpecialSticky,
];
$permission = [];
@@ -149,9 +149,9 @@ protected function getGroupAsRwxString(int $permissions, Permission $read, Permi
// Determine special bit
$specialChar = match ($group) {
- 'owner' => ($permissions & Permission::SPECIAL_SETUID->value) ? 's' : null,
- 'group' => ($permissions & Permission::SPECIAL_SETGID->value) ? 's' : null,
- 'public' => ($permissions & Permission::SPECIAL_STICKY->value) ? 't' : null,
+ 'owner' => ($permissions & Permission::SpecialSetUid->value) ? 's' : null,
+ 'group' => ($permissions & Permission::SpecialSetGid->value) ? 's' : null,
+ 'public' => ($permissions & Permission::SpecialSticky->value) ? 't' : null,
};
// Execute + special bit handling
@@ -172,9 +172,9 @@ public function toRwxString(): string
{
$permissions = Permission::calculate(...$this->permissions);
- $owner = $this->getGroupAsRwxString($permissions, Permission::OWNER_READ, Permission::OWNER_WRITE, Permission::OWNER_EXECUTE, 'owner');
- $group = $this->getGroupAsRwxString($permissions, Permission::GROUP_READ, Permission::GROUP_WRITE, Permission::GROUP_EXECUTE, 'group');
- $public = $this->getGroupAsRwxString($permissions, Permission::PUBLIC_READ, Permission::PUBLIC_WRITE, Permission::PUBLIC_EXECUTE, 'public');
+ $owner = $this->getGroupAsRwxString($permissions, Permission::OwnerRead, Permission::OwnerWrite, Permission::OwnerExecute, 'owner');
+ $group = $this->getGroupAsRwxString($permissions, Permission::GroupRead, Permission::GroupWrite, Permission::GroupExecute, 'group');
+ $public = $this->getGroupAsRwxString($permissions, Permission::PublicRead, Permission::PublicWrite, Permission::PublicExecute, 'public');
return "{$owner}{$group}{$public}";
}
diff --git a/src/mako/functions.php b/src/mako/functions.php
index 017644aa0..c14f0c3f3 100644
--- a/src/mako/functions.php
+++ b/src/mako/functions.php
@@ -36,11 +36,11 @@ function env(string $variableName, mixed $default = null, bool $localOnly = fals
return match ($as) {
null => $value,
- Type::BOOL => filter_var($value, FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE),
- Type::INT => filter_var($value, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE),
- Type::FLOAT => filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE),
- Type::JSON_AS_OBJECT => json_decode($value ?? 'null'),
- Type::JSON_AS_ARRAY => json_decode($value ?? 'null', flags: JSON_OBJECT_AS_ARRAY),
+ Type::Bool => filter_var($value, FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE),
+ Type::Int => filter_var($value, FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE),
+ Type::Float => filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_NULL_ON_FAILURE),
+ Type::JsonAsObject => json_decode($value ?? 'null'),
+ Type::JsonAsArray => json_decode($value ?? 'null', flags: JSON_OBJECT_AS_ARRAY),
} ?? $default;
}
}
diff --git a/src/mako/gatekeeper/LoginStatus.php b/src/mako/gatekeeper/LoginStatus.php
index 6c1f0d7bf..e8ff1b99a 100644
--- a/src/mako/gatekeeper/LoginStatus.php
+++ b/src/mako/gatekeeper/LoginStatus.php
@@ -7,16 +7,31 @@
namespace mako\gatekeeper;
+use Deprecated;
+
/**
* Login status codes.
*/
enum LoginStatus: int
{
- case OK = 1;
- case BANNED = 2;
- case NOT_ACTIVATED = 3;
- case INVALID_CREDENTIALS = 4;
- case LOCKED = 5;
+ /* Start compatibility */
+ #[Deprecated('use LoginStatus::Ok instead', 'Mako 12.2.0')]
+ public const OK = self::Ok;
+ #[Deprecated('use LoginStatus::Banned instead', 'Mako 12.2.0')]
+ public const BANNED = self::Banned;
+ #[Deprecated('use LoginStatus::NotActivated instead', 'Mako 12.2.0')]
+ public const NOT_ACTIVATED = self::NotActivated;
+ #[Deprecated('use LoginStatus::InvalidCredentials instead', 'Mako 12.2.0')]
+ public const INVALID_CREDENTIALS = self::InvalidCredentials;
+ #[Deprecated('use LoginStatus::Locked instead', 'Mako 12.2.0')]
+ public const LOCKED = self::Locked;
+ /* End compatibility */
+
+ case Ok = 1;
+ case Banned = 2;
+ case NotActivated = 3;
+ case InvalidCredentials = 4;
+ case Locked = 5;
/**
* Returns the status code.
@@ -27,10 +42,10 @@ public function getCode(): int
}
/**
- * Returns TRUE if OK and FALSE otherwise.
+ * Returns TRUE if Ok and FALSE otherwise.
*/
public function toBool(): bool
{
- return $this === self::OK;
+ return $this === self::Ok;
}
}
diff --git a/src/mako/gatekeeper/adapters/Session.php b/src/mako/gatekeeper/adapters/Session.php
index 642a03971..5c8f99e45 100644
--- a/src/mako/gatekeeper/adapters/Session.php
+++ b/src/mako/gatekeeper/adapters/Session.php
@@ -136,16 +136,16 @@ protected function authenticate(int|string $identifier, #[SensitiveParameter] ?s
if ($user !== null) {
if ($this->options['throttling']['enabled'] && $user->isLocked()) {
- return LoginStatus::LOCKED;
+ return LoginStatus::Locked;
}
if ($force || $user->validatePassword($password)) {
if (!$user->isActivated()) {
- return LoginStatus::NOT_ACTIVATED;
+ return LoginStatus::NotActivated;
}
if ($user->isBanned()) {
- return LoginStatus::BANNED;
+ return LoginStatus::Banned;
}
if ($this->options['throttling']['enabled']) {
@@ -154,7 +154,7 @@ protected function authenticate(int|string $identifier, #[SensitiveParameter] ?s
$this->user = $user;
- return LoginStatus::OK;
+ return LoginStatus::Ok;
}
else {
if ($this->options['throttling']['enabled']) {
@@ -163,7 +163,7 @@ protected function authenticate(int|string $identifier, #[SensitiveParameter] ?s
}
}
- return LoginStatus::INVALID_CREDENTIALS;
+ return LoginStatus::InvalidCredentials;
}
/**
@@ -185,12 +185,12 @@ protected function setRememberMeCookie(): void
public function login(null|int|string $identifier, #[SensitiveParameter] ?string $password, bool $remember = false, bool $force = false): LoginStatus
{
if (empty($identifier)) {
- return LoginStatus::INVALID_CREDENTIALS;
+ return LoginStatus::InvalidCredentials;
}
$status = $this->authenticate($identifier, $password, $force);
- if ($status === LoginStatus::OK) {
+ if ($status === LoginStatus::Ok) {
$this->session->regenerateId();
$this->session->regenerateToken();
@@ -218,7 +218,7 @@ public function forceLogin(int|string $identifier, bool $remember = false): Logi
*/
public function basicAuth(bool $clearResponse = false): bool
{
- if ($this->isLoggedIn() || $this->login($this->request->getUsername(), $this->request->getPassword()) === LoginStatus::OK) {
+ if ($this->isLoggedIn() || $this->login($this->request->getUsername(), $this->request->getPassword()) === LoginStatus::Ok) {
return true;
}
@@ -228,7 +228,7 @@ public function basicAuth(bool $clearResponse = false): bool
$this->response->headers->add('WWW-Authenticate', 'basic');
- $this->response->setStatus(Status::UNAUTHORIZED);
+ $this->response->setStatus(Status::Unauthorized);
return false;
}
diff --git a/src/mako/http/Response.php b/src/mako/http/Response.php
index 76121c9fd..e7767be2c 100644
--- a/src/mako/http/Response.php
+++ b/src/mako/http/Response.php
@@ -35,7 +35,7 @@ class Response
/**
* Default HTTP status.
*/
- public const Status DEFAULT_STATUS = Status::OK;
+ public const Status DEFAULT_STATUS = Status::Ok;
/**
* Response body.
@@ -434,7 +434,7 @@ public function send(): void
$this->headers->add('ETag', $hash);
if (str_replace('-gzip', '', $this->request->headers->get('If-None-Match', '')) === $hash) {
- $this->setStatus(Status::NOT_MODIFIED);
+ $this->setStatus(Status::NotModified);
$sendBody = false;
}
diff --git a/src/mako/http/exceptions/BadRequestException.php b/src/mako/http/exceptions/BadRequestException.php
index 0a8d693d8..754ce157c 100644
--- a/src/mako/http/exceptions/BadRequestException.php
+++ b/src/mako/http/exceptions/BadRequestException.php
@@ -27,6 +27,6 @@ class BadRequestException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::BAD_REQUEST, $message, $previous);
+ parent::__construct(Status::BadRequest, $message, $previous);
}
}
diff --git a/src/mako/http/exceptions/ForbiddenException.php b/src/mako/http/exceptions/ForbiddenException.php
index ada96ffef..f77ae7eaf 100644
--- a/src/mako/http/exceptions/ForbiddenException.php
+++ b/src/mako/http/exceptions/ForbiddenException.php
@@ -27,6 +27,6 @@ class ForbiddenException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::FORBIDDEN, $message, $previous);
+ parent::__construct(Status::Forbidden, $message, $previous);
}
}
diff --git a/src/mako/http/exceptions/GoneException.php b/src/mako/http/exceptions/GoneException.php
index d4e2989cd..28d543a57 100644
--- a/src/mako/http/exceptions/GoneException.php
+++ b/src/mako/http/exceptions/GoneException.php
@@ -27,6 +27,6 @@ class GoneException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::GONE, $message, $previous);
+ parent::__construct(Status::Gone, $message, $previous);
}
}
diff --git a/src/mako/http/exceptions/InvalidTokenException.php b/src/mako/http/exceptions/InvalidTokenException.php
index 6414e660e..ee7fe17e6 100644
--- a/src/mako/http/exceptions/InvalidTokenException.php
+++ b/src/mako/http/exceptions/InvalidTokenException.php
@@ -27,6 +27,6 @@ class InvalidTokenException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::INVALID_TOKEN, $message, $previous);
+ parent::__construct(Status::InvalidToken, $message, $previous);
}
}
diff --git a/src/mako/http/exceptions/MethodNotAllowedException.php b/src/mako/http/exceptions/MethodNotAllowedException.php
index 57e53dbc8..40abbf1cb 100644
--- a/src/mako/http/exceptions/MethodNotAllowedException.php
+++ b/src/mako/http/exceptions/MethodNotAllowedException.php
@@ -32,7 +32,7 @@ public function __construct(
?Throwable $previous = null,
protected array $allowedMethods = []
) {
- parent::__construct(Status::METHOD_NOT_ALLOWED, $message, $previous);
+ parent::__construct(Status::MethodNotAllowed, $message, $previous);
}
/**
diff --git a/src/mako/http/exceptions/NotFoundException.php b/src/mako/http/exceptions/NotFoundException.php
index 34a5d0290..ff91ee38a 100644
--- a/src/mako/http/exceptions/NotFoundException.php
+++ b/src/mako/http/exceptions/NotFoundException.php
@@ -27,6 +27,6 @@ class NotFoundException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::NOT_FOUND, $message, $previous);
+ parent::__construct(Status::NotFound, $message, $previous);
}
}
diff --git a/src/mako/http/exceptions/RangeNotSatisfiableException.php b/src/mako/http/exceptions/RangeNotSatisfiableException.php
index b45ea1f00..63c301a7d 100644
--- a/src/mako/http/exceptions/RangeNotSatisfiableException.php
+++ b/src/mako/http/exceptions/RangeNotSatisfiableException.php
@@ -27,6 +27,6 @@ class RangeNotSatisfiableException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::RANGE_NOT_SATISFIABLE, $message, $previous);
+ parent::__construct(Status::RangeNotSatisfiable, $message, $previous);
}
}
diff --git a/src/mako/http/exceptions/ServiceUnavailableException.php b/src/mako/http/exceptions/ServiceUnavailableException.php
index 8777265f9..721fb7782 100644
--- a/src/mako/http/exceptions/ServiceUnavailableException.php
+++ b/src/mako/http/exceptions/ServiceUnavailableException.php
@@ -27,6 +27,6 @@ class ServiceUnavailableException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::SERVICE_UNAVAILABLE, $message, $previous);
+ parent::__construct(Status::ServiceUnavailable, $message, $previous);
}
}
diff --git a/src/mako/http/exceptions/TooManyRequestsException.php b/src/mako/http/exceptions/TooManyRequestsException.php
index 8428076c8..fea3e0379 100644
--- a/src/mako/http/exceptions/TooManyRequestsException.php
+++ b/src/mako/http/exceptions/TooManyRequestsException.php
@@ -39,7 +39,7 @@ public function __construct(
?Throwable $previous = null,
protected ?DateTimeInterface $retryAfter = null
) {
- parent::__construct(Status::TOO_MANY_REQUESTS, $message, $previous);
+ parent::__construct(Status::TooManyRequests, $message, $previous);
}
/**
diff --git a/src/mako/http/exceptions/UnauthorizedException.php b/src/mako/http/exceptions/UnauthorizedException.php
index 5d3fb34ba..f11ae400b 100644
--- a/src/mako/http/exceptions/UnauthorizedException.php
+++ b/src/mako/http/exceptions/UnauthorizedException.php
@@ -27,6 +27,6 @@ class UnauthorizedException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::UNAUTHORIZED, $message, $previous);
+ parent::__construct(Status::Unauthorized, $message, $previous);
}
}
diff --git a/src/mako/http/exceptions/UnsupportedMediaTypeException.php b/src/mako/http/exceptions/UnsupportedMediaTypeException.php
index 39782a0d4..0708fe11a 100644
--- a/src/mako/http/exceptions/UnsupportedMediaTypeException.php
+++ b/src/mako/http/exceptions/UnsupportedMediaTypeException.php
@@ -27,6 +27,6 @@ class UnsupportedMediaTypeException extends HttpStatusException
*/
public function __construct(string $message = '', ?Throwable $previous = null)
{
- parent::__construct(Status::UNSUPPORTED_MEDIA_TYPE, $message, $previous);
+ parent::__construct(Status::UnsupportedMediaType, $message, $previous);
}
}
diff --git a/src/mako/http/response/Status.php b/src/mako/http/response/Status.php
index b134f566c..1129a3171 100644
--- a/src/mako/http/response/Status.php
+++ b/src/mako/http/response/Status.php
@@ -7,90 +7,227 @@
namespace mako\http\response;
+use Deprecated;
+
/**
* HTTP status codes.
*/
enum Status: int
{
+ /* Start compatibility */
+ #[Deprecated('use Status::Continue instead', 'Mako 12.2.0')]
+ public const CONTINUE = self::Continue;
+ #[Deprecated('use Status::SwitchingProtocols instead', 'Mako 12.2.0')]
+ public const SWITCHING_PROTOCOLS = self::SwitchingProtocols;
+ #[Deprecated('use Status::Processing instead', 'Mako 12.2.0')]
+ public const PROCESSING = self::Processing;
+ #[Deprecated('use Status::EarlyHints instead', 'Mako 12.2.0')]
+ public const EARLY_HINTS = self::EarlyHints;
+ #[Deprecated('use Status::Ok instead', 'Mako 12.2.0')]
+ public const OK = self::Ok;
+ #[Deprecated('use Status::Created instead', 'Mako 12.2.0')]
+ public const CREATED = self::Created;
+ #[Deprecated('use Status::Accepted instead', 'Mako 12.2.0')]
+ public const ACCEPTED = self::Accepted;
+ #[Deprecated('use Status::NonAuthoritativeInformation instead', 'Mako 12.2.0')]
+ public const NON_AUTHORITATIVE_INFORMATION = self::NonAuthoritativeInformation;
+ #[Deprecated('use Status::NoContent instead', 'Mako 12.2.0')]
+ public const NO_CONTENT = self::NoContent;
+ #[Deprecated('use Status::ResetContent instead', 'Mako 12.2.0')]
+ public const RESET_CONTENT = self::ResetContent;
+ #[Deprecated('use Status::PartialContent instead', 'Mako 12.2.0')]
+ public const PARTIAL_CONTENT = self::PartialContent;
+ #[Deprecated('use Status::MultiStatus instead', 'Mako 12.2.0')]
+ public const MULTI_STATUS = self::MultiStatus;
+ #[Deprecated('use Status::AlreadyReported instead', 'Mako 12.2.0')]
+ public const ALREADY_REPORTED = self::AlreadyReported;
+ #[Deprecated('use Status::ImUsed instead', 'Mako 12.2.0')]
+ public const IM_USED = self::ImUsed;
+ #[Deprecated('use Status::MultipleChoices instead', 'Mako 12.2.0')]
+ public const MULTIPLE_CHOICES = self::MultipleChoices;
+ #[Deprecated('use Status::MovedPermanently instead', 'Mako 12.2.0')]
+ public const MOVED_PERMANENTLY = self::MovedPermanently;
+ #[Deprecated('use Status::Found instead', 'Mako 12.2.0')]
+ public const FOUND = self::Found;
+ #[Deprecated('use Status::SeeOther instead', 'Mako 12.2.0')]
+ public const SEE_OTHER = self::SeeOther;
+ #[Deprecated('use Status::NotModified instead', 'Mako 12.2.0')]
+ public const NOT_MODIFIED = self::NotModified;
+ #[Deprecated('use Status::UseProxy instead', 'Mako 12.2.0')]
+ public const USE_PROXY = self::UseProxy;
+ #[Deprecated('use Status::TemporaryRedirect instead', 'Mako 12.2.0')]
+ public const TEMPORARY_REDIRECT = self::TemporaryRedirect;
+ #[Deprecated('use Status::PermanentRedirect instead', 'Mako 12.2.0')]
+ public const PERMANENT_REDIRECT = self::PermanentRedirect;
+ #[Deprecated('use Status::BadRequest instead', 'Mako 12.2.0')]
+ public const BAD_REQUEST = self::BadRequest;
+ #[Deprecated('use Status::Unauthorized instead', 'Mako 12.2.0')]
+ public const UNAUTHORIZED = self::Unauthorized;
+ #[Deprecated('use Status::PaymentRequired instead', 'Mako 12.2.0')]
+ public const PAYMENT_REQUIRED = self::PaymentRequired;
+ #[Deprecated('use Status::Forbidden instead', 'Mako 12.2.0')]
+ public const FORBIDDEN = self::Forbidden;
+ #[Deprecated('use Status::NotFound instead', 'Mako 12.2.0')]
+ public const NOT_FOUND = self::NotFound;
+ #[Deprecated('use Status::MethodNotAllowed instead', 'Mako 12.2.0')]
+ public const METHOD_NOT_ALLOWED = self::MethodNotAllowed;
+ #[Deprecated('use Status::NotAcceptable instead', 'Mako 12.2.0')]
+ public const NOT_ACCEPTABLE = self::NotAcceptable;
+ #[Deprecated('use Status::ProxyAuthenticationRequired instead', 'Mako 12.2.0')]
+ public const PROXY_AUTHENTICATION_REQUIRED = self::ProxyAuthenticationRequired;
+ #[Deprecated('use Status::RequestTimeout instead', 'Mako 12.2.0')]
+ public const REQUEST_TIMEOUT = self::RequestTimeout;
+ #[Deprecated('use Status::Conflict instead', 'Mako 12.2.0')]
+ public const CONFLICT = self::Conflict;
+ #[Deprecated('use Status::Gone instead', 'Mako 12.2.0')]
+ public const GONE = self::Gone;
+ #[Deprecated('use Status::LengthRequired instead', 'Mako 12.2.0')]
+ public const LENGTH_REQUIRED = self::LengthRequired;
+ #[Deprecated('use Status::PreconditionFailed instead', 'Mako 12.2.0')]
+ public const PRECONDITION_FAILED = self::PreconditionFailed;
+ #[Deprecated('use Status::PayloadTooLarge instead', 'Mako 12.2.0')]
+ public const PAYLOAD_TOO_LARGE = self::PayloadTooLarge;
+ #[Deprecated('use Status::UriTooLong instead', 'Mako 12.2.0')]
+ public const URI_TOO_LONG = self::UriTooLong;
+ #[Deprecated('use Status::UnsupportedMediaType instead', 'Mako 12.2.0')]
+ public const UNSUPPORTED_MEDIA_TYPE = self::UnsupportedMediaType;
+ #[Deprecated('use Status::RangeNotSatisfiable instead', 'Mako 12.2.0')]
+ public const RANGE_NOT_SATISFIABLE = self::RangeNotSatisfiable;
+ #[Deprecated('use Status::ExpectationFailed instead', 'Mako 12.2.0')]
+ public const EXPECTATION_FAILED = self::ExpectationFailed;
+ #[Deprecated('use Status::ImATeapot instead', 'Mako 12.2.0')]
+ public const IM_A_TEAPOT = self::ImATeapot;
+ #[Deprecated('use Status::AuthenticationTimeout instead', 'Mako 12.2.0')]
+ public const AUTENTICATION_TIMEOUT = self::AuthenticationTimeout;
+ #[Deprecated('use Status::AuthenticationTimeout instead', 'Mako 12.2.0')]
+ public const AUTHENTICATION_TIMEOUT = self::AuthenticationTimeout;
+ #[Deprecated('use Status::MisdirectedRequest instead', 'Mako 12.2.0')]
+ public const MISDIRECTED_REQUEST = self::MisdirectedRequest;
+ #[Deprecated('use Status::UnprocessableEntity instead', 'Mako 12.2.0')]
+ public const UNPROCESSABLE_ENTITY = self::UnprocessableEntity;
+ #[Deprecated('use Status::Locked instead', 'Mako 12.2.0')]
+ public const LOCKED = self::Locked;
+ #[Deprecated('use Status::FailedDependency instead', 'Mako 12.2.0')]
+ public const FAILED_DEPENDENCY = self::FailedDependency;
+ #[Deprecated('use Status::TooEarly instead', 'Mako 12.2.0')]
+ public const TOO_EARLY = self::TooEarly;
+ #[Deprecated('use Status::UpgradeRequired instead', 'Mako 12.2.0')]
+ public const UPGRADE_REQUIRED = self::UpgradeRequired;
+ #[Deprecated('use Status::PreconditionRequired instead', 'Mako 12.2.0')]
+ public const PRECONDITION_REQUIRED = self::PreconditionRequired;
+ #[Deprecated('use Status::TooManyRequests instead', 'Mako 12.2.0')]
+ public const TOO_MANY_REQUESTS = self::TooManyRequests;
+ #[Deprecated('use Status::RequestHeaderFieldsTooLarge instead', 'Mako 12.2.0')]
+ public const REQUEST_HEADER_FIELDS_TOO_LARGE = self::RequestHeaderFieldsTooLarge;
+ #[Deprecated('use Status::UnavailableForLegalReasons instead', 'Mako 12.2.0')]
+ public const UNAVAILABLE_FOR_LEGAL_REASONS = self::UnavailableForLegalReasons;
+ #[Deprecated('use Status::InvalidToken instead', 'Mako 12.2.0')]
+ public const INVALID_TOKEN = self::InvalidToken;
+ #[Deprecated('use Status::TokenRequired instead', 'Mako 12.2.0')]
+ public const TOKEN_REQUIRED = self::TokenRequired;
+ #[Deprecated('use Status::InternalServerError instead', 'Mako 12.2.0')]
+ public const INTERNAL_SERVER_ERROR = self::InternalServerError;
+ #[Deprecated('use Status::NotImplemented instead', 'Mako 12.2.0')]
+ public const NOT_IMPLEMENTED = self::NotImplemented;
+ #[Deprecated('use Status::BadGateway instead', 'Mako 12.2.0')]
+ public const BAD_GATEWAY = self::BadGateway;
+ #[Deprecated('use Status::ServiceUnavailable instead', 'Mako 12.2.0')]
+ public const SERVICE_UNAVAILABLE = self::ServiceUnavailable;
+ #[Deprecated('use Status::GatewayTimeout instead', 'Mako 12.2.0')]
+ public const GATEWAY_TIMEOUT = self::GatewayTimeout;
+ #[Deprecated('use Status::HttpVersionNotSupported instead', 'Mako 12.2.0')]
+ public const HTTP_VERSION_NOT_SUPPORTED = self::HttpVersionNotSupported;
+ #[Deprecated('use Status::VariantAlsoNegotiates instead', 'Mako 12.2.0')]
+ public const VARIANT_ALSO_NEGOTIATES = self::VariantAlsoNegotiates;
+ #[Deprecated('use Status::InsufficientStorage instead', 'Mako 12.2.0')]
+ public const INSUFFICIENT_STORAGE = self::InsufficientStorage;
+ #[Deprecated('use Status::LoopDetected instead', 'Mako 12.2.0')]
+ public const LOOP_DETECTED = self::LoopDetected;
+ #[Deprecated('use Status::NotExtended instead', 'Mako 12.2.0')]
+ public const NOT_EXTENDED = self::NotExtended;
+ #[Deprecated('use Status::NetworkAuthenticationRequired instead', 'Mako 12.2.0')]
+ public const NETWORK_AUTHENTICATION_REQUIRED = self::NetworkAuthenticationRequired;
+ /* End compatibility */
+
// 1xx Informational
- case CONTINUE = 100;
- case SWITCHING_PROTOCOLS = 101;
- case PROCESSING = 102;
- case EARLY_HINTS = 103;
+ case Continue = 100;
+ case SwitchingProtocols = 101;
+ case Processing = 102;
+ case EarlyHints = 103;
// 2xx Success
- case OK = 200;
- case CREATED = 201;
- case ACCEPTED = 202;
- case NON_AUTHORITATIVE_INFORMATION = 203;
- case NO_CONTENT = 204;
- case RESET_CONTENT = 205;
- case PARTIAL_CONTENT = 206;
- case MULTI_STATUS = 207;
- case ALREADY_REPORTED = 208;
- case IM_USED = 226;
+ case Ok = 200;
+ case Created = 201;
+ case Accepted = 202;
+ case NonAuthoritativeInformation = 203;
+ case NoContent = 204;
+ case ResetContent = 205;
+ case PartialContent = 206;
+ case MultiStatus = 207;
+ case AlreadyReported = 208;
+ case ImUsed = 226;
// 3xx Redirection
- case MULTIPLE_CHOICES = 300;
- case MOVED_PERMANENTLY = 301;
- case FOUND = 302;
- case SEE_OTHER = 303;
- case NOT_MODIFIED = 304;
- case USE_PROXY = 305;
- case TEMPORARY_REDIRECT = 307;
- case PERMANENT_REDIRECT = 308;
+ case MultipleChoices = 300;
+ case MovedPermanently = 301;
+ case Found = 302;
+ case SeeOther = 303;
+ case NotModified = 304;
+ case UseProxy = 305;
+ case TemporaryRedirect = 307;
+ case PermanentRedirect = 308;
// 4xx Client Error
- case BAD_REQUEST = 400;
- case UNAUTHORIZED = 401;
- case PAYMENT_REQUIRED = 402;
- case FORBIDDEN = 403;
- case NOT_FOUND = 404;
- case METHOD_NOT_ALLOWED = 405;
- case NOT_ACCEPTABLE = 406;
- case PROXY_AUTHENTICATION_REQUIRED = 407;
- case REQUEST_TIMEOUT = 408;
- case CONFLICT = 409;
- case GONE = 410;
- case LENGTH_REQUIRED = 411;
- case PRECONDITION_FAILED = 412;
- case PAYLOAD_TOO_LARGE = 413;
- case URI_TOO_LONG = 414;
- case UNSUPPORTED_MEDIA_TYPE = 415;
- case RANGE_NOT_SATISFIABLE = 416;
- case EXPECTATION_FAILED = 417;
- case IM_A_TEAPOT = 418;
- case AUTENTICATION_TIMEOUT = 419;
- case MISDIRECTED_REQUEST = 421;
- case UNPROCESSABLE_ENTITY = 422;
- case LOCKED = 423;
- case FAILED_DEPENDENCY = 424;
- case TOO_EARLY = 425;
- case UPGRADE_REQUIRED = 426;
- case PRECONDITION_REQUIRED = 428;
- case TOO_MANY_REQUESTS = 429;
- case REQUEST_HEADER_FIELDS_TOO_LARGE = 431;
- case UNAVAILABLE_FOR_LEGAL_REASONS = 451;
- case INVALID_TOKEN = 498;
- case TOKEN_REQUIRED = 499;
+ case BadRequest = 400;
+ case Unauthorized = 401;
+ case PaymentRequired = 402;
+ case Forbidden = 403;
+ case NotFound = 404;
+ case MethodNotAllowed = 405;
+ case NotAcceptable = 406;
+ case ProxyAuthenticationRequired = 407;
+ case RequestTimeout = 408;
+ case Conflict = 409;
+ case Gone = 410;
+ case LengthRequired = 411;
+ case PreconditionFailed = 412;
+ case PayloadTooLarge = 413;
+ case UriTooLong = 414;
+ case UnsupportedMediaType = 415;
+ case RangeNotSatisfiable = 416;
+ case ExpectationFailed = 417;
+ case ImATeapot = 418;
+ case AuthenticationTimeout = 419;
+ case MisdirectedRequest = 421;
+ case UnprocessableEntity = 422;
+ case Locked = 423;
+ case FailedDependency = 424;
+ case TooEarly = 425;
+ case UpgradeRequired = 426;
+ case PreconditionRequired = 428;
+ case TooManyRequests = 429;
+ case RequestHeaderFieldsTooLarge = 431;
+ case UnavailableForLegalReasons = 451;
+ case InvalidToken = 498;
+ case TokenRequired = 499;
// 5xx Server Error
- case INTERNAL_SERVER_ERROR = 500;
- case NOT_IMPLEMENTED = 501;
- case BAD_GATEWAY = 502;
- case SERVICE_UNAVAILABLE = 503;
- case GATEWAY_TIMEOUT = 504;
- case HTTP_VERSION_NOT_SUPPORTED = 505;
- case VARIANT_ALSO_NEGOTIATES = 506;
- case INSUFFICIENT_STORAGE = 507;
- case LOOP_DETECTED = 508;
- case NOT_EXTENDED = 510;
- case NETWORK_AUTHENTICATION_REQUIRED = 511;
+ case InternalServerError = 500;
+ case NotImplemented = 501;
+ case BadGateway = 502;
+ case ServiceUnavailable = 503;
+ case GatewayTimeout = 504;
+ case HttpVersionNotSupported = 505;
+ case VariantAlsoNegotiates = 506;
+ case InsufficientStorage = 507;
+ case LoopDetected = 508;
+ case NotExtended = 510;
+ case NetworkAuthenticationRequired = 511;
/**
* Returns the status code.
@@ -108,83 +245,83 @@ public function getMessage(): string
return match ($this) {
// 1xx Informational
- self::CONTINUE => 'Continue',
- self::SWITCHING_PROTOCOLS => 'Switching Protocols',
- self::PROCESSING => 'Processing',
- self::EARLY_HINTS => 'Early Hints',
+ self::Continue => 'Continue',
+ self::SwitchingProtocols => 'Switching Protocols',
+ self::Processing => 'Processing',
+ self::EarlyHints => 'Early Hints',
// 2xx Success
- self::OK => 'OK',
- self::CREATED => 'Created',
- self::ACCEPTED => 'Accepted',
- self::NON_AUTHORITATIVE_INFORMATION => 'Non-Authoritative Information',
- self::NO_CONTENT => 'No Content',
- self::RESET_CONTENT => 'Reset Content',
- self::PARTIAL_CONTENT => 'Partial Content',
- self::MULTI_STATUS => 'Multi-Status',
- self::ALREADY_REPORTED => 'Already Reported',
- self::IM_USED => 'IM Used',
+ self::Ok => 'OK',
+ self::Created => 'Created',
+ self::Accepted => 'Accepted',
+ self::NonAuthoritativeInformation => 'Non-Authoritative Information',
+ self::NoContent => 'No Content',
+ self::ResetContent => 'Reset Content',
+ self::PartialContent => 'Partial Content',
+ self::MultiStatus => 'Multi-Status',
+ self::AlreadyReported => 'Already Reported',
+ self::ImUsed => 'IM Used',
// 3xx Redirection
- self::MULTIPLE_CHOICES => 'Multiple Choices',
- self::MOVED_PERMANENTLY => 'Moved Permanently',
- self::FOUND => 'Found',
- self::SEE_OTHER => 'See Other',
- self::NOT_MODIFIED => 'Not Modified',
- self::USE_PROXY => 'Use Proxy',
- self::TEMPORARY_REDIRECT => 'Temporary Redirect',
- self::PERMANENT_REDIRECT => 'Permanent Redirect',
+ self::MultipleChoices => 'Multiple Choices',
+ self::MovedPermanently => 'Moved Permanently',
+ self::Found => 'Found',
+ self::SeeOther => 'See Other',
+ self::NotModified => 'Not Modified',
+ self::UseProxy => 'Use Proxy',
+ self::TemporaryRedirect => 'Temporary Redirect',
+ self::PermanentRedirect => 'Permanent Redirect',
// 4xx Client Error
- self::BAD_REQUEST => 'Bad Request',
- self::UNAUTHORIZED => 'Unauthorized',
- self::PAYMENT_REQUIRED => 'Payment Required',
- self::FORBIDDEN => 'Forbidden',
- self::NOT_FOUND => 'Not Found',
- self::METHOD_NOT_ALLOWED => 'Method Not Allowed',
- self::NOT_ACCEPTABLE => 'Not Acceptable',
- self::PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required',
- self::REQUEST_TIMEOUT => 'Request Timeout',
- self::CONFLICT => 'Conflict',
- self::GONE => 'Gone',
- self::LENGTH_REQUIRED => 'Length Required',
- self::PRECONDITION_FAILED => 'Precondition Failed',
- self::PAYLOAD_TOO_LARGE => 'Payload Too Large',
- self::URI_TOO_LONG => 'URI Too Long',
- self::UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',
- self::RANGE_NOT_SATISFIABLE => 'Range Not Satisfiable',
- self::EXPECTATION_FAILED => 'Expectation Failed',
- self::IM_A_TEAPOT => 'I\'m a teapot',
- self::AUTENTICATION_TIMEOUT => 'Authentication Timeout',
- self::MISDIRECTED_REQUEST => 'Misdirected Request',
- self::UNPROCESSABLE_ENTITY => 'Unprocessable Entity',
- self::LOCKED => 'Locked',
- self::FAILED_DEPENDENCY => 'Failed Dependency',
- self::TOO_EARLY => 'Too Early',
- self::UPGRADE_REQUIRED => 'Upgrade Required',
- self::PRECONDITION_REQUIRED => 'Precondition Required',
- self::TOO_MANY_REQUESTS => 'Too Many Requests',
- self::REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large',
- self::UNAVAILABLE_FOR_LEGAL_REASONS => 'Unavailable For Legal Reasons',
- self::INVALID_TOKEN => 'Invalid Token',
- self::TOKEN_REQUIRED => 'Token Required',
+ self::BadRequest => 'Bad Request',
+ self::Unauthorized => 'Unauthorized',
+ self::PaymentRequired => 'Payment Required',
+ self::Forbidden => 'Forbidden',
+ self::NotFound => 'Not Found',
+ self::MethodNotAllowed => 'Method Not Allowed',
+ self::NotAcceptable => 'Not Acceptable',
+ self::ProxyAuthenticationRequired => 'Proxy Authentication Required',
+ self::RequestTimeout => 'Request Timeout',
+ self::Conflict => 'Conflict',
+ self::Gone => 'Gone',
+ self::LengthRequired => 'Length Required',
+ self::PreconditionFailed => 'Precondition Failed',
+ self::PayloadTooLarge => 'Payload Too Large',
+ self::UriTooLong => 'URI Too Long',
+ self::UnsupportedMediaType => 'Unsupported Media Type',
+ self::RangeNotSatisfiable => 'Range Not Satisfiable',
+ self::ExpectationFailed => 'Expectation Failed',
+ self::ImATeapot => 'I\'m a teapot',
+ self::AuthenticationTimeout => 'Authentication Timeout',
+ self::MisdirectedRequest => 'Misdirected Request',
+ self::UnprocessableEntity => 'Unprocessable Entity',
+ self::Locked => 'Locked',
+ self::FailedDependency => 'Failed Dependency',
+ self::TooEarly => 'Too Early',
+ self::UpgradeRequired => 'Upgrade Required',
+ self::PreconditionRequired => 'Precondition Required',
+ self::TooManyRequests => 'Too Many Requests',
+ self::RequestHeaderFieldsTooLarge => 'Request Header Fields Too Large',
+ self::UnavailableForLegalReasons => 'Unavailable For Legal Reasons',
+ self::InvalidToken => 'Invalid Token',
+ self::TokenRequired => 'Token Required',
// 5xx Server Error
- self::INTERNAL_SERVER_ERROR => 'Internal Server Error',
- self::NOT_IMPLEMENTED => 'Not Implemented',
- self::BAD_GATEWAY => 'Bad Gateway',
- self::SERVICE_UNAVAILABLE => 'Service Unavailable',
- self::GATEWAY_TIMEOUT => 'Gateway Timeout',
- self::HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version Not Supported',
- self::VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',
- self::INSUFFICIENT_STORAGE => 'Insufficient Storage',
- self::LOOP_DETECTED => 'Loop Detected',
- self::NOT_EXTENDED => 'Not Extended',
- self::NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required',
+ self::InternalServerError => 'Internal Server Error',
+ self::NotImplemented => 'Not Implemented',
+ self::BadGateway => 'Bad Gateway',
+ self::ServiceUnavailable => 'Service Unavailable',
+ self::GatewayTimeout => 'Gateway Timeout',
+ self::HttpVersionNotSupported => 'HTTP Version Not Supported',
+ self::VariantAlsoNegotiates => 'Variant Also Negotiates',
+ self::InsufficientStorage => 'Insufficient Storage',
+ self::LoopDetected => 'Loop Detected',
+ self::NotExtended => 'Not Extended',
+ self::NetworkAuthenticationRequired => 'Network Authentication Required',
};
}
}
diff --git a/src/mako/http/response/senders/File.php b/src/mako/http/response/senders/File.php
index 20e0453db..ebace553d 100644
--- a/src/mako/http/response/senders/File.php
+++ b/src/mako/http/response/senders/File.php
@@ -256,7 +256,7 @@ public function send(Request $request, Response $response): void
// Not an acceptable range so we'll just send an empty response
// along with a "requested range not satisfiable" status
- $response->setStatus(Status::RANGE_NOT_SATISFIABLE);
+ $response->setStatus(Status::RangeNotSatisfiable);
$response->sendHeaders();
}
@@ -273,7 +273,7 @@ public function send(Request $request, Response $response): void
// Valid range so we'll need to tell the client which range we're sending
// and set the content-length header value to the length of the byte range
- $response->setStatus(Status::PARTIAL_CONTENT);
+ $response->setStatus(Status::PartialContent);
$response->headers->add('Content-Range', sprintf('bytes %s-%s/%s', $range['start'], $range['end'], $this->fileSize));
diff --git a/src/mako/http/response/senders/Redirect.php b/src/mako/http/response/senders/Redirect.php
index 1271fa2d5..b54c60318 100644
--- a/src/mako/http/response/senders/Redirect.php
+++ b/src/mako/http/response/senders/Redirect.php
@@ -25,37 +25,37 @@ class Redirect implements ResponseSenderInterface
/**
* Moved permanently status code.
*/
- public const Status MOVED_PERMANENTLY = Status::MOVED_PERMANENTLY;
+ public const Status MOVED_PERMANENTLY = Status::MovedPermanently;
/**
* Found status code.
*/
- public const Status FOUND = Status::FOUND;
+ public const Status FOUND = Status::Found;
/**
* See other status code.
*/
- public const Status SEE_OTHER = Status::SEE_OTHER;
+ public const Status SEE_OTHER = Status::SeeOther;
/**
* Temporary redirect status code.
*/
- public const Status TEMPORARY_REDIRECT = Status::TEMPORARY_REDIRECT;
+ public const Status TEMPORARY_REDIRECT = Status::TemporaryRedirect;
/**
* Permanent redirect status code.
*/
- public const Status PERMANENT_REDIRECT = Status::PERMANENT_REDIRECT;
+ public const Status PERMANENT_REDIRECT = Status::PermanentRedirect;
/**
* Supported redirect types.
*/
public const array SUPPORTED_STATUS_CODES = [
- Status::MOVED_PERMANENTLY,
- Status::FOUND,
- Status::SEE_OTHER,
- Status::TEMPORARY_REDIRECT,
- Status::PERMANENT_REDIRECT,
+ Status::MovedPermanently,
+ Status::Found,
+ Status::SeeOther,
+ Status::TemporaryRedirect,
+ Status::PermanentRedirect,
];
/**
@@ -68,7 +68,7 @@ class Redirect implements ResponseSenderInterface
*/
public function __construct(
protected string $location,
- int|Status $status = Status::FOUND
+ int|Status $status = Status::Found
) {
$this->setStatus($status);
}
@@ -98,7 +98,7 @@ public function setStatus(int|Status $status): Redirect
*/
public function movedPermanently(): Redirect
{
- $this->status = Status::MOVED_PERMANENTLY;
+ $this->status = Status::MovedPermanently;
return $this;
}
@@ -110,7 +110,7 @@ public function movedPermanently(): Redirect
*/
public function found(): Redirect
{
- $this->status = Status::FOUND;
+ $this->status = Status::Found;
return $this;
}
@@ -122,7 +122,7 @@ public function found(): Redirect
*/
public function seeOther(): Redirect
{
- $this->status = Status::SEE_OTHER;
+ $this->status = Status::SeeOther;
return $this;
}
@@ -134,7 +134,7 @@ public function seeOther(): Redirect
*/
public function temporaryRedirect(): Redirect
{
- $this->status = Status::TEMPORARY_REDIRECT;
+ $this->status = Status::TemporaryRedirect;
return $this;
}
@@ -146,7 +146,7 @@ public function temporaryRedirect(): Redirect
*/
public function permanentRedirect(): Redirect
{
- $this->status = Status::PERMANENT_REDIRECT;
+ $this->status = Status::PermanentRedirect;
return $this;
}
diff --git a/src/mako/http/response/senders/stream/event/Type.php b/src/mako/http/response/senders/stream/event/Type.php
index 83997eefc..f7e069ad9 100644
--- a/src/mako/http/response/senders/stream/event/Type.php
+++ b/src/mako/http/response/senders/stream/event/Type.php
@@ -7,14 +7,29 @@
namespace mako\http\response\senders\stream\event;
+use Deprecated;
+
/**
* Event stream field types.
*/
enum Type: string
{
- case COMMENT = '';
- case DATA = 'data';
- case EVENT = 'event';
- case ID = 'id';
- case RETRY = 'retry';
+ /* Start compatibility */
+ #[Deprecated('use Type::Comment instead', 'Mako 12.2.0')]
+ public const COMMENT = self::Comment;
+ #[Deprecated('use Type::Data instead', 'Mako 12.2.0')]
+ public const DATA = self::Data;
+ #[Deprecated('use Type::Event instead', 'Mako 12.2.0')]
+ public const EVENT = self::Event;
+ #[Deprecated('use Type::Id instead', 'Mako 12.2.0')]
+ public const ID = self::Id;
+ #[Deprecated('use Type::Retry instead', 'Mako 12.2.0')]
+ public const RETRY = self::Retry;
+ /* End compatibility */
+
+ case Comment = '';
+ case Data = 'data';
+ case Event = 'event';
+ case Id = 'id';
+ case Retry = 'retry';
}
diff --git a/src/mako/pixel/image/operations/AspectRatio.php b/src/mako/pixel/image/operations/AspectRatio.php
index 6a57569f3..70c6478a5 100644
--- a/src/mako/pixel/image/operations/AspectRatio.php
+++ b/src/mako/pixel/image/operations/AspectRatio.php
@@ -7,28 +7,41 @@
namespace mako\pixel\image\operations;
+use Deprecated;
+
/**
* Aspect ratio.
*/
enum AspectRatio
{
+ /* Start compatibility */
+ #[Deprecated('use AspectRatio::Ignore instead', 'Mako 12.2.0')]
+ public const IGNORE = self::Ignore;
+ #[Deprecated('use AspectRatio::Auto instead', 'Mako 12.2.0')]
+ public const AUTO = self::Auto;
+ #[Deprecated('use AspectRatio::Width instead', 'Mako 12.2.0')]
+ public const WIDTH = self::Width;
+ #[Deprecated('use AspectRatio::Height instead', 'Mako 12.2.0')]
+ public const HEIGHT = self::Height;
+ /* End compatibility */
+
/**
* Ignore the aspect ratio.
*/
- case IGNORE;
+ case Ignore;
/**
* Calculate smallest size based on given height and width while maintaining aspect ratio.
*/
- case AUTO;
+ case Auto;
/**
* Calculate new size on given width while maintaining aspect ratio.
*/
- case WIDTH;
+ case Width;
/**
* Calculate new size on given height while maintaining aspect ratio.
*/
- case HEIGHT;
+ case Height;
}
diff --git a/src/mako/pixel/image/operations/Flip.php b/src/mako/pixel/image/operations/Flip.php
index eec28fdf7..43209f1e3 100644
--- a/src/mako/pixel/image/operations/Flip.php
+++ b/src/mako/pixel/image/operations/Flip.php
@@ -7,18 +7,27 @@
namespace mako\pixel\image\operations;
+use Deprecated;
+
/**
* Flip.
*/
enum Flip
{
+ /* Start compatibility */
+ #[Deprecated('Use Flip::Horizontal instead', 'Mako 12.2.0')]
+ public const HORIZONTAL = self::Horizontal;
+ #[Deprecated('Use Flip::Vertical instead', 'Mako 12.2.0')]
+ public const VERTICAL = self::Vertical;
+ /* End compatibility */
+
/**
* Flip horizontally.
*/
- case HORIZONTAL;
+ case Horizontal;
/**
* Flip vertically.
*/
- case VERTICAL;
+ case Vertical;
}
diff --git a/src/mako/pixel/image/operations/WatermarkPosition.php b/src/mako/pixel/image/operations/WatermarkPosition.php
index 6a0babdd5..cb756f761 100644
--- a/src/mako/pixel/image/operations/WatermarkPosition.php
+++ b/src/mako/pixel/image/operations/WatermarkPosition.php
@@ -7,33 +7,48 @@
namespace mako\pixel\image\operations;
+use Deprecated;
+
/**
* Watermark position.
*/
enum WatermarkPosition
{
+ /* Start compatibility */
+ #[Deprecated('use WatermarkPosition::TopLeft instead', 'Mako 12.2.0')]
+ public const TOP_LEFT = self::TopLeft;
+ #[Deprecated('use WatermarkPosition::TopRight instead', 'Mako 12.2.0')]
+ public const TOP_RIGHT = self::TopRight;
+ #[Deprecated('use WatermarkPosition::BottomLeft instead', 'Mako 12.2.0')]
+ public const BOTTOM_LEFT = self::BottomLeft;
+ #[Deprecated('use WatermarkPosition::BottomRight instead', 'Mako 12.2.0')]
+ public const BOTTOM_RIGHT = self::BottomRight;
+ #[Deprecated('use WatermarkPosition::Center instead', 'Mako 12.2.0')]
+ public const CENTER = self::Center;
+ /* End compatibility */
+
/**
* Top left corner.
*/
- case TOP_LEFT;
+ case TopLeft;
/**
* Top right corner.
*/
- case TOP_RIGHT;
+ case TopRight;
/**
* Bottom left corner.
*/
- case BOTTOM_LEFT;
+ case BottomLeft;
/**
- * Bottom left corner.
+ * Bottom right corner.
*/
- case BOTTOM_RIGHT;
+ case BottomRight;
/**
* Centered.
*/
- case CENTER;
+ case Center;
}
diff --git a/src/mako/pixel/image/operations/gd/Flip.php b/src/mako/pixel/image/operations/gd/Flip.php
index 4c2773c82..5a53e525a 100644
--- a/src/mako/pixel/image/operations/gd/Flip.php
+++ b/src/mako/pixel/image/operations/gd/Flip.php
@@ -28,7 +28,7 @@ class Flip implements OperationInterface
* Constructor.
*/
public function __construct(
- protected FlipDirection $direction = FlipDirection::HORIZONTAL
+ protected FlipDirection $direction = FlipDirection::Horizontal
) {
}
@@ -49,7 +49,7 @@ public function apply(object &$imageResource): void
imagefill($flipped, 0, 0, $transparent);
- if ($this->direction === FlipDirection::VERTICAL) {
+ if ($this->direction === FlipDirection::Vertical) {
for ($y = 0; $y < $height; $y++) {
imagecopy($flipped, $imageResource, 0, $y, 0, $height - $y - 1, $width, 1);
}
diff --git a/src/mako/pixel/image/operations/gd/Resize.php b/src/mako/pixel/image/operations/gd/Resize.php
index 648d5faa0..c7b05b018 100644
--- a/src/mako/pixel/image/operations/gd/Resize.php
+++ b/src/mako/pixel/image/operations/gd/Resize.php
@@ -33,7 +33,7 @@ class Resize implements OperationInterface
public function __construct(
protected int $width,
protected ?int $height = null,
- protected AspectRatio $aspectRatio = AspectRatio::AUTO
+ protected AspectRatio $aspectRatio = AspectRatio::Auto
) {
}
diff --git a/src/mako/pixel/image/operations/gd/Watermark.php b/src/mako/pixel/image/operations/gd/Watermark.php
index 3ce5f0d5f..9935f06d5 100644
--- a/src/mako/pixel/image/operations/gd/Watermark.php
+++ b/src/mako/pixel/image/operations/gd/Watermark.php
@@ -33,7 +33,7 @@ class Watermark implements OperationInterface
*/
public function __construct(
protected Gd|string $image,
- protected WatermarkPosition $position = WatermarkPosition::BOTTOM_RIGHT,
+ protected WatermarkPosition $position = WatermarkPosition::BottomRight,
protected int $opacity = 100,
protected int $margin = 0
) {
@@ -77,19 +77,19 @@ public function apply(object &$imageResource): void
}
switch ($this->position) {
- case WatermarkPosition::TOP_RIGHT:
+ case WatermarkPosition::TopRight:
$x = imagesx($imageResource) - $watermarkWidth - $this->margin;
$y = 0 + $this->margin;
break;
- case WatermarkPosition::BOTTOM_LEFT:
+ case WatermarkPosition::BottomLeft:
$x = 0 + $this->margin;
$y = imagesy($imageResource) - $watermarkHeight - $this->margin;
break;
- case WatermarkPosition::BOTTOM_RIGHT:
+ case WatermarkPosition::BottomRight:
$x = imagesx($imageResource) - $watermarkWidth - $this->margin;
$y = imagesy($imageResource) - $watermarkHeight - $this->margin;
break;
- case WatermarkPosition::CENTER:
+ case WatermarkPosition::Center:
$x = (imagesx($imageResource) - $watermarkWidth) / 2;
$y = (imagesy($imageResource) - $watermarkHeight) / 2;
break;
diff --git a/src/mako/pixel/image/operations/imagemagick/Flip.php b/src/mako/pixel/image/operations/imagemagick/Flip.php
index 6f347c463..22ad869fe 100644
--- a/src/mako/pixel/image/operations/imagemagick/Flip.php
+++ b/src/mako/pixel/image/operations/imagemagick/Flip.php
@@ -20,7 +20,7 @@ class Flip implements OperationInterface
* Constructor.
*/
public function __construct(
- protected FlipDirection $direction = FlipDirection::HORIZONTAL
+ protected FlipDirection $direction = FlipDirection::Horizontal
) {
}
@@ -32,7 +32,7 @@ public function __construct(
#[Override]
public function apply(object &$imageResource): void
{
- if ($this->direction === FlipDirection::VERTICAL) {
+ if ($this->direction === FlipDirection::Vertical) {
$imageResource->flipImage();
}
else {
diff --git a/src/mako/pixel/image/operations/imagemagick/Resize.php b/src/mako/pixel/image/operations/imagemagick/Resize.php
index f8adff159..ebe9ae674 100644
--- a/src/mako/pixel/image/operations/imagemagick/Resize.php
+++ b/src/mako/pixel/image/operations/imagemagick/Resize.php
@@ -25,7 +25,7 @@ class Resize implements OperationInterface
public function __construct(
protected int $width,
protected ?int $height = null,
- protected AspectRatio $aspectRatio = AspectRatio::AUTO
+ protected AspectRatio $aspectRatio = AspectRatio::Auto
) {
}
diff --git a/src/mako/pixel/image/operations/imagemagick/Watermark.php b/src/mako/pixel/image/operations/imagemagick/Watermark.php
index 79119815a..6becc0306 100644
--- a/src/mako/pixel/image/operations/imagemagick/Watermark.php
+++ b/src/mako/pixel/image/operations/imagemagick/Watermark.php
@@ -23,7 +23,7 @@ class Watermark implements OperationInterface
*/
public function __construct(
protected ImageMagick|string $image,
- protected WatermarkPosition $position = WatermarkPosition::BOTTOM_RIGHT,
+ protected WatermarkPosition $position = WatermarkPosition::BottomRight,
protected int $opacity = 100,
protected int $margin = 0
) {
@@ -50,19 +50,19 @@ public function apply(object &$imageResource): void
}
switch ($this->position) {
- case WatermarkPosition::TOP_RIGHT:
+ case WatermarkPosition::TopRight:
$x = $imageResource->getImageWidth() - $watermarkWidth - $this->margin;
$y = 0 + $this->margin;
break;
- case WatermarkPosition::BOTTOM_LEFT:
+ case WatermarkPosition::BottomLeft:
$x = 0 + $this->margin;
$y = $imageResource->getImageHeight() - $watermarkHeight - $this->margin;
break;
- case WatermarkPosition::BOTTOM_RIGHT:
+ case WatermarkPosition::BottomRight:
$x = $imageResource->getImageWidth() - $watermarkWidth - $this->margin;
$y = $imageResource->getImageHeight() - $watermarkHeight - $this->margin;
break;
- case WatermarkPosition::CENTER:
+ case WatermarkPosition::Center:
$x = ($imageResource->getImageWidth() - $watermarkWidth) / 2;
$y = ($imageResource->getImageHeight() - $watermarkHeight) / 2;
break;
diff --git a/src/mako/pixel/image/operations/traits/CalculateNewDimensionsTrait.php b/src/mako/pixel/image/operations/traits/CalculateNewDimensionsTrait.php
index e52e6b806..25bc95e5c 100644
--- a/src/mako/pixel/image/operations/traits/CalculateNewDimensionsTrait.php
+++ b/src/mako/pixel/image/operations/traits/CalculateNewDimensionsTrait.php
@@ -27,7 +27,7 @@ protected function calculateNewDimensions(int $width, ?int $height, int $oldWidt
$newHeight = round($oldHeight * ($width / 100));
}
else {
- if ($aspectRatio === AspectRatio::AUTO) {
+ if ($aspectRatio === AspectRatio::Auto) {
// Calculate smallest size based on given height and width while maintaining aspect ratio
$percentage = min(($width / $oldWidth), ($height / $oldHeight));
@@ -35,13 +35,13 @@ protected function calculateNewDimensions(int $width, ?int $height, int $oldWidt
$newWidth = round($oldWidth * $percentage);
$newHeight = round($oldHeight * $percentage);
}
- elseif ($aspectRatio === AspectRatio::WIDTH) {
+ elseif ($aspectRatio === AspectRatio::Width) {
// Base new size on given width while maintaining aspect ratio
$newWidth = $width;
$newHeight = round($oldHeight * ($width / $oldWidth));
}
- elseif ($aspectRatio === AspectRatio::HEIGHT) {
+ elseif ($aspectRatio === AspectRatio::Height) {
// Base new size on given height while maintaining aspect ratio
$newWidth = round($oldWidth * ($height / $oldHeight));
diff --git a/src/mako/pixel/metadata/xmp/XmpReader.php b/src/mako/pixel/metadata/xmp/XmpReader.php
index 66469ac1d..3dd9a714c 100644
--- a/src/mako/pixel/metadata/xmp/XmpReader.php
+++ b/src/mako/pixel/metadata/xmp/XmpReader.php
@@ -256,14 +256,14 @@ protected function getRawProperties(?string $namespace, ?string $propertyName):
protected function hydrate(array $properties): array
{
foreach ($properties as &$property) {
- if ($property['options'] & Type::ARRAY->value) {
+ if ($property['options'] & Type::Array->value) {
$property = new ArrayProperty(
$property['namespace'],
$property['options'],
$property['name']
);
}
- elseif ($property['options'] & Type::QUALIFIER->value) {
+ elseif ($property['options'] & Type::Qualifier->value) {
$property = new QualifierProperty(
$property['namespace'],
$property['options'],
@@ -271,7 +271,7 @@ protected function hydrate(array $properties): array
$property['value']
);
}
- elseif ($property['options'] & Type::STRUCT->value) {
+ elseif ($property['options'] & Type::Struct->value) {
$property = new StructProperty(
$property['namespace'],
$property['options'],
diff --git a/src/mako/pixel/metadata/xmp/properties/Type.php b/src/mako/pixel/metadata/xmp/properties/Type.php
index a46fdaa27..db89021eb 100644
--- a/src/mako/pixel/metadata/xmp/properties/Type.php
+++ b/src/mako/pixel/metadata/xmp/properties/Type.php
@@ -7,14 +7,25 @@
namespace mako\pixel\metadata\xmp\properties;
+use Deprecated;
+
/**
* Value type enum.
*/
enum Type: int
{
- case STRUCT = 0x00000100;
+ /* Start compatibility */
+ #[Deprecated('use Type::Struct instead', 'Mako 12.2.0')]
+ public const STRUCT = self::Struct;
+ #[Deprecated('use Type::Array instead', 'Mako 12.2.0')]
+ public const ARRAY = self::Array;
+ #[Deprecated('use Type::Qualifier instead', 'Mako 12.2.0')]
+ public const QUALIFIER = self::Qualifier;
+ /* End compatibility */
+
+ case Struct = 0x00000100;
- case ARRAY = 0x00000200;
+ case Array = 0x00000200;
- case QUALIFIER = 0x00000020;
+ case Qualifier = 0x00000020;
}
diff --git a/tests/unit/FunctionsTest.php b/tests/unit/FunctionsTest.php
index ae9056a53..c54501774 100644
--- a/tests/unit/FunctionsTest.php
+++ b/tests/unit/FunctionsTest.php
@@ -76,14 +76,14 @@ public function testEnvWithBooleanValues(): void
$_ENV['MAKO_TRUE'] = 'true';
$_ENV['MAKO_FALSE'] = 'false';
- $this->assertTrue(env('MAKO_TRUE', as: Type::BOOL));
- $this->assertFalse(env('MAKO_FALSE', as: Type::BOOL));
+ $this->assertTrue(env('MAKO_TRUE', as: Type::Bool));
+ $this->assertFalse(env('MAKO_FALSE', as: Type::Bool));
$_ENV['MAKO_TRUE'] = '1';
$_ENV['MAKO_FALSE'] = '0';
- $this->assertTrue(env('MAKO_TRUE', as: Type::BOOL));
- $this->assertFalse(env('MAKO_FALSE', as: Type::BOOL));
+ $this->assertTrue(env('MAKO_TRUE', as: Type::Bool));
+ $this->assertFalse(env('MAKO_FALSE', as: Type::Bool));
}
/**
@@ -94,8 +94,8 @@ public function testEnvWithIntValues(): void
$_ENV['MAKO_VALID'] = '1234';
$_ENV['MAKO_INVALID'] = 'foobar';
- $this->assertSame(1234, env('MAKO_VALID', as: Type::INT));
- $this->assertNull(env('MAKO_INVALID', as: Type::INT));
+ $this->assertSame(1234, env('MAKO_VALID', as: Type::Int));
+ $this->assertNull(env('MAKO_INVALID', as: Type::Int));
}
/**
@@ -106,8 +106,8 @@ public function testEnvWithFloatValues(): void
$_ENV['MAKO_VALID'] = '1.2';
$_ENV['MAKO_INVALID'] = 'foobar';
- $this->assertSame(1.2, env('MAKO_VALID', as: Type::FLOAT));
- $this->assertNull(env('MAKO_INVALID', as: Type::FLOAT));
+ $this->assertSame(1.2, env('MAKO_VALID', as: Type::Float));
+ $this->assertNull(env('MAKO_INVALID', as: Type::Float));
}
/**
@@ -117,12 +117,12 @@ public function testEnvWithJsonObjectValues(): void
{
$_ENV['MAKO_JSON'] = '{"foo": "bar"}';
- $value = env('MAKO_JSON', as: Type::JSON_AS_OBJECT);
+ $value = env('MAKO_JSON', as: Type::JsonAsObject);
$this->assertIsObject($value);
$this->assertSame('bar', $value->foo);
- $value = env('MAKO_NO_JSON', as: Type::JSON_AS_OBJECT);
+ $value = env('MAKO_NO_JSON', as: Type::JsonAsObject);
$this->assertNull($value);
}
@@ -134,12 +134,12 @@ public function testEnvWithJsonArrayValues(): void
{
$_ENV['MAKO_JSON'] = '{"foo": "bar"}';
- $value = env('MAKO_JSON', as: Type::JSON_AS_ARRAY);
+ $value = env('MAKO_JSON', as: Type::JsonAsArray);
$this->assertIsArray($value);
$this->assertSame('bar', $value['foo']);
- $value = env('MAKO_NO_JSON', as: Type::JSON_AS_ARRAY);
+ $value = env('MAKO_NO_JSON', as: Type::JsonAsArray);
$this->assertNull($value);
}
diff --git a/tests/unit/cli/input/components/ConfirmationTest.php b/tests/unit/cli/input/components/ConfirmationTest.php
index bd284b2c2..e05afcea3 100644
--- a/tests/unit/cli/input/components/ConfirmationTest.php
+++ b/tests/unit/cli/input/components/ConfirmationTest.php
@@ -259,7 +259,7 @@ public function testInteractiveConfirmationYes(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::LEFT->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Left->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -267,7 +267,7 @@ public function testInteractiveConfirmationYes(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertTrue($confirmation->ask('Delete all files?'));
}
@@ -287,7 +287,7 @@ public function testInteractiveConfirmationNo(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertFalse($confirmation->ask('Delete all files?'));
}
@@ -307,7 +307,7 @@ public function testInteractiveConfirmationDefaultNo(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertFalse($confirmation->ask('Delete all files?', false));
}
@@ -327,7 +327,7 @@ public function testInteractiveConfirmationDefaulYes(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertTrue($confirmation->ask('Delete all files?', true));
}
@@ -350,7 +350,7 @@ public function testInteractiveConfirmationYesWithCustomLabels(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::LEFT->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Left->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -358,7 +358,7 @@ public function testInteractiveConfirmationYesWithCustomLabels(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertTrue($confirmation->ask('Delete all files?'));
}
@@ -380,7 +380,7 @@ public function testInteractiveConfirmationYesWithCustomTheme(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::LEFT->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Left->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -388,7 +388,7 @@ public function testInteractiveConfirmationYesWithCustomTheme(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertTrue($confirmation->ask('Delete all files?'));
}
diff --git a/tests/unit/cli/input/components/SelectTest.php b/tests/unit/cli/input/components/SelectTest.php
index 033621692..4c3087495 100644
--- a/tests/unit/cli/input/components/SelectTest.php
+++ b/tests/unit/cli/input/components/SelectTest.php
@@ -365,7 +365,7 @@ public function testInteractiveSelectAndPickFirstOption(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::RIGHT->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Right->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -374,7 +374,7 @@ public function testInteractiveSelectAndPickFirstOption(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertSame(0, $select->ask(
'Favorite food?',
@@ -398,7 +398,7 @@ public function testInteractiveSelectAndPickFirstOptionWithAsciiTheme(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::RIGHT->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Right->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -407,7 +407,7 @@ public function testInteractiveSelectAndPickFirstOptionWithAsciiTheme(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertSame(0, $select->ask(
'Favorite food?',
@@ -431,7 +431,7 @@ public function testInteractiveSelectAndPickFirstOptionWithAsciiThemeAndCustomOp
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::RIGHT->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Right->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -440,7 +440,7 @@ public function testInteractiveSelectAndPickFirstOptionWithAsciiThemeAndCustomOp
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertSame(0, $select->ask(
'Favorite food?',
@@ -465,7 +465,7 @@ public function testInteractiveSelectAndPickSecondOption(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::DOWN->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Down->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -474,7 +474,7 @@ public function testInteractiveSelectAndPickSecondOption(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::RIGHT->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Right->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -483,7 +483,7 @@ public function testInteractiveSelectAndPickSecondOption(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertSame(1, $select->ask(
'Favorite food?',
@@ -507,7 +507,7 @@ public function testInteractiveSelectAndPickMultipleOptions(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::SPACE->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Space->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -516,7 +516,7 @@ public function testInteractiveSelectAndPickMultipleOptions(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::UP->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Up->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -525,7 +525,7 @@ public function testInteractiveSelectAndPickMultipleOptions(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::SPACE->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Space->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -534,7 +534,7 @@ public function testInteractiveSelectAndPickMultipleOptions(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertSame([0, 1], $select->ask(
'Favorite food?',
@@ -558,7 +558,7 @@ public function testInteractiveSelectAndPickMultipleOptionsAndReturnValues(): vo
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::SPACE->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Space->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -567,7 +567,7 @@ public function testInteractiveSelectAndPickMultipleOptionsAndReturnValues(): vo
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::UP->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Up->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -576,7 +576,7 @@ public function testInteractiveSelectAndPickMultipleOptionsAndReturnValues(): vo
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::SPACE->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Space->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -585,7 +585,7 @@ public function testInteractiveSelectAndPickMultipleOptionsAndReturnValues(): vo
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertSame(['Burgers', 'Sushi'], $select->ask(
'Favorite food?',
@@ -609,7 +609,7 @@ public function testInteractiveSelectAndPickFirstOptionAfterPickingNoOption(): v
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -620,7 +620,7 @@ public function testInteractiveSelectAndPickFirstOptionAfterPickingNoOption(): v
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::LEFT->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Left->value);
$output->shouldReceive('write')->once()->with(<<<'OUTPUT'
@@ -629,7 +629,7 @@ public function testInteractiveSelectAndPickFirstOptionAfterPickingNoOption(): v
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertSame(0, $select->ask(
'Favorite food?',
@@ -653,7 +653,7 @@ public function testInteractiveSelectAndNoOption(): void
OUTPUT);
- $input->shouldReceive('readBytes')->once()->andReturn(Key::ENTER->value);
+ $input->shouldReceive('readBytes')->once()->andReturn(Key::Enter->value);
$this->assertSame(null, $select->ask(
'Favorite food?',
diff --git a/tests/unit/database/query/compilers/MariaDBCompilerTest.php b/tests/unit/database/query/compilers/MariaDBCompilerTest.php
index 5778d5c49..afb28eb79 100644
--- a/tests/unit/database/query/compilers/MariaDBCompilerTest.php
+++ b/tests/unit/database/query/compilers/MariaDBCompilerTest.php
@@ -71,7 +71,7 @@ public function testBasicEuclidianWhereVectorDistance(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->whereVectorDistance('embedding', [1, 2, 3, 4, 5], maxDistance: 0.5, vectorDistance: VectorDistance::EUCLIDEAN)
+ ->whereVectorDistance('embedding', [1, 2, 3, 4, 5], maxDistance: 0.5, vectorDistance: VectorDistance::Euclidean)
->getCompiler()->select();
$this->assertEquals('SELECT * FROM `foobar` WHERE VEC_DISTANCE_EUCLIDEAN(`embedding`, VEC_FromText(?)) <= ?', $query['sql']);
@@ -165,7 +165,7 @@ public function testOrderByVectorDistanceEuclidean(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->orderByVectorDistance('embedding', [1, 2, 3, 4, 5], VectorDistance::EUCLIDEAN)
+ ->orderByVectorDistance('embedding', [1, 2, 3, 4, 5], VectorDistance::Euclidean)
->getCompiler()->select();
$this->assertEquals('SELECT * FROM `foobar` ORDER BY VEC_DISTANCE_EUCLIDEAN(`embedding`, VEC_FromText(?)) ASC', $query['sql']);
@@ -255,7 +255,7 @@ public function testVectorEuclideanDistanceSelectValue(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->select([new OutVectorDistance('embedding', [1, 2, 3, 4], VectorDistance::EUCLIDEAN)])
+ ->select([new OutVectorDistance('embedding', [1, 2, 3, 4], VectorDistance::Euclidean)])
->getCompiler()->select();
$this->assertEquals('SELECT VEC_DISTANCE_EUCLIDEAN(`embedding`, VEC_FromText(?)) FROM `foobar`', $query['sql']);
diff --git a/tests/unit/database/query/compilers/MySQLCompilerTest.php b/tests/unit/database/query/compilers/MySQLCompilerTest.php
index 355e695e9..7a0dee24e 100644
--- a/tests/unit/database/query/compilers/MySQLCompilerTest.php
+++ b/tests/unit/database/query/compilers/MySQLCompilerTest.php
@@ -260,7 +260,7 @@ public function testBasicEuclidianWhereVectorDistance(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->whereVectorDistance('embedding', [1, 2, 3, 4, 5], maxDistance: 0.5, vectorDistance: VectorDistance::EUCLIDEAN)
+ ->whereVectorDistance('embedding', [1, 2, 3, 4, 5], maxDistance: 0.5, vectorDistance: VectorDistance::Euclidean)
->getCompiler()->select();
$this->assertEquals("SELECT * FROM `foobar` WHERE DISTANCE(`embedding`, STRING_TO_VECTOR(?), 'EUCLIDEAN') <= ?", $query['sql']);
@@ -354,7 +354,7 @@ public function testOrderByVectorDistanceEuclidean(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->orderByVectorDistance('embedding', [1, 2, 3, 4, 5], VectorDistance::EUCLIDEAN)
+ ->orderByVectorDistance('embedding', [1, 2, 3, 4, 5], VectorDistance::Euclidean)
->getCompiler()->select();
$this->assertEquals("SELECT * FROM `foobar` ORDER BY DISTANCE(`embedding`, STRING_TO_VECTOR(?), 'EUCLIDEAN') ASC", $query['sql']);
@@ -444,7 +444,7 @@ public function testVectorEuclideanDistanceSelectValue(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->select([new OutVectorDistance('embedding', [1, 2, 3, 4], VectorDistance::EUCLIDEAN)])
+ ->select([new OutVectorDistance('embedding', [1, 2, 3, 4], VectorDistance::Euclidean)])
->getCompiler()->select();
$this->assertEquals("SELECT DISTANCE(`embedding`, STRING_TO_VECTOR(?), 'EUCLIDEAN') FROM `foobar`", $query['sql']);
diff --git a/tests/unit/database/query/compilers/PostgresCompilerTest.php b/tests/unit/database/query/compilers/PostgresCompilerTest.php
index 18e290744..8c152aa45 100644
--- a/tests/unit/database/query/compilers/PostgresCompilerTest.php
+++ b/tests/unit/database/query/compilers/PostgresCompilerTest.php
@@ -232,7 +232,7 @@ public function testBasicEuclidianWhereVectorDistance(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->whereVectorDistance('embedding', [1, 2, 3, 4, 5], maxDistance: 0.5, vectorDistance: VectorDistance::EUCLIDEAN)
+ ->whereVectorDistance('embedding', [1, 2, 3, 4, 5], maxDistance: 0.5, vectorDistance: VectorDistance::Euclidean)
->getCompiler()->select();
$this->assertEquals('SELECT * FROM "foobar" WHERE "embedding" <-> ? <= ?', $query['sql']);
@@ -326,7 +326,7 @@ public function testOrderByVectorDistanceEuclidean(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->orderByVectorDistance('embedding', [1, 2, 3, 4, 5], VectorDistance::EUCLIDEAN)
+ ->orderByVectorDistance('embedding', [1, 2, 3, 4, 5], VectorDistance::Euclidean)
->getCompiler()->select();
$this->assertEquals('SELECT * FROM "foobar" ORDER BY "embedding" <-> ? ASC', $query['sql']);
@@ -416,7 +416,7 @@ public function testVectorEuclideanDistanceSelectValue(): void
$query = $this->getBuilder();
$query = $query->table('foobar')
- ->select([new OutVectorDistance('embedding', [1, 2, 3, 4], VectorDistance::EUCLIDEAN)])
+ ->select([new OutVectorDistance('embedding', [1, 2, 3, 4], VectorDistance::Euclidean)])
->getCompiler()->select();
$this->assertEquals('SELECT "embedding" <-> ? FROM "foobar"', $query['sql']);
diff --git a/tests/unit/error/handlers/web/ProductionHandlerTest.php b/tests/unit/error/handlers/web/ProductionHandlerTest.php
index 197cc61a5..956cfbed4 100644
--- a/tests/unit/error/handlers/web/ProductionHandlerTest.php
+++ b/tests/unit/error/handlers/web/ProductionHandlerTest.php
@@ -59,7 +59,7 @@ public function testRegularErrorWithView(): void
$response->shouldReceive('setBody')->once()->with('rendered')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::INTERNAL_SERVER_ERROR)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::InternalServerError)->andReturn($response);
$response->shouldReceive('send')->once();
@@ -192,7 +192,7 @@ public function testRegularErrorWithRenderException(): void
$response->shouldReceive('setBody')->once()->with('rendered')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::INTERNAL_SERVER_ERROR)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::InternalServerError)->andReturn($response);
$response->shouldReceive('send')->once();
@@ -247,7 +247,7 @@ public function testHttpExceptionWithView(): void
$response->shouldReceive('setBody')->once()->with('rendered')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::METHOD_NOT_ALLOWED)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::MethodNotAllowed)->andReturn($response);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -332,7 +332,7 @@ public function testRegularErrorWithoutView(): void
$response->shouldReceive('setBody')->once()->with('An error has occurred while processing your request.')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::INTERNAL_SERVER_ERROR)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::InternalServerError)->andReturn($response);
$response->shouldReceive('send')->once();
@@ -376,7 +376,7 @@ public function testRegularErrorWithoutViewWithResetExceptions(): void
$response->shouldReceive('setBody')->once()->with('An error has occurred while processing your request.')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::INTERNAL_SERVER_ERROR)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::InternalServerError)->andReturn($response);
$response->shouldReceive('send')->once();
@@ -416,7 +416,7 @@ public function testRegularErrorWithJsonResponse(): void
$response->shouldReceive('setBody')->once()->with('{"error":{"code":500,"message":"An error has occurred while processing your request.","exception_id":"exception_id"}}')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::INTERNAL_SERVER_ERROR)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::InternalServerError)->andReturn($response);
$response->shouldReceive('send')->once();
@@ -461,7 +461,7 @@ public function testHttpExceptionWithJsonResponse(): void
$response->shouldReceive('setBody')->once()->with('{"error":{"code":403,"message":"You don\'t have permission to access the requested resource.","exception_id":"exception_id","metadata":{"foo":"bar"}}}')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::FORBIDDEN)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::Forbidden)->andReturn($response);
$response->shouldReceive('send')->once();
@@ -518,7 +518,7 @@ public function testRegularErrorWithXmlResponse(): void
500An error has occurred while processing your request.exception_id
')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::INTERNAL_SERVER_ERROR)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::InternalServerError)->andReturn($response);
$response->shouldReceive('send')->once();
@@ -575,7 +575,7 @@ public function testHttpExceptionWithXmlResponse(): void
403You don\'t have permission to access the requested resource.exception_idbar
')->andReturn($response);
- $response->shouldReceive('setStatus')->once()->with(Status::FORBIDDEN)->andReturn($response);
+ $response->shouldReceive('setStatus')->once()->with(Status::Forbidden)->andReturn($response);
$response->shouldReceive('send')->once();
diff --git a/tests/unit/file/PermissionTest.php b/tests/unit/file/PermissionTest.php
index 25d0cf74b..6c8479d3a 100644
--- a/tests/unit/file/PermissionTest.php
+++ b/tests/unit/file/PermissionTest.php
@@ -24,109 +24,109 @@ public function testCalculate(): void
$this->assertSame(0o000, Permission::calculate());
- $this->assertSame(0o000, Permission::calculate(Permission::NONE));
+ $this->assertSame(0o000, Permission::calculate(Permission::None));
//
- $this->assertSame(0o100, Permission::calculate(Permission::OWNER_EXECUTE));
+ $this->assertSame(0o100, Permission::calculate(Permission::OwnerExecute));
- $this->assertSame(0o200, Permission::calculate(Permission::OWNER_WRITE));
+ $this->assertSame(0o200, Permission::calculate(Permission::OwnerWrite));
- $this->assertSame(0o300, Permission::calculate(Permission::OWNER_EXECUTE_WRITE));
+ $this->assertSame(0o300, Permission::calculate(Permission::OwnerExecuteWrite));
- $this->assertSame(0o400, Permission::calculate(Permission::OWNER_READ));
+ $this->assertSame(0o400, Permission::calculate(Permission::OwnerRead));
- $this->assertSame(0o500, Permission::calculate(Permission::OWNER_EXECUTE_READ));
+ $this->assertSame(0o500, Permission::calculate(Permission::OwnerExecuteRead));
- $this->assertSame(0o600, Permission::calculate(Permission::OWNER_WRITE_READ));
+ $this->assertSame(0o600, Permission::calculate(Permission::OwnerWriteRead));
- $this->assertSame(0o700, Permission::calculate(Permission::OWNER_FULL));
+ $this->assertSame(0o700, Permission::calculate(Permission::OwnerFull));
//
- $this->assertSame(0o010, Permission::calculate(Permission::GROUP_EXECUTE));
+ $this->assertSame(0o010, Permission::calculate(Permission::GroupExecute));
- $this->assertSame(0o020, Permission::calculate(Permission::GROUP_WRITE));
+ $this->assertSame(0o020, Permission::calculate(Permission::GroupWrite));
- $this->assertSame(0o030, Permission::calculate(Permission::GROUP_EXECUTE_WRITE));
+ $this->assertSame(0o030, Permission::calculate(Permission::GroupExecuteWrite));
- $this->assertSame(0o040, Permission::calculate(Permission::GROUP_READ));
+ $this->assertSame(0o040, Permission::calculate(Permission::GroupRead));
- $this->assertSame(0o050, Permission::calculate(Permission::GROUP_EXECUTE_READ));
+ $this->assertSame(0o050, Permission::calculate(Permission::GroupExecuteRead));
- $this->assertSame(0o060, Permission::calculate(Permission::GROUP_WRITE_READ));
+ $this->assertSame(0o060, Permission::calculate(Permission::GroupWriteRead));
- $this->assertSame(0o070, Permission::calculate(Permission::GROUP_FULL));
+ $this->assertSame(0o070, Permission::calculate(Permission::GroupFull));
//
- $this->assertSame(0o001, Permission::calculate(Permission::PUBLIC_EXECUTE));
+ $this->assertSame(0o001, Permission::calculate(Permission::PublicExecute));
- $this->assertSame(0o002, Permission::calculate(Permission::PUBLIC_WRITE));
+ $this->assertSame(0o002, Permission::calculate(Permission::PublicWrite));
- $this->assertSame(0o003, Permission::calculate(Permission::PUBLIC_EXECUTE_WRITE));
+ $this->assertSame(0o003, Permission::calculate(Permission::PublicExecuteWrite));
- $this->assertSame(0o004, Permission::calculate(Permission::PUBLIC_READ));
+ $this->assertSame(0o004, Permission::calculate(Permission::PublicRead));
- $this->assertSame(0o005, Permission::calculate(Permission::PUBLIC_EXECUTE_READ));
+ $this->assertSame(0o005, Permission::calculate(Permission::PublicExecuteRead));
- $this->assertSame(0o006, Permission::calculate(Permission::PUBLIC_WRITE_READ));
+ $this->assertSame(0o006, Permission::calculate(Permission::PublicWriteRead));
- $this->assertSame(0o007, Permission::calculate(Permission::PUBLIC_FULL));
+ $this->assertSame(0o007, Permission::calculate(Permission::PublicFull));
//
- $this->assertSame(0o1000, Permission::calculate(Permission::SPECIAL_STICKY));
+ $this->assertSame(0o1000, Permission::calculate(Permission::SpecialSticky));
- $this->assertSame(0o2000, Permission::calculate(Permission::SPECIAL_SETGID));
+ $this->assertSame(0o2000, Permission::calculate(Permission::SpecialSetGid));
- $this->assertSame(0o4000, Permission::calculate(Permission::SPECIAL_SETUID));
+ $this->assertSame(0o4000, Permission::calculate(Permission::SpecialSetUid));
// Test combinations
$this->assertSame(0o666, Permission::calculate(
- Permission::OWNER_WRITE_READ,
- Permission::GROUP_WRITE_READ,
- Permission::PUBLIC_WRITE_READ)
+ Permission::OwnerWriteRead,
+ Permission::GroupWriteRead,
+ Permission::PublicWriteRead)
);
$this->assertSame(0o777, Permission::calculate(
- Permission::OWNER_FULL,
- Permission::GROUP_FULL,
- Permission::PUBLIC_FULL
+ Permission::OwnerFull,
+ Permission::GroupFull,
+ Permission::PublicFull
));
$this->assertSame(0o744, Permission::calculate(
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::PUBLIC_READ)
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::PublicRead)
);
$this->assertSame(0o755, Permission::calculate(
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE)
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute)
);
$this->assertSame(0o1755, Permission::calculate(
- Permission::SPECIAL_STICKY,
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE)
+ Permission::SpecialSticky,
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute)
);
$this->assertSame(0o3755, Permission::calculate(
- Permission::SPECIAL_STICKY,
- Permission::SPECIAL_SETGID,
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE)
+ Permission::SpecialSticky,
+ Permission::SpecialSetGid,
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute)
);
}
@@ -139,7 +139,7 @@ public function testHasPermissionsWithInvalidPermissions(): void
$this->expectExceptionMessage('The integer [ 13337 ] does not represent a valid octal between 0o0000 and 0o7777.');
- Permission::hasPermissions(13337, Permission::NONE);
+ Permission::hasPermissions(13337, Permission::None);
}
/**
@@ -147,25 +147,25 @@ public function testHasPermissionsWithInvalidPermissions(): void
*/
public function testHasPermissions(): void
{
- $this->assertTrue(Permission::hasPermissions(0o666, Permission::OWNER_WRITE_READ));
+ $this->assertTrue(Permission::hasPermissions(0o666, Permission::OwnerWriteRead));
- $this->assertTrue(Permission::hasPermissions(0o777, Permission::OWNER_FULL));
+ $this->assertTrue(Permission::hasPermissions(0o777, Permission::OwnerFull));
- $this->assertTrue(Permission::hasPermissions(0o777, Permission::OWNER_FULL, Permission::GROUP_FULL));
+ $this->assertTrue(Permission::hasPermissions(0o777, Permission::OwnerFull, Permission::GroupFull));
- $this->assertTrue(Permission::hasPermissions(0o777, Permission::OWNER_FULL, Permission::GROUP_FULL, Permission::PUBLIC_FULL));
+ $this->assertTrue(Permission::hasPermissions(0o777, Permission::OwnerFull, Permission::GroupFull, Permission::PublicFull));
- $this->assertTrue(Permission::hasPermissions(0o755, Permission::OWNER_FULL));
+ $this->assertTrue(Permission::hasPermissions(0o755, Permission::OwnerFull));
- $this->assertTrue(Permission::hasPermissions(0o1000, Permission::SPECIAL_STICKY));
+ $this->assertTrue(Permission::hasPermissions(0o1000, Permission::SpecialSticky));
- $this->assertTrue(Permission::hasPermissions(0o3000, Permission::SPECIAL_STICKY, Permission::SPECIAL_SETGID));
+ $this->assertTrue(Permission::hasPermissions(0o3000, Permission::SpecialSticky, Permission::SpecialSetGid));
- $this->assertTrue(Permission::hasPermissions(0o7000, Permission::SPECIAL_STICKY, Permission::SPECIAL_SETGID, Permission::SPECIAL_SETUID));
+ $this->assertTrue(Permission::hasPermissions(0o7000, Permission::SpecialSticky, Permission::SpecialSetGid, Permission::SpecialSetUid));
- $this->assertFalse(Permission::hasPermissions(0o755, Permission::GROUP_WRITE));
+ $this->assertFalse(Permission::hasPermissions(0o755, Permission::GroupWrite));
- $this->assertFalse(Permission::hasPermissions(0o755, Permission::PUBLIC_WRITE));
+ $this->assertFalse(Permission::hasPermissions(0o755, Permission::PublicWrite));
}
/**
@@ -175,8 +175,8 @@ public function testHasPermissionsWithNoPermissions(): void
{
$this->assertTrue(Permission::hasPermissions(0o000));
- $this->assertTrue(Permission::hasPermissions(0o000, Permission::NONE));
+ $this->assertTrue(Permission::hasPermissions(0o000, Permission::None));
- $this->assertFalse(Permission::hasPermissions(0o777, Permission::NONE));
+ $this->assertFalse(Permission::hasPermissions(0o777, Permission::None));
}
}
diff --git a/tests/unit/file/PermissionsTest.php b/tests/unit/file/PermissionsTest.php
index 76da8d53b..614656a0d 100644
--- a/tests/unit/file/PermissionsTest.php
+++ b/tests/unit/file/PermissionsTest.php
@@ -35,25 +35,25 @@ public function testFromInt(): void
{
$permissions = Permissions::fromInt(0o000);
- $this->assertSame([Permission::NONE], $permissions->getPermissions());
+ $this->assertSame([Permission::None], $permissions->getPermissions());
//
$permissions = Permissions::fromInt(0o700);
- $this->assertSame([Permission::OWNER_READ, Permission::OWNER_WRITE, Permission::OWNER_EXECUTE], $permissions->getPermissions());
+ $this->assertSame([Permission::OwnerRead, Permission::OwnerWrite, Permission::OwnerExecute], $permissions->getPermissions());
//
$permissions = Permissions::fromInt(0o444);
- $this->assertSame([Permission::OWNER_READ, Permission::GROUP_READ, Permission::PUBLIC_READ], $permissions->getPermissions());
+ $this->assertSame([Permission::OwnerRead, Permission::GroupRead, Permission::PublicRead], $permissions->getPermissions());
//
$permissions = Permissions::fromInt(0o666);
- $this->assertSame([Permission::OWNER_READ, Permission::OWNER_WRITE, Permission::GROUP_READ, Permission::GROUP_WRITE, Permission::PUBLIC_READ, Permission::PUBLIC_WRITE], $permissions->getPermissions());
+ $this->assertSame([Permission::OwnerRead, Permission::OwnerWrite, Permission::GroupRead, Permission::GroupWrite, Permission::PublicRead, Permission::PublicWrite], $permissions->getPermissions());
}
/**
@@ -63,13 +63,13 @@ public function testGetPermissions(): void
{
$permissions = new Permissions;
- $this->assertSame([Permission::NONE], $permissions->getPermissions());
+ $this->assertSame([Permission::None], $permissions->getPermissions());
//
- $permissions = new Permissions(Permission::OWNER_FULL);
+ $permissions = new Permissions(Permission::OwnerFull);
- $this->assertSame([Permission::OWNER_READ, Permission::OWNER_WRITE, Permission::OWNER_EXECUTE], $permissions->getPermissions());
+ $this->assertSame([Permission::OwnerRead, Permission::OwnerWrite, Permission::OwnerExecute], $permissions->getPermissions());
}
/**
@@ -81,37 +81,37 @@ public function testHasPermissions(): void
$this->assertTrue($permissions->hasPermissions());
- $this->assertTrue($permissions->hasPermissions(Permission::NONE));
+ $this->assertTrue($permissions->hasPermissions(Permission::None));
- $this->assertFalse($permissions->hasPermissions(Permission::SPECIAL_SETUID));
+ $this->assertFalse($permissions->hasPermissions(Permission::SpecialSetUid));
- $this->assertFalse($permissions->hasPermissions(Permission::OWNER_READ));
+ $this->assertFalse($permissions->hasPermissions(Permission::OwnerRead));
- $this->assertFalse($permissions->hasPermissions(Permission::GROUP_READ));
+ $this->assertFalse($permissions->hasPermissions(Permission::GroupRead));
- $this->assertFalse($permissions->hasPermissions(Permission::PUBLIC_READ));
+ $this->assertFalse($permissions->hasPermissions(Permission::PublicRead));
//
- $permissions = new Permissions(Permission::OWNER_READ, Permission::GROUP_READ, Permission::PUBLIC_READ);
+ $permissions = new Permissions(Permission::OwnerRead, Permission::GroupRead, Permission::PublicRead);
- $this->assertTrue($permissions->hasPermissions(Permission::OWNER_READ));
+ $this->assertTrue($permissions->hasPermissions(Permission::OwnerRead));
- $this->assertTrue($permissions->hasPermissions(Permission::GROUP_READ));
+ $this->assertTrue($permissions->hasPermissions(Permission::GroupRead));
- $this->assertTrue($permissions->hasPermissions(Permission::PUBLIC_READ));
+ $this->assertTrue($permissions->hasPermissions(Permission::PublicRead));
//
- $permissions = new Permissions(Permission::SPECIAL_STICKY, Permission::OWNER_READ, Permission::GROUP_READ, Permission::PUBLIC_READ);
+ $permissions = new Permissions(Permission::SpecialSticky, Permission::OwnerRead, Permission::GroupRead, Permission::PublicRead);
- $this->assertTrue($permissions->hasPermissions(Permission::SPECIAL_STICKY));
+ $this->assertTrue($permissions->hasPermissions(Permission::SpecialSticky));
- $this->assertTrue($permissions->hasPermissions(Permission::OWNER_READ));
+ $this->assertTrue($permissions->hasPermissions(Permission::OwnerRead));
- $this->assertTrue($permissions->hasPermissions(Permission::GROUP_READ));
+ $this->assertTrue($permissions->hasPermissions(Permission::GroupRead));
- $this->assertTrue($permissions->hasPermissions(Permission::PUBLIC_READ));
+ $this->assertTrue($permissions->hasPermissions(Permission::PublicRead));
}
/**
@@ -125,24 +125,24 @@ public function testToInt(): void
//
- $permissions = new Permissions(Permission::NONE);
+ $permissions = new Permissions(Permission::None);
$this->assertSame(0o000, $permissions->toInt());
//
- $permissions = new Permissions(Permission::OWNER_FULL, Permission::GROUP_FULL, Permission::PUBLIC_FULL);
+ $permissions = new Permissions(Permission::OwnerFull, Permission::GroupFull, Permission::PublicFull);
$this->assertSame(0o777, $permissions->toInt());
//
$permissions = new Permissions(
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame(0o755, $permissions->toInt());
@@ -150,12 +150,12 @@ public function testToInt(): void
//
$permissions = new Permissions(
- Permission::SPECIAL_STICKY,
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::SpecialSticky,
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame(0o1755, $permissions->toInt());
@@ -163,13 +163,13 @@ public function testToInt(): void
//
$permissions = new Permissions(
- Permission::SPECIAL_STICKY,
- Permission::SPECIAL_SETGID,
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::SpecialSticky,
+ Permission::SpecialSetGid,
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame(0o3755, $permissions->toInt());
@@ -177,14 +177,14 @@ public function testToInt(): void
//
$permissions = new Permissions(
- Permission::SPECIAL_STICKY,
- Permission::SPECIAL_SETGID,
- Permission::SPECIAL_SETUID,
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::SpecialSticky,
+ Permission::SpecialSetGid,
+ Permission::SpecialSetUid,
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame(0o7755, $permissions->toInt());
@@ -201,36 +201,36 @@ public function testToOctalString(): void
//
- $permissions = new Permissions(Permission::NONE);
+ $permissions = new Permissions(Permission::None);
$this->assertSame('000', $permissions->toOctalString());
//
- $permissions = new Permissions(Permission::OWNER_FULL, Permission::GROUP_FULL, Permission::PUBLIC_FULL);
+ $permissions = new Permissions(Permission::OwnerFull, Permission::GroupFull, Permission::PublicFull);
$this->assertSame('777', $permissions->toOctalString());
//
- $permissions = new Permissions(Permission::PUBLIC_FULL);
+ $permissions = new Permissions(Permission::PublicFull);
$this->assertSame('007', $permissions->toOctalString());
//
- $permissions = new Permissions(Permission::GROUP_FULL);
+ $permissions = new Permissions(Permission::GroupFull);
$this->assertSame('070', $permissions->toOctalString());
//
$permissions = new Permissions(
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame('755', $permissions->toOctalString());
@@ -238,12 +238,12 @@ public function testToOctalString(): void
//
$permissions = new Permissions(
- Permission::SPECIAL_STICKY,
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::SpecialSticky,
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame('1755', $permissions->toOctalString());
@@ -251,13 +251,13 @@ public function testToOctalString(): void
//
$permissions = new Permissions(
- Permission::SPECIAL_STICKY,
- Permission::SPECIAL_SETGID,
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::SpecialSticky,
+ Permission::SpecialSetGid,
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame('3755', $permissions->toOctalString());
@@ -265,14 +265,14 @@ public function testToOctalString(): void
//
$permissions = new Permissions(
- Permission::SPECIAL_STICKY,
- Permission::SPECIAL_SETGID,
- Permission::SPECIAL_SETUID,
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::SpecialSticky,
+ Permission::SpecialSetGid,
+ Permission::SpecialSetUid,
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame('7755', $permissions->toOctalString());
@@ -289,30 +289,30 @@ public function testToRwxString(): void
//
- $permissions = new Permissions(Permission::NONE);
+ $permissions = new Permissions(Permission::None);
$this->assertSame('---------', $permissions->toRwxString());
//
- $permissions = new Permissions(Permission::OWNER_FULL, Permission::GROUP_FULL, Permission::PUBLIC_FULL);
+ $permissions = new Permissions(Permission::OwnerFull, Permission::GroupFull, Permission::PublicFull);
$this->assertSame('rwxrwxrwx', $permissions->toRwxString());
//
- $permissions = new Permissions(Permission::PUBLIC_FULL);
+ $permissions = new Permissions(Permission::PublicFull);
$this->assertSame('------rwx', $permissions->toRwxString());
//
$permissions = new Permissions(
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute
);
$this->assertSame('rwxr-xr-x', $permissions->toRwxString());
@@ -320,14 +320,14 @@ public function testToRwxString(): void
//
$permissions = new Permissions(
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::GROUP_EXECUTE,
- Permission::PUBLIC_READ,
- Permission::PUBLIC_EXECUTE,
- Permission::SPECIAL_STICKY,
- Permission::SPECIAL_SETGID,
- Permission::SPECIAL_SETUID
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::GroupExecute,
+ Permission::PublicRead,
+ Permission::PublicExecute,
+ Permission::SpecialSticky,
+ Permission::SpecialSetGid,
+ Permission::SpecialSetUid
);
$this->assertSame('rwsr-sr-t', $permissions->toRwxString());
@@ -335,12 +335,12 @@ public function testToRwxString(): void
//
$permissions = new Permissions(
- Permission::OWNER_FULL,
- Permission::GROUP_READ,
- Permission::PUBLIC_READ,
- Permission::SPECIAL_STICKY,
- Permission::SPECIAL_SETGID,
- Permission::SPECIAL_SETUID
+ Permission::OwnerFull,
+ Permission::GroupRead,
+ Permission::PublicRead,
+ Permission::SpecialSticky,
+ Permission::SpecialSetGid,
+ Permission::SpecialSetUid
);
$this->assertSame('rwsr-Sr-T', $permissions->toRwxString());
@@ -348,12 +348,12 @@ public function testToRwxString(): void
//
$permissions = new Permissions(
- Permission::OWNER_READ,
- Permission::GROUP_READ,
- Permission::PUBLIC_READ,
- Permission::SPECIAL_STICKY,
- Permission::SPECIAL_SETGID,
- Permission::SPECIAL_SETUID
+ Permission::OwnerRead,
+ Permission::GroupRead,
+ Permission::PublicRead,
+ Permission::SpecialSticky,
+ Permission::SpecialSetGid,
+ Permission::SpecialSetUid
);
$this->assertSame('r-Sr-Sr-T', $permissions->toRwxString());
@@ -370,25 +370,25 @@ public function testAdd(): void
//
- $this->assertInstanceOf(Permissions::class, $permissions->add(Permission::OWNER_FULL));
+ $this->assertInstanceOf(Permissions::class, $permissions->add(Permission::OwnerFull));
$this->assertSame(0o0700, $permissions->toInt());
//
- $permissions->add(Permission::OWNER_FULL);
+ $permissions->add(Permission::OwnerFull);
$this->assertSame(0o0700, $permissions->toInt());
//
- $permissions->add(Permission::GROUP_FULL);
+ $permissions->add(Permission::GroupFull);
$this->assertSame(0o0770, $permissions->toInt());
//
- $permissions->add(Permission::PUBLIC_READ, Permission::PUBLIC_WRITE, Permission::PUBLIC_EXECUTE);
+ $permissions->add(Permission::PublicRead, Permission::PublicWrite, Permission::PublicExecute);
$this->assertSame(0o0777, $permissions->toInt());
}
@@ -404,25 +404,25 @@ public function testRemove(): void
//
- $this->assertInstanceOf(Permissions::class, $permissions->remove(Permission::PUBLIC_WRITE));
+ $this->assertInstanceOf(Permissions::class, $permissions->remove(Permission::PublicWrite));
$this->assertSame(0o0775, $permissions->toInt());
//
- $permissions->remove(Permission::PUBLIC_WRITE);
+ $permissions->remove(Permission::PublicWrite);
$this->assertSame(0o0775, $permissions->toInt());
//
- $permissions->remove(Permission::GROUP_WRITE);
+ $permissions->remove(Permission::GroupWrite);
$this->assertSame(0o0755, $permissions->toInt());
//
- $permissions->remove(Permission::PUBLIC_EXECUTE, Permission::GROUP_EXECUTE);
+ $permissions->remove(Permission::PublicExecute, Permission::GroupExecute);
$this->assertSame(0o0744, $permissions->toInt());
}
diff --git a/tests/unit/gatekeeper/LoginStatusTest.php b/tests/unit/gatekeeper/LoginStatusTest.php
index 3e20ee1be..f92606a26 100644
--- a/tests/unit/gatekeeper/LoginStatusTest.php
+++ b/tests/unit/gatekeeper/LoginStatusTest.php
@@ -19,11 +19,11 @@ class LoginStatusTest extends TestCase
*/
public function testLoginStatus(): void
{
- $this->assertSame(1, LoginStatus::OK->value);
- $this->assertSame(2, LoginStatus::BANNED->value);
- $this->assertSame(3, LoginStatus::NOT_ACTIVATED->value);
- $this->assertSame(4, LoginStatus::INVALID_CREDENTIALS->value);
- $this->assertSame(5, LoginStatus::LOCKED->value);
+ $this->assertSame(1, LoginStatus::Ok->value);
+ $this->assertSame(2, LoginStatus::Banned->value);
+ $this->assertSame(3, LoginStatus::NotActivated->value);
+ $this->assertSame(4, LoginStatus::InvalidCredentials->value);
+ $this->assertSame(5, LoginStatus::Locked->value);
}
/**
@@ -31,11 +31,11 @@ public function testLoginStatus(): void
*/
public function testGetCode(): void
{
- $this->assertSame(1, LoginStatus::OK->getCode());
- $this->assertSame(2, LoginStatus::BANNED->getCode());
- $this->assertSame(3, LoginStatus::NOT_ACTIVATED->getCode());
- $this->assertSame(4, LoginStatus::INVALID_CREDENTIALS->getCode());
- $this->assertSame(5, LoginStatus::LOCKED->getCode());
+ $this->assertSame(1, LoginStatus::Ok->getCode());
+ $this->assertSame(2, LoginStatus::Banned->getCode());
+ $this->assertSame(3, LoginStatus::NotActivated->getCode());
+ $this->assertSame(4, LoginStatus::InvalidCredentials->getCode());
+ $this->assertSame(5, LoginStatus::Locked->getCode());
}
/**
@@ -43,10 +43,10 @@ public function testGetCode(): void
*/
public function testToBool(): void
{
- $this->assertTrue(LoginStatus::OK->toBool());
- $this->assertFalse(LoginStatus::BANNED->toBool());
- $this->assertFalse(LoginStatus::NOT_ACTIVATED->toBool());
- $this->assertFalse(LoginStatus::INVALID_CREDENTIALS->toBool());
- $this->assertFalse(LoginStatus::LOCKED->toBool());
+ $this->assertTrue(LoginStatus::Ok->toBool());
+ $this->assertFalse(LoginStatus::Banned->toBool());
+ $this->assertFalse(LoginStatus::NotActivated->toBool());
+ $this->assertFalse(LoginStatus::InvalidCredentials->toBool());
+ $this->assertFalse(LoginStatus::Locked->toBool());
}
}
diff --git a/tests/unit/gatekeeper/adapters/SessionTest.php b/tests/unit/gatekeeper/adapters/SessionTest.php
index 0ad29e22b..5d6b71b10 100644
--- a/tests/unit/gatekeeper/adapters/SessionTest.php
+++ b/tests/unit/gatekeeper/adapters/SessionTest.php
@@ -330,7 +330,7 @@ public function testLoginWithWrongEmail(): void
$status = $adapter->login('foo@example.org', 'password');
$this->assertFalse($status->toBool());
- $this->assertEquals(LoginStatus::INVALID_CREDENTIALS, $status);
+ $this->assertEquals(LoginStatus::InvalidCredentials, $status);
}
/**
@@ -351,7 +351,7 @@ public function testLoginWithWrongPassword(): void
$status = $adapter->login('foo@example.org', 'password');
$this->assertFalse($status->toBool());
- $this->assertEquals(LoginStatus::INVALID_CREDENTIALS, $status);
+ $this->assertEquals(LoginStatus::InvalidCredentials, $status);
}
/**
@@ -374,7 +374,7 @@ public function testLoginForNonActivatedUser(): void
$status = $adapter->login('foo@example.org', 'password');
$this->assertFalse($status->toBool());
- $this->assertEquals(LoginStatus::NOT_ACTIVATED, $status);
+ $this->assertEquals(LoginStatus::NotActivated, $status);
}
/**
@@ -399,7 +399,7 @@ public function testLoginForBannedUser(): void
$status = $adapter->login('foo@example.org', 'password');
$this->assertFalse($status->toBool());
- $this->assertEquals(LoginStatus::BANNED, $status);
+ $this->assertEquals(LoginStatus::Banned, $status);
}
/**
@@ -434,7 +434,7 @@ public function testSuccessfulLogin(): void
$status = $adapter->login('foo@example.org', 'password');
$this->assertTrue($status->toBool());
- $this->assertEquals(LoginStatus::OK, $status);
+ $this->assertEquals(LoginStatus::Ok, $status);
}
/**
@@ -621,7 +621,7 @@ public function testLoginWithWrongPasswordAndThrottling(): void
$status = $adapter->login('foo@example.org', 'password');
$this->assertFalse($status->toBool());
- $this->assertEquals(LoginStatus::INVALID_CREDENTIALS, $status);
+ $this->assertEquals(LoginStatus::InvalidCredentials, $status);
}
/**
@@ -682,7 +682,7 @@ public function testLoginWithLockedAccount(): void
$status = $adapter->login('foo@example.org', 'password');
$this->assertFalse($status->toBool());
- $this->assertEquals(LoginStatus::LOCKED, $status);
+ $this->assertEquals(LoginStatus::Locked, $status);
}
/**
@@ -706,7 +706,7 @@ public function testBasicAuth(): void
$this->headers = $responseHeaders;
})->bindTo($response, Response::class)();
- $response->shouldReceive('setStatus')->once()->with(Status::UNAUTHORIZED);
+ $response->shouldReceive('setStatus')->once()->with(Status::Unauthorized);
$adapter = Mockery::mock(Session::class . '[isLoggedIn,login]', [$this->getUserRepository(), $this->getGroupRepository(), $request, $response, $this->getSession()]);
@@ -715,7 +715,7 @@ public function testBasicAuth(): void
$adapter->shouldReceive('isLoggedIn')->once()->andReturn(false);
- $adapter->shouldReceive('login')->once()->with(null, null)->andReturn(LoginStatus::INVALID_CREDENTIALS);
+ $adapter->shouldReceive('login')->once()->with(null, null)->andReturn(LoginStatus::InvalidCredentials);
$this->assertFalse($adapter->basicAuth());
}
@@ -741,7 +741,7 @@ public function testBasicAuthWithClear(): void
$this->headers = $responseHeaders;
})->bindTo($response, Response::class)();
- $response->shouldReceive('setStatus')->once()->with(Status::UNAUTHORIZED);
+ $response->shouldReceive('setStatus')->once()->with(Status::Unauthorized);
$response->shouldReceive('clear')->once();
@@ -752,7 +752,7 @@ public function testBasicAuthWithClear(): void
$adapter->shouldReceive('isLoggedIn')->once()->andReturn(false);
- $adapter->shouldReceive('login')->once()->with(null, null)->andReturn(LoginStatus::INVALID_CREDENTIALS);
+ $adapter->shouldReceive('login')->once()->with(null, null)->andReturn(LoginStatus::InvalidCredentials);
$this->assertFalse($adapter->basicAuth(true));
}
@@ -790,7 +790,7 @@ public function testBasicAuthLoggingIn(): void
$adapter->shouldReceive('isLoggedIn')->once()->andReturn(false);
- $adapter->shouldReceive('login')->once()->with('foo@example.org', 'password')->andReturn(LoginStatus::OK);
+ $adapter->shouldReceive('login')->once()->with('foo@example.org', 'password')->andReturn(LoginStatus::Ok);
$this->assertTrue($adapter->basicAuth());
}
diff --git a/tests/unit/http/ResponseTest.php b/tests/unit/http/ResponseTest.php
index c78abaac2..914b021c9 100644
--- a/tests/unit/http/ResponseTest.php
+++ b/tests/unit/http/ResponseTest.php
@@ -177,7 +177,7 @@ public function testDefaultStatus(): void
{
$response = new Response($this->getRequest());
- $this->assertEquals(Status::OK, $response->getStatus());
+ $this->assertEquals(Status::Ok, $response->getStatus());
}
@@ -190,7 +190,7 @@ public function testValidStatus(): void
$response->setStatus(404);
- $this->assertEquals(Status::NOT_FOUND, $response->getStatus());
+ $this->assertEquals(Status::NotFound, $response->getStatus());
}
@@ -328,7 +328,7 @@ public function testReset(): void
$this->assertCount(0, $response->getCookies());
- $this->assertSame(Status::OK, $response->getStatus());
+ $this->assertSame(Status::Ok, $response->getStatus());
}
/**
@@ -362,7 +362,7 @@ public function testResetExcept(): void
$this->assertCount(1, $response->getCookies());
- $this->assertSame(Status::OK, $response->getStatus());
+ $this->assertSame(Status::Ok, $response->getStatus());
}
/**
@@ -396,7 +396,7 @@ public function testResetExceptWithNoExceptions(): void
$this->assertCount(0, $response->getCookies());
- $this->assertSame(Status::OK, $response->getStatus());
+ $this->assertSame(Status::Ok, $response->getStatus());
}
/**
diff --git a/tests/unit/http/response/StatusTest.php b/tests/unit/http/response/StatusTest.php
index dd8fc4b56..ea476a3e0 100644
--- a/tests/unit/http/response/StatusTest.php
+++ b/tests/unit/http/response/StatusTest.php
@@ -20,9 +20,9 @@ class StatusTest extends TestCase
*/
public function testStatus(): void
{
- $this->assertSame(Status::OK, Status::from(200));
- $this->assertSame('OK', Status::OK->getMessage());
- $this->assertSame(200, Status::OK->getCode());
+ $this->assertSame(Status::Ok, Status::from(200));
+ $this->assertSame('OK', Status::Ok->getMessage());
+ $this->assertSame(200, Status::Ok->getCode());
}
/**
diff --git a/tests/unit/http/response/builders/JSONTest.php b/tests/unit/http/response/builders/JSONTest.php
index 09fe2c57c..f74ec1a6c 100644
--- a/tests/unit/http/response/builders/JSONTest.php
+++ b/tests/unit/http/response/builders/JSONTest.php
@@ -54,7 +54,7 @@ public function testBuildWithStatus(): void
$response->shouldReceive('setType')->once()->with('application/json');
- $response->shouldReceive('setStatus')->once()->with(Status::BAD_REQUEST);
+ $response->shouldReceive('setStatus')->once()->with(Status::BadRequest);
$response->shouldReceive('setBody')->once()->with('[1,2,3]');
@@ -64,7 +64,7 @@ public function testBuildWithStatus(): void
$json->setStatus(400);
- $this->assertSame(Status::BAD_REQUEST, $json->getStatus());
+ $this->assertSame(Status::BadRequest, $json->getStatus());
$json->build($request, $response);
}
@@ -106,7 +106,7 @@ public function testBuildWithStatusAndCharsetFromConstructor(): void
$response->shouldReceive('setType')->once()->with('application/json');
- $response->shouldReceive('setStatus')->once()->with(Status::OK);
+ $response->shouldReceive('setStatus')->once()->with(Status::Ok);
$response->shouldReceive('setCharset')->once()->with('UTF-8');
@@ -116,7 +116,7 @@ public function testBuildWithStatusAndCharsetFromConstructor(): void
$json = new JSON([1, 2, 3], 0, 200, 'UTF-8');
- $this->assertSame(Status::OK, $json->getStatus());
+ $this->assertSame(Status::Ok, $json->getStatus());
$this->assertSame('UTF-8', $json->getCharset());
diff --git a/tests/unit/http/response/senders/EventStreamTest.php b/tests/unit/http/response/senders/EventStreamTest.php
index 4b8c96b36..bb2fe4ffa 100644
--- a/tests/unit/http/response/senders/EventStreamTest.php
+++ b/tests/unit/http/response/senders/EventStreamTest.php
@@ -62,7 +62,7 @@ public function testBasicEventStream(): void
{
$eventStream = Mockery::mock(EventStream::class, [function () {
yield new Event(
- new Field(Type::DATA, 'hello, world!')
+ new Field(Type::Data, 'hello, world!')
);
}]);
@@ -82,8 +82,8 @@ public function testEventStreamWithMultipleFields(): void
{
$eventStream = Mockery::mock(EventStream::class, [function () {
yield new Event(
- new Field(Type::EVENT, 'greeting'),
- new Field(Type::DATA, 'hello, world!')
+ new Field(Type::Event, 'greeting'),
+ new Field(Type::Data, 'hello, world!')
);
}]);
@@ -103,12 +103,12 @@ public function testEventStreamWithMultipleEvents(): void
{
$eventStream = Mockery::mock(EventStream::class, [function () {
yield new Event(
- new Field(Type::EVENT, 'greeting'),
- new Field(Type::DATA, 'first hello')
+ new Field(Type::Event, 'greeting'),
+ new Field(Type::Data, 'first hello')
);
yield new Event(
- new Field(Type::EVENT, 'greeting'),
- new Field(Type::DATA, 'second hello')
+ new Field(Type::Event, 'greeting'),
+ new Field(Type::Data, 'second hello')
);
}]);
@@ -129,7 +129,7 @@ public function testEventStreamWithStringable(): void
{
$eventStream = Mockery::mock(EventStream::class, [function () {
yield new Event(
- new Field(Type::DATA, new class implements Stringable {
+ new Field(Type::Data, new class implements Stringable {
public function __toString(): string
{
return 'this is a string';
@@ -154,7 +154,7 @@ public function testEventStreamWithJsonSerializable(): void
{
$eventStream = Mockery::mock(EventStream::class, [function () {
yield new Event(
- new Field(Type::DATA, new class implements JsonSerializable {
+ new Field(Type::Data, new class implements JsonSerializable {
public function jsonSerialize(): mixed
{
return [1, 2, 3];
diff --git a/tests/unit/http/response/senders/RedirectTest.php b/tests/unit/http/response/senders/RedirectTest.php
index 46db7d45f..1a285e2eb 100644
--- a/tests/unit/http/response/senders/RedirectTest.php
+++ b/tests/unit/http/response/senders/RedirectTest.php
@@ -33,7 +33,7 @@ public function testSend(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::FOUND);
+ $response->shouldReceive('setStatus')->once()->with(Status::Found);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -45,7 +45,7 @@ public function testSend(): void
$redirect = new Redirect('http://example.org');
- $this->assertSame(Status::FOUND, $redirect->getStatus());
+ $this->assertSame(Status::Found, $redirect->getStatus());
$redirect->send($request, $response);
}
@@ -63,7 +63,7 @@ public function testSendWithConstructorStatus(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::FOUND);
+ $response->shouldReceive('setStatus')->once()->with(Status::Found);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -75,7 +75,7 @@ public function testSendWithConstructorStatus(): void
$redirect = new Redirect('http://example.org', 302);
- $this->assertSame(Status::FOUND, $redirect->getStatus());
+ $this->assertSame(Status::Found, $redirect->getStatus());
$redirect->send($request, $response);
}
@@ -93,7 +93,7 @@ public function testSendWithStatus(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::FOUND);
+ $response->shouldReceive('setStatus')->once()->with(Status::Found);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -107,7 +107,7 @@ public function testSendWithStatus(): void
$redirect->setStatus(302);
- $this->assertSame(Status::FOUND, $redirect->getStatus());
+ $this->assertSame(Status::Found, $redirect->getStatus());
$redirect->send($request, $response);
}
@@ -125,7 +125,7 @@ public function testSendWithStatus301(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::MOVED_PERMANENTLY);
+ $response->shouldReceive('setStatus')->once()->with(Status::MovedPermanently);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -139,7 +139,7 @@ public function testSendWithStatus301(): void
$redirect->movedPermanently();
- $this->assertSame(Status::MOVED_PERMANENTLY, $redirect->getStatus());
+ $this->assertSame(Status::MovedPermanently, $redirect->getStatus());
$redirect->send($request, $response);
}
@@ -157,7 +157,7 @@ public function testSendWithStatus302(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::FOUND);
+ $response->shouldReceive('setStatus')->once()->with(Status::Found);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -171,7 +171,7 @@ public function testSendWithStatus302(): void
$redirect->found();
- $this->assertSame(Status::FOUND, $redirect->getStatus());
+ $this->assertSame(Status::Found, $redirect->getStatus());
$redirect->send($request, $response);
}
@@ -189,7 +189,7 @@ public function testSendWithStatus303(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::SEE_OTHER);
+ $response->shouldReceive('setStatus')->once()->with(Status::SeeOther);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -203,7 +203,7 @@ public function testSendWithStatus303(): void
$redirect->seeOther();
- $this->assertSame(Status::SEE_OTHER, $redirect->getStatus());
+ $this->assertSame(Status::SeeOther, $redirect->getStatus());
$redirect->send($request, $response);
}
@@ -221,7 +221,7 @@ public function testSendWithStatus307(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::TEMPORARY_REDIRECT);
+ $response->shouldReceive('setStatus')->once()->with(Status::TemporaryRedirect);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -235,7 +235,7 @@ public function testSendWithStatus307(): void
$redirect->temporaryRedirect();
- $this->assertSame(Status::TEMPORARY_REDIRECT, $redirect->getStatus());
+ $this->assertSame(Status::TemporaryRedirect, $redirect->getStatus());
$redirect->send($request, $response);
}
@@ -253,7 +253,7 @@ public function testSendWithStatus308(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::PERMANENT_REDIRECT);
+ $response->shouldReceive('setStatus')->once()->with(Status::PermanentRedirect);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -267,7 +267,7 @@ public function testSendWithStatus308(): void
$redirect->permanentRedirect();
- $this->assertSame(Status::PERMANENT_REDIRECT, $redirect->getStatus());
+ $this->assertSame(Status::PermanentRedirect, $redirect->getStatus());
$redirect->send($request, $response);
}
diff --git a/tests/unit/http/response/senders/stream/event/EventTest.php b/tests/unit/http/response/senders/stream/event/EventTest.php
index cb406125b..c52762707 100644
--- a/tests/unit/http/response/senders/stream/event/EventTest.php
+++ b/tests/unit/http/response/senders/stream/event/EventTest.php
@@ -22,8 +22,8 @@ class EventTest extends TestCase
public function testEvent(): void
{
$event = new Event(
- new Field(Type::DATA, 'foobar'),
- new Field(Type::DATA, 'barfoo'),
+ new Field(Type::Data, 'foobar'),
+ new Field(Type::Data, 'barfoo'),
);
$this->assertCount(2, $event->fields);
diff --git a/tests/unit/http/response/senders/stream/event/FieldTest.php b/tests/unit/http/response/senders/stream/event/FieldTest.php
index b71646f5a..9f7914fd8 100644
--- a/tests/unit/http/response/senders/stream/event/FieldTest.php
+++ b/tests/unit/http/response/senders/stream/event/FieldTest.php
@@ -20,9 +20,9 @@ class FieldTest extends TestCase
*/
public function testField(): void
{
- $field = new Field(Type::DATA, 'foobar');
+ $field = new Field(Type::Data, 'foobar');
- $this->assertSame(Type::DATA, $field->type);
+ $this->assertSame(Type::Data, $field->type);
$this->assertSame('foobar', $field->value);
}
}
diff --git a/tests/unit/http/routing/RouterTest.php b/tests/unit/http/routing/RouterTest.php
index 4ca043fb2..0801c52c2 100644
--- a/tests/unit/http/routing/RouterTest.php
+++ b/tests/unit/http/routing/RouterTest.php
@@ -181,7 +181,7 @@ public function testRedirect(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::MOVED_PERMANENTLY);
+ $response->shouldReceive('setStatus')->once()->with(Status::MovedPermanently);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;
@@ -275,7 +275,7 @@ public function testRedirectWithDirtyUrl(): void
$response = Mockery::mock(Response::class);
- $response->shouldReceive('setStatus')->once()->with(Status::MOVED_PERMANENTLY);
+ $response->shouldReceive('setStatus')->once()->with(Status::MovedPermanently);
(function () use ($responseHeaders): void {
$this->headers = $responseHeaders;