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

PHP 8.1 Compatibility #42

Closed
fandisus opened this issue May 6, 2022 · 2 comments · Fixed by #43
Closed

PHP 8.1 Compatibility #42

fandisus opened this issue May 6, 2022 · 2 comments · Fixed by #43

Comments

@fandisus
Copy link

fandisus commented May 6, 2022

Running garden-cli with PHP 8.1.5 gives me:

Deprecated: Return type of Garden\Cli\Schema\OptSchema::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Schema\OptSchema.php on line 231

Deprecated: Return type of Garden\Cli\Args::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 219

Deprecated: Return type of Garden\Cli\Args::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 236

Deprecated: Return type of Garden\Cli\Args::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 247

Deprecated: Return type of Garden\Cli\Args::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 259

Deprecated: Return type of Garden\Cli\Args::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in D:_pro\Target\target_web\vendor\vanilla\garden-cli\src\Args.php on line 270

I can not push to new branch or create pull request. So... If okay, please help me doing these:
src\Schema\OptSchema.php
Line 231: Add return type: mixed
public function jsonSerialize() : mixed {

src\Args.php
Line 219: Add return type: mixed
public function jsonSerialize() : mixed {
Line 236: Add return type: bool
public function offsetExists($offset) : bool {
Line 247: Add return type: mixed
public function offsetGet($offset) : mixed {
Line 259: Add return type: void
public function offsetSet($offset, $value) : void {
Line 270: Add return type: void
public function offsetUnset($offset) : void {

Doing this will break compatibility with PHP below Version 7. But since the requirement for garden-cli is PHP 7 or above, then i think it's safe to do above changes.

SMillerDev added a commit to SMillerDev/garden-cli that referenced this issue Jun 6, 2022
@Donatello-za
Copy link

Hi, when will this fix be released officially?

@Donatello-za
Copy link

There is a small issue in the REAMD.md in this pull request:

The documentation says the following about the setTimeFormat method for the StreamLogger class.

| Method                | Default   | Notes                                                                                                                  |
| ------                | -------   |------------------------------------------------------------------------------------------------------------------------|
| `setTimeFormat`       | `'%F %T'` | Set the time format. This can be a `date` string or a callback.                                                        |

The %F and %T formats will not work as the date() function is now used instead of strftime() (which has been deprecated in PHP 8.1). The documentation should say:

| Method                | Default         | Notes                                                                                                                  |
| ------                | --------------- |------------------------------------------------------------------------------------------------------------------------|
| `setTimeFormat`       | `'Y-m-d H:i:s'` | Set the time format. This can be a `date` string or a callback.                                                        |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants