Skip to content

Commit

Permalink
Merge pull request reeze#3 from reeze/master
Browse files Browse the repository at this point in the history
merge update
  • Loading branch information
zither committed Jan 15, 2015
2 parents 08b717c + 9809ddd commit b82ec2f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion book/chapt04/04-03-function-call.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## 函数的调用
函数被调用需要一些基本的信息,比如函数的名称,参数以及函数的定义(也就是函数的具体执行内容),
从我们开发者的角度来看,定义了一个函数我们在执行的时候自然知道这个函数叫什么名字,
以及调用的时候给传递了什么参数、函数的操作内容。但是对于Zend引擎不能像我们这样能“看懂”php源代码,
以及调用的时候给传递了什么参数、函数的操作内容。但是对于Zend引擎不能像我们这样能“看懂”php源代码,
它需要对代码进行处理以后才能执行。我们还是从以下两个小例子开始:

[php]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ the final modifier is allowed only for methods and classes in ..
public static function __get();
}

若运行这段代码,则会显示Warning:Warning: The magic method __get() must have public visibility and cannot be static in
若运行这段代码,则会显示: Warning: The magic method __get() must have public visibility and cannot be static in

这段编译检测在zend_do_begin_function_declaration函数中对应的源码如下:

Expand Down
4 changes: 2 additions & 2 deletions book/chapt05/05-03-class-visibility.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ PHP提供了public、protected及private三个层次访问控制。这和其他
// ...省略

如此,就将访问控制的相关参数传递给了将要执行的中间代码。
假如我们先现在有下面一段代码
假如我们现在有下面一段代码

[php]
class Tipi{
Expand Down Expand Up @@ -155,7 +155,7 @@ PHP提供了public、protected及private三个层次访问控制。这和其他
在doSth()方法中,我们要访问$b对象的属性money,这是Zend引擎检查我们能否访问$b对象的这个属性,
这是Zend赢取获取$b对象的类,以及要访问的属性信息,首先要看看这个属性是否为public,公开的话直接访问就好了。
如果是protected的则继续调用zend_check_protected()函数检查,因为涉及到该类的父类,这里不继续跟这个函数了,
看看是private的情况下是什么情况,在函数doSth()执行的时候,这时的EG(scope)指向的正是类A,ce变量值得就是变量$b的类,
看看是private的情况下是什么情况,在函数doSth()执行的时候,这时的EG(scope)指向的正是类A,ce的变量值就是变量$b的类,
而$b的类就是类A,这样检查就判断成功返回1,也就表示可以访问。

至于成员函数的检查规则类似,就留给读者自己去探索了。
4 changes: 2 additions & 2 deletions book/chapt05/05-04-class-inherit-abstract.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ PHP内核将类的继承实现放在了"编译阶段",因此使用VLD生成中
$context->run();

$cat = new Cat();
$context = new Context();
$context = new Context($cat);
$context->run();

上面是策略模式示例性的简单实现。对于不同的动物,其跑的方式不一样,
Expand Down Expand Up @@ -262,7 +262,7 @@ zend_do_begin_function_declaration函数。在此函数中有如下代码:


抽象类,接口,普通类都是保存在zend_class_entry结构体中,他们只通过一个标志字段来区分,
抽象类和接口还有一个共性:无法实例化。那我们看看Zend在那里限制的。要实例化一个对象我们只能使用new关键字来进行。
抽象类和接口还有一个共性:无法实例化。那我们看看Zend在哪里限制的。要实例化一个对象我们只能使用new关键字来进行。
下面是执行new是进行的操作:

[c]
Expand Down

0 comments on commit b82ec2f

Please sign in to comment.