rfc:class-like_primitive_types
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:class-like_primitive_types [2016/12/19 21:23] – plural ajf | rfc:class-like_primitive_types [2016/12/19 22:21] – ajf | ||
---|---|---|---|
Line 53: | Line 53: | ||
* < | * < | ||
* < | * < | ||
- | * < | + | * < |
==== Features not extended to primitives ==== | ==== Features not extended to primitives ==== | ||
Line 62: | Line 62: | ||
* < | * < | ||
* < | * < | ||
+ | * < | ||
**FIXME:** What do I do about reflection? | **FIXME:** What do I do about reflection? | ||
+ | |||
+ | === Serializable and resources === | ||
+ | |||
+ | The resource type will not implement the < | ||
==== Primitive type class hierarchy ==== | ==== Primitive type class hierarchy ==== | ||
Line 70: | Line 75: | ||
<code php> | <code php> | ||
- | final class null implements Serializable, | + | /* There is no shadow |
- | public function __toString() { /* ... */ } | + | |
- | public function serialize() { /* ... */ } | + | |
- | public function unserialize($serialized) { /* ... */ } | + | |
- | public function jsonSerialize() { /* ... */ } | + | |
- | } | + | |
final class bool implements Serializable, | final class bool implements Serializable, | ||
public function __toString() { /* ... */ } | public function __toString() { /* ... */ } | ||
Line 110: | Line 111: | ||
} | } | ||
} | } | ||
- | final class resource | + | final class resource { |
public function __toString() { /* ... */ } | public function __toString() { /* ... */ } | ||
- | public function serialize() { /* ... */ } | ||
- | public function unserialize($serialized) { /* ... */ } | ||
} | } | ||
</ | </ | ||
Line 132: | Line 131: | ||
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
- | This does not impact existing extensions, their view of the world is unchanged and the other primitive types are still primitives. | + | This does not impact existing extensions: their view of the world is unchanged and the primitive types other than objects |
**FIXME:** Reflection. | **FIXME:** Reflection. | ||
Line 143: | Line 142: | ||
**FIXME:** Reflection, Opcache. | **FIXME:** Reflection, Opcache. | ||
+ | |||
+ | ==== Should null have a shadow class? ==== | ||
+ | |||
+ | Or in other words, should these features be extended to < | ||
+ | |||
+ | < | ||
+ | |||
+ | Would methods like < | ||
+ | |||
+ | In JavaScript, '' | ||
+ | |||
+ | This RFC currently chooses to omit null from the extension of most features of objects to the other types, but excepts < | ||
+ | |||
+ | ==== Should resource be supported? ==== | ||
+ | |||
+ | Resource is a legacy type that could be wholly replaced by objects in future. Extending these features to this type would be further entrenching it and contrary to the goal of its eventual removal. | ||
+ | |||
+ | In particular, < | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
Line 152: | Line 169: | ||
The extension of these features to the other primitive types opens up a number of future possibilities. | The extension of these features to the other primitive types opens up a number of future possibilities. | ||
- | One of these would be [[http:// | + | One of these would be [[http:// |
+ | |||
+ | It also means we can easily introduce new superclasses of our other primitive types. For example, a new < | ||
+ | |||
+ | Likewise, we could introduce new interfaces implemented by our other primitive types. One potential use for this is operator overloading. PHP could add an interface for number-like classes, which when implemented, | ||
- | It also means we can easily introduce new superclasses of our other primitive types. For example, a new <php>\Number</ | + | <php>instanceof</ |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== |
rfc/class-like_primitive_types.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1