From 370bb99d281329d57097c14de8f3620a7c248bd6 Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Fri, 27 Nov 2020 23:40:12 +0000 Subject: [PATCH] Document the ::class constant on objects Also, improve ::class description based on comments. Closes GH-239. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351711 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/oop5/basic.xml | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/language/oop5/basic.xml b/language/oop5/basic.xml index 3c320de5d2..2d234c179e 100644 --- a/language/oop5/basic.xml +++ b/language/oop5/basic.xml @@ -413,7 +413,7 @@ a default value ::class - Since PHP 5.5, the class keyword is also used for class + The class keyword is also used for class name resolution. You can get a string containing the fully qualified name of the ClassName class by using ClassName::class. This is particularly useful with @@ -449,7 +449,49 @@ NS\ClassName are expanded even if the class does not exist. No error is issued in that case. + + Missing class name resolution + + +]]> + + &example.outputs; + + + + + + As of PHP 8.0.0, the ::class constant may also be used on + objects. This resolution happens at runtime, not compile time. Its effect is + the same as calling get_class on the object. + + + Object name resolution + + +]]> + + &example.outputs; + + + +