-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
Scope of Change
A shortened syntax for fluent interfaces will be allowed.
Rationale
Omit typing return $this;
.
Functionality
The this
keyword will be reused as the method's return type. The following two are equivalent:
// Current definition
public class URL {
protected string $host;
public self setHost(string $host) {
$this.host= $host;
return $this;
}
}
// New and shortened version
public class URL {
protected string $host;
public this setHost(string $host) {
$this.host= $host;
}
}
If we combine this with the compact member assignment syntax from RFC #240, we can even write:
public class URL {
protected string $host;
public this setHost($this.host) { }
}
Security considerations
n/a
Speed impact
None, resolved during compile time.
Dependencies
n/a
Related documents
- RFC Compact assignment syntax #240 - Compact assignment syntax
- RFC Compact method syntax #241 - Compact method syntax