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

Url: Add method removeQueryParameter(). #196

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/Bug_report.md

This file was deleted.

9 changes: 0 additions & 9 deletions .github/ISSUE_TEMPLATE/Feature_request.md

This file was deleted.

12 changes: 0 additions & 12 deletions .github/ISSUE_TEMPLATE/Support_question.md

This file was deleted.

21 changes: 0 additions & 21 deletions .github/ISSUE_TEMPLATE/Support_us.md

This file was deleted.

2 changes: 0 additions & 2 deletions .github/funding.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/pull_request_template.md

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.1
php-version: 8.0
coverage: none

- run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress
Expand All @@ -24,7 +24,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
coverage: none

- run: composer create-project nette/coding-standard temp/coding-standard ^3 --no-progress
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
coverage: none

- run: composer install --no-progress --prefer-dist
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
php: ['7.2', '7.3', '7.4', '8.0']
php: ['8.0']
# sapi: ['php', 'php-cgi']

fail-fast: false
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.2
php-version: 8.0
coverage: none
extensions: fileinfo, intl

Expand All @@ -53,7 +53,7 @@ jobs:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
coverage: none
extensions: fileinfo, intl

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ install:
# Install PHP
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
- IF %PHP%==1 cd c:\php
- IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-7.2.28-Win32-VC15-x64.zip --output php.zip
- IF %PHP%==1 curl https://windows.php.net/downloads/releases/archives/php-8.0.1-Win32-vs16-x64.zip --output php.zip
- IF %PHP%==1 7z x php.zip >nul
- IF %PHP%==1 echo extension_dir=ext >> php.ini
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
}
],
"require": {
"php": ">=7.2 <8.1",
"nette/utils": "^3.1"
"php": ">=8.0 <8.1",
"nette/utils": "^3.2 || ^4.0"
},
"require-dev": {
"nette/di": "^3.0",
"nette/tester": "^2.0",
"nette/security": "^3.0",
"tracy/tracy": "^2.4",
"nette/di": "^4.0",
"nette/tester": "^2.4",
"nette/security": "^4.0",
"tracy/tracy": "^2.8",
"phpstan/phpstan": "^0.12"
},
"conflict": {
Expand All @@ -42,7 +42,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
"dev-master": "4.0-dev"
}
}
}
33 changes: 0 additions & 33 deletions contributing.md

This file was deleted.

