Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
CanProxyAssertion.php
001 <?php
002 /*
003 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
004 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
005 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
006 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
007 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
008 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
009 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
010 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
011 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
012 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
013 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
014 *
015 * This software consists of voluntary contributions made by many individuals
016 * and is licensed under the MIT license.
017 */
018
019 namespace ProxyManager\ProxyGenerator\Assertion;
020
021 use BadMethodCallException;
022 use ProxyManager\Exception\InvalidProxiedClassException;
023 use ReflectionClass;
024 use ReflectionMethod;
025
026 /**
027 * Assertion that verifies that a class can be proxied
028 *
029 * @author Marco Pivetta <ocramius@gmail.com>
030 * @license MIT
031 */
032 final class CanProxyAssertion
033 {
034 /**
035 * Disabled constructor: not meant to be instantiated
036 *
037 * @throws BadMethodCallException
038 */
039 public function __construct()
040 {
041 throw new BadMethodCallException('Unsupported constructor.');
042 }
043
044 /**
045 * @param ReflectionClass $originalClass
046 * @param bool $allowInterfaces
047 *
048 * @throws InvalidProxiedClassException
049 */
050 public static function assertClassCanBeProxied(ReflectionClass $originalClass, $allowInterfaces = true)
051 {
052 self::isNotFinal($originalClass);
053 self::hasNoAbstractProtectedMethods($originalClass);
054
055 if (! $allowInterfaces) {
056 self::isNotInterface($originalClass);
057 }
058 }
059
060 /**
061 * @param ReflectionClass $originalClass
062 *
063 * @throws InvalidProxiedClassException
064 */
065 private static function isNotFinal(ReflectionClass $originalClass)
066 {
067 if ($originalClass->isFinal()) {
068 throw InvalidProxiedClassException::finalClassNotSupported($originalClass);
069 }
070 }
071
072 /**
073 * @param ReflectionClass $originalClass
074 *
075 * @throws InvalidProxiedClassException
076 */
077 private static function hasNoAbstractProtectedMethods(ReflectionClass $originalClass)
078 {
079 $protectedAbstract = array_filter(
080 $originalClass->getMethods(),
081 function (ReflectionMethod $method) {
082 return $method->isAbstract() && $method->isProtected();
083 }
084 );
085
086 if ($protectedAbstract) {
087 throw InvalidProxiedClassException::abstractProtectedMethodsNotSupported($originalClass);
088 }
089 }
090
091 /**
092 * @param ReflectionClass $originalClass
093 *
094 * @throws InvalidProxiedClassException
095 */
096 private static function isNotInterface(ReflectionClass $originalClass)
097 {
098 if ($originalClass->isInterface()) {
099 throw InvalidProxiedClassException::interfaceNotSupported($originalClass);
100 }
101 }
102 }
103