From 18895e7aa77e9237955e078ca5e56d9099a28747 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 3 Jul 2025 13:59:43 +0200 Subject: [PATCH 1/4] Removing magic getter method from AbstractWebApplication --- docs/index.md | 2 ++ docs/v2-to-v3-update.md | 7 +++++ docs/v3-to-v4-update.md | 15 ++++++++++ src/AbstractWebApplication.php | 54 ---------------------------------- 4 files changed, 24 insertions(+), 54 deletions(-) create mode 100644 docs/v2-to-v3-update.md create mode 100644 docs/v3-to-v4-update.md diff --git a/docs/index.md b/docs/index.md index 63cbabff..656c20a5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,2 +1,4 @@ * [Overview](overview.md) * [Updating from v1 to v2](v1-to-v2-update.md) +* [Updating from v2 to v3](v2-to-v3-update.md) +* [Updating from v3 to v4](v3-to-v4-update.md) diff --git a/docs/v2-to-v3-update.md b/docs/v2-to-v3-update.md new file mode 100644 index 00000000..1e9ea89c --- /dev/null +++ b/docs/v2-to-v3-update.md @@ -0,0 +1,7 @@ +## Updating from v2 to v3 + +The following changes were made to the Application package between v1 and v2. + +### Minimum supported PHP version raised + +All Framework packages now require PHP 8.1 or newer. diff --git a/docs/v3-to-v4-update.md b/docs/v3-to-v4-update.md new file mode 100644 index 00000000..cedee96f --- /dev/null +++ b/docs/v3-to-v4-update.md @@ -0,0 +1,15 @@ +## Updating from v3 to v4 + +The following changes were made to the Application package between v3 and v4. + +### Access to input data + +Accessing the input data in the input attribute of the application can now only be done via the `getInput()`. + +```php +// Old +$app->input->getInt(); + +// New +$app->getInput()->getInt(); +``` diff --git a/src/AbstractWebApplication.php b/src/AbstractWebApplication.php index 23464c00..a8df352c 100644 --- a/src/AbstractWebApplication.php +++ b/src/AbstractWebApplication.php @@ -213,46 +213,6 @@ public function __construct( $this->loadSystemUris(); } - /** - * Magic method to access properties of the application. - * - * @param string $name The name of the property. - * - * @return Input|null A value if the property name is valid, null otherwise. - * - * @since 2.0.0 - * @deprecated 3.0 This is a B/C proxy for deprecated read accesses - */ - public function __get($name) - { - switch ($name) { - case 'input': - \trigger_deprecation( - 'joomla/application', - '2.0.0', - 'Accessing the input property of %s is deprecated, use the %s::getInput() method instead.', - self::class, - self::class - ); - - return $this->getInput(); - - default: - $trace = \debug_backtrace(); - \trigger_error( - \sprintf( - 'Undefined property via __get(): %1$s in %2$s on line %3$s', - $name, - $trace[0]['file'], - $trace[0]['line'] - ), - E_USER_NOTICE - ); - - return null; - } - } - /** * Execute the application. * @@ -478,20 +438,6 @@ public function redirect($url, $status = 303) echo $html; } else { - // Check if we have a boolean for the status variable for compatibility with v1 of the framework - // @deprecated 3.0 - if (\is_bool($status)) { - \trigger_deprecation( - 'joomla/application', - '2.0.0', - 'Passing a boolean value for the $status argument in %s() is deprecated,' - . ' an integer should be passed instead.', - __METHOD__ - ); - - $status = $status ? 301 : 303; - } - if (!\is_int($status) && !$this->isRedirectState($status)) { throw new \InvalidArgumentException('You have not supplied a valid HTTP status code'); } From 52dbc1f4a6b49c4a63d493fd737cf745a9a79fc5 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 3 Jul 2025 14:02:46 +0200 Subject: [PATCH 2/4] Additional documentation --- docs/v3-to-v4-update.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/v3-to-v4-update.md b/docs/v3-to-v4-update.md index cedee96f..18dfbb4b 100644 --- a/docs/v3-to-v4-update.md +++ b/docs/v3-to-v4-update.md @@ -13,3 +13,7 @@ $app->input->getInt(); // New $app->getInput()->getInt(); ``` + +### Status on redirect + +When calling `$app->redirect()`, you can not hand over a boolean value for the status, but always have to use an integer representing the HTTP status code. From 0ec2e7a70ac84d790956555bfbdc906a4f044b16 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Thu, 3 Jul 2025 14:07:22 +0200 Subject: [PATCH 3/4] Additional cleanup --- src/AbstractWebApplication.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AbstractWebApplication.php b/src/AbstractWebApplication.php index a8df352c..2b901491 100644 --- a/src/AbstractWebApplication.php +++ b/src/AbstractWebApplication.php @@ -383,8 +383,8 @@ public function getInput(): Input * Other" code in the header pointing to the new location. If the headers have already been sent this will be * accomplished using a JavaScript statement. * - * @param string $url The URL to redirect to. Can only be http/https URL - * @param integer|boolean $status The HTTP status code to be provided. 303 is assumed by default. + * @param string $url The URL to redirect to. Can only be http/https URL + * @param integer $status The HTTP status code to be provided. 303 is assumed by default. * * @return void * From cfbe2291a82144c7d3f61a547ef7e27f34059857 Mon Sep 17 00:00:00 2001 From: Hannes Papenberg Date: Fri, 4 Jul 2025 18:03:42 +0200 Subject: [PATCH 4/4] Removing deprecated input from redirect() method in interface --- src/WebApplicationInterface.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WebApplicationInterface.php b/src/WebApplicationInterface.php index 5fcd11a2..837b59b0 100644 --- a/src/WebApplicationInterface.php +++ b/src/WebApplicationInterface.php @@ -34,8 +34,8 @@ public function getInput(): Input; * If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently" or "303 See Other" code in the header * pointing to the new location. If the headers have already been sent this will be accomplished using a JavaScript statement. * - * @param string $url The URL to redirect to. Can only be http/https URL - * @param integer|boolean $status The HTTP status code to be provided. 303 is assumed by default. + * @param string $url The URL to redirect to. Can only be http/https URL + * @param integer $status The HTTP status code to be provided. 303 is assumed by default. * * @return void *