php: Fix char* typecheck typemap to accept Null

The corresponding in typemap already does.

Fixes #1655, reported by CJSlominski.
This commit is contained in:
Olly Betts 2021-03-18 10:53:58 +13:00 committed by Olly Betts
parent 157465f65b
commit b7dedecfdd
4 changed files with 25 additions and 1 deletions

View File

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
2021-03-18: olly
#1655 [PHP] Fix char* typecheck typemap to accept PHP Null like the
corresponding in typemap does.
2021-03-18: olly
#1900, #1905 [PHP] Fix wrapping of overloaded directed methods with
non-void return.

View File

@ -23,4 +23,7 @@ class Unknown;
int test2(Unknown* unknown) { return 0; }
int test2(Base* base) { return 1; }
int test3(const char*, const Base* = 0, bool = false) { return 0; }
int test3(Base&, const char* = 0, const Base* = 0, bool = false) { return 1; }
%}

View File

@ -0,0 +1,14 @@
<?php
require "tests.php";
require "overload_polymorphic.php";
$t = new Derived();
check::equal(overload_polymorphic::test($t), 0, "test(Derived)");
check::equal(overload_polymorphic::test(1), 1, "test(1)");
check::equal(overload_polymorphic::test2($t), 1, "test2(Derived)");
check::equal(overload_polymorphic::test3($t, null, $t), 1, "test3(Derived, null, Derived)");
check::done();
?>

View File

@ -465,7 +465,10 @@
%php_typecheck(double,SWIG_TYPECHECK_DOUBLE,IS_DOUBLE)
%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING)
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char []
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&
" $1 = (Z_TYPE($input) == IS_STRING || Z_TYPE($input) == IS_NULL); "
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char []
" $1 = (Z_TYPE($input) == IS_STRING); "
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE