Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Flight and faster performance #623

Merged
merged 2 commits into from
Feb 16, 2025
Merged

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