fix linebreak

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@271867 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Carola 'Sammy' Kummert 2008-12-25 17:24:43 +00:00
parent 31a79096d2
commit 73ec6ee786

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<sect1 xml:id="language.oop5.late-static-bindings" xmlns="http://docbook.org/ns/docbook">
<title>Late Static Bindings</title>
<para>
@ -9,19 +9,19 @@
<para>
This feature was named "late static bindings" with an internal perspective in
mind. "Late binding" comes from the fact that <literal>static::</literal>
will no longer be resolved using the class where the method is defined but
mind. "Late binding" comes from the fact that <literal>static::</literal>
will no longer be resolved using the class where the method is defined but
it will rather be computed using runtime information.
It was also called a "static binding" as it can be used for (but is not
It was also called a "static binding" as it can be used for (but is not
limited to) static method calls.
</para>
<sect2 xml:id="language.oop5.late-static-bindings.self">
<title>Limitations of <literal>self::</literal></title>
<para>
Static references to the current class like <literal>self::</literal> or
<literal>__CLASS__</literal> are resolved using the class in which the
Static references to the current class like <literal>self::</literal> or
<literal>__CLASS__</literal> are resolved using the class in which the
function belongs, as in where it was defined:
</para>
<example>
@ -34,18 +34,18 @@ class A {
echo __CLASS__;
}
public static function test() {
self::who();
}
}
self::who();
}
}
class B extends A {
class B extends A {
public static function who() {
echo __CLASS__;
}
}
}
}
B::test();
?>
?>
]]>
</programlisting>
&example.outputs;
@ -57,16 +57,16 @@ A
</example>
</sect2>
<sect2 xml:id="language.oop5.late-static-bindings.usage">
<title>Late Static Bindings' usage</title>
<para>
Late static bindings tries to solve that limitation by introducing a
Late static bindings tries to solve that limitation by introducing a
keyword that references the class that was initially called at runtime.
Basically, a keyword that would allow you to reference
<literal>B</literal> from <literal>test()</literal> in the previous
example. It was decided not to introduce a new keyword but rather use
Basically, a keyword that would allow you to reference
<literal>B</literal> from <literal>test()</literal> in the previous
example. It was decided not to introduce a new keyword but rather use
<literal>static</literal> that was already reserved.
</para>
@ -80,18 +80,18 @@ class A {
echo __CLASS__;
}
public static function test() {
static::who(); // Here comes Late Static Bindings
}
}
static::who(); // Here comes Late Static Bindings
}
}
class B extends A {
class B extends A {
public static function who() {
echo __CLASS__;
}
}
}
}
B::test();
?>
?>
]]>
</programlisting>
&example.outputs;
@ -104,7 +104,7 @@ B
<note>
<para>
<literal>static::</literal> does not work like <literal>$this</literal> for
static methods! <literal>$this-></literal> follows the rules of
static methods! <literal>$this-></literal> follows the rules of
inheritance while <literal>static::</literal> doesn't. This difference is
detailed later on this manual page.
</para>
@ -140,7 +140,7 @@ class TestParent {
$o = new TestChild;
$o->test();
?>
?>
]]>
</programlisting>
&example.outputs;
@ -153,7 +153,10 @@ TestParent
</example>
<note>
<para>
Late static bindings' resolution will stop at a fully resolved static call with no fallback. On the other hand, static calls using keywords like <literal>parent::</literal> or <literal>self::</literal> will forward the calling information.
Late static bindings' resolution will stop at a fully resolved static call
with no fallback. On the other hand, static calls using keywords like
<literal>parent::</literal> or <literal>self::</literal> will forward the
calling information.
</para>
<example>
<title>Forwarding and non-forwarding calls</title>
@ -164,7 +167,7 @@ class A {
public static function foo() {
static::who();
}
public static function who() {
echo __CLASS__."\n";
}
@ -188,7 +191,7 @@ class C extends B {
}
C::test();
?>
?>
]]>
</programlisting>
&example.outputs;
@ -205,10 +208,10 @@ C
<sect2 xml:id="language.oop5.late-static-bindings.edge-cases">
<title>Edge cases</title>
<para>
There are lots of different ways to trigger a method call in PHP, like
There are lots of different ways to trigger a method call in PHP, like
callbacks or magic methods. As late static bindings base their resolution
on runtime information, it might give unexpected results in so-called edge
cases.
on runtime information, it might give unexpected results in so-called edge
cases.
</para>
<example>
<title>Late static bindings inside magic methods</title>
@ -235,7 +238,7 @@ class B extends A {
$b = new B;
$b->foo;
?>
?>
]]>
</programlisting>
&example.outputs;