Skip to content

Commit

Permalink
Fixed incorrect return type declarations in the deprecated RequestVar…
Browse files Browse the repository at this point in the history
…iable

fixes #4124
  • Loading branch information
brandonkelly committed Apr 11, 2019
1 parent 72d2d33 commit 005bd93
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixed
- Fixed an error that occurred when installing a missing plugin from the Settings → Plugins page.
- Fixed PHP type errors that could occur when calling some deprecated `craft.request` methods in templates. ([#4124](https://github.com/craftcms/cms/issues/4124))

## 3.1.22 - 2019-04-10

Expand Down
32 changes: 16 additions & 16 deletions src/web/twig/variables/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public function getScriptName(): string
/**
* Returns the request's URI.
*
* @return mixed
* @return string
*/
public function getPath()
public function getPath(): string
{
Craft::$app->getDeprecator()->log('craft.request.getPath()', 'craft.request.getPath() has been deprecated. Use craft.app.request.pathInfo instead.');

Expand All @@ -134,9 +134,9 @@ public function getPath()
/**
* Returns the request's full URL.
*
* @return mixed
* @return string
*/
public function getUrl()
public function getUrl(): string
{
Craft::$app->getDeprecator()->log('craft.request.getUrl()', 'craft.request.getUrl() has been deprecated. Use craft.app.request.absoluteUrl instead.');

Expand Down Expand Up @@ -222,9 +222,9 @@ public function getCookie(string $name)
/**
* Returns the server name.
*
* @return string
* @return string|null
*/
public function getServerName(): string
public function getServerName()
{
Craft::$app->getDeprecator()->log('craft.request.getServerName()', 'craft.request.getServerName() has been deprecated. Use craft.app.request.serverName instead.');

Expand Down Expand Up @@ -272,9 +272,9 @@ public function getPageNum(): int
* Returns the schema and host part of the application URL. The returned URL does not have an ending slash. By
* default this is determined based on the user request information.
*
* @return string
* @return string|null
*/
public function getHostInfo(): string
public function getHostInfo()
{
Craft::$app->getDeprecator()->log('craft.request.getHostInfo()', 'craft.request.getHostInfo() has been deprecated. Use craft.app.request.hostInfo instead.');

Expand Down Expand Up @@ -334,9 +334,9 @@ public function getServerPort()
/**
* Returns the URL referrer or null if not present.
*
* @return string
* @return string|null
*/
public function getUrlReferrer(): string
public function getUrlReferrer()
{
Craft::$app->getDeprecator()->log('craft.request.getUrlReferrer()', 'craft.request.getUrlReferrer() has been deprecated. Use craft.app.request.referrer instead.');

Expand All @@ -346,9 +346,9 @@ public function getUrlReferrer(): string
/**
* Returns the user agent or null if not present.
*
* @return string
* @return string|null
*/
public function getUserAgent(): string
public function getUserAgent()
{
Craft::$app->getDeprecator()->log('craft.request.getUserAgent()', 'craft.request.getUserAgent() has been deprecated. Use craft.app.request.userAgent instead.');

Expand Down Expand Up @@ -449,9 +449,9 @@ public function getPost(string $name = null, string $default = null)
/**
* Returns the user IP address.
*
* @return string
* @return string|null
*/
public function getUserHostAddress(): string
public function getUserHostAddress()
{
Craft::$app->getDeprecator()->log('craft.request.getUserHostAddress()', 'craft.request.getUserHostAddress() has been deprecated. Use craft.app.request.userIP instead.');

Expand All @@ -464,9 +464,9 @@ public function getUserHostAddress(): string
* Considering any of these server vars besides REMOTE_ADDR can be spoofed, this method should not be used when you
* need a trusted source for the IP address. Use `$_SERVER['REMOTE_ADDR']` instead.
*
* @return string The IP address.
* @return string|null The IP address.
*/
public function getIpAddress(): string
public function getIpAddress()
{
Craft::$app->getDeprecator()->log('craft.request.getIpAddress()', 'craft.request.getIpAddress() has been deprecated. Use craft.app.request.userIP instead.');

Expand Down

0 comments on commit 005bd93

Please sign in to comment.