Arquivos
hhvm/hphp/test/quick/ctor_param_promotion.php
T
Dario Russi ef99ac3445 Allow parameter promotion in constructors
Extend PHP to allow constructor paramters to be promoted to fields. Reduce plumbing of class declaration and helps productivity.
2013-07-06 11:12:21 -07:00

23 linhas
296 B
PHP

<?php
//
// this works
//
class A {
public $c;
public function __construct(protected $a, public $b, $arg) {
$this->c = $arg;
}
public function getA() {
return $this->a;
}
}
$a = new A('hi', 3, array());
foreach ($a as $k => $v) {
var_dump($k, $v);
}
var_dump($a->getA());