You are here

public function ServerRequest::withAttribute in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/zendframework/zend-diactoros/src/ServerRequest.php \Zend\Diactoros\ServerRequest::withAttribute()
  2. 8.0 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\ServerRequest::withAttribute()
Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-diactoros/src/ServerRequest.php \Zend\Diactoros\ServerRequest::withAttribute()

Return an instance with the specified derived request attribute.

This method allows setting a single derived request attribute as described in getAttributes().

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the updated attribute.

Parameters

string $name The attribute name.:

mixed $value The value of the attribute.:

Return value

self

Overrides ServerRequestInterface::withAttribute

See also

getAttributes()

File

vendor/zendframework/zend-diactoros/src/ServerRequest.php, line 194

Class

ServerRequest
Server-side HTTP request

Namespace

Zend\Diactoros

Code

public function withAttribute($attribute, $value) {
  $new = clone $this;
  $new->attributes[$attribute] = $value;
  return $new;
}