Skip to content

Commit e3227b1

Browse files
committed
Release v3.0.0
2 parents e9c204f + 4cc59cf commit e3227b1

9 files changed

+347
-119
lines changed

.github/workflows/code_analysis.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717
- name: PHPStan
1818
run: composer phpstan
1919

20-
- name: Easy Coding Standard
21-
run: composer ecs
22-
2320
- name: Nette Tester
2421
run: composer tester
22+
php:
23+
- "7.4"
24+
- "8.0"
25+
- "8.1"
2526

26-
27-
name: ${{ matrix.actions.name }}
27+
name: ${{ matrix.actions.name }} on PHP ${{ matrix.php }}
2828
runs-on: ubuntu-latest
2929

3030

@@ -37,7 +37,7 @@ jobs:
3737
- name: Setup PHP
3838
uses: shivammathur/setup-php@v2
3939
with:
40-
php-version: 7.3
40+
php-version: ${{ matrix.php }}
4141
coverage: none
4242

4343

@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
path: |
5454
${{ steps.composer-cache.outputs.dir }}
55-
key: ${{ runner.os }}-composer-data-${{ hashFiles('composer.json') }}
55+
key: ${{ runner.os }}-composer-data-${{ hashFiles('composer.json') }}-php-${{ matrix.php }}
5656
restore-keys: |
5757
${{ runner.os }}-composer-data-
5858
@@ -61,11 +61,11 @@ jobs:
6161
with:
6262
path: |
6363
**/composer.lock
64-
key: ${{ runner.os }}-composer-lock-${{ hashFiles('composer.json') }}
64+
key: ${{ runner.os }}-composer-lock-${{ hashFiles('composer.json') }}-php-${{ matrix.php }}
6565

6666

6767
- name: Install Composer
6868
run: composer install --no-progress
6969

7070

71-
- run: ${{ matrix.actions.run }}
71+
- run: ${{ matrix.actions.run }}

.phpstorm.meta.php

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace PHPSTORM_META {
4+
5+
expectedArguments(
6+
\Redbitcz\DebugMode\Detector::__construct(),
7+
0,
8+
\Redbitcz\DebugMode\Detector::MODE_FULL,
9+
\Redbitcz\DebugMode\Detector::MODE_SIMPLE,
10+
\Redbitcz\DebugMode\Detector::MODE_ENABLER,
11+
\Redbitcz\DebugMode\Detector::MODE_COOKIE,
12+
\Redbitcz\DebugMode\Detector::MODE_ENV,
13+
\Redbitcz\DebugMode\Detector::MODE_IP
14+
);
15+
16+
expectedArguments(
17+
\Redbitcz\DebugMode\Detector::detect(),
18+
0,
19+
\Redbitcz\DebugMode\Detector::MODE_FULL,
20+
\Redbitcz\DebugMode\Detector::MODE_SIMPLE,
21+
\Redbitcz\DebugMode\Detector::MODE_ENABLER,
22+
\Redbitcz\DebugMode\Detector::MODE_COOKIE,
23+
\Redbitcz\DebugMode\Detector::MODE_ENV,
24+
\Redbitcz\DebugMode\Detector::MODE_IP
25+
);
26+
27+
expectedArguments(
28+
\Redbitcz\DebugMode\Detector::detectProductionMode(),
29+
0,
30+
\Redbitcz\DebugMode\Detector::MODE_FULL,
31+
\Redbitcz\DebugMode\Detector::MODE_SIMPLE,
32+
\Redbitcz\DebugMode\Detector::MODE_ENABLER,
33+
\Redbitcz\DebugMode\Detector::MODE_COOKIE,
34+
\Redbitcz\DebugMode\Detector::MODE_ENV,
35+
\Redbitcz\DebugMode\Detector::MODE_IP
36+
);
37+
}

