diff options
Diffstat (limited to 'vendor/chillerlan/php-settings-container/examples/advanced.php')
-rw-r--r-- | vendor/chillerlan/php-settings-container/examples/advanced.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/vendor/chillerlan/php-settings-container/examples/advanced.php b/vendor/chillerlan/php-settings-container/examples/advanced.php index 1030b0a29..f11642c83 100644 --- a/vendor/chillerlan/php-settings-container/examples/advanced.php +++ b/vendor/chillerlan/php-settings-container/examples/advanced.php @@ -1,6 +1,5 @@ <?php /** - * @filesource advanced.php * @created 28.08.2018 * @author smiley <[email protected]> * @copyright 2018 smiley @@ -15,7 +14,7 @@ require_once __DIR__.'/../vendor/autoload.php'; // from library #1 trait SomeOptions{ - protected $foo; + protected string $foo = ''; // this method will be called in SettingsContainerAbstract::__construct() after the properties have been set protected function SomeOptions(){ @@ -26,7 +25,7 @@ trait SomeOptions{ // from library #2 trait MoreOptions{ - protected $bar = 'whatever'; // provide default values + protected string $bar = 'whatever'; // provide default values } $commonOptions = [ @@ -37,10 +36,16 @@ $commonOptions = [ ]; // now plug the several library options together to a single object -/** @var \chillerlan\Settings\SettingsContainerInterface $container */ -$container = new class ($commonOptions) extends SettingsContainerAbstract{ + +/** + * @property string $foo + * @property string $bar + */ +class MySettings extends SettingsContainerAbstract{ use SomeOptions, MoreOptions; // ... }; +$container = new MySettings($commonOptions); + var_dump($container->foo); // -> WHATEVER (constructor ran strtoupper on the value) var_dump($container->bar); // -> nothing |