Req #71723 [Opn->Sus]: Ability to create internal classes/functions

From: Date: Sun, 27 Mar 2016 12:32:55 +0000
Subject: Req #71723 [Opn->Sus]: Ability to create internal classes/functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200158@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71723&edit=1 ID: 71723 Updated by: krakjoe@php.net Reported by: untuned20 at gmail dot com Summary: Ability to create internal classes/functions -Status: Open +Status: Suspended Type: Feature/Change Request Package: *Programming Data Structures PHP Version: Irrelevant Block user comment: N Private report: N New Comment: For this kind of change, an RFC is required. Please see: https://wiki.php.net/rfc/howto Previous Comments: ------------------------------------------------------------------------ [2016-03-06 15:59:01] untuned20 at gmail dot com Description: ------------ The ability to make classes/functions "internal" which would make them only instantiatable and/or callable from within the current root namespace. This would be helpful when creating a library where you only want classes to be available to other classes within the library. As to someone using the library they wouldn't be able to initiate the class in the library or use it outside of the namespace. Test script: --------------- namespace RootSpace\SubSpace; internal class TestClass {} --- namespace RootSpace\OtherSpace; use RootSpace\SubSpace\TestClass; class AnotherClass { public function test(){ $class = new TestClass(); } } --- namespace MySpace; use RootSpace\SubSpace\TestClass; class MyClass { public function test(){ $class = new TestClass(); } } Expected result: ---------------- "AnotherClass" should create an instance of TestClass it "AnotherClass::test()" is called because they share the same root space "RootSpace". "MyClass" should throw an error when "MyClass::test()" is called because it isn't in the root space "RootSpace" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=71723&edit=1

« previous php.bugs (#200158) next »