-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add PHP 8 support #8
Conversation
Signed-off-by: Geert Eltink <geert.eltink@gmail.com>
Signed-off-by: Geert Eltink <geert.eltink@gmail.com>
@@ -14,13 +14,15 @@ | |||
* Configuration provider for the package. | |||
* | |||
* @see https://docs.laminas.dev/laminas-component-installer/ | |||
* | |||
* phpcs:disable WebimpressCodingStandard.PHP.DisallowFqn.FileName |
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.
38 | ERROR | Zend\ProblemDetails\ProblemDetailsMiddleware must be imported but file with name ProblemDetailsMiddleware exists in the namespace
39 | ERROR | Zend\ProblemDetails\ProblemDetailsNotFoundHandler must be imported but file with name ProblemDetailsNotFoundHandler exists in the namespace
40 | ERROR | Zend\ProblemDetails\ProblemDetailsResponseFactory must be imported but file with name ProblemDetailsResponseFactory exists in the namespace
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.
@geerteltink Not sure how WebimpressCodingStandard.PHP.DisallowFqn.FileName
is related to the issue you have reported ;-)
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.
@michalbundyra Ah, I tagged the wrong line. This is causing:
FILE: src/ConfigProvider.php
----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------
38 | ERROR | Zend\ProblemDetails\ProblemDetailsMiddleware must be imported but file with name ProblemDetailsMiddleware exists in the namespace
39 | ERROR | Zend\ProblemDetails\ProblemDetailsNotFoundHandler must be imported but file with name ProblemDetailsNotFoundHandler exists in the namespace
40 | ERROR | Zend\ProblemDetails\ProblemDetailsResponseFactory must be imported but file with name ProblemDetailsResponseFactory exists in the namespace
----------------------------------------------------------------------------------------------------------------------------------------------------------
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.
What I've done in other packages is to import these classes at the top of the file, but with the prefix "Legacy":
use Zend\ProblemDetails\ProblemDetailsResponseFactory as LegacyProblemDetailsResponseFactory;
When you reference them later:
LegacyProblemDetailsResponseFactory::class
will then work, and you no longer get those phpcs issues. It also makes it clear why we are importing them.
public function toArray() : array; | ||
public function toArray(): array; | ||
|
||
public function jsonSerialize(): array; |
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.
This is a fix for PhpUnit Mock. I'm not sure if I did something wrong, but without this it complaints about not being able to create a mock for jsonSerialize
because it's an abstract method.
@weierophinney any idea on how to fix this properly?
private $response; | ||
|
||
/** @var ProblemDetailsResponseFactory */ | ||
private $factory; | ||
|
||
private const UTF_8_INVALID_2_OCTET_SEQUENCE = "\xc3\x28"; | ||
|
||
protected function setUp() : void | ||
protected function setUp(): void |
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.
There are about 26 phpunit errors left in this file and I don't know where it is coming from:
Return value of PHPUnit\Framework\Constraint\Callback::matches() must be of the type bool, string returned
@weierophinney any idea what I miss here?
Signed-off-by: Geert Eltink <geert.eltink@gmail.com>
TBH: Its quite hard to review a PR which is meant to be a PHP upgrade with lots of codestyle changes. |
I can change the title if you want :D I agree I could have made 2 MR's but after merging one, there I have to fix a ton of merge conflicts in the other. Besides that, in src it's code style only and in test it's mostly the change from prophecy to mock. If you think the MR is un reviewable, please close it and I'll make another one. |
@@ -4,6 +4,8 @@ | |||
* @see https://github.com/mezzio/mezzio-problem-details for the canonical source repository | |||
* @copyright https://github.com/mezzio/mezzio-problem-details/blob/master/COPYRIGHT.md | |||
* @license https://github.com/mezzio/mezzio-problem-details/blob/master/LICENSE.md New BSD License | |||
* | |||
* phpcs:disable WebimpressCodingStandard.Namespaces.UnusedUseStatement.UnusedUse |
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.
Reported in webimpress/coding-standard#118
JSON_PRETTY_PRINT is not detected as a used contants.
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.
@michalbundyra this is where the issue is.
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.
Yeah, I know ;-) I have a fix already, will release tomorrow, thanks 👍
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.
@geerteltink it has been resolved now in webimpress/coding-standard - 1.1.6 release.
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.
I saw your new release. I'll update this PR with the change soon.
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.
Looks sane; I don't see any BC breaks.
I've left some feedback on how to address the legacy ZF classes in the `ConfigProvider.
@@ -14,13 +14,15 @@ | |||
* Configuration provider for the package. | |||
* | |||
* @see https://docs.laminas.dev/laminas-component-installer/ | |||
* | |||
* phpcs:disable WebimpressCodingStandard.PHP.DisallowFqn.FileName |
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.
What I've done in other packages is to import these classes at the top of the file, but with the prefix "Legacy":
use Zend\ProblemDetails\ProblemDetailsResponseFactory as LegacyProblemDetailsResponseFactory;
When you reference them later:
LegacyProblemDetailsResponseFactory::class
will then work, and you no longer get those phpcs issues. It also makes it clear why we are importing them.
@@ -42,9 +38,8 @@ | |||
"willdurand/negotiation": "^2.3" |
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.
This dependency is not compatible with PHP 8 - therfore this patch isn't as well.
It declares a class name which is a keyword in PHP 8: https://github.com/willdurand/Negotiation/blob/2.x/src/Negotiation/Match.php
It must be ^3.0
to support PHP 8 - See willdurand/Negotiation#106
We need |
Any way I can help push this forward? |
@acelaya you can take the branch, add |
env: | ||
- DEPS=lowest | ||
- php: 7.3 | ||
- php: nightly |
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.
8.0 can be used
Sounds good. I can do that. |
I have just created a new PR #11, which includes this branch, plus the latest changes requested here. |
@Ocramius @samsonasik I did all required changes in #11 to make the build green. Feel free to review there. |
Closing here: commits ported to #11 for now :-) |
Fixes #7