Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Default values in ServerRequest #46

Merged
merged 1 commit into from
Jun 4, 2015

Conversation

weierophinney
Copy link
Member

I am using the symfony psr bridge currently, and there are a few problems because of missing default values in ServerRequest:

    /**
     * @var array
     */
    private $cookieParams;

    /**
     * @var array
     */
    private $parsedBody;

    /**
     * @var array
     */
    private $queryParams;

    /**
     * @var array
     */
    private $serverParams;

    /**
     * @var array
     */
    private $uploadedFiles;

I can see in the construtor, that $serverParams and $uploadedFiles will be initialized. The $attributes have ben fixed here: #9

But why are $cookieParams, $parsedBody and $queryParams by default NULL and not a empty array? This is not compatile with the api of ServerRequestInterface.

@weierophinney
Copy link
Member

You are correct with regards to cookie params and query params; those must be arrays, and I'll get a patch shortly for that.

However, parsed body allows returning any of null, array, or object. As such, its default is correct.

Per [PSR-7 section 3.2.1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md#321-psrhttpmessageserverrequestinterface),
cookie and query params MUST return an array by default; currently, they
return null if not initialized. This patch adds tests for that behavior,
as well as a test to ensure the parsed body is null by default, and
provides default values for each (and, in the case of parsed body,
documents all possible types it allows).
@weierophinney weierophinney added this to the 1.0.2 milestone Jun 4, 2015
weierophinney added a commit that referenced this pull request Jun 4, 2015
@weierophinney weierophinney merged commit ef8fb12 into zendframework:master Jun 4, 2015
weierophinney added a commit that referenced this pull request Jun 4, 2015
@weierophinney weierophinney deleted the hotfix/46 branch June 4, 2015 17:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant