【opencart3源码分析】代理类proxy.php

<?php
/**
 * @package		OpenCart
 * @author		Daniel Kerr
 * @copyright	Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
 * @license		https://opensource.org/licenses/GPL-3.0
 * @link		https://www.opencart.com
*/

/**
* 代理类
*/
class Proxy {
    /**
     * 
     * 获取
     * @param	string	$key
     */	
	public function &__get($key) {
		return $this->{$key};
	}	

    /**
     * 
     * 设置
     * @param	string	$key
	 * @param	string	$value
     */	
	public function __set($key, $value) {
		 $this->{$key} = $value;
	}

    /**
     * 调用
     * @param $key
     * @param $args
     * @return mixed
     */
	public function __call($key, $args) {
		if (isset($this->{$key})) {
			return call_user_func_array($this->{$key}, $args);
		} else {
		    // 追踪代码调用信息
			$trace = debug_backtrace();

			exit('<b>Notice</b>:  Undefined property: Proxy::' . $key . ' in <b>' . $trace[1]['file'] . '</b> on line <b>' . $trace[1]['line'] . '</b>');
		}
	}
}

猜你喜欢

转载自blog.csdn.net/qq2942713658/article/details/81351331
今日推荐