File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
jphp-runtime/src/php/runtime/ext/core Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 2525import php .runtime .lang .ForeachIterator ;
2626import php .runtime .lang .IObject ;
2727import php .runtime .lang .Resource ;
28- import php .runtime .memory .ArrayMemory ;
29- import php .runtime .memory .LongMemory ;
30- import php .runtime .memory .ObjectMemory ;
31- import php .runtime .memory .StringMemory ;
28+ import php .runtime .memory .*;
3229import php .runtime .memory .helper .ObservableMemory ;
3330import php .runtime .reflection .*;
3431import php .runtime .util .StackTracer ;
@@ -413,9 +410,23 @@ public static boolean is_string(Memory memory) {
413410 return memory .isString ();
414411 }
415412
413+ protected static Memory to_floating_point (String s ) {
414+ try {
415+ return new DoubleMemory (Double .parseDouble (s ));
416+ } catch (NumberFormatException nfe ) {
417+ return null ;
418+ }
419+ }
420+
416421 @ Immutable
417422 public static boolean is_numeric (Memory memory ) {
418- return StringMemory .toNumeric (memory .toString (), false , null ) != null ;
423+ if (memory .isNumber ()) {
424+ return true ;
425+ } else {
426+ String asString = memory .toString ();
427+ return StringMemory .toLong (asString , true ) != null || to_floating_point (asString ) != null ;
428+ }
429+ //return StringMemory.toNumeric(memory.toString(), false, null) != null;
419430 }
420431
421432 @ Immutable
You can’t perform that action at this time.
0 commit comments