Skip to content

Commit

Permalink
Update to support latest http-foundation (#3)
Browse files Browse the repository at this point in the history
min php version 8.0
  • Loading branch information
MrEssex authored Dec 17, 2024
1 parent c7708b3 commit 5f0e394
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
}
],
"require": {
"php": ">=7.2",
"php": "^8.0",
"ext-json": "*",
"packaged/helpers": "^1.9||^2.0",
"packaged/config": "^1.2",
"symfony/http-foundation": "~4.2"
"symfony/http-foundation": "^v7.2.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0"
Expand Down
2 changes: 1 addition & 1 deletion src/LinkBuilder/LinkBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function asUrl(): string

protected function _isStandardPort($scheme, $port)
{
return ('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443);
return ('http' === $scheme && $port === 80) || ('https' === $scheme && $port === 443);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getDefinedTlds()
return $this->getFqdn()->getDefinedTlds();
}

public function isSecure($allowUntrustedHeaders = false)
public function isSecure($allowUntrustedHeaders = false): bool
{
return $this->_cachedPart(
'isSecure-' . ($allowUntrustedHeaders ? 1 : 0),
Expand Down Expand Up @@ -197,7 +197,7 @@ public function isStandardPort()
$scheme = $this->getScheme();
$port = $this->getPort();

return ('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443);
return ('http' === $scheme && $port === 80) || ('https' === $scheme && $port === 443);
}

/**
Expand Down Expand Up @@ -327,7 +327,7 @@ public function referrer($default = null)
*
* @return array
*/
public function getClientIps()
public function getClientIps(): array
{
return $this->_cachedPart(
'clientIps',
Expand Down Expand Up @@ -364,7 +364,7 @@ function () {
*
* @api
*/
public function getClientIp()
public function getClientIp(): string
{
$ipAddresses = $this->getClientIps();
return end($ipAddresses);
Expand Down
9 changes: 6 additions & 3 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class Response extends \Symfony\Component\HttpFoundation\Response
protected $_headersSent = false;
protected $_sendDebugHeaders;

public static function create(?string $content = '', int $status = 200, array $headers = []): static
{
return new static($content, $status, $headers);
}

/**
* @return string
*/
Expand Down Expand Up @@ -55,10 +60,9 @@ public function setCallStartTime($time)
* Add Debug Headers before sending
*
* @inheritdoc
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function sendHeaders()
public function sendHeaders(?int $statusCode = null): static
{
if(!$this->_headersSent)
{
Expand All @@ -71,7 +75,6 @@ public function sendHeaders()

/**
* Define Debug Headers
*
* Automatically called by ->send()
*/
public function setDebugHeaders()
Expand Down
2 changes: 1 addition & 1 deletion src/Responses/BoolResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class BoolResponse extends Response
{
public static function create($bool = true, $status = 200, $headers = [])
public static function create($bool = true, int $status = 200, array $headers = []): static
{
return parent::create($bool ? 'true' : 'false', $status, $headers);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Responses/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class JsonResponse extends Response
{
public static function create($object = null, $status = 200, $headers = [])
public static function create($object = null, $status = 200, $headers = []): static
{
return static::raw(json_encode($object, JSON_INVALID_UTF8_SUBSTITUTE), $status, $headers);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Responses/RedirectResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@

class RedirectResponse extends \Symfony\Component\HttpFoundation\RedirectResponse
{

public static function create($url, $status = 302, $headers = []): static
{
return new static($url, $status, $headers);
}
}
2 changes: 1 addition & 1 deletion src/Responses/TextResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class TextResponse extends Response
{
public static function create($text = '', $status = 200, $headers = [])
public static function create($text = '', $status = 200, $headers = []): static
{
$resp = parent::create($text, $status, $headers);
$resp->headers->set("Content-Type", "text/plain");
Expand Down

0 comments on commit 5f0e394

Please sign in to comment.