Skip to content

Fix: remove deprecation notices in PHP 8.4 #300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [8.2, 8.3]
php: [8.2, 8.3, 8.4]
laravel: [11]

steps:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. This projec

## Unreleased

### Fixed

- Remove deprecation notices in PHP 8.4.

## [4.1.0] - 2024-06-26

### Fixed
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
"require": {
"php": "^8.2",
"ext-json": "*",
"laravel-json-api/core": "^4.1",
"laravel-json-api/eloquent": "^4.1",
"laravel-json-api/encoder-neomerx": "^4.0",
"laravel-json-api/exceptions": "^3.0",
"laravel-json-api/spec": "^3.0",
"laravel-json-api/validation": "^4.0",
"laravel-json-api/core": "^4.3.2",
"laravel-json-api/eloquent": "^4.4",
"laravel-json-api/encoder-neomerx": "^4.1",
"laravel-json-api/exceptions": "^3.1",
"laravel-json-api/spec": "^3.1",
"laravel-json-api/validation": "^4.2",
"laravel/framework": "^11.0"
},
"require-dev": {
"laravel-json-api/testing": "^3.0",
"laravel-json-api/testing": "^3.0.2",
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^10.5"
},
Expand Down
21 changes: 16 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false"
beStrictAboutTestsThatDoNotTestAnything="true" bootstrap="vendor/autoload.php" colors="true"
processIsolation="false" stopOnError="false" stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache"
backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
beStrictAboutTestsThatDoNotTestAnything="true"
bootstrap="vendor/autoload.php"
colors="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
failOnWarning="true"
failOnDeprecation="true"
failOnNotice="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
>
<coverage/>
<testsuites>
<testsuite name="Unit">
Expand Down
4 changes: 2 additions & 2 deletions src/Exceptions/HttpNotAcceptableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class HttpNotAcceptableException extends HttpException
* @param int $code
*/
public function __construct(
string $message = null,
Throwable $previous = null,
?string $message = null,
?Throwable $previous = null,
array $headers = [],
int $code = 0
) {
Expand Down
16 changes: 8 additions & 8 deletions src/Routing/ActionRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function __construct(
string $resourceType,
array $options,
string $controller,
string $prefix = null
?string $prefix = null
) {
$this->router = $router;
$this->resource = $resource;
Expand Down Expand Up @@ -106,7 +106,7 @@ public function withId(): self
* @param string|null $method
* @return ActionProxy
*/
public function get(string $uri, string $method = null): ActionProxy
public function get(string $uri, ?string $method = null): ActionProxy
{
return $this->register('get', $uri, $method);
}
Expand All @@ -118,7 +118,7 @@ public function get(string $uri, string $method = null): ActionProxy
* @param string|null $method
* @return ActionProxy
*/
public function post(string $uri, string $method = null): ActionProxy
public function post(string $uri, ?string $method = null): ActionProxy
{
return $this->register('post', $uri, $method);
}
Expand All @@ -130,7 +130,7 @@ public function post(string $uri, string $method = null): ActionProxy
* @param string|null $method
* @return ActionProxy
*/
public function patch(string $uri, string $method = null): ActionProxy
public function patch(string $uri, ?string $method = null): ActionProxy
{
return $this->register('patch', $uri, $method);
}
Expand All @@ -142,7 +142,7 @@ public function patch(string $uri, string $method = null): ActionProxy
* @param string|null $method
* @return ActionProxy
*/
public function put(string $uri, string $method = null): ActionProxy
public function put(string $uri, ?string $method = null): ActionProxy
{
return $this->register('put', $uri, $method);
}
Expand All @@ -154,7 +154,7 @@ public function put(string $uri, string $method = null): ActionProxy
* @param string|null $method
* @return ActionProxy
*/
public function delete(string $uri, string $method = null): ActionProxy
public function delete(string $uri, ?string $method = null): ActionProxy
{
return $this->register('delete', $uri, $method);
}
Expand All @@ -166,7 +166,7 @@ public function delete(string $uri, string $method = null): ActionProxy
* @param string|null $method
* @return ActionProxy
*/
public function options(string $uri, string $method = null): ActionProxy
public function options(string $uri, ?string $method = null): ActionProxy
{
return $this->register('options', $uri, $method);
}
Expand All @@ -177,7 +177,7 @@ public function options(string $uri, string $method = null): ActionProxy
* @param string|null $action
* @return ActionProxy
*/
public function register(string $method, string $uri, string $action = null): ActionProxy
public function register(string $method, string $uri, ?string $action = null): ActionProxy
{
$action = $action ?: $this->guessControllerAction($uri);
$parameter = $this->getParameter();
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/PendingResourceRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function relationships(Closure $callback): self
* @param Closure|null $callback
* @return $this
*/
public function actions($prefixOrCallback, Closure $callback = null): self
public function actions($prefixOrCallback, ?Closure $callback = null): self
{
if ($prefixOrCallback instanceof Closure && null === $callback) {
$this->actionsPrefix = null;
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/ResourceRegistrar.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(RegistrarContract $router, Server $server)
* @param string|null $controller
* @return PendingResourceRegistration
*/
public function resource(string $resourceType, string $controller = null): PendingResourceRegistration
public function resource(string $resourceType, ?string $controller = null): PendingResourceRegistration
{
return new PendingResourceRegistration(
$this,
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Integration/Routing/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ protected function createServer(string $name): Server
protected function createSchema(
Server $server,
string $name,
string $pattern = null,
string $uriType = null
?string $pattern = null,
?string $uriType = null
): Schema
{
$schema = $this->createMock(Schema::class);
Expand All @@ -89,7 +89,7 @@ protected function createSchema(
* @param string|null $uriName
* @return void
*/
protected function createRelation(MockObject $schema, string $fieldName, string $uriName = null): void
protected function createRelation(MockObject $schema, string $fieldName, ?string $uriName = null): void
{
$relation = $this->createMock(Relation::class);
$relation->method('name')->willReturn($fieldName);
Expand Down