-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Add is_countable under PHP 7.3 #115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you :)
src/Php73/bootstrap.php
Outdated
|
||
if (PHP_VERSION_ID < 70300) { | ||
if (!function_exists('is_countable')) { | ||
function is_countable($s) { return p\Php73::is_countable($s); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for such a simple implementation, I think we can inline the code a remove the static class (as done on other polyfills AFAIK)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolas-grekas Sure, gonna do this!
tests/Php73/Php72Test.php
Outdated
/** | ||
* @author Gabriel Caruso <carusogabriel34@gmail.com> | ||
* | ||
* @covers Symfony\Polyfill\Php73\Php73::<!public> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be removed in you accept the previous comment (same below)
tests/Php73/Php72Test.php
Outdated
$this->assertTrue(is_countable([1, 2, 3])); | ||
$this->assertTrue(is_countable(new \ArrayIterator(['foo', 'bar', 'baz']))); | ||
$this->assertTrue(is_countable(new \ArrayIterator())); | ||
$this->assertFalse(is_countable(new \stdClass())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a case with generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keradus Is this possible with 5.x tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even if not, it shall still be tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the root composer.json needs to be updated to add the replace
rule for the new package.
src/Php73/composer.json
Outdated
"minimum-stability": "dev", | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.7-dev" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be 1.8 (and we should bump the version in master before merging this), as this is a new feature and so will be a new minor version, not a new patch version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof I'll just wait for the official merge in php-src, I'll do it :)
@nicolas-grekas Should be ready to go 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎
- Travis is failing (as you used short-array syntax not yet available for 5.3)
- generator test case shall be added, to ensure polyfill works for it properly
- tests are suppose to be executed, on different environments, with polyfill (on PHP versions that don't have the feature yet), and without it (using real feature). here, we always run test with a polyfill, never on PHP 7.3, as 7.3 is not part of Travis matrix
tests/Php73/Php73Test.php
Outdated
for ($i = 1; $i <= 10; ++$i) { | ||
yield $i; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keradus Is there a way to add generators tests without breaking the build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the yield
code would need to be extracted to dedicated file and loaded conditionally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keradus Done, thanks.
*/ | ||
public function testIsCountable() | ||
{ | ||
$this->assertTrue(is_countable(array(1, 2, '3'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keradus Fixed the array syntax, thanks.
looks better with every change @carusogabriel ! one last thing - could you extend |
Sure, thanks for the tip, I always amend my commits, but I'll start to commit and then squash them before merging the PR, thanks!
Sure, pushing these changes ASAP. |
@keradus There's one remain error in PHP 7.3 that I couldn't figure out how to solve. Maybe we should just add 7.2? |
the feature you are adding has to be tested under 7.3. if not, then we test only "does our polyfill work like we expect", but don't "does our polyfill expectation are same as original implementation". if you ask me, I would be fine with reverting travis changes and do it as separated PR. |
@stof , your request has been already fulfilled, could you please revisit your review ? In general, missing thing on Travis is related to |
@@ -50,6 +51,7 @@ | |||
"src/Php70/bootstrap.php", | |||
"src/Php71/bootstrap.php", | |||
"src/Php72/bootstrap.php", | |||
"src/Php73/bootstrap.php", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the branch-alias should be updated to 1.8-dev for all composer.json files of the repo
src/Php73/LICENSE
Outdated
@@ -0,0 +1,19 @@ | |||
Copyright (c) 2015-2018 Fabien Potencier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2018 only (not "2015-")
src/Php73/bootstrap.php
Outdated
|
||
if (PHP_VERSION_ID < 70300) { | ||
if (!function_exists('is_countable')) { | ||
function is_countable($s) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function should be on one single line (to make the test suite work as expected)
$s
should be renamed by $var
I suppose also.
Would you mind adding
|
Could we please add different feature with different PR? |
Thank you @carusogabriel. |
This PR was squashed before being merged into the 1.7-dev branch (closes #115). Discussion ---------- Add is_countable under PHP 7.3 As requested by @nicolas-grekas :) Waiting for php/php-src#3026 Commits ------- 803a622 Add is_countable under PHP 7.3
FYI, I removed the nightly line because it failed for unrelated reason, to be fixed in a next PR. hrtime() welcome now. |
As noted in the commit here: symfony/polyfill-php73@f713942#r28736995
|
…t implement \Countable (pierredup) This PR was merged into the 1.8-dev branch. Discussion ---------- Update is_countable to include countable objects that doesn't implement \Countable Some objects are countable but don't implement `Countable` ([#115#issuecomment-384361414](#115 (comment))) The objects that I could identify that is countable is `ResourceBundle` and `SimpleXmlElement` Commits ------- b53929e Update is_countable to include countable objects that doesn't implement \Countable
…t implement \Countable (pierredup) This PR was merged into the 1.8-dev branch. Discussion ---------- Update is_countable to include countable objects that doesn't implement \Countable Some objects are countable but don't implement `Countable` ([symfony/polyfill#115#issuecomment-384361414](symfony/polyfill#115 (comment))) The objects that I could identify that is countable is `ResourceBundle` and `SimpleXmlElement` Commits ------- b53929e Update is_countable to include countable objects that doesn't implement \Countable
As requested by @nicolas-grekas :)
Waiting for php/php-src#3026