Skip to content

Comments

Prevent void param type#1142

Open
WoutervdBrink wants to merge 1 commit intonikic:masterfrom
WoutervdBrink:prevent-param-void-type
Open

Prevent void param type#1142
WoutervdBrink wants to merge 1 commit intonikic:masterfrom
WoutervdBrink:prevent-param-void-type

Conversation

@WoutervdBrink
Copy link

PHP 7.1 introduced the void type. Consequently, it is no longer allowed to specify void as the parameter type:

<?php
function foo(void $bar) {}
  • This pull request adds detection for this behavior and rejects functions that have the identifier void as parameter type.
  • Pre-7.1, it was allowed to create a class class void {} and use that as a parameter type. In this case, the parameter's type is the name void, so the error isn't thrown.
  • Two test cases are added to verify the above behavior.

The 5.0-7.1 behavior is tested on 3v4l: https://3v4l.org/Krff3#veol

Fixes #1137.

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 this pull request may close these issues.

Type error

1 participant