Comments (10)
Thanks, I'll look in to this.
from inspekt.
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.
from inspekt.
My environment:
OS:Windows XP Professional SP3
Apache:2.0.63.200
PHP:5.2.9-2
inspekt:0.4.0
from inspekt.
I changed the order of test case to
testTestAlnum2()
testTestAlnum()
testTestAlnum3()
and i got three failures :(
from inspekt.
So you're not running the newest codebase? Please make sure you do. 0.4.1 has been pushed and released.
from inspekt.
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.
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.
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.
Yes, this is PHP's behavior.
from inspekt.
Thank you!
from inspekt.
Related Issues (12)
- isZip() Regex HOT 1
- keyExists, getInt and getRaw fail when value to get is equal to zero HOT 2
- Inspekt::isIp() should support ipv6
- Different results using local and composer loaded Inspekt HOT 1
- float validation failure with trailing Zero HOT 1
- Ambiguous references to ../vendor/autoload.php HOT 2
- Validating email subdomain, max 6 chars (Inspekt.php#L84) HOT 1
- no apparent way to test for numbers, letters, and spaces
- inspekt.org is broken for me HOT 2
- filter_superglobals.php example enhancement HOT 1
- array_key_exists Problem with ArrayObject on PHP8 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inspekt.