Skip to content

Float in GET params #200

Description

@AndrewHlavac

Version: 2.4.12

Bug Description

There is a problem when converting float GET params in \Nette\Application\UI\ComponentReflection::convertType(). Because conversion from string to float and back does not have to give the same result, in some cases it ends up with the data-loss check.

Steps To Reproduce

class FooPresenter extends \Nette\Application\UI\Presenter {
  public function actionBar(float $length) {
  }
}

When you call /foo/bar/?length=1.2 everything work as expected.
When you call /foo/bar/?length=1.0 the BadRequestException is thrown.

Expected Behavior

Value 1.0 should be treated as float not string.

Possible Solution

I was not able to find out other solution then handle each scalar type differently.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions