ef99ac3445
Extend PHP to allow constructor paramters to be promoted to fields. Reduce plumbing of class declaration and helps productivity.
23 linhas
296 B
PHP
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());
|
|
|