composer exec phpcbf -- --standard=PSR2

pull/685/head
fadrian06 2 days ago
parent 85c4b38858
commit 29595ef9e1

@ -118,13 +118,7 @@ class RouteCommand extends AbstractBaseCommand
$methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
foreach ($methods as $method) {
$lowercaseMethod = strtolower($method);
if (
$this->{$lowercaseMethod} === true &&
(
$route->methods[0] === '*' ||
in_array($method, $route->methods, true) === true
)
) {
if ($this->{$lowercaseMethod} === true && ($route->methods[0] === '*' || in_array($method, $route->methods, true) === true)) {
$boolval = true;
break;
}

@ -64,10 +64,7 @@ class Dispatcher
{
$containerInterfaceNS = '\Psr\Container\ContainerInterface';
if (
is_a($containerHandler, $containerInterfaceNS)
|| is_callable($containerHandler)
) {
if (is_a($containerHandler, $containerInterfaceNS) || is_callable($containerHandler)) {
$this->containerHandler = $containerHandler;
return;
@ -289,10 +286,7 @@ class Dispatcher
*/
public function execute($callback, array &$params = [])
{
if (
is_string($callback) === true
&& (strpos($callback, '->') !== false || strpos($callback, '::') !== false)
) {
if (is_string($callback) === true && (strpos($callback, '->') !== false || strpos($callback, '::') !== false)) {
$callback = $this->parseStringClassAndMethod($callback);
}

@ -439,15 +439,7 @@ class Request
*/
public static function getScheme(): string
{
if (
(strtolower(self::getVar('HTTPS')) === 'on')
||
(self::getVar('HTTP_X_FORWARDED_PROTO') === 'https')
||
(self::getVar('HTTP_FRONT_END_HTTPS') === 'on')
||
(self::getVar('REQUEST_SCHEME') === 'https')
) {
if ((strtolower(self::getVar('HTTPS')) === 'on') || (self::getVar('HTTP_X_FORWARDED_PROTO') === 'https') || (self::getVar('HTTP_FRONT_END_HTTPS') === 'on') || (self::getVar('REQUEST_SCHEME') === 'https')) {
return 'https';
}

@ -14,6 +14,9 @@
<rule ref="PSR1">
</rule>
<rule ref="PSR2">
</rule>
<file>index.php</file>
<file>flight</file>
<file>tests</file>

@ -45,14 +45,18 @@ class DispatcherTest extends TestCase
public function testHasEvent(): void
{
$this->dispatcher->set('map-event', function (): void {});
$this->dispatcher->set('map-event', function (): void {
//
});
$this->assertTrue($this->dispatcher->has('map-event'));
}
public function testClearAllRegisteredEvents(): void
{
$customFunction = $anotherFunction = function (): void {};
$customFunction = $anotherFunction = function (): void {
//
};
$this->dispatcher
->set('map-event', $customFunction)
@ -69,7 +73,9 @@ class DispatcherTest extends TestCase
public function testClearDeclaredRegisteredEvent(): void
{
$customFunction = $anotherFunction = function (): void {};
$customFunction = $anotherFunction = function (): void {
//
};
$this->dispatcher
->set('map-event', $customFunction)
@ -243,7 +249,9 @@ class DispatcherTest extends TestCase
$output = '';
$invalidCallable = 'invalidGlobalFunction';
$validCallable = function (): void {};
$validCallable = function (): void {
//
};
$this->dispatcher->filter([$validCallable, $invalidCallable], $params, $output);
}
@ -324,7 +332,7 @@ class DispatcherTest extends TestCase
{
$this->expectException(TypeError::class);
$this->expectExceptionMessageMatches('#tests\\\\classes\\\\ContainerDefault::__construct\(\).+flight\\\\Engine, null given#');
$result = $this->dispatcher->execute([ContainerDefault::class, 'testTheContainer']);
$this->dispatcher->execute([ContainerDefault::class, 'testTheContainer']);
}
public function testContainerDicePdoWrapperTestBadParams(): void

@ -122,7 +122,9 @@ class EventSystemTest extends TestCase
Flight::map('onEvent', function ($event, $callback) use (&$called) {
$called = true;
});
Flight::onEvent('test.event', function () {});
Flight::onEvent('test.event', function () {
//
});
$this->assertTrue($called, 'Overridden onEvent method should be called.');
}
@ -232,7 +234,9 @@ class EventSystemTest extends TestCase
{
$this->assertFalse(Flight::eventDispatcher()->hasListeners('test.event'), 'Event should not have listeners before registration');
Flight::onEvent('test.event', function () {});
Flight::onEvent('test.event', function () {
//
});
$this->assertTrue(Flight::eventDispatcher()->hasListeners('test.event'), 'Event should have listeners after registration');
}
@ -242,8 +246,12 @@ class EventSystemTest extends TestCase
*/
public function testGetListeners(): void
{
$callback1 = function () {};
$callback2 = function () {};
$callback1 = function () {
//
};
$callback2 = function () {
//
};
$this->assertEmpty(Flight::eventDispatcher()->getListeners('test.event'), 'Event should have no listeners before registration');
@ -273,8 +281,12 @@ class EventSystemTest extends TestCase
{
$this->assertEmpty(Flight::eventDispatcher()->getAllRegisteredEvents(), 'No events should be registered initially');
Flight::onEvent('test.event1', function () {});
Flight::onEvent('test.event2', function () {});
Flight::onEvent('test.event1', function () {
//
});
Flight::onEvent('test.event2', function () {
//
});
$events = Flight::eventDispatcher()->getAllRegisteredEvents();
$this->assertCount(2, $events, 'Should return all registered event names');
@ -311,9 +323,15 @@ class EventSystemTest extends TestCase
*/
public function testRemoveAllListeners(): void
{
Flight::onEvent('test.event', function () {});
Flight::onEvent('test.event', function () {});
Flight::onEvent('another.event', function () {});
Flight::onEvent('test.event', function () {
//
});
Flight::onEvent('test.event', function () {
//
});
Flight::onEvent('another.event', function () {
//
});
$this->assertTrue(Flight::eventDispatcher()->hasListeners('test.event'), 'Event should have listeners before removal');
$this->assertTrue(Flight::eventDispatcher()->hasListeners('another.event'), 'Another event should have listeners');
@ -330,7 +348,9 @@ class EventSystemTest extends TestCase
public function testRemoveListenersForNonexistentEvent(): void
{
// Should not throw any errors
Flight::eventDispatcher()->removeListener('nonexistent.event', function () {});
Flight::eventDispatcher()->removeListener('nonexistent.event', function () {
//
});
Flight::eventDispatcher()->removeAllListeners('nonexistent.event');
$this->assertTrue(true, 'Removing listeners for nonexistent events should not throw errors');

@ -411,14 +411,18 @@ class RouterTest extends TestCase
public function testRouteBeingReturned(): void
{
$route = $this->router->map('/hi', function () {});
$route = $this->router->map('/hi', function () {
//
});
$route_in_router = $this->router->getRoutes()[0];
$this->assertSame($route, $route_in_router);
}
public function testRouteSetAlias(): void
{
$route = $this->router->map('/hi', function () {});
$route = $this->router->map('/hi', function () {
//
});
$route->setAlias('hello');
$this->assertEquals('hello', $route->alias);
}

@ -7,7 +7,10 @@ namespace tests\classes;
class Factory
{
// Cannot be instantiated
private function __construct() {}
private function __construct()
{
//
}
public static function create(): self
{

@ -6,17 +6,38 @@ namespace tests\groupcompactsyntax;
final class PostsController
{
public function index(): void {}
public function show(string $id): void {}
public function create(): void {}
public function store(): void {}
public function edit(string $id): void {}
public function update(string $id): void {}
public function destroy(string $id): void {}
public function index(): void
{
//
}
public function show(string $id): void
{
//
}
public function create(): void
{
//
}
public function store(): void
{
//
}
public function edit(string $id): void
{
//
}
public function update(string $id): void
{
//
}
public function destroy(string $id): void
{
//
}
}

@ -6,7 +6,13 @@ namespace tests\groupcompactsyntax;
final class TodosController
{
public function index(): void {}
public function index(): void
{
//
}
public function show(string $id): void {}
public function show(string $id): void
{
//
}
}

Loading…
Cancel
Save