Ad
  • Custom User Avatar

    the setup of this kata in PHP has really big issues. not only are most solutions wrong, including the author's, because they use the value 0.0 to detect invalid inputs, which means they fail the simple test case assertSame(0.0, parseFloat("0.0")), but, contrary to all other languages, the random tests expect 123.0 for something like "123abc", just because (float) / floatval() in PHP behaves differently than most other languages (e.g. for the same input JavaScript returns NaN, Python raises a ValueError, etc.)

    the description does not indicate the expected behavior at all, which means all languages likely fallback to the behavior of their builtin.

    I made a fork there adding the "0.0" fixed test and replacing the reference solution with something saner, but i'm not going to self-approve, as this will invalidate all solutions.

  • Custom User Avatar

    I checked the history of versions, those invalid solutions managed to pass because tests used the loose equality assertEquals() when the translation was published. it has since been changed to the more robust assertSame()

  • Custom User Avatar

    all the previous solutions don't work either

    how did you determine that ? I tried a dozen solutions from the Solutions page and most worked. a few old solutions did not work because they perform no error checking at all and return 0.0 instead of null for invalid inputs like "abcd"

  • Custom User Avatar

    I am not saying that the setup of this task is great, but I just completed this task in PHP.

  • Custom User Avatar

    duplicate of this issue

  • Custom User Avatar

    I understand your point, but it does not seem to be official PHP terminology. Browsing the official documentation for anonymous functions, one can read sentences such as:

    Anonymous functions, also known as closures ...

    Closures may also inherit variables from the parent scope ...

    The whole document uses the terms "anonymous function" and "closure" interchangeably

  • Custom User Avatar

    can you write an anonymous function for which instanceof Closure yields false ?