2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Installation
composer require nette/http
```

It requires PHP version 7.2 and supports PHP up to 8.0.
It requires PHP version 8.0.


HTTP Request
Expand Down
7 changes: 3 additions & 4 deletions src/Bridges/HttpDI/HttpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
class HttpExtension extends Nette\DI\CompilerExtension
{
/** @var bool */
private $cliMode;
private bool $cliMode;


public function __construct(bool $cliMode = false)
Expand Down Expand Up @@ -116,7 +115,7 @@ private function sendHeaders()
$this->initialization->addBody('$cspNonce = base64_encode(random_bytes(16));');
$value = Nette\DI\ContainerBuilder::literal(
'str_replace(?, ? . $cspNonce, ?)',
["'nonce", "'nonce-", $value]
["'nonce", "'nonce-", $value],
);
}
$headers['Content-Security-Policy' . ($key === 'csp' ? '' : '-Report-Only')] = $value;
Expand All @@ -135,7 +134,7 @@ private function sendHeaders()

$this->initialization->addBody(
'Nette\Http\Helpers::initCookie($this->getService(?), $response);',
[$this->prefix('request')]
[$this->prefix('request')],
);
}

Expand Down
16 changes: 3 additions & 13 deletions src/Bridges/HttpDI/SessionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
*/
class SessionExtension extends Nette\DI\CompilerExtension
{
/** @var bool */
private $debugMode;
private bool $debugMode;

/** @var bool */
private $cliMode;
private bool $cliMode;


public function __construct(bool $debugMode = false, bool $cliMode = false)
Expand All @@ -41,7 +39,7 @@ public function getConfigSchema(): Nette\Schema\Schema
'expiration' => Expect::string()->dynamic(),
'handler' => Expect::string()->dynamic(),
'readAndClose' => Expect::bool(),
'cookieSamesite' => Expect::anyOf(IResponse::SAME_SITE_LAX, IResponse::SAME_SITE_STRICT, IResponse::SAME_SITE_NONE, true)
'cookieSamesite' => Expect::anyOf(IResponse::SAME_SITE_LAX, IResponse::SAME_SITE_STRICT, IResponse::SAME_SITE_NONE)
->firstIsDefault(),
])->otherItems('mixed');
}
Expand All @@ -64,14 +62,6 @@ public function loadConfiguration()
if (($config->cookieDomain ?? null) === 'domain') {
$config->cookieDomain = $builder::literal('$this->getByType(Nette\Http\IRequest::class)->getUrl()->getDomain(2)');
}
if (isset($config->cookieSecure)) {
trigger_error("The item 'session › cookieSecure' is deprecated, use 'http › cookieSecure' (it has default value 'auto').", E_USER_DEPRECATED);
unset($config->cookieSecure);
}
if ($config->cookieSamesite === true) {
trigger_error("In 'session › cookieSamesite' replace true with 'Lax'.", E_USER_DEPRECATED);
$config->cookieSamesite = IResponse::SAME_SITE_LAX;
}
$this->compiler->addExportedType(Nette\Http\IRequest::class);

if ($this->debugMode && $config->debugger) {
Expand Down
9 changes: 3 additions & 6 deletions src/Http/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@ class Context
{
use Nette\SmartObject;

/** @var IRequest */
private $request;
private IRequest $request;

/** @var IResponse */
private $response;
private IResponse $response;


public function __construct(IRequest $request, IResponse $response)
Expand All @@ -35,9 +33,8 @@ public function __construct(IRequest $request, IResponse $response)

/**
* Attempts to cache the sent entity by its last modification date.
* @param string|int|\DateTimeInterface $lastModified
*/
public function isModified($lastModified = null, string $etag = null): bool
public function isModified(string|int|\DateTimeInterface $lastModified = null, string $etag = null): bool
{
if ($lastModified) {
$this->response->setHeader('Last-Modified', Helpers::formatDate($lastModified));
Expand Down
20 changes: 7 additions & 13 deletions src/Http/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,15 @@ final class FileUpload

public const IMAGE_MIME_TYPES = ['image/gif', 'image/png', 'image/jpeg', 'image/webp'];

/** @var string */
private $name;
private string $name;

/** @var string|false|null */
private $type;
private string|false|null $type = null;

/** @var int */
private $size;
private int $size;

/** @var string */
private $tmpName;
private string $tmpName;

/** @var int */
private $error;
private int $error;


public function __construct(?array $value)
Expand Down Expand Up @@ -169,9 +164,8 @@ public function hasFile(): bool

/**
* Moves an uploaded file to a new location. If the destination file already exists, it will be overwritten.
* @return static
*/
public function move(string $dest)
public function move(string $dest): static
{
$dir = dirname($dest);
Nette\Utils\FileSystem::createDir($dir);
Expand All @@ -181,7 +175,7 @@ public function move(string $dest)
[$this->tmpName, $dest],
function (string $message) use ($dest): void {
throw new Nette\InvalidStateException("Unable to move uploaded file '$this->tmpName' to '$dest'. $message");
}
},
);
@chmod($dest, 0666); // @ - possible low permission to chmod
$this->tmpName = $dest;
Expand Down
5 changes: 2 additions & 3 deletions src/Http/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ final class Helpers

/**
* Returns HTTP valid date format.
* @param string|int|\DateTimeInterface $time
*/
public static function formatDate($time): string
public static function formatDate(string|int|\DateTimeInterface $time): string
{
$time = DateTime::from($time)->setTimezone(new \DateTimeZone('GMT'));
return $time->format('D, d M Y H:i:s \G\M\T');
Expand All @@ -41,7 +40,7 @@ public static function formatDate($time): string
public static function ipMatch(string $ip, string $mask): bool
{
[$mask, $size] = explode('/', $mask . '/');
$tmp = function (int $n): string { return sprintf('%032b', $n); };
$tmp = fn(int $n): string => sprintf('%032b', $n);
$ip = implode('', array_map($tmp, unpack('N*', inet_pton($ip))));
$mask = implode('', array_map($tmp, unpack('N*', inet_pton($mask))));
$max = strlen($ip);
Expand Down