Skip to content

[Validator] Check cascasdedGroups for being countable #21155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

[Validator] Check cascasdedGroups for being countable #21155

wants to merge 3 commits into from

Conversation

scaytrase
Copy link
Contributor

@scaytrase scaytrase commented Jan 4, 2017

Prevents notice for PHP 7.2

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR

Just repeated for this place #20859
Waiting travis to fill in the Tests pass field

cascasdedGroups can be null at this point (according to failures and phpdoc)

Prevents notice for PHP 7.2
@scaytrase
Copy link
Contributor Author

Not sure if AppVeyor fail is related (https://ci.appveyor.com/project/fabpot/symfony/build/1.0.16476#L492)

@scaytrase
Copy link
Contributor Author

Btw why not add the nightly php builds as allowed-failure travus matrix entry? I think this would expose these failure points a bit earlier

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Jan 6, 2017
@nicolas-grekas
Copy link
Member

@scaytrase because nighlty builds create false positive failures when then break. We could add then as "allowed failures", but that would consume a Travis job thus slow down everyone.
Beside: 👍

@@ -746,7 +746,7 @@ private function validateGenericNode($value, $object, $cacheKey, MetadataInterfa
// The $cascadedGroups property is set, if the "Default" group is
// overridden by a group sequence
// See validateClassNode()
$cascadedGroups = count($cascadedGroups) > 0
$cascadedGroups = ((is_array($cascadedGroups) || $cascadedGroups instanceof \Countable) && count($cascadedGroups) > 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surrounding brackets should be removed

@scaytrase
Copy link
Contributor Author

@nicolas-grekas by slowing down you just mean that we consume one more container per build or making the build being longer?

if second - AFAIK travis marks build green as soon as every mandatory job finishes green.

if first we can make the travis to skip the job if branch is not 2.x or master. Or not a tag. Thus we will check only merged commits or tags only an we will collect at least one run on nigtly build per release

@scaytrase
Copy link
Contributor Author

Travis failed this time:

https://travis-ci.org/symfony/symfony/jobs/189505947#L2114

Fatal error: Call to undefined method PHPUnit_Framework_TestResult::addWarning() in /home/travis/build/symfony/symfony/vendor/symfony/phpunit-bridge/SymfonyTestsListener.php on line 215

Seems unrelated

@xabbuh
Copy link
Member

xabbuh commented Jan 6, 2017

Why not checking then that the value is not equal to null?

@scaytrase
Copy link
Contributor Author

scaytrase commented Jan 6, 2017

@xabbuh I have the same thoughts on the start. But the array|null contract is specified only within the phpdoc annotation, no more, so in a real something other could be passed here, yes, like \ArrayAccess?

if we have an array $cascadedGroups = null (or modern ?array $cascadedGroups some days) signature - yes, the null check would be definetely most proper one.

If you sure, that array|null signature is guaranteed somewhere else, I can change this.

@xabbuh
Copy link
Member

xabbuh commented Jan 6, 2017

We always rely on the fact that argument types comply with the ones specified in the docblock when we cannot use type hints (for example, we don't have additional checks for scalar types). If you don't respect this contract, you are basically on your own.

@scaytrase
Copy link
Contributor Author

@xabbuh sounds reasonable, updated the check

@xabbuh
Copy link
Member

xabbuh commented Jan 8, 2017

👍

Status: Reviewed

@fabpot
Copy link
Member

fabpot commented Jan 8, 2017

Thank you @scaytrase.

@fabpot fabpot closed this Jan 8, 2017
fabpot added a commit that referenced this pull request Jan 8, 2017
…ytrase)

This PR was squashed before being merged into the 2.7 branch (closes #21155).

Discussion
----------

[Validator] Check cascasdedGroups for being countable

Prevents notice for PHP 7.2

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        |

Just repeated for this place #20859
Waiting travis to fill in the `Tests pass` field

`cascasdedGroups` can be null at this point (according to failures and phpdoc)

Commits
-------

8fa45a1 [Validator] Check cascasdedGroups for being countable
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.

5 participants