Skip to content
This repository was archived by the owner on Dec 31, 2022. It is now read-only.

Commit 143d1b1

Browse files
author
Анатолий Нехай
committed
code improved
1 parent 3c614ef commit 143d1b1

16 files changed

Lines changed: 93 additions & 36 deletions

src/HeaderAccessControlAllowHeaders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function setValue(string ...$value) : self
7878
/**
7979
* Gets the header value
8080
*
81-
* @return array<int, string>
81+
* @return list<string>
8282
*/
8383
public function getValue() : array
8484
{

src/HeaderAccessControlAllowMethods.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function setValue(string ...$value) : self
8181
/**
8282
* Gets the header value
8383
*
84-
* @return array<int, string>
84+
* @return list<string>
8585
*/
8686
public function getValue() : array
8787
{

src/HeaderAccessControlAllowOrigin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,12 @@ public function getFieldValue() : string
9999
return '*';
100100
}
101101

102-
$value = $uri->getScheme() . '://' . $uri->getHost();
103-
if (null !== $uri->getPort()) {
104-
$value .= ':' . $uri->getPort();
102+
$value = $uri->getScheme() . ':';
103+
$value .= '//' . $uri->getHost();
104+
105+
$port = $uri->getPort();
106+
if (null !== $port) {
107+
$value .= ':' . $port;
105108
}
106109

107110
return $value;

src/HeaderAccessControlExposeHeaders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function setValue(string ...$value) : self
7878
/**
7979
* Gets the header value
8080
*
81-
* @return array<string>
81+
* @return list<string>
8282
*/
8383
public function getValue() : array
8484
{

src/HeaderAllow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function setValue(string ...$value) : self
8181
/**
8282
* Gets the header value
8383
*
84-
* @return array<int, string>
84+
* @return list<string>
8585
*/
8686
public function getValue() : array
8787
{

src/HeaderClearSiteData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function setValue(string ...$value) : self
7878
/**
7979
* Gets the header value
8080
*
81-
* @return array<int, string>
81+
* @return list<string>
8282
*/
8383
public function getValue() : array
8484
{

src/HeaderContentLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function setValue(string ...$value) : self
8787
/**
8888
* Gets the header value
8989
*
90-
* @return array<int, string>
90+
* @return list<string>
9191
*/
9292
public function getValue() : array
9393
{

src/HeaderDate.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Import classes
1616
*/
1717
use DateTime;
18+
use DateTimeImmutable;
1819
use DateTimeInterface;
1920
use DateTimeZone;
2021

@@ -81,8 +82,14 @@ public function getFieldName() : string
8182
*/
8283
public function getFieldValue() : string
8384
{
84-
$this->getTimestamp()->setTimezone(new DateTimeZone('GMT'));
85+
$timestamp = $this->getTimestamp();
8586

86-
return $this->getTimestamp()->format(DateTime::RFC822);
87+
/** @psalm-suppress RedundantCondition */
88+
if ($timestamp instanceof DateTime ||
89+
$timestamp instanceof DateTimeImmutable) {
90+
$timestamp->setTimezone(new DateTimeZone('GMT'));
91+
}
92+
93+
return $timestamp->format(DateTime::RFC822);
8794
}
8895
}

src/HeaderExpires.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Import classes
1616
*/
1717
use DateTime;
18+
use DateTimeImmutable;
1819
use DateTimeInterface;
1920
use DateTimeZone;
2021

@@ -81,8 +82,14 @@ public function getFieldName() : string
8182
*/
8283
public function getFieldValue() : string
8384
{
84-
$this->getTimestamp()->setTimezone(new DateTimeZone('GMT'));
85+
$timestamp = $this->getTimestamp();
8586

86-
return $this->getTimestamp()->format(DateTime::RFC822);
87+
/** @psalm-suppress RedundantCondition */
88+
if ($timestamp instanceof DateTime ||
89+
$timestamp instanceof DateTimeImmutable) {
90+
$timestamp->setTimezone(new DateTimeZone('GMT'));
91+
}
92+
93+
return $timestamp->format(DateTime::RFC822);
8794
}
8895
}

src/HeaderLastModified.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Import classes
1616
*/
1717
use DateTime;
18+
use DateTimeImmutable;
1819
use DateTimeInterface;
1920
use DateTimeZone;
2021

@@ -81,8 +82,14 @@ public function getFieldName() : string
8182
*/
8283
public function getFieldValue() : string
8384
{
84-
$this->getTimestamp()->setTimezone(new DateTimeZone('GMT'));
85+
$timestamp = $this->getTimestamp();
8586

86-
return $this->getTimestamp()->format(DateTime::RFC822);
87+
/** @psalm-suppress RedundantCondition */
88+
if ($timestamp instanceof DateTime ||
89+
$timestamp instanceof DateTimeImmutable) {
90+
$timestamp->setTimezone(new DateTimeZone('GMT'));
91+
}
92+
93+
return $timestamp->format(DateTime::RFC822);
8794
}
8895
}

0 commit comments

Comments
 (0)