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

Add PHP 8 support #8

Closed
wants to merge 3 commits into from
Closed

Add PHP 8 support #8

wants to merge 3 commits into from

Conversation

geerteltink
Copy link
Contributor

@geerteltink geerteltink commented Oct 11, 2020

  • Update PHP constraint to ^7.3 || ~8.0.0
  • Update PHPUnit constraint to ^9.3
  • Remove constraint for phpspec/prophecy
  • Update Travis job matrix to cover 7.3, 7.4, and 8.0
  • Migrate tests from Prophecy to PHPUnit mocks
  • Update to coding standard constraint ~2.1.0

Fixes #7

Signed-off-by: Geert Eltink <geert.eltink@gmail.com>
Signed-off-by: Geert Eltink <geert.eltink@gmail.com>
@geerteltink geerteltink added the Enhancement New feature or request label Oct 11, 2020
@geerteltink geerteltink added this to the 1.3.0 milestone Oct 11, 2020
@@ -14,13 +14,15 @@
* Configuration provider for the package.
*
* @see https://docs.laminas.dev/laminas-component-installer/
*
* phpcs:disable WebimpressCodingStandard.PHP.DisallowFqn.FileName
Copy link
Contributor Author

@geerteltink geerteltink Oct 11, 2020

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

Copy link
Member

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 ;-)

Copy link
Contributor Author

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
----------------------------------------------------------------------------------------------------------------------------------------------------------

Copy link
Contributor

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;
Copy link
Contributor Author

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
Copy link
Contributor Author

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>
@boesing
Copy link
Member

boesing commented Oct 11, 2020

TBH: Its quite hard to review a PR which is meant to be a PHP upgrade with lots of codestyle changes.
I'd prefer having a dedicated CS 2.0 PR rather than combined with PHP 8.0.

@geerteltink
Copy link
Contributor Author

TBH: Its quite hard to review a PR which is meant to be a PHP upgrade with lots of codestyle changes.
I'd prefer having a dedicated CS 2.0 PR rather than combined with PHP 8.0.

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
Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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 👍

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@weierophinney weierophinney left a 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
Copy link
Contributor

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"

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

@boesing
Copy link
Member

boesing commented Dec 4, 2020

We need willdurand/negotiation v3 support in here to properly support PHP 8.0 as stated in #10
Are you still on this @geerteltink or shall we take over?

@acelaya
Copy link
Contributor

acelaya commented Jan 22, 2021

Any way I can help push this forward?

@Ocramius
Copy link
Member

@acelaya you can take the branch, add willdurand/negotiation:^3 support, and then we'd merge that.

env:
- DEPS=lowest
- php: 7.3
- php: nightly
Copy link
Member

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

@acelaya
Copy link
Contributor

acelaya commented Jan 23, 2021

Sounds good. I can do that.

@acelaya acelaya mentioned this pull request Jan 23, 2021
@acelaya
Copy link
Contributor

acelaya commented Jan 23, 2021

I have just created a new PR #11, which includes this branch, plus the latest changes requested here.

@acelaya
Copy link
Contributor

acelaya commented Jan 23, 2021

@Ocramius @samsonasik I did all required changes in #11 to make the build green. Feel free to review there.

@Ocramius Ocramius self-assigned this Jan 24, 2021
@Ocramius Ocramius added the Duplicate This issue or pull request already exists label Jan 24, 2021
@Ocramius
Copy link
Member

Closing here: commits ported to #11 for now :-)

@Ocramius Ocramius closed this Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate This issue or pull request already exists Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP 8.0 support
8 participants