diff --git a/components/property_access.rst b/components/property_access.rst index bfe739e3e30..dde7230660a 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -252,23 +252,31 @@ can use setters, the magic ``__set()`` method or properties to set values:: $this->lastName = $name; } + public function getLastName() + { + return $this->lastName; + } + + public function getChildren() + { + return $this->children; + } + public function __set($property, $value) { $this->$property = $value; } - - // ... } $person = new Person(); $accessor->setValue($person, 'firstName', 'Wouter'); - $accessor->setValue($person, 'lastName', 'de Jong'); - $accessor->setValue($person, 'children', array(new Person())); + $accessor->setValue($person, 'lastName', 'de Jong'); // setLastName is called + $accessor->setValue($person, 'children', array(new Person())); // __set is called var_dump($person->firstName); // 'Wouter' var_dump($person->getLastName()); // 'de Jong' - var_dump($person->children); // array(Person()); + var_dump($person->getChildren()); // array(Person()); You can also use ``__call()`` to set values but you need to enable the feature, see `Enable other Features`_. diff --git a/service_container/service_decoration.rst b/service_container/service_decoration.rst index 1bd86f9e681..b090a311244 100644 --- a/service_container/service_decoration.rst +++ b/service_container/service_decoration.rst @@ -232,6 +232,6 @@ order by configuring the priority of decoration, this can be any integer number The generated code will be the following:: - $this->services['foo'] = new Baz(new Bar(new Foo()))); + $this->services['foo'] = new Baz(new Bar(new Foo())); .. _decorator pattern: https://en.wikipedia.org/wiki/Decorator_pattern