1. Go to this page and download the library: Download adagio/property-exposer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adagio / property-exposer example snippets
// Before
class Foo
{
private $bar, $baz;
public function setBar($value)
{
$this->bar = $value;
}
public function getBar()
{
return $this->bar;
}
public function getBaz()
{
return $this->baz;
}
public function doSomething()
{
// ...
}
}
// After
/**
*
* @property int $bar Bar
* @property-read string $baz Baz
*/
class Foo
{
use PropertyExposerTrait;
private $bar, $baz;
public function doSomething()
{
// ...
}
}
use Adagio\PropertyExposer\PropertyExposerTrait;
/**
*
* @property int $bar Bar
* @property-read string $baz Baz
*/
final class Foo
{
use PropertyExposerTrait;
/**
*
* @var int
*/
private $bar = 7;
/**
*
* @var string
*/
private $baz = 'test';
}
$foo = new Foo;
echo $foo->bar."\n"; // 7
$foo->bar = 1;
echo $foo->bar."\n"; // 1
echo $foo->baz."\n"; // "test"
$foo->baz = 'test2'; // Exception...
echo $foo->baz."\n";
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.