File tree Expand file tree Collapse file tree 6 files changed +42
-17
lines changed
Expand file tree Collapse file tree 6 files changed +42
-17
lines changed Original file line number Diff line number Diff line change 11language : php
22
33php :
4- - 7.1
5- - 7.2
64 - 7.3
75 - 7.4
6+ - 8.0
7+
8+ env :
9+ - XDEBUG_MODE=coverage
810
911before_script :
1012 - mkdir -p build/logs
1113 - composer self-update
12- - travis_retry composer install --prefer-source --no-interaction
14+ - |
15+ if [ $(phpenv version-name) != '8.0' ]; then
16+ travis_retry composer install --prefer-source --no-interaction
17+ fi
18+ if [ $(phpenv version-name) == '8.0' ]; then
19+ travis_retry composer install --prefer-source --no-interaction --ignore-platform-req=php
20+ fi
1321 - composer dump-autoload -o
1422
1523script :
1624 - composer cs-check
1725 - bin/phpstan analyse src/ --level=max
18- - bin/kahlan --coverage=4 --reporter=verbose --clover=build/logs/clover.xml
19- - bin/php-coveralls -v --exclude-no-stmt
26+ - |
27+ if [ $(phpenv version-name) != '8.0' ]; then
28+ bin/kahlan --coverage=4 --reporter=verbose --clover=build/logs/clover.xml && bin/php-coveralls -v --exclude-no-stmt
29+ fi
30+ if [ $(phpenv version-name) == '8.0' ]; then
31+ bin/kahlan --reporter=verbose
32+ fi
2033
2134notifications :
2235 email : false
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ ForceHttpsModule
22================
33
44[ ![ Latest Version] ( https://img.shields.io/github/release/samsonasik/ForceHttpsModule.svg?style=flat-square )] ( https://github.com/samsonasik/ForceHttpsModule/releases )
5- [ ![ Build Status] ( https://travis-ci.org /samsonasik/ForceHttpsModule.svg?branch=master )] ( https://travis-ci.org/samsonasik/ForceHttpsModule )
5+ [ ![ Build Status] ( https://travis-ci.com /samsonasik/ForceHttpsModule.svg?branch=master )] ( https://travis-ci.org/samsonasik/ForceHttpsModule )
66[ ![ Coverage Status] ( https://coveralls.io/repos/github/samsonasik/ForceHttpsModule/badge.svg?branch=master )] ( https://coveralls.io/github/samsonasik/ForceHttpsModule?branch=master )
77[ ![ PHPStan] ( https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat )] ( https://github.com/phpstan/phpstan )
88[ ![ Downloads] ( https://poser.pugx.org/samsonasik/force-https-module/downloads )] ( https://packagist.org/packages/samsonasik/force-https-module )
Original file line number Diff line number Diff line change 2424 }
2525 ],
2626 "require" : {
27- "php" : " ^7.1" ,
28- "webmozart/assert" : " ^1.4" ,
29- "laminas/laminas-console" : " ^2.5"
27+ "php" : " ^7.3|~8.0" ,
28+ "webmozart/assert" : " ^1.9"
3029 },
3130 "conflict" : {
3231 "mezzio/mezzio" : " <3.0" ,
3332 "laminas/laminas-mvc" : " <3.0"
3433 },
3534 "require-dev" : {
36- "kahlan/kahlan" : " ^4 .0" ,
35+ "kahlan/kahlan" : " ^5 .0" ,
3736 "php-coveralls/php-coveralls" : " ^2.1" ,
38- "phpstan/phpstan" : " ^0.10.8 " ,
39- "phpstan/phpstan-webmozart-assert" : " ^0.10.0 " ,
37+ "phpstan/phpstan" : " ^0.12 " ,
38+ "phpstan/phpstan-webmozart-assert" : " ^0.12 " ,
4039 "laminas/laminas-coding-standard" : " ^2.0" ,
4140 "mezzio/mezzio" : " ^3.0" ,
4241 "laminas/laminas-mvc" : " ^3.0"
Original file line number Diff line number Diff line change 11includes :
22 - vendor/phpstan/phpstan-webmozart-assert/extension.neon
33
4+ parameters :
5+ checkMissingIterableValueType : false
6+
Original file line number Diff line number Diff line change 2424
2525 it ('not attach on route on console ' , function () {
2626
27- Console:: overrideIsConsole (true );
27+ allow (ForceHttps::class)-> toReceive ( ' isInConsole ' )-> andReturn (true );
2828 $ listener = new ForceHttps ([
2929 'enable ' => true ,
3030 'force_all_routes ' => true ,
4040
4141 it ('not attach when not enabled ' , function () {
4242
43- Console:: overrideIsConsole (false );
43+ allow (ForceHttps::class)-> toReceive ( ' isInConsole ' )-> andReturn (false );
4444 $ listener = new ForceHttps ([
4545 'enable ' => false ,
4646 'force_all_routes ' => true ,
5656
5757 it ('attach on route event on non-console and enable ' , function () {
5858
59- Console:: overrideIsConsole (false );
59+ allow (ForceHttps::class)-> toReceive ( ' isInConsole ' )-> andReturn (false );
6060 $ listener = new ForceHttps ([
6161 'enable ' => true ,
6262 'force_all_routes ' => true ,
Original file line number Diff line number Diff line change 55namespace ForceHttpsModule \Listener ;
66
77use ForceHttpsModule \HttpsTrait ;
8- use Laminas \Console \Console ;
98use Laminas \EventManager \AbstractListenerAggregate ;
109use Laminas \EventManager \EventManagerInterface ;
1110use Laminas \Http \PhpEnvironment \Request ;
1211use Laminas \Http \PhpEnvironment \Response ;
1312use Laminas \Mvc \MvcEvent ;
1413use Laminas \Router \RouteMatch ;
1514
15+ use function defined ;
1616use function sprintf ;
1717
18+ use const PHP_SAPI ;
19+
1820class ForceHttps extends AbstractListenerAggregate
1921{
2022 use HttpsTrait;
@@ -32,7 +34,7 @@ public function __construct(array $config)
3234 */
3335 public function attach (EventManagerInterface $ events , $ priority = 1 ): void
3436 {
35- if (Console:: isConsole () || ! $ this ->config ['enable ' ]) {
37+ if ($ this -> isInConsole () || ! $ this ->config ['enable ' ]) {
3638 return ;
3739 }
3840
@@ -105,4 +107,12 @@ public function forceHttpsScheme(MvcEvent $e): void
105107
106108 exit (0 );
107109 }
110+
111+ /**
112+ * Check if currently running in console
113+ */
114+ private function isInConsole (): bool
115+ {
116+ return PHP_SAPI === 'cli ' || defined ('STDIN ' );
117+ }
108118}
You can’t perform that action at this time.
0 commit comments