Giter Club home page Giter Club logo

Comments (10)

funkatron avatar funkatron commented on July 19, 2024

Thanks, I'll look in to this.

from inspekt.

funkatron avatar funkatron commented on July 19, 2024

I created unit tests based on this, and I can't recreate the behavior with the latest codebase. I'll be pushing up a 0.4.1 soon, but I'd be interested to know which version you're using. Otherwise, I think this is solved.

530fc33

from inspekt.

absszero avatar absszero commented on July 19, 2024

My environment:
OS:Windows XP Professional SP3
Apache:2.0.63.200
PHP:5.2.9-2
inspekt:0.4.0

from inspekt.

absszero avatar absszero commented on July 19, 2024

I changed the order of test case to
testTestAlnum2()
testTestAlnum()
testTestAlnum3()

and i got three failures :(

from inspekt.

funkatron avatar funkatron commented on July 19, 2024

So you're not running the newest codebase? Please make sure you do. 0.4.1 has been pushed and released.

from inspekt.

absszero avatar absszero commented on July 19, 2024

yes , I running the newest one , and do again,

require_once "Inspekt.php";

$_POST = array();
$_POST['a'] = '0';
$_POST['b'] = '2009-12-25';  
$_POST['c'] = '0';

$cage_POST = Inspekt::makePostCage(); 
var_dump( $cage_POST->testAlnum ('a') );    <= string '0' (length=1) , OK
var_dump( $cage_POST->testGreaterThan ('b' , 25 ) );  <= string '2009-12-25' (length=10) , WRONG
var_dump( $cage_POST->testLessThan ('c' , 25 ) );  < = string '0' (length=1) , OK

from inspekt.

funkatron avatar funkatron commented on July 19, 2024

your second case matches PHP behavior for string to integer conversion.

will output 'int(2009)'

As it states on http://us3.php.net/manual/en/language.operators.comparison.php

If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically.

So, the string '2009-12-25' is converted to the integer 2009, which is indeed greater than 25. The original value is returned because the test is passed.

Can you describe or provide code for what you think should happen in terms of type conversion? So far I haven't gotten that from you.

from inspekt.

absszero avatar absszero commented on July 19, 2024

sorry , my description was not clear .

my question is the automatic type conversion is permitted ?
so we can compare any string like '2009jkelj;vkshgjew' with a integer 25

from inspekt.

funkatron avatar funkatron commented on July 19, 2024

Yes, this is PHP's behavior.

from inspekt.

absszero avatar absszero commented on July 19, 2024

Thank you!

from inspekt.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.