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

Skip to content

[Console] Fix SymfonyStyle::ask usage #9741

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

Merged
merged 2 commits into from
May 15, 2018
Merged

Conversation

liviubalan
Copy link
Contributor

Use function "ctype_digit" instead of "is_integer" because "$number" is not an integer value, but a string

Use function "ctype_digit" instead of "is_integer" because "$number" is not an integer value, but a string
@@ -238,7 +238,7 @@ User Input Methods
the third argument::

$io->ask('Number of workers to start', 1, function ($number) {
if (!is_integer($number)) {
if (!ctype_digit($number)) {
Copy link
Member

Choose a reason for hiding this comment

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

Won't this fail if the user types nothing and the default value (which actually is an integer) is used? What about combining both checks?

Copy link
Member

Choose a reason for hiding this comment

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

Could we use http://php.net/is_numeric first and then cast to int?

@javiereguiluz
Copy link
Member

Thanks Liviu for reporting this bug! I finally changed the code to use is_numeric() and a (int) cast.

@javiereguiluz javiereguiluz merged commit 9bb23e1 into symfony:2.7 May 15, 2018
javiereguiluz added a commit that referenced this pull request May 15, 2018
…eguiluz)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Fix SymfonyStyle::ask usage

Use function "ctype_digit" instead of "is_integer" because "$number" is not an integer value, but a string

<!--

If your pull request fixes a BUG, use the oldest maintained branch that contains
the bug (see https://symfony.com/roadmap for the list of maintained branches).

If your pull request documents a NEW FEATURE, use the same Symfony branch where
the feature was introduced (and `master` for features of unreleased versions).

-->

Commits
-------

9bb23e1 Use is_numeric()
38bcfcb [Console] Fix SymfonyStyle::ask usage
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.

4 participants