I'm not sure how that's happening on your server. I had to make assumptions about the MiddlewareTest
class, modify your class names, and added some simple debugging lines, but with this code:
<?php
/**
* I'm not sure what you have in this class.
* Perhaps the problem lies here on your side.
* Is this constructor doing something to nullify those properties?
* Are those properties also defined in this class?
*/
abstract class MiddlewareTest {
// I assume this properties are also defined here
protected $title = NULL;
protected $type = NULL;
protected $resolution = NULL;
protected $uuid = NULL;
public function __construct()
{}
protected function createChannel($title, $type, $resolution)
{
echo "<pre>" . __LINE__ . ": "; var_export(array($this->title, $this->type, $this->resolution)); echo "</pre>";
echo "<pre>" . __LINE__ . ": "; var_export(array($title, $type, $resolution)); echo "</pre>";
return var_export(array($title, $type, $resolution), true);
}
}
// 'parent' is a keyword, so let's just use A and B
class A extends MiddlewareTest
{
// abstract channel properties
protected $title = NULL;
protected $type = NULL;
protected $resolution = NULL;
function __construct() {
parent::__construct();
echo "<pre>" . __LINE__ . ": "; var_export(array($this->title, $this->type, $this->resolution)); echo "</pre>";
$this->uuid = $this->createChannel($this->title, $this->type, $this->resolution);
echo "<pre>" . __LINE__ . ": "; var_export($this->uuid); echo "</pre>";
}
}
class B extends A
{
// channel properties
protected $title = "Power";
protected $type = "power";
protected $resolution = 1000;
}
$B = new B();
?>
I get these results:
37: array (
0 => 'Power',
1 => 'power',
2 => 1000,
)
20: array (
0 => 'Power',
1 => 'power',
2 => 1000,
)
21: array (
0 => 'Power',
1 => 'power',
2 => 1000,
)
39: 'array (
0 => \'Power\',
1 => \'power\',
2 => 1000,
)'
As you can see, the values turn out to be passed in just as they are defined in the instantiated class, just as expected.
Can you give some details on your MiddlewareTest class that might shed some light on why you might be experiencing this behavior?
What version of php are you running?