From 7de45151c2d8777bf1b99863f36666a7d23cc5b0 Mon Sep 17 00:00:00 2001 From: Christoph Michael Becker Date: Fri, 25 Nov 2016 23:09:57 +0000 Subject: [PATCH] Fix #73593: constant visibility needs to be documented git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@341146 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/oop5/visibility.xml | 68 +++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/language/oop5/visibility.xml b/language/oop5/visibility.xml index 8c9840595c..456b5627ee 100644 --- a/language/oop5/visibility.xml +++ b/language/oop5/visibility.xml @@ -3,7 +3,7 @@ Visibility - The visibility of a property or method can be defined by prefixing + The visibility of a property, a method or (as of PHP 7.1.0) a constant can be defined by prefixing the declaration with the keywords public, protected or private. Class members declared public can be @@ -189,6 +189,72 @@ $myFoo->test(); // Bar::testPrivate + + Constant Visibility + + As of PHP 7.1.0, class constants may be defined as public, private, or + protected. Constants declared without any explicit visibility + keyword are defined as public. + + + + Constant Declaration as of PHP 7.1.0 + +foo(); // Public, Protected and Private work + + +/** + * Define MyClass2 + */ +class MyClass2 extends MyClass +{ + // This is public + function foo2() + { + echo self::MY_PUBLIC; + echo self::MY_PROTECTED; + echo self::MY_PRIVATE; // Fatal Error + } +} + +$myclass2 = new MyClass2; +echo MyClass2::MY_PUBLIC; // Works +$myclass2->foo2(); // Public and Protected work, not Private +?> +]]> + + + + + Visibility from other objects