You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: published/records.ptxt
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ $uid = $user->id;
26
26
// ...
27
27
$uid = 5; // somehow accidentally sets uid to an unrelated integer
28
28
// ...
29
-
updateUserRole($uid, Role::ADMIN()); // accidental passing of
29
+
updateUserRole($uid, Role::ADMIN()); // accidental passing of
30
30
</code>
31
31
32
32
In this example, the uid is accidentally set to a plain integer, and updateUserRole is called with the wrong value.
@@ -64,7 +64,7 @@ This RFC proposes the introduction of a new record keyword in PHP to define immu
64
64
65
65
A ''%%record%%'' is defined by the word "record", followed by the name of its type, an open parenthesis containing one or more typed parameters that become public, immutable, properties. They may optionally implement an interface using the ''%%implements%%'' keyword. A ''%%record%%'' body is optional.
66
66
67
-
A ''%%record%%'' may contain a constructor with zero arguments to perform further initialization, if required. If it does not have a constructor, an implicit, empty contstructor is provided.
67
+
A ''%%record%%'' may contain a constructor with zero arguments to perform further initialization if required. If it does not have a constructor, an implicit, empty contstructor is provided.
68
68
69
69
A ''%%record%%'' body may contain property hooks, methods, and use traits (so long as they do not conflict with ''%%record%%'' rules). Regular properties may also be defined, but they are immutable by default and are no different from ''%%const%%''.
70
70
@@ -89,7 +89,7 @@ record PaintBucket(StockPaint ...$constituents) {
89
89
public function mixIn(StockPaint $paint): PaintBucket {
@@ -151,7 +151,7 @@ record User(string $name, string $email) {
151
151
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
152
152
throw new InvalidArgumentException("Invalid email address");
153
153
}
154
-
154
+
155
155
$this->id = hash('sha256', $email);
156
156
$this->name = ucwords($name);
157
157
}
@@ -190,7 +190,7 @@ Records in PHP will be fully supported by the reflection API, providing access t
190
190
191
191
=== ReflectionClass support ===
192
192
193
-
''%%ReflectionClass%%'' can be used to inspect records, their properties, and methods. Any attempt to modify record properties via reflection will throw an exception, maintaining immutability. Attempting to create a new instance via ''%%ReflectionClass%%'' will cause a ''%%ReflectionException%%'' to be thrown.
193
+
It can be used to inspect records, their properties, and methods. Any attempt to modify record properties via reflection will throw an exception, maintaining immutability. Attempting to create a new instance via ''%%ReflectionClass%%'' will cause a ''%%ReflectionException%%'' to be thrown.
194
194
195
195
<code php>
196
196
$point = Point(3, 4);
@@ -249,9 +249,9 @@ record(Point)#1 (2) {
249
249
250
250
A ''%%record%%'' cannot be named after an existing ''%%record%%'', ''%%class%%'' or ''%%function%%''. This is because defining a ''%%record%%'' creates both a ''%%class%%'' and a ''%%function%%'' with the same name.
251
251
252
-
==== Auto loading ====
252
+
==== Autoloading ====
253
253
254
-
As invoking a record value by its name looks remarkably similar to calling a function, and PHP has no function autoloader, auto loading will not be supported in this implementation. If function auto loading were to be implemented in the future, an autoloader could locate the ''%%record%%'' and autoload it. The author of this RFC strongly encourages someone to put forward a function auto loading RFC if auto loading is desired for records.
254
+
As invoking a record value by its name looks remarkably similar to calling a function, and PHP has no function autoloader, autoloading will not be supported in this implementation. If function autoloading were to be implemented in the future, an autoloader could locate the ''%%record%%'' and autoload it. The author of this RFC strongly encourages someone to put forward a function autoloading RFC if autoloading is desired for records.
0 commit comments