Last active
March 19, 2016 19:20
-
-
Save nelson6e65/5749d7a4697705b51938 to your computer and use it in GitHub Desktop.
php_nml v0.5.1: Reproduce issue when customized getter/setter prefixes (https://github.com/nelson6e65/php_nml/issues/9)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace AwesomeNamespace { | |
use NelsonMartell\Utilities\UnitTesting\Assert; | |
use NelsonMartell\Object; | |
use NelsonMartell\PropertiesHandler; | |
class Human extends Object { | |
use PropertiesHandler; | |
public function __construct($name = '') | |
{ | |
echo "\n".__METHOD__."\n"; | |
parent::__construct(); | |
unset($this->Name, $this->Sex); | |
echo "\n Prefixes BEFORE change:"; | |
echo "\n ".static::$getterPrefix; | |
echo "\n ".static::$setterPrefix; | |
static::$getterPrefix = 'get_'; | |
static::$setterPrefix = 'set_'; | |
echo "\n Prefixes AFTER change:"; | |
echo "\n ".static::$getterPrefix; | |
echo "\n ".static::$setterPrefix; | |
$this->name = $name; | |
} | |
public $Name; | |
private $name = ''; | |
public function get_Name() { | |
echo "\n".__METHOD__."\n"; | |
return $this->name; | |
} | |
public function set_Name($value) { | |
echo "\n".__METHOD__."\n"; | |
$this->name = $value; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<title>Customize PropertiesHandler prefixes values issue</title> | |
</head> | |
<?php | |
// define('CODE_ANALYSIS', TRUE); | |
define('NML_AUTOLOADER', '../php_nml/autoload.php'); | |
require_once(NML_AUTOLOADER); | |
require_once('Human.php'); | |
// require_once('Animal.php'); | |
use AwesomeNamespace\Human; | |
// use AwesomeNamespace\Animal; | |
?> | |
<body style="margin: 20px"> | |
<div id='human'> | |
<h3>Human extends Object</h3> | |
<pre> | |
<?php | |
$obj = new Human('Nathaly'); | |
echo "\nObject content:"; | |
var_dump($obj); | |
echo "\nName is '{$obj->Name}'.\n"; | |
$obj->Name = 'Nathan'; | |
echo "\nNow, the name is '{$obj->Name}'.\n"; | |
echo "\nObject content:"; | |
var_dump($obj); | |
echo "\n\nTrying to use object as string:\n"; | |
echo "String of object is: '{$obj->toString()}'"; | |
?> | |
</pre> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment