Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@juliangut
Copy link
Contributor

As per this comments: #618 (comment) #618 (comment)

Support variadic arguments when calling addDefinitions

@juliangut
Copy link
Contributor Author

The build error is coming from PHPStan

------ ------------------------------------------------------------------
 Line src/ContainerBuilder.php
 ------ ------------------------------------------------------------------
  314    PHPDoc tag @param for parameter $definitions with type
array<array|DI\Definition\Source\DefinitionSource|string> is not
subtype of native type array<int, mixed>
 ------ ------------------------------------------------------------------

This is the code

    /**
     * Add definitions to the container.
     *
     * @param string[]|array[]|DefinitionSource[] $definitions Can be an array of definitions, the
     *                                                   name of a file containing definitions
     *                                                   or a DefinitionSource object.
     * @return $this
     */
    public function addDefinitions(...$definitions) : self
    {
    [...]

@mnapoli
Copy link
Member

mnapoli commented Sep 17, 2018

Regarding the coding style I've added a commit on master to fix the coding style (Symfony added a new rule that breaks BC): a989248 If you merge/rebase master your PR should be OK.

As for phpstan I think you don't need to update the types in the phpdoc, try this and see if it works:

string|array|DefinitionSource

@juliangut
Copy link
Contributor Author

Finally! dockblock syntax on variadic arguments does not seam to be well documented

phpstan/phpstan#979 (comment)

@mnapoli
Copy link
Member

mnapoli commented Sep 17, 2018

Thanks!

@mnapoli mnapoli merged commit 5e8b809 into PHP-DI:master Sep 17, 2018
@juliangut juliangut deleted the variadic-add-definitions branch September 18, 2018 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants