Skip to content

Simplify Flight and faster performance#623

Merged
n0nag0n merged 2 commits intoflightphp:masterfrom
joanhey:patch-1
Feb 16, 2025
Merged

Simplify Flight and faster performance#623
n0nag0n merged 2 commits intoflightphp:masterfrom
joanhey:patch-1

Conversation

@joanhey
Copy link
Contributor

@joanhey joanhey commented Feb 14, 2025

Null coalescing operator work from PHP 7.0

I don't know if is it necessary the setEngine() because is public ?
I think that is for use an extended Engine. But before never will work if changed before any call, because don't change the $initialized.

Null coalescing operator work from PHP 7.0
@joanhey
Copy link
Contributor Author

joanhey commented Feb 14, 2025

I see that you use it in the tests:

protected function setUp(): void
    {
        $_SERVER = [];
        $_REQUEST = [];
        Flight::init();
        Flight::setEngine(new Engine());
        Flight::set('flight.views.path', __DIR__ . '/views');
    }

But when you call the Flight::init(), automatically set the engine with new Engine() if not set.
I don't understand why later call Flight::setEngine(new Engine()); and also invalidate the before init().

It'll work the same with:

protected function setUp(): void
    {
        $_SERVER = [];
        $_REQUEST = [];
        //Flight::setEngine(new Engine());
        Flight::set('flight.views.path', __DIR__ . '/views');
    }

Well with the new Engine(), you have a new one for setUp(), but that's what we need to avoid in persistent applications. And also in tests, to run faster tests.

@n0nag0n n0nag0n merged commit 2bb058e into flightphp:master Feb 16, 2025
6 checks passed
@n0nag0n
Copy link
Collaborator

n0nag0n commented Feb 16, 2025

I see that you use it in the tests:

protected function setUp(): void
    {
        $_SERVER = [];
        $_REQUEST = [];
        Flight::init();
        Flight::setEngine(new Engine());
        Flight::set('flight.views.path', __DIR__ . '/views');
    }

But when you call the Flight::init(), automatically set the engine with new Engine() if not set. I don't understand why later call Flight::setEngine(new Engine()); and also invalidate the before init().

It'll work the same with:

protected function setUp(): void
    {
        $_SERVER = [];
        $_REQUEST = [];
        //Flight::setEngine(new Engine());
        Flight::set('flight.views.path', __DIR__ . '/views');
    }

Well with the new Engine(), you have a new one for setUp(), but that's what we need to avoid in persistent applications. And also in tests, to run faster tests.

I tried looking into this, but when I did it, a bunch of unit tests blew up and it created some weird behavior. We may have to wait until the other PR goes into master before we can pull this one off correctly.

@joanhey joanhey deleted the patch-1 branch February 16, 2025 16:09
@joanhey
Copy link
Contributor Author

joanhey commented Feb 16, 2025

If you have your tests to work without setUp() the engine, the framework will work correctly with any persistent app (async).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments