Skip to content

Commit

Permalink
constants are PascalCase
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 27, 2022
1 parent 7d8647b commit 941380d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/Bootstrap/Configurator.php
Expand Up @@ -23,7 +23,11 @@ class Configurator
{
use Nette\SmartObject;

public const COOKIE_SECRET = 'nette-debug';
public const CookieSecret = 'nette-debug';

/** @deprecated use Configurator::CookieSecret */
public const COOKIE_SECRET = self::CookieSecret;


/** @var callable[] function (Configurator $sender, DI\Compiler $compiler); Occurs after the compiler is created */
public $onCompile = [];
Expand Down Expand Up @@ -348,8 +352,8 @@ protected function getCacheDirectory(): string
public static function detectDebugMode($list = null): bool
{
$addr = $_SERVER['REMOTE_ADDR'] ?? php_uname('n');
$secret = is_string($_COOKIE[self::COOKIE_SECRET] ?? null)
? $_COOKIE[self::COOKIE_SECRET]
$secret = is_string($_COOKIE[self::CookieSecret] ?? null)
? $_COOKIE[self::CookieSecret]
: null;
$list = is_string($list)
? preg_split('#[,\s]+#', $list)
Expand Down
4 changes: 2 additions & 2 deletions tests/Bootstrap/Configurator.debugMode.phpt
Expand Up @@ -89,13 +89,13 @@ test('missing $_SERVER[REMOTE_ADDR]', function () {
test('secret', function () {
unset($_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = '192.168.1.1';
$_COOKIE[Configurator::COOKIE_SECRET] = '*secret*';
$_COOKIE[Configurator::CookieSecret] = '*secret*';

Assert::false(Configurator::detectDebugMode());
Assert::true(Configurator::detectDebugMode('192.168.1.1'));
Assert::false(Configurator::detectDebugMode('abc@192.168.1.1'));
Assert::true(Configurator::detectDebugMode('*secret*@192.168.1.1'));

$_COOKIE[Configurator::COOKIE_SECRET] = ['*secret*'];
$_COOKIE[Configurator::CookieSecret] = ['*secret*'];
Assert::false(Configurator::detectDebugMode('*secret*@192.168.1.1'));
});

0 comments on commit 941380d

Please sign in to comment.