Skip to content

Commit 9f280d7

Browse files
committed
readme.md: improvements
1 parent 2227ea7 commit 9f280d7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Whereas the former code executed successfully (although it contained an error),
4646

4747
![](https://files.nette.org/git/doc-2.1/debugger-circle.png)
4848

49-
Trait `Nette\SmartObject` made `Circle` more strict and threw an exception when you tried to access an undeclared property. And `Tracy\Debugger` displayed error message about it. Line of code with fatal typo is now highlighted and error message has meaningful description: *Cannot write to an undeclared property Circle::$raduis*. Programmer can now fix the mistake he might have otherwise missed and which could be a real pain to find later.
49+
Trait `Nette\SmartObject` made `Circle` more strict and threw an exception when you tried to access an undeclared property. And Tracy displayed error message about it. Line of code with fatal typo is now highlighted and error message has meaningful description: *Cannot write to an undeclared property Circle::$raduis, did you mean $radius?*. Programmer can now fix the mistake he might have otherwise missed and which could be a real pain to find later.
5050

5151
One of many remarkable abilities of `Nette\SmartObject` is throwing exceptions when accessing undeclared members.
5252

@@ -60,14 +60,14 @@ $circle->unknownMethod(); // throws Nette\MemberAccessException
6060
But it has much more to offer!
6161

6262

63-
Properties, getters a setters
64-
-----------------------------
63+
Properties, getters and setters
64+
-------------------------------
6565

6666
In modern object oriented languages *property* describes members of class, which look like variables but are represented by methods. When reading or assigning values to those "variables", methods are called instead (so-called getters and setters). It is really useful feature, which allows us to control the access to these variables. Using this we can validate inputs or postpone the computation of values of these variables to the time when it is actually accessed.
6767

6868
Any class that uses `Nette\SmartObject` acquires the ability to imitate properties. Only thing you need to do is to keep simple convention:
6969

70-
- Add annotation `@property type $xyz`
70+
- Add annotation `@property <type> $name`
7171
- Getter's name is `getXyz()` or `isXyz()`, setter's is `setXyz()`
7272
- It is possible to have `@property-read` only and `@property-write` only properties
7373
- Names of properties are case-sensitive (first letter being an exception)
@@ -142,7 +142,7 @@ class Circle
142142
$circle = new Circle;
143143

144144
// adding an event handler
145-
$circle->onChange[] = function ($circle, $oldValue, $newValue) {
145+
$circle->onChange[] = function (Circle $circle, $oldValue, $newValue) {
146146
echo 'there was a change!';
147147
};
148148

0 commit comments

Comments
 (0)