Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ jobs:
run: php -d memory_limit=-1 vendor/bin/phpcs --standard=PSR12 tests

- name: PHPStan (Src)
run: php -d memory_limit=-1 vendor/bin/phpstan analyse --level max src
run: php -d memory_limit=-1 vendor/bin/phpstan analyse --level 10 src

- name: PHPStan (Tests)
run: php -d memory_limit=-1 vendor/bin/phpstan analyse --level max tests
run: php -d memory_limit=-1 vendor/bin/phpstan analyse --level 10 tests

tests-phpunit:
runs-on: ubuntu-latest
Expand Down
4 changes: 1 addition & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
stopOnWarning="true"
bootstrap="vendor/autoload.php"
cacheDirectory="tests/build/cache"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/13.0/phpunit.xsd"
backupStaticProperties="false"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
Expand All @@ -25,9 +25,7 @@
>
<php>
<env name="APP_ENV" value="testing" />

<ini name="date.timezone" value="America/Bogota" />
<ini name="intl.default_locale" value="C.UTF-8" />
<ini name="memory_limit" value="2048M" />
</php>

Expand Down
38 changes: 26 additions & 12 deletions src/LionRequest/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ public static function finish(mixed $response, bool $isJson = true): never
* @param string $status The type of status on the object.
* @param string|null $message Message inside the object.
* @param int $code HTTP status code inside the object.
* @param mixed $data Extra data inside the object.
* @param array<mixed>|bool|float|int|null|object|string $data Extra data inside
* the object.
*
* @return stdClass
*/
public static function custom(
string $status,
?string $message = null,
int $code = Http::OK,
mixed $data = null
array|bool|float|int|null|object|string $data = null
): stdClass {
http_response_code($code);

Expand All @@ -83,12 +84,16 @@ public static function custom(
*
* @param string|null $message Message inside the object.
* @param int $code HTTP status code inside the object.
* @param mixed $data Extra data inside the object.
* @param array<mixed>|bool|float|int|null|object|string $data Extra data inside
* the object.
*
* @return stdClass
*/
public static function success(?string $message = null, int $code = Http::OK, mixed $data = null): stdClass
{
public static function success(
?string $message = null,
int $code = Http::OK,
array|bool|float|int|null|object|string $data = null
): stdClass {
return self::custom(Status::SUCCESS, $message, $code, $data);
}

Expand All @@ -97,7 +102,8 @@ public static function success(?string $message = null, int $code = Http::OK, mi
*
* @param string|null $message Message inside the object.
* @param int $code HTTP status code inside the object.
* @param mixed $data Extra data inside the object.
* @param array<mixed>|bool|float|int|null|object|string $data Extra data inside
* the object.
*
* @return stdClass
*/
Expand All @@ -114,12 +120,16 @@ public static function error(
*
* @param string|null $message Message inside the object.
* @param int $code HTTP status code inside the object.
* @param mixed $data Extra data inside the object.
* @param array<mixed>|bool|float|int|null|object|string $data Extra data inside
* the object.
*
* @return stdClass
*/
public static function warning(?string $message = null, int $code = Http::OK, mixed $data = null): stdClass
{
public static function warning(
?string $message = null,
int $code = Http::OK,
array|bool|float|int|null|object|string $data = null
): stdClass {
return self::custom(Status::WARNING, $message, $code, $data);
}

Expand All @@ -128,12 +138,16 @@ public static function warning(?string $message = null, int $code = Http::OK, mi
*
* @param string|null $message Message inside the object.
* @param int $code HTTP status code inside the object.
* @param mixed $data Extra data inside the object.
* @param array<mixed>|bool|float|int|null|object|string $data Extra data inside
* the object.
*
* @return stdClass
*/
public static function info(?string $message = null, int $code = Http::OK, mixed $data = null): stdClass
{
public static function info(
?string $message = null,
int $code = Http::OK,
array|bool|float|int|null|object|string $data = null
): stdClass {
return self::custom(Status::INFO, $message, $code, $data);
}
}
Loading