Skip to content
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

Enable PHP 8.1 Support #360

Closed
wants to merge 5 commits into from
Closed
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: 2 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ on:
jobs:
coding-standards:
uses: alleyinteractive/.github/.github/workflows/php-coding-standards.yml@main
with:
php: 8.1
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
php-tests:
strategy:
matrix:
php: [8.0]
php: [8.0, 8.1]
wordpress: ["latest"]
multisite: [true, false]
uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"laravel/serializable-closure": "^1.2",
"league/flysystem": "^1.1",
"league/flysystem-cached-adapter": "^1.1",
"monolog/monolog": "^2.7 || ^3.0",
"monolog/monolog": "^2.7",
"nesbot/carbon": "^2.53",
"nette/php-generator": "^3.6",
"nunomaduro/termwind": "^1.14",
Expand All @@ -42,7 +42,7 @@
"voku/portable-ascii": "^1.4"
},
"require-dev": {
"alleyinteractive/alley-coding-standards": "^0.3 || ^0.4 || ^1.0",
"alleyinteractive/alley-coding-standards": "^1.0",
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^9.3.3",
"symplify/monorepo-builder": "^10.1"
Expand Down
8 changes: 4 additions & 4 deletions src/mantle/config/class-repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function all(): array {
* @param mixed $offset Offset to retrieve.
* @return bool
*/
public function offsetExists( $offset ): bool {
public function offsetExists( mixed $offset ): bool {
return $this->has( $offset );
}

Expand All @@ -93,7 +93,7 @@ public function offsetExists( $offset ): bool {
* @param mixed $offset Offset to retrieve.
* @return mixed
*/
public function offsetGet( $offset ) {
public function offsetGet( mixed $offset ): mixed {
return $this->get( $offset );
}

Expand All @@ -103,7 +103,7 @@ public function offsetGet( $offset ) {
* @param mixed $offset Offset to set.
* @param mixed $value Value to set.
*/
public function offsetSet( $offset, $value ) {
public function offsetSet( mixed $offset, mixed $value ): void {
$this->set( $offset, $value );
}

Expand All @@ -112,7 +112,7 @@ public function offsetSet( $offset, $value ) {
*
* @param mixed $offset Offset to unset.
*/
public function offsetUnset( $offset ) {
public function offsetUnset( mixed $offset ): void {
$this->set( $offset, null );
}
}
4 changes: 2 additions & 2 deletions src/mantle/container/class-container.php
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,8 @@ public function offsetExists( mixed $key ): bool {
* @param mixed $key
* @return mixed
*/
public function offsetGet( mixed $key ) {
return $this->make( $key );
public function offsetGet( mixed $key ): mixed {
return $this->make( $key );
}

/**
Expand Down
27 changes: 10 additions & 17 deletions src/mantle/database/factory/class-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,48 +245,41 @@ public function load( $path ) {
/**
* Determine if the given offset exists.
*
* @param string $offset
*
* @param mixed $offset Offset to check on.
* @return bool
*/
public function offsetExists( $offset ) {
public function offsetExists( mixed $offset ): bool {
return isset( $this->definitions[ $offset ] );
}

/**
* Get the value of the given offset.
*
* @param string $offset
*
* @param mixed $offset Offset to retrieve.
* @return mixed
*/
public function offsetGet( $offset ) {
public function offsetGet( mixed $offset ): mixed {
return $this->make( $offset );
}

/**
* Set the given offset to the given value.
*
* @param string $offset
* @param callable $value
*
* @param mixed $offset Offset to assign the value to.
* @param mixed $value Value to set.
* @return void
*/
public function offsetSet( $offset, $value ) {
$this->define(
$offset, // phpcs:ignore
$value
);
public function offsetSet( mixed $offset, mixed $value ): void {
$this->define( $offset, $value );
}

/**
* Unset the value at the given offset.
*
* @param string $offset
*
* @param mixed $offset Offset to unset.
* @return void
*/
public function offsetUnset( $offset ) {
public function offsetUnset( mixed $offset ): void {
unset( $this->definitions[ $offset ] );
}
}
24 changes: 12 additions & 12 deletions src/mantle/database/model/class-model.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,39 +314,39 @@ public static function get_object_name(): ?string {
/**
* Check if an offset exists.
*
* @param string $offset Array offset.
* @param mixed $offset Array offset.
* @return bool
*/
public function offsetExists( $offset ): bool {
public function offsetExists( mixed $offset ): bool {
return null !== $this->get( $offset );
}

/**
* Get data by the offset.
*
* @param string $offset Array offset.
* @param mixed $offset Array offset.
* @return mixed
*/
public function offsetGet( $offset ) {
public function offsetGet( mixed $offset ): mixed {
return $this->get( $offset );
}

/**
* Set data by offset.
*
* @param string $offset Offset name.
* @param mixed $value Value to set.
* @param mixed $offset Offset name.
* @param mixed $value Value to set.
*/
public function offsetSet( $offset, $value ) {
return $this->set( $offset, $value );
public function offsetSet( mixed $offset, mixed $value ): void {
$this->set( $offset, $value );
}

/**
* Unset data by offset.
*
* @param string $offset Offset to unset.
* @param mixed $offset Offset to unset.
*/
public function offsetUnset( $offset ) {
public function offsetUnset( mixed $offset ): void {
$this->set( $offset, null );
unset( $this->relations[ $offset ] );
}
Expand Down Expand Up @@ -576,9 +576,9 @@ public function to_json( $options = 0 ): string {
/**
* Convert the object into something JSON serializable.
*
* @return array
* @return mixed
*/
public function jsonSerialize() {
public function jsonSerialize(): mixed {
return $this->to_array();
}
}
19 changes: 13 additions & 6 deletions src/mantle/database/pagination/class-paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
* Paginator for query results.
*/
class Paginator implements Arrayable, ArrayAccess, Countable, Jsonable, JsonSerializable, Htmlable, PaginatorContract {
/**
* Query parameters to append.
*
* @var array<string, string>
*/
public $append = [];

/**
* Current page number
*
Expand Down Expand Up @@ -481,9 +488,9 @@ public function to_array(): array {
/**
* Convert the object into something JSON serializable.
*
* @return array
* @return mixed
*/
public function jsonSerialize() {
public function jsonSerialize(): mixed {
return $this->to_array();
}

Expand All @@ -503,7 +510,7 @@ public function to_json( $options = 0 ) {
* @param mixed $offset Array offset.
* @return bool
*/
public function offsetExists( $offset ): bool {
public function offsetExists( mixed $offset ): bool {
return isset( $this->items[ $offset ] );
}

Expand All @@ -513,7 +520,7 @@ public function offsetExists( $offset ): bool {
* @param mixed $offset Offset to get.
* @return mixed
*/
public function offsetGet( $offset ) {
public function offsetGet( mixed $offset ): mixed {
return $this->items[ $offset ];
}

Expand All @@ -524,7 +531,7 @@ public function offsetGet( $offset ) {
* @param mixed $value Value to set.
* @return void
*/
public function offsetSet( $offset, $value ): void {
public function offsetSet( mixed $offset, mixed $value ): void {
$this->items[ $offset ] = $value;
}

Expand All @@ -534,7 +541,7 @@ public function offsetSet( $offset, $value ): void {
* @param mixed $offset Offset to delete.
* @return void
*/
public function offsetUnset( $offset ): void {
public function offsetUnset( mixed $offset ): void {
unset( $this->items[ $offset ] );
}

Expand Down
2 changes: 1 addition & 1 deletion src/mantle/support/class-arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ public static function sort_recursive( $array ) {
* @return string
*/
public static function query( $array ) {
return http_build_query( $array, null, '&', PHP_QUERY_RFC3986 );
return http_build_query( $array, '', '&', PHP_QUERY_RFC3986 );
}

/**
Expand Down
25 changes: 12 additions & 13 deletions src/mantle/support/class-collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
/**
* Collections class file.
*
* phpcs:disable Squiz.Commenting.FunctionComment.MissingParamComment, Squiz.Commenting.FunctionComment.MissingParamTag
*
* @package Mantle
*/

// phpcs:disable Squiz.Commenting.FunctionComment.MissingParamComment

// phpcs:disable Squiz.Commenting.FunctionComment.MissingParamTag

namespace Mantle\Support;

use ArrayAccess;
Expand All @@ -17,6 +15,7 @@
use Mantle\Database\Model;
use function Mantle\Support\Helpers\value;
use stdClass;
use Traversable;

/**
* Collection
Expand Down Expand Up @@ -93,10 +92,10 @@ public function all() {
/**
* Get a lazy collection for the items in this collection.
*
* @return \Mantle\Support\LazyCollection
* @return void
*/
public function lazy() {
return new LazyCollection( $this->items );
throw new \RuntimeException( 'Lazy collections are not supported at this time. ' ); // phpcs:ignore
}

/**
Expand Down Expand Up @@ -1091,7 +1090,7 @@ public function sort( $callback = null ) {

$callback && is_callable( $callback )
? uasort( $items, $callback )
: asort( $items, $callback );
: asort( $items, $callback ?? SORT_REGULAR );

return new static( $items );
}
Expand Down Expand Up @@ -1296,7 +1295,7 @@ public function pad( $size, $value ) {
*
* @return \ArrayIterator
*/
public function getIterator() {
public function getIterator(): Traversable {
return new ArrayIterator( $this->items );
}

Expand All @@ -1305,7 +1304,7 @@ public function getIterator() {
*
* @return int
*/
public function count() {
public function count(): int {
return count( $this->items );
}

Expand Down Expand Up @@ -1336,7 +1335,7 @@ public function to_base() {
* @param mixed $key
* @return bool
*/
public function offsetExists( $key ) {
public function offsetExists( mixed $key ): bool {
return array_key_exists( $key, $this->items );
}

Expand All @@ -1346,7 +1345,7 @@ public function offsetExists( $key ) {
* @param mixed $key
* @return mixed
*/
public function offsetGet( $key ) {
public function offsetGet( mixed $key ): mixed {
return $this->items[ $key ];
}

Expand All @@ -1357,7 +1356,7 @@ public function offsetGet( $key ) {
* @param mixed $value
* @return void
*/
public function offsetSet( $key, $value ) {
public function offsetSet( mixed $key, mixed $value ): void {
if ( is_null( $key ) ) {
$this->items[] = $value;
} else {
Expand All @@ -1371,7 +1370,7 @@ public function offsetSet( $key, $value ) {
* @param string $key
* @return void
*/
public function offsetUnset( $key ) {
public function offsetUnset( $key ): void {
unset( $this->items[ $key ] );
}
}
4 changes: 2 additions & 2 deletions src/mantle/support/traits/trait-enumerates-values.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ function ( $value ) {
/**
* Convert the object into something JSON serializable.
*
* @return array
* @return mixed
*/
public function jsonSerialize() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
public function jsonSerialize(): mixed { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
return array_map(
function ( $value ) {
if ( $value instanceof JsonSerializable ) {
Expand Down
Loading