Server : nginx/1.20.2 System : Linux VM-4-4-centos 3.10.0-1160.66.1.el7.x86_64 #1 SMP Wed May 18 16:02:34 UTC 2022 x86_64 User : www ( 1000) PHP Version : 5.6.40 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /www/wwwroot/greatapp.cn/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/Node/ |
<?php /* * This file is part of the Prophecy. * (c) Konstantin Kudryashov <ever.zet@gmail.com> * Marcello Duarte <marcello.duarte@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Prophecy\Doubler\Generator\Node; use Prophecy\Exception\Doubler\MethodNotExtendableException; use Prophecy\Exception\InvalidArgumentException; /** * Class node. * * @author Konstantin Kudryashov <ever.zet@gmail.com> */ class ClassNode { private $parentClass = 'stdClass'; private $interfaces = array(); private $properties = array(); private $unextendableMethods = array(); /** * @var MethodNode[] */ private $methods = array(); public function getParentClass() { return $this->parentClass; } /** * @param string $class */ public function setParentClass($class) { $this->parentClass = $class ?: 'stdClass'; } /** * @return string[] */ public function getInterfaces() { return $this->interfaces; } /** * @param string $interface */ public function addInterface($interface) { if ($this->hasInterface($interface)) { return; } array_unshift($this->interfaces, $interface); } /** * @param string $interface * * @return bool */ public function hasInterface($interface) { return in_array($interface, $this->interfaces); } public function getProperties() { return $this->properties; } public function addProperty($name, $visibility = 'public') { $visibility = strtolower($visibility); if (!in_array($visibility, array('public', 'private', 'protected'))) { throw new InvalidArgumentException(sprintf( '`%s` property visibility is not supported.', $visibility )); } $this->properties[$name] = $visibility; } /** * @return MethodNode[] */ public function getMethods() { return $this->methods; } public function addMethod(MethodNode $method) { if (!$this->isExtendable($method->getName())){ $message = sprintf( 'Method `%s` is not extendable, so can not be added.', $method->getName() ); throw new MethodNotExtendableException($message, $this->getParentClass(), $method->getName()); } $this->methods[$method->getName()] = $method; } public function removeMethod($name) { unset($this->methods[$name]); } /** * @param string $name * * @return MethodNode|null */ public function getMethod($name) { return $this->hasMethod($name) ? $this->methods[$name] : null; } /** * @param string $name * * @return bool */ public function hasMethod($name) { return isset($this->methods[$name]); } /** * @return string[] */ public function getUnextendableMethods() { return $this->unextendableMethods; } /** * @param string $unextendableMethod */ public function addUnextendableMethod($unextendableMethod) { if (!$this->isExtendable($unextendableMethod)){ return; } $this->unextendableMethods[] = $unextendableMethod; } /** * @param string $method * @return bool */ public function isExtendable($method) { return !in_array($method, $this->unextendableMethods); } }