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

[4.4] refactor: a single point of sending the Response. #7519

Merged
merged 2 commits into from
Jun 6, 2023

Conversation

iRedds
Copy link
Collaborator

@iRedds iRedds commented May 24, 2023

Description
This PR refactors the CodeIgniter class code so that all successful responses, except those caused by exceptions, are sent from one place.

  • The CodeIgniter::handleRequest() method now always returns a Response.
  • Moved HTTP cli check and page cache check to CodeIgniter::handleRequest() method. Because these methods generate a Response and are actually part of the request processing.
  • Event call Events::trigger('pre_system') moved to method CodeIgniter::handleRequest() and is now on the same "level" as Events::trigger('post_system')
  • The CodeIgniter::$returnResponse property has been deprecated as it is no longer used.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@iRedds iRedds added refactor Pull requests that refactor code 4.4 labels May 24, 2023
@iRedds iRedds changed the title [4.4] feature: a single point of sending the Response. [4.4] refactor: a single point of sending the Response. May 24, 2023
@iRedds
Copy link
Collaborator Author

iRedds commented May 24, 2023

I'm a bit surprised that psalm can't find the Tests\Support\Controllers\Popcorn class.
Moreover, he has no claims to the same class from the neighboring test.

@kenjis
Copy link
Member

kenjis commented Jun 3, 2023

I don't know why but rarely Psalm reports errors that cannot reproduce.
I cannot reproduce the following error:

Run vendor/bin/psalm
Target PHP version: 7.4 (inferred from composer.json).
Scanning files...
Analyzing files...

░░░░░░░░░░░░░░░░░░░░░░

ERROR: UndefinedClass - tests/system/CodeIgniterTest.php:141:33 - Class, interface or enum named Tests\Support\Controllers\Popcorn does not exist (see https://psalm.dev/019)
        $routes->set404Override('Tests\Support\Controllers\Popcorn::pop');

https://github.com/codeigniter4/CodeIgniter4/actions/runs/5067800693/jobs/9099299107?pr=7519

And I reran the check, it passed.

Co-authored-by: kenjis <kenji.uui@gmail.com>
@kenjis kenjis merged commit 74f9b58 into codeigniter4:4.4 Jun 6, 2023
@kenjis
Copy link
Member

kenjis commented Jun 6, 2023

@iRedds Thank you!

@iRedds iRedds deleted the sending-response branch June 6, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.4 refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants