Skip to content

Commit 9ae6c56

Browse files
committed
updated for PHP7
1 parent ffdbb90 commit 9ae6c56

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"issues": "http://github.com/uestla/HttpAuthExtension/issues"
1111
},
1212
"require": {
13-
"php": ">=5.3.0",
13+
"php": ">= 7.3",
1414
"nette/di": "~2.3",
1515
"nette/http": "~2.3"
1616
},

src/HttpAuthExtension/HttpAuthExtension.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/**
46
* This file is part of the HttpAuthExtension package
57
*
@@ -22,11 +24,7 @@ class HttpAuthExtension extends Nette\DI\CompilerExtension
2224
);
2325

2426

25-
/**
26-
* @param Nette\PhpGenerator\ClassType $class
27-
* @return void
28-
*/
29-
public function afterCompile(Nette\PhpGenerator\ClassType $class)
27+
public function afterCompile(Nette\PhpGenerator\ClassType $class): void
3028
{
3129
$config = $this->getConfig($this->defaults);
3230

@@ -41,15 +39,10 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
4139
}
4240

4341

44-
/**
45-
* @param Nette\Configurator $configurator
46-
* @param string $prefix
47-
* @return void
48-
*/
49-
public static function register(Nette\Configurator $configurator, $prefix = 'httpAuth')
42+
public static function register(Nette\Configurator $configurator, string $prefix = 'httpAuth'): void
5043
{
5144
$class = __CLASS__;
52-
$configurator->onCompile[] = function ($configurator, $compiler) use ($prefix, $class) {
45+
$configurator->onCompile[] = static function ($configurator, $compiler) use ($prefix, $class): void {
5346
$compiler->addExtension($prefix, new $class);
5447
};
5548
}

src/HttpAuthExtension/HttpAuthenticator.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types = 1);
4+
35
/**
46
* This file is part of the HttpAuthExtension package
57
*
@@ -30,13 +32,7 @@ class HttpAuthenticator extends Nette\Object
3032
private $title;
3133

3234

33-
/**
34-
* @param Http\Response $response
35-
* @param string $username
36-
* @param string $password
37-
* @param string $title
38-
*/
39-
public function __construct(Http\Response $response, $username, $password, $title)
35+
public function __construct(Http\Response $response, string $username, string $password, string $title)
4036
{
4137
$this->response = $response;
4238
$this->username = $username;
@@ -45,11 +41,9 @@ public function __construct(Http\Response $response, $username, $password, $titl
4541
}
4642

4743

48-
/** @return void */
49-
public function run()
44+
public function run(): void
5045
{
51-
if (!isset($_SERVER['PHP_AUTH_USER'])
52-
|| $_SERVER['PHP_AUTH_USER'] !== $this->username || $_SERVER['PHP_AUTH_PW'] !== $this->password) {
46+
if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] !== $this->username || $_SERVER['PHP_AUTH_PW'] !== $this->password) {
5347
$this->response->setHeader('WWW-Authenticate', 'Basic realm="' . $this->title . '"');
5448
$this->response->setCode(Http\IResponse::S401_UNAUTHORIZED);
5549
echo '<h1>Authentication failed.</h1>';

0 commit comments

Comments
 (0)