Skip to content

[5.x] Add native types to the web application API, drop the IE redirect - #171

Open
Hackwar wants to merge 2 commits into
joomla-framework:5.x-devfrom
Hackwar:5.x-web-application-types
Open

Hackwar wants to merge 2 commits into
joomla-framework:5.x-devfrom
Hackwar:5.x-web-application-types

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary of Changes

AbstractWebApplication, WebApplicationInterface, SessionAwareWebApplicationInterface and SessionAwareWebApplicationTrait only documented their parameter, return and property types (redirect($url, $status = 303), setHeader(), checkToken(), getFormToken(), allowCache(), …). This PR declares them natively, e.g. redirect(string $url, int $status = 303): void, setHeader(string $name, string $value, bool $replace = false): static, and types the properties (public string $charSet, public ?\DateTime $modifiedDate, public WebClient $client, protected Input $input, …). The full list is in the update guide.

It also removes the JavaScript redirect page that redirect() sent to Internet Explorer (Trident) for non-ASCII URLs; IE is out of support since 2022, so the redirect is always a Location header now. The fallback for "headers already sent" stays.

Decisions taken here, for review:

  • redirect() returns void, not never as suggested: it ends with close(), which applications and tests override so that it does not exit; a never return type would turn those overrides into a TypeError.
  • The public properties ($charSet, $mimeType, $httpVersion, $modifiedDate, $client) are typed but stay public. Making them protected with accessors (also suggested) would break every application that sets $app->mimeType/$app->charSet directly, including the CMS, and needs a 4.x deprecation first — left for the maintainers to decide.
  • The hard-coded Expires: Wed, 17 Aug 2005 00:00:00 GMT for uncacheable responses is unchanged: any date in the past has the same effect, so changing it would only churn tests and docs.

Testing Instructions

vendor/bin/phpunit, vendor/bin/phpstan analyse. testRedirectWithJavascriptRedirect (asserting the IE page) is replaced by testRedirectWithNonAsciiUrlForInternetExplorer, which expects a Location header and no output.

Documentation Changes Required

docs/v4-to-v5-update.md (native types incl. the strict_types caveat for setHeader('Status', 404), typed properties, IE redirect removal) and the signatures in docs/api-reference.md.

Depends on #169 (adds docs/v4-to-v5-update.md; its commit is included here until it is merged). Related to #170 (both add to the same tables in the update guide, expect a small conflict there) and to the 4.x PRs #158 and #160–#166 (expect conflicts when 4.x-dev is merged into 5.x-dev in docs/api-reference.md rows for redirect()/setHeader() and in redirect() (#160 moves the status check next to the removed IE branch), where the new signatures must be kept).

🤖 Generated with Claude Code

Hackwar and others added 2 commits November 12, 2026 23:20
Several 5.0 changes need an entry in the update guide; adding the page
first keeps those pull requests from conflicting over creating it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AbstractWebApplication, WebApplicationInterface and the session aware
interface and trait only documented their parameter, return and property
types. They are now declared natively.

redirect() answered Internet Explorer with a JavaScript redirect page for
non-ASCII URLs. Internet Explorer is out of support since 2022, so the
redirect is now always sent as a Location header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant