-
Notifications
You must be signed in to change notification settings - Fork 0
Add PHP 8 issues #31
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
base: main
Are you sure you want to change the base?
Add PHP 8 issues #31
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| {"lint-only-modified-files":true} | ||
| {"lint-only-modified-files":false} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @param $a | ||
| * @param $b | ||
| * Call str_contains! | ||
| * @return bool | ||
| */ | ||
| function find_my_string( $a, $b ): bool { | ||
| if ( $x = str_contains( $a, $b ) ) { | ||
| echo 'The string has been found'; | ||
| } else { | ||
| echo "String not found"; | ||
| } | ||
|
|
||
| return $x; | ||
| } | ||
| $result2 = find_my_string('a', 'b'); | ||
| var_dump( $result2 ); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // Just a test files with various cool PHP8 stuffs | ||
| $my_super_array = [ | ||
| 1.0, | ||
| 'string', | ||
| true, | ||
| ]; | ||
|
|
||
| /** | ||
| * Yay fun function | ||
| * | ||
| * @param integer|string|boolean $arg | ||
| * | ||
| * @return string | ||
| */ | ||
| function php8_fun( int|string|bool $arg ): string { | ||
| $result = match ( $arg ) { | ||
| 1.0 => 'Float!', | ||
| 'string' => 'String', | ||
| 'sup' => 'string!!!', | ||
| default => gettype( $arg ) | ||
| }; | ||
| return $result; | ||
| } | ||
|
|
||
| $result = fn( $c ) => $c . php8_fun( $my_super_array[ array_rand( $my_super_array, 1 ) ] ); | ||
|
|
||
| $x = 'x'; | ||
| var_dump( $result($x) ); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Fatal error | ||
| */ | ||
| class C1 { | ||
| public function method(array $a) {} | ||
| } | ||
| class C2 extends C1 { | ||
| public function method(int $a) {} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 Error: PHP syntax error: Declaration of C2::method(int $a) must be compatible with C1::method(array $a) (Generic.PHP.Syntax.PHPSyntax). |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.