Fix new director_classes_runme.php for PHP7
This commit is contained in:
parent
2de2efb0bb
commit
14df91f8a0
1 changed files with 53 additions and 22 deletions
|
|
@ -8,30 +8,61 @@ check::classes(array('director_classes', 'Base', 'BaseClass', 'Caller', 'Derived
|
|||
// New vars
|
||||
check::globals(array('PrintDebug'));
|
||||
|
||||
class PHPDerived extends Base {
|
||||
function Val(DoubleHolder $x) { return $x; }
|
||||
function Ref(DoubleHolder $x) { return $x; }
|
||||
function Ptr(?DoubleHolder $x) { var_dump($x); return $x; }
|
||||
function ConstPtrRef(?DoubleHolder $x) { return $x; }
|
||||
function FullyOverloaded($x) {
|
||||
$rv = parent::FullyOverloaded($x);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
}
|
||||
function SemiOverloaded($x) {
|
||||
# this is going to be awkward because we can't really
|
||||
# semi-overload in PHP, but we can sort of fake it.
|
||||
if (!is_int($x)) {
|
||||
return parent::SemiOverloaded($x);
|
||||
if (PHP_MAJOR_VERSION < 8) {
|
||||
// Without type declarations since we don't generate them for PHP < 8
|
||||
// and we need to be compatible with method declarations in Base.
|
||||
class PHPDerived extends Base {
|
||||
function Val($x) { return $x; }
|
||||
function Ref($x) { return $x; }
|
||||
function Ptr($x) { var_dump($x); return $x; }
|
||||
function ConstPtrRef($x) { return $x; }
|
||||
function FullyOverloaded($x) {
|
||||
$rv = parent::FullyOverloaded($x);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
}
|
||||
function SemiOverloaded($x) {
|
||||
# this is going to be awkward because we can't really
|
||||
# semi-overload in PHP, but we can sort of fake it.
|
||||
if (!is_int($x)) {
|
||||
return parent::SemiOverloaded($x);
|
||||
}
|
||||
$rv = parent::SemiOverloaded($x);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
}
|
||||
function DefaultParms($x, $y = 1.1) {
|
||||
$rv = parent::DefaultParms($x, $y);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
}
|
||||
$rv = parent::SemiOverloaded($x);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
}
|
||||
function DefaultParms(int $x, float $y = 1.1) {
|
||||
$rv = parent::DefaultParms($x, $y);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
} else {
|
||||
class PHPDerived extends Base {
|
||||
function Val(DoubleHolder $x) { return $x; }
|
||||
function Ref(DoubleHolder $x) { return $x; }
|
||||
function Ptr(?DoubleHolder $x) { var_dump($x); return $x; }
|
||||
function ConstPtrRef(?DoubleHolder $x) { return $x; }
|
||||
function FullyOverloaded($x) {
|
||||
$rv = parent::FullyOverloaded($x);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
}
|
||||
function SemiOverloaded($x) {
|
||||
# this is going to be awkward because we can't really
|
||||
# semi-overload in PHP, but we can sort of fake it.
|
||||
if (!is_int($x)) {
|
||||
return parent::SemiOverloaded($x);
|
||||
}
|
||||
$rv = parent::SemiOverloaded($x);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
}
|
||||
function DefaultParms(int $x, float $y = 1.1) {
|
||||
$rv = parent::DefaultParms($x, $y);
|
||||
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
|
||||
return $rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue