user-documentation
user-documentation copied to clipboard
No good examples for parameter variance in method overrides
Please complete the information below:
Where is the problem?
What is the problem?
It does not provide an example of an overridden method with parameters. Specifically I was interested in three things, two of which were not covered:
- Can the overriding method have a broader parameter type? (contravariance)
- Can the overriding method have a stricter return type? (covariance) -- It can :white_check_mark:
- Can the overriding method parameters have different names so long as the types are the same? (name invariance)
The examples provided only gave an example of covariance (get(): num
is overridden with get(): float
), but did not show if contravariance or name invariance is supported.
Please don't change anything below this point.
- Build ID: HHVM=HHVM-4.154.0:HSL=v4.108.1:2022-06-02T01:16:10+0000:1fa47f258c6b68f8ec01899aa82fd6ffa0957109
- Page requested: /hack/classes/inheritance
- Page requested at: Mon, 06 Jun 2022 17:42:17 +0000