Skip to content

Commit

Permalink
Merge pull request #10942 from cakephp/charset-getter
Browse files Browse the repository at this point in the history
Add a getter for Response::charset
  • Loading branch information
markstory committed Jul 25, 2017
2 parents c175277 + 9b51f48 commit 0057bea
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
1 change: 0 additions & 1 deletion phpstan.neon
Expand Up @@ -4,7 +4,6 @@ parameters:
ignoreErrors:
- '#Function wincache_ucache_[a-zA-Z0-9_]+ not found#'
- '#Function xcache_[a-zA-Z0-9_]+ not found#'
- '#Function fastcgi_[a-zA-Z0-9_]+ not found#'
- '#Cake\\Database\\Type\\[a-zA-Z0-9_]+Type::__construct\(\) does not call parent constructor from Cake\\Database\\Type#'
- '#Constructor of class Cake\\[a-zA-Z0-9_\\]+ has an unused parameter#'
- '#Call to an undefined method Cake\\Console\\Shell::main\(\)#'
Expand Down
1 change: 1 addition & 0 deletions src/Cache/Engine/ApcEngine.php
Expand Up @@ -230,6 +230,7 @@ public function groups()
*/
public function clearGroup($group)
{
$success = false;
apcu_inc($this->_config['prefix'] . $group, 1, $success);

return $success;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/CommandCollection.php
Expand Up @@ -116,7 +116,7 @@ public function has($name)
* Get the target for a command.
*
* @param string $name The named shell.
* @return string|Cake\Console\Shell Either the shell class or an instance.
* @return string|\Cake\Console\Shell Either the shell class or an instance.
* @throws \InvalidArgumentException when unknown commands are fetched.
*/
public function get($name)
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Client/Request.php
Expand Up @@ -186,7 +186,7 @@ protected function addHeaders(array $headers)
* @param string $name The name of the cookie to get/set
* @param string|null $value Either the value or null when getting values.
* @return mixed Either $this or the cookie value.
* @deprected 3.5.0 No longer used. CookieCollections now add `Cookie` header to the request
* @deprecated 3.5.0 No longer used. CookieCollections now add `Cookie` header to the request
* before sending. Use Cake\Http\Cookie\CookieCollection::addToRequest() to make adding cookies
* to a request easier.
*/
Expand Down
14 changes: 12 additions & 2 deletions src/Http/Response.php
Expand Up @@ -1153,7 +1153,7 @@ public function mapType($ctype)
*
* @param string|null $charset Character set string.
* @return string Current charset
* @deprecated 3.4.0 Use withCharset() instead.
* @deprecated 3.5.0 Use getCharset()/withCharset() instead.
*/
public function charset($charset = null)
{
Expand All @@ -1166,6 +1166,16 @@ public function charset($charset = null)
return $this->_charset;
}

/**
* Retruns the current charset.
*
* @return string
*/
public function getCharset()
{
return $this->_charset;
}

/**
* Get a new instance with an updated charset.
*
Expand All @@ -1185,7 +1195,7 @@ public function withCharset($charset)
* Sets the correct headers to instruct the client to not cache the response
*
* @return void
* @deprected 3.4.0 Use withDisabledCache() instead.
* @deprecated 3.4.0 Use withDisabledCache() instead.
*/
public function disableCache()
{
Expand Down
2 changes: 1 addition & 1 deletion src/ORM/Association/DependentDeleteTrait.php
Expand Up @@ -22,7 +22,7 @@
*
* Included by HasOne and HasMany association classes.
*
* @deprected 3.5.0 Unused in CakePHP now. This class will be removed in 4.0.0
* @deprecated 3.5.0 Unused in CakePHP now. This class will be removed in 4.0.0
*/
trait DependentDeleteTrait
{
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Http/ResponseTest.php
Expand Up @@ -144,7 +144,7 @@ public function testCharset()
}

/**
* Tests withCharset method
* Tests the getCharset/withCharset methods
*
* @return void
*/
Expand All @@ -155,6 +155,7 @@ public function testWithCharset()

$new = $response->withCharset('iso-8859-1');
$this->assertNotContains('iso', $response->getHeaderLine('Content-Type'), 'Old instance not changed');
$this->assertSame('iso-8859-1', $new->getCharset());

$this->assertEquals('text/html; charset=iso-8859-1', $new->getHeaderLine('Content-Type'));
}
Expand Down

0 comments on commit 0057bea

Please sign in to comment.