README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ at any environment.
99
Package allows your app to switch to Debug Mode:
1010
- automatically on localhost's environment by IP,
1111
- semi-automatically on any environment where you set `APP_DEBUG` environment variable (useful for Docker dev-stack),
12-
- semi-automatically disable Debug mode on any environment where you set `app-debug-mode` cookie variable (useful for
12+
- semi-automatically **disable** Debug mode on any environment where you set `app-debug-mode` cookie variable (useful for
1313
tests and similar cases),
1414
- manually enable/disable (force turn-on or turn-off) Debug Mode.
1515

@@ -20,7 +20,10 @@ Package is optimized for invoking in very early lifecycle phase of your App
2020
## Requirements
2121
Package requires:
2222

23-
- PHP version at least 7.3
23+
- PHP version at least 7.4
24+
25+
Enabler requires:
26+
2427
- Temporary directory with writable access
2528

2629
## Installation
@@ -31,17 +34,15 @@ composer require redbitcz/debug-mode-enabler
3134
## Using
3235
Anywhere in your app you can determine if app is running in Debug mode by simple code:
3336
```php
34-
$debugMode = \Redbitcz\DebugMode\Detector::detect($tempDir); //bool
37+
$debugMode = \Redbitcz\DebugMode\Detector::detect(); //bool
3538
```
36-
where `$tempDir` is required path to temporary directory.
3739

3840
It returns `$debugMode` = `true` when it detects Debug environment or manually switched.
3941

4042
### Using with Nette
4143
In Boostrap use package like in this example:
4244
```php
43-
$tempDir = __DIR__ . '/../temp';
44-
$debugModeDetector = new \Redbitcz\DebugMode\Detector($tempDir);
45+
$debugModeDetector = new \Redbitcz\DebugMode\Detector();
4546

4647
$configurator = new Configurator();
4748
$configurator->setDebugMode($debugModeDetector->isDebugMode());
@@ -72,6 +73,9 @@ Enabler provide feature to force enable or disable Debug Mode anywhere for user'
7273
This example turn on Debug Mode for user's browser:
7374
```php
7475
$enabler = new \Redbitcz\DebugMode\Enabler($tempDir);
76+
77+
$detector = new \Redbitcz\DebugMode\Detector(\Redbitcz\DebugMode\Detector::MODE_FULL, $enabler);
78+
7579
$enabler->activate(true);
7680
```
7781

@@ -93,7 +97,8 @@ internally with `Detector` instance in `Bootstrap`.
9397
To re-use already existing instance you can inject it to DI Container:
9498
```php
9599
$tempDir = __DIR__ . '/../temp';
96-
$debugModeDetector = new \Redbitcz\DebugMode\Detector($tempDir);
100+
$enabler = new \Redbitcz\DebugMode\Enabler($tempDir);
101+
$debugModeDetector = new \Redbitcz\DebugMode\Detector(\Redbitcz\DebugMode\Detector::MODE_FULL, $enabler);
97102
98103
$configurator = new Configurator();
99104
$configurator->setDebugMode($debugModeDetector->isDebugMode());

composer.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=7.3.4",
18+
"php": ">=7.4",
1919
"nette/utils": "^3.0"
2020
},
2121
"autoload": {
@@ -37,14 +37,11 @@
3737
}
3838
},
3939
"require-dev": {
40-
"phpstan/phpstan": "^0.12.50",
41-
"symplify/easy-coding-standard": "^8.3",
42-
"nette/tester": "^2.3"
40+
"phpstan/phpstan": "^0.12.98",
41+
"nette/tester": "^2.4"
4342
},
4443
"scripts": {
45-
"phpstan": "phpstan analyze src --level 8",
46-
"ecs": "ecs check src tests --set psr12",
47-
"ecs-fix": "ecs check src tests --set psr12 --fix",
44+
"phpstan": "phpstan analyze src -c phpstan.neon --level 8",
4845
"tester": "tester tests"
4946
}
5047
}

phpstan.neon

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#Parameter \#3 \$options of function setcookie expects .+#'
5+
path: src/Enabler.php
6+
count: 2

0 commit comments

Comments
 (0)