php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68876 Access specifier for class
Submitted: 2015-01-21 14:13 UTC Modified: 2017-08-05 04:53 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: kulinchoksi at gmail dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: 5.6.4 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
36 - 8 = ?
Subscribe to this entry?

 
 [2015-01-21 14:13 UTC] kulinchoksi at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.oop5.visibility
---

In recent versions of PHP, we have introduced feature of namespaces.

I was thinking of the scenario where we can specify access specifier/visibility of classes also.

We may allow to access instantiation of the class inside namespace only if it's private.
Although I'm not sure about allowing the objects of that class outside the namespace but I think, it should be allowed in any case.

Example of encapsulating classes in namespace could be:
- Different payment classes may represent different payment methods.
- A payment manager class can only access the payment factory which will decide to instantiate particular type of payment class.
- In application, we would access payment class via manager class only. So manager class can behave like a public interface of payment entities.

Example:

namespace application/payment;

abstract class Payment {
    ...
}

private class TypePaypal extends Payment {
    ...
}

private class TypePaymentInAdvance extends Payment {
    ...
}

class PaymentFactory {
    ...
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-21 14:35 UTC] nikic@php.net
-Package: PHP Language Specification +Package: *General Issues
 [2015-02-24 23:10 UTC] edgar dot r dot sandi at gmail dot com
I think that you maybe is asking by:

https://github.com/php/php-src/pull/947

I'm right?

cross your fingers!

cheers
 [2017-08-05 04:53 UTC] stas@php.net
-Status: Open +Status: Suspended
 [2017-08-05 04:53 UTC] stas@php.net
Thank you for your interest in PHP and for submitting a feature request. Please be aware that due to the magnitude of change this request requires, it would be necessary to discuss it on PHP Internals list (internals@lists.php.net) as an RFC. Please read the guide about creating RFCs here:
https://wiki.php.net/rfc/howto
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the Internals list (http://php.net/mailing-lists.php) and/or solicit help from one of the experienced developers. 

Please to not consider this comment as a negative view on the merits of your proposal - every proposal which requires changes of certain magnitude, even the very successful and widely supported ones, must be done through the RFC process. This helps make the process predictable, transparent and accessible to all developers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 01:01:31 2024 UTC