Doc #80497 [Ver->Csd]: Incorrect example #11 for ::class on OOP The Basics page

From: Date: Wed, 09 Dec 2020 10:50:11 +0000
Subject: Doc #80497 [Ver->Csd]: Incorrect example #11 for ::class on OOP The Basics page
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18221@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80497&edit=1

 ID:                 80497
 Updated by:         phpdocbot@php.net
 Reported by:        iamvar at gmail dot com
 Summary:            Incorrect example #11 for ::class on OOP The Basics
                     page
-Status:             Verified
+Status:             Closed
 Type:               Documentation Problem
 Package:            Class/Object related
 PHP Version:        Irrelevant
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=4528db2d91279a8f120bacfd84e48f7e2281d923
Log: Fix #80497: Incorrect example #11 for ::class on OOP The Basics page


Previous Comments:
------------------------------------------------------------------------
[2020-12-09 10:49:24] cmb@php.net

Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=351963
Log: Fix #80497: Incorrect example #11 for ::class on OOP The Basics page

------------------------------------------------------------------------
[2020-12-09 06:14:47] requinix@php.net

> Word Class in the namespace,
As of PHP 8, using "Class" is okay because the namespace name is considered as a whole. https://3v4l.org/AEJP5

A revised example avoiding that issue and fixing the backslash would be

<?php
print Does\Not\Exist::class;
?>

------------------------------------------------------------------------
[2020-12-09 06:04:01] iamvar at gmail dot com

Description:
------------
On the https://www.php.net/manual/en/language.oop5.basic.php
There is a typo
It said that
print Some\Class\DoesNot\Exist::class;

will print Some\Class\Does\Not\Exist

But it will not, there are 2 problems:
Word Class in the namespace, missing slash for print statement DoesNot\Exist instead of
Does\Not\Exist 

Test script:
---------------
print Some\Class\DoesNot\Exist::class;

Expected result:
----------------
print Does\Not\Exist::class;

will print Does\Not\Exist

Actual result:
--------------
Parse error:  syntax error, unexpected 'Class' (T_CLASS), expecting identifier (T_STRING)
in php shell code on line 1


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



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


Thread (3 messages)

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