Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:代码真干净, 一行注释都没有
<?php namespace mvc; require 'Model.php'; require 'View.php'; class Container1 { protected $instance = []; public function bind($alias, \Closure $process) { $this->instance[$alias] = $process; } public function make($alias, $params=[]) { return call_user_func_array($this->instance[$alias], []); } } $container = new Container1(); $container->bind('model', function () {return new Model();}); $container->bind('view', function () {return new View();}); class Facade { protected static $container = null; protected static $data = []; public static function initialize(Container1 $container) { static::$container = $container; } public static function getData() { static::$data = static::$container->make('model')->getData(); } public static function fetch() { return static::$container->make('view')->fetch(static::$data); } } class Student extends Facade { } class Controller5 { public function __construct(Container1 $container) { Student::initialize($container); } public function index() { Student::getData(); return Student::fetch(); } } $controller = new Controller5($container); echo $controller->index();