It may be early in the morning, or I'm completely blind, but why am I getting "Fatal error: using $ this if not in the context of the object" in the following code. There is nothing static there.
Grade:
<?php
class Property
{
private $values;
public function __contruct($file)
{
$this->values = parse_ini_file($file, false);
}
public function get($key, $default = null)
{
if (key_exists($key, $this->values)) {
return $this->values[$key];
}
return $default;
}
}
Test:
<?php
class PropertyTest extends Test
{
public function testGet()
{
$prop = new Property($this->getResource('test.properties'));
$this->assertEquals('foo', $prop->get('test.entry', 'xyz'));
$this->assertEquals('bar', $prop->get('test.entry2', 'xyz'));
$this->assertEquals('xyz', $prop->get('test.entry3', 'xyz'));
$this->assertEquals(null, $prop->get('test.entry3'));
}
}
Edit
Error comments indicating a trace. The error occurs when PropertyTest-> testGet () is launched in the first $ prop-> get () called by the first line of the Property-> get () method.
Decision
Besides the xdazz typo found, and Phil's fatigue pointed to, user985935 was right. :)
To do this briefly, my classloader used static get, and the phpUnit error misled my research and my information, which I offer you to find my problem. Unfortunately.