-
Notifications
You must be signed in to change notification settings - Fork 29
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 Support #39
PHP 8 Support #39
Conversation
src/Dflydev/FigCookies/Cookie.php
Outdated
{ | ||
return new static($name, $value); | ||
return new self($name, $value); |
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.
class is not final, means this is a behavior change
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.
Reverted.
src/Dflydev/FigCookies/Cookies.php
Outdated
{ | ||
return new static(Cookie::listFromCookieString($string)); | ||
return new self(Cookie::listFromCookieString($string)); |
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.
class is not final, means this is a behavior change
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.
Reverted.
|
||
/** @var Cookie $cookie */ | ||
$cookie = new static($cookieName); | ||
$cookie = new self($cookieName); |
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.
class is not final, means this is a behavior change
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.
Reverted.
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 one isn't reverted yet
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.
Indeed, can this one get updated, too?
src/Dflydev/FigCookies/SetCookie.php
Outdated
{ | ||
return new static($name, $value); | ||
return new self($name, $value); |
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.
class is not final, means this is a behavior change
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.
Reverted.
|
||
/** @var SetCookie $setCookie */ | ||
$setCookie = new static($cookieName); | ||
$setCookie = new self($cookieName); |
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.
class is not final, means this is a behavior change
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.
Reverted.
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 one isn't reverted yet
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.
Indeed, can this one get updated, too?
{ | ||
return new static(array_map(function (string $setCookieString) : SetCookie { | ||
return new self(array_map(static function (string $setCookieString): SetCookie { |
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.
class is not final, means this is a behavior change
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.
Reverted.
{ | ||
return new static(array_map(function (string $setCookieString) : SetCookie { | ||
return new self(array_map(static function (string $setCookieString): SetCookie { |
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.
class is not final, means this is a behavior change
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.
Reverted.
@dominikzogg Is there something else that needs to be done here? Can we merge this? |
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.
|
||
/** @var Cookie $cookie */ | ||
$cookie = new static($cookieName); | ||
$cookie = new self($cookieName); |
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 one isn't reverted yet
{ | ||
$cookieString = implode('; ', $this->cookies); | ||
|
||
$request = $request->withHeader(static::COOKIE_HEADER, $cookieString); | ||
$request = $request->withHeader(self::COOKIE_HEADER, $cookieString); |
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.
changes are low (http spec), but also this constant could be overridden
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 think I've completely underestimated the static::
vs self::
implications in a few places... Is doing static::
bad here for some reason?
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.
static:: means it will take the called class, while self:: will take the class the self:: is done in the class that does the self:: call:
{ | ||
$cookieString = $request->getHeaderLine(static::COOKIE_HEADER); | ||
$cookieString = $request->getHeaderLine(self::COOKIE_HEADER); |
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.
changes are low (http spec), but also this constant could be overridden
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 think I've completely underestimated the static::
vs self::
implications in a few places... Is doing static::
bad here for some reason?
{ | ||
return new self(self::STRICT); | ||
return new static(self::STRICT); |
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.
it's a final class, static is useless here
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.
But is it wrong?
{ | ||
return new self(self::LAX); | ||
return new static(self::LAX); |
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.
it's a final class, static is useless here
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.
But is it wrong?
return SetCookie::fromSetCookieString($setCookieString); | ||
}, $response->getHeader(static::SET_COOKIE_HEADER))); | ||
}, $response->getHeader(self::SET_COOKIE_HEADER))); |
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.
changes are low (http spec), but also this constant could be overridden
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 think I've completely underestimated the static::
vs self::
implications in a few places... Is doing static::
bad here for some reason?
$request = $this->prophesize(static::INTERFACE_PSR_HTTP_MESSAGE_REQUEST); | ||
$request->getHeaderLine(Cookies::COOKIE_HEADER)->willReturn($cookieString); | ||
/** @var RequestInterface|MockObject $request */ | ||
$request = $this->createMock(self::INTERFACE_PSR_HTTP_MESSAGE_REQUEST); |
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.
prophecy is still usable, by loading a trait
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 have no idea if @simensen wants to keep prophecy
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 don't care about Prophecy. I think this was maybe added by @Ocramius at some point?
@@ -210,7 +207,7 @@ public function provideCookieStringAndExpectedCookiesData() : array | |||
} | |||
|
|||
/** @return string[][]|Cookie[][] */ | |||
public function provideGetsCookieByNameData() | |||
public function provideGetsCookieByNameData(): 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.
test is not final could be overridden (i would take the risk of a BC here)
@@ -57,7 +59,7 @@ public function withAddedHeader($name, $value) | |||
/** {@inheritDoc} */ | |||
public function withoutHeader($name) | |||
{ | |||
$clone = clone($this); | |||
$clone = clone$this; |
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.
$clone = clone$this; | |
$clone = clone $this; |
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.
Let's get this change added to the PR.
/** @var ResponseInterface|ObjectProphecy $response */ | ||
$response = $this->prophesize(static::INTERFACE_PSR_HTTP_MESSAGE_RESPONSE); | ||
$response->getHeader(SetCookies::SET_COOKIE_HEADER)->willReturn($setCookieStrings); | ||
/** @var ResponseInterface|MockObject $response */ |
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.
prophecy is still usable, by loading a trait
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 have no idea if @simensen wants to keep prophecy
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.
Happy to drop it if it's easier at this point.
@dominikzogg How are we doing on this one? My bad for not catching this earlier. @Ocramius, are you able to take a look at this? I think your big changes were some of the last things to go in here. |
@simensen i get aware about this PR, cause i like to create an issue about the lack of PHP 8 support. In my opinion its PR is much larger than it needs to be, but its not my repository, so i only mentioned the things that i believe are critical like (self vs static changes). |
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 looks good. Agreed it is maybe larger than needed (especially the style changes) but none of them look altogether bad. Would love to get sign off from @Ocramius, though, as he did a lot of work on this recently.
|
||
/** @var Cookie $cookie */ | ||
$cookie = new static($cookieName); | ||
$cookie = new self($cookieName); |
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.
Indeed, can this one get updated, too?
{ | ||
$cookieString = implode('; ', $this->cookies); | ||
|
||
$request = $request->withHeader(static::COOKIE_HEADER, $cookieString); | ||
$request = $request->withHeader(self::COOKIE_HEADER, $cookieString); |
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 think I've completely underestimated the static::
vs self::
implications in a few places... Is doing static::
bad here for some reason?
{ | ||
$cookieString = $request->getHeaderLine(static::COOKIE_HEADER); | ||
$cookieString = $request->getHeaderLine(self::COOKIE_HEADER); |
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 think I've completely underestimated the static::
vs self::
implications in a few places... Is doing static::
bad here for some reason?
{ | ||
return new self(self::STRICT); | ||
return new static(self::STRICT); |
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.
But is it wrong?
{ | ||
return new self(self::LAX); | ||
return new static(self::LAX); |
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.
But is it wrong?
foreach ($this->setCookies as $setCookie) { | ||
$response = $response->withAddedHeader(static::SET_COOKIE_HEADER, (string) $setCookie); | ||
$response = $response->withAddedHeader(self::SET_COOKIE_HEADER, (string) $setCookie); |
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 think I've completely underestimated the static::
vs self::
implications in a few places... Is doing static::
bad here for some reason?
return SetCookie::fromSetCookieString($setCookieString); | ||
}, $response->getHeader(static::SET_COOKIE_HEADER))); | ||
}, $response->getHeader(self::SET_COOKIE_HEADER))); |
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 think I've completely underestimated the static::
vs self::
implications in a few places... Is doing static::
bad here for some reason?
$request = $this->prophesize(static::INTERFACE_PSR_HTTP_MESSAGE_REQUEST); | ||
$request->getHeaderLine(Cookies::COOKIE_HEADER)->willReturn($cookieString); | ||
/** @var RequestInterface|MockObject $request */ | ||
$request = $this->createMock(self::INTERFACE_PSR_HTTP_MESSAGE_REQUEST); |
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 don't care about Prophecy. I think this was maybe added by @Ocramius at some point?
@@ -57,7 +59,7 @@ public function withAddedHeader($name, $value) | |||
/** {@inheritDoc} */ | |||
public function withoutHeader($name) | |||
{ | |||
$clone = clone($this); | |||
$clone = clone$this; |
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.
Let's get this change added to the PR.
/** @var ResponseInterface|ObjectProphecy $response */ | ||
$response = $this->prophesize(static::INTERFACE_PSR_HTTP_MESSAGE_RESPONSE); | ||
$response->getHeader(SetCookies::SET_COOKIE_HEADER)->willReturn($setCookieStrings); | ||
/** @var ResponseInterface|MockObject $response */ |
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.
Happy to drop it if it's easier at this point.
@canvural are you up for making the requested changes? :) If not, I can see if I can take over. |
I can fix it, but Wednesday earliest. Style changes are because of
|
@canvural Awesome, thanks. Indeed, it makes sense re: the style changes. :) However, it might have been possible to not upgrade that dependency so far just yet. I'm happy with it as-is, to be clear. It does make it harder to review the PR, tho. Re Thanks again for your help! |
Change from |
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 think PHP 8 should be added to CI's matrix (I can mot do it myself right now)
@@ -20,10 +20,12 @@ | |||
} | |||
}, | |||
"require-dev": { | |||
"phpunit/phpunit": "^7.2.6", | |||
"phpunit/phpunit": "^7.2.6 || ^9", |
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.
The minimum php version of this lib is php 7.2, so the minimum vesion of phpunit could be 8, as that still supports php 7.2
{ | ||
$cookieString = implode('; ', $this->cookies); | ||
|
||
$request = $request->withHeader(static::COOKIE_HEADER, $cookieString); | ||
$request = $request->withHeader(self::COOKIE_HEADER, $cookieString); |
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.
static:: means it will take the called class, while self:: will take the class the self:: is done in the class that does the self:: call:
{ | ||
if ($expires === null) { | ||
return 0; | ||
} | ||
|
||
if ($expires instanceof DateTimeInterface) { | ||
return $expires->getTimestamp(); | ||
return (int) $expires->getTimestamp(); |
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.
Before php 8, this method could return false on failure.
Hi, this is the last dependency preventing my project from runnin on php 8.0, can I do something to help get this ready? should I fork the pull-request and complete the pending changes? |
Thank you! |
This PR: