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

Be more strict with types #2914

Merged
merged 4 commits into from Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -32,7 +32,8 @@
"ext-json": "*",
"guzzlehttp/promises": "^1.4",
"guzzlehttp/psr7": "^1.7 || ^2.0",
"psr/http-client": "^1.0"
"psr/http-client": "^1.0",
"symfony/deprecation-contracts": "^2.4"
Nyholm marked this conversation as resolved.
Show resolved Hide resolved
},
"provide": {
"psr/http-client-implementation": "1.0"
Expand Down
4 changes: 4 additions & 0 deletions phpstan-baseline.neon
Expand Up @@ -110,3 +110,7 @@ parameters:
count: 2
path: src/Middleware.php

-
message: "#^Result of && is always false\\.$#"
count: 1
path: src/Cookie/SetCookie.php
38 changes: 37 additions & 1 deletion src/Cookie/SetCookie.php
Expand Up @@ -128,6 +128,10 @@ public function getName()
*/
public function setName($name): void
{
if (!is_string($name)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['Name'] = $name;
}

Expand All @@ -148,6 +152,10 @@ public function getValue()
*/
public function setValue($value): void
{
if (!is_string($value)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['Value'] = $value;
}

Expand All @@ -168,6 +176,10 @@ public function getDomain()
*/
public function setDomain($domain): void
{
if (!is_string($domain)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['Domain'] = $domain;
}

Expand All @@ -188,6 +200,10 @@ public function getPath()
*/
public function setPath($path): void
{
if (!is_string($path)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['Path'] = $path;
}

Expand All @@ -198,7 +214,7 @@ public function setPath($path): void
*/
public function getMaxAge()
{
return $this->data['Max-Age'];
return null === $this->data['Max-Age'] ? null : (int) $this->data['Max-Age'];
}

/**
Expand All @@ -208,6 +224,10 @@ public function getMaxAge()
*/
public function setMaxAge($maxAge): void
{
if (!is_int($maxAge)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['Max-Age'] = $maxAge;
}

Expand All @@ -228,6 +248,10 @@ public function getExpires()
*/
public function setExpires($timestamp): void
{
if (!is_int($timestamp) && !is_string($timestamp)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int or string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['Expires'] = \is_numeric($timestamp)
? (int) $timestamp
: \strtotime($timestamp);
Expand All @@ -250,6 +274,10 @@ public function getSecure()
*/
public function setSecure($secure): void
{
if (!is_bool($secure)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a boolean to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['Secure'] = $secure;
}

Expand All @@ -270,6 +298,10 @@ public function getDiscard()
*/
public function setDiscard($discard): void
{
if (!is_bool($discard)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a boolean to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['Discard'] = $discard;
}

Expand All @@ -290,6 +322,10 @@ public function getHttpOnly()
*/
public function setHttpOnly($httpOnly): void
{
if (!is_bool($httpOnly)) {
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a boolean to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
}

$this->data['HttpOnly'] = $httpOnly;
}

Expand Down