rfc:namespace-visibility

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
rfc:namespace-visibility [2018/07/18 21:27] – created mdwheelerfc:namespace-visibility [2018/07/18 21:39] mdwheele
Line 89: Line 89:
  
   - Public declarations will be visible from anywhere, which is the current behaviour. If no modifier is supplied, public shall be the default to maintain backwards compatibility with this behaviour.   - Public declarations will be visible from anywhere, which is the current behaviour. If no modifier is supplied, public shall be the default to maintain backwards compatibility with this behaviour.
-  - Protected declarations will be visible from anywhere that *shares* a higher-level namespace with the target of the visibility modifier. For example, ``Vendor\SampleClassand `Vendor\Deeper\SampleClassshare `Vendor`.+  - Protected declarations will be visible from anywhere that **shares** a higher-level namespace with the target of the visibility modifier. For example, ''Vendor\SampleClass'' and ''Vendor\Deeper\SampleClass'' share ''Vendor''.
   - Private declarations will only be visible from the namespace in which they are declared.   - Private declarations will only be visible from the namespace in which they are declared.
  
Line 153: Line 153:
 </code> </code>
  
-Because ''\Example\Nested'' shares a parent-namespace with ''\Example\ProtectedClass'', it can instantiate the class through its ''protected'' namespace visibility. Instantiation of classes within functions and closures behaves no different than if executed at the root of the namespace. All that matters is the namespace that the code is executing *from* compared to the *target class* namespace and modifier.+Because ''\Example\Nested'' shares a parent-namespace with ''\Example\ProtectedClass'', it can instantiate the class through its ''protected'' namespace visibility. Instantiation of classes within functions and closures behaves no different than if executed at the root of the namespace. All that matters is the namespace that the code is executing **from** compared to the **target class** namespace and modifier.
  
 <code php> <code php>
Line 165: Line 165:
  
     new \Example\ProtectedClass();            // ILLEGAL     new \Example\ProtectedClass();            // ILLEGAL
-    (new Factory())->make();                  // ILLEGAL+    (new Factory())->make();                 // ILLEGAL
  
     new \Example\PublicClass();               // legal     new \Example\PublicClass();               // legal
rfc/namespace-visibility.txt · Last modified: 2018/07/18 21:42 by mdwheele