[PHP7] Add support for package private class, trait and interface

Consumes PR #931 

TBD together with RFC

Implementation progress:

* [x] Add lexical support for public classes, traits and interfaces
* [x] Make sure public classes, traits and interfaces are supported correctly
* [x] Add lexical support for private classes, traits and interfaces
* [x] Implement compile time checks for private extension and implementation
* [x] Implement run time check for private class instantiation
* [ ] Find a sponsor to review and help polish implementation
* [x] Implement `ReflectionClass::isPublic()` and `ReflectionClass::isPrivate()`
* [x] Implement `ReflectionClass::setAccessible()`

Add more tests coverage for:

ReflectionClass:

* [x] Add test for `ReflectionClass::isPublic()` with implicit value
* [x] Add test for `ReflectionClass::isPublic()` with explicit value
* [x] Add test for `ReflectionClass::isPrivate()` with explicit value
* [x] Add test for `ReflectionClass::setAccessible()`

Classes:

* [x] Top level private class, top level instantiation
* [x] Top level private class, top level class instantiation
* [x] Top level private class, top level class extension
* [x] Top level private class, different namespace class instantiation
* [x] Top level private class, different namespace class extension
* [x] Namespaced private class, top level instantiation
* [x] Namespaced private class, top level class instantiation
* [x] Namespaced private class, top level class extension
* [x] Namespaced private class, same namespace class instantiation
* [x] Namespaced private class, same namespace class extension
* [x] Namespaced private class, different namespace class instantiation
* [x] Namespaced private class, different namespace class extension
* [x] Any of the above test using autoloading

Interfaces:

* [x] Top level private interface, top level class implementation
* [x] Top level private interface, different namespace class implementation
* [x] Namespaced private interface, top level class implementation
* [x] Namespaced private interface, same namespace class implementation
* [x] Namespaced private interface, different namespace class implementation
* [x] Any of the above test using autoloading

Traits:

* [x] Top level private trait, top level class usage
* [x] Top level private trait, different namespace class usage
* [x] Namespaced private trait, top level class usage
* [x] Namespaced private trait, same namespace class usage
* [x] Namespaced private trait, different namespace class usage
* [x] Any of the above test using autoloading
Extremely disagree.
PHP is evolving, and developers should do so...

It was the same with the reggae \e operator or even ereg_*

It's natural that this "Class_With_Underscored_Name" represents a
"package" name and folders + class name are logically uppercase, as Juti
said: Unix deal in this way...
The same works with "ClassWithCamelCasedName"

Nowadays vendors are really committed to quality, we are not talking about
orphan libraries in PEAR...

Anyway, it's out of scope of this PR.

2014-12-13 12:33 GMT-05:00 Kubo2 <notifications@github.com>:
>
> In Zend/zend_inheritance.c
> <https://github.com/php/php-src/pull/947#discussion-diff-21789707>:
>
> >  		zend_error_noreturn(E_COMPILE_ERROR, "Class %s may not inherit from final class (%s)", ce->name->val, parent_ce->name->val);
> >  	}
> > +	if (parent_ce->ce_flags & ZEND_ACC_PRIVATE) {
> > +		/* Inspect if class and extended class are in the same namespace */
> > +		if (!(
> > +			strrchr(ce->name->val, '\\') != NULL &&
> > +			strrchr(parent_ce->name->val, '\\') != NULL &&
> > +			strncmp(ce->name->val, parent_ce->name->val, strrchr(ce->name->val, '\\') - ce->name->val + 1) == 0
>
> @kinncj <https://github.com/kinncj> No, it isn't related to BC. But in
> PHP world, there is a big number of programmers, who does not all have the
> same conventions (especially if one writes Class_With_Underscored_Name,
> other ClassWithCamelCasedName but someone else
> Classwithfulllowercasenameexceptfirstcharacter) and if you are
> instantiating such third-party classes, it is a good thing to at least
> partially keep your own or your core's conventions (because the code looks
> much better).
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/php/php-src/pull/947/files#r21789707>.
>


-- 
*---------------------------------------------------*
*             Kinn Coelho Julião*
*
<http://www.zend.com/en/yellow-pages#show-ClientCandidateID=ZEND013483>*

*               About.me/kinncj <http://About.me/kinncj>*
*---------------------------------------------------*