Doc #79206 [Com]: More typed properties docs: uninitialized state, behavior with __get/set, etc.

From: Date: Mon, 23 Aug 2021 09:25:40 +0000
Subject: Doc #79206 [Com]: More typed properties docs: uninitialized state, behavior with __get/set, etc.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-19096@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79206&edit=1

 ID:                 79206
 Comment by:         greedy dot ivan at gmail dot com
 Reported by:        greedy dot ivan at gmail dot com
 Summary:            More typed properties docs: uninitialized state,
                     behavior with __get/set, etc.
 Status:             Feedback
 Type:               Documentation Problem
 Package:            Class/Object related
 PHP Version:        7.4.2
 Block user comment: N
 Private report:     N

 New Comment:

agreed


Previous Comments:
------------------------------------------------------------------------
[2021-08-22 20:47:49] requinix@php.net

I'm satisfied with the updated documentation. @ivan?

------------------------------------------------------------------------
[2021-08-22 17:08:10] deleugyn+php at gmail dot com

Looks like https://www.php.net/manual/en/language.oop5.properties.php#language.oop5.properties.typed-properties
describes how typed properties work and there's an example of how Error is thrown for
unitilialized properties.

Perhaps this can be closed?

------------------------------------------------------------------------
[2020-02-01 23:22:59] requinix@php.net

> Maybe PHP RFC page needs some disclaimer that implementation details may differ from what in on
> the RFC page
> itself.
1. Everything in the RFC is supposed to be correct and the implementation should not differ. What
likely happened here is that the mailing list discussion resulted in the error being changed to an
Error and the author forgot to update the RFC. Typed properties was a complicated subject to talk
about.
2. The RFC is not supposed to act as documentation. The manual proper should cover everything. If
there is no documentation then that is a problem.

And I don't see sufficient documentation. What's there now is just an example of the
syntax.
https://www.php.net/manual/en/language.oop5.properties.php

------------------------------------------------------------------------
[2020-02-01 22:55:11] greedy dot ivan at gmail dot com

> Regarding the RFC itself, it is not the final documentation

Thank you for this clarification.

PHP docs contains almost nothing about typed property feature and how it works. All references in
Internet goes to that RFC. So, it is assumed that reading implemented PHP RFC is a good point to
know how feature works and many details about it.

Maybe PHP RFC page needs some disclaimer that implementation details may differ from what in on the
RFC page itself.

------------------------------------------------------------------------
[2020-02-01 22:32:00] requinix@php.net

> If this is a documentation error, how to fix it?
I don't see where in the documentation (php.net/manual) it says accessing an uninitialized
typed property results in a TypeError.
Regarding the RFC itself, it is not the final documentation. Minor details may change during
discussion and implementation and sometimes they don't always make it back into the originating
RFC.

> if this is an implementation error, it should be fixed.
I don't believe that TypeError is proper for this situation: 

https://www.php.net/manual/en/class.typeerror.php
> There are three scenarios where a TypeError may be thrown. The first is where the argument type
> being passed to
> a function does not match its corresponding declared parameter type. The second is where a
> value being returned
> from a function does not match the declared function return type. The third is where an invalid
> number of
> arguments are passed to a built-in PHP function (strict mode only).

I don't see a more suitable error available
https://www.php.net/manual/en/reserved.exceptions.php

so a generic Error seems appropriate.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=79206


--
Edit this bug report at https://bugs.php.net/bug.php?id=79206&edit=1


Thread (11 messages)

« previous php.doc.bugs (#19096) next »