svn: /phpdoc/kr/trunk/language/oop5/ inheritance.xml interfaces.xml
[email protected] (Yu Ilho)
| Newsgroups | php.doc.kr |
|---|---|
| Message-ID | <[email protected]> |
acidd15 Sat, 20 Dec 2014 05:47:26 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=335318
Log:
rollback to en to trace the build problem of kr document.
Changed paths:
U phpdoc/kr/trunk/language/oop5/inheritance.xml
U phpdoc/kr/trunk/language/oop5/interfaces.xml
svn-diffs-335318.txt
(text/x-diff, 10.4 KB)
Modified: phpdoc/kr/trunk/language/oop5/inheritance.xml
===================================================================
--- phpdoc/kr/trunk/language/oop5/inheritance.xml 2014-12-20 02:14:41 UTC (rev 335317)
+++ phpdoc/kr/trunk/language/oop5/inheritance.xml 2014-12-20 05:47:26 UTC (rev 335318)
@@ -1,33 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 334699 Maintainer: acidd15 Status: ready -->
-<!-- Reviewed: no -->
-
<sect1 xml:id="language.oop5.inheritance" xmlns="http://docbook.org/ns/docbook">
- <title>객체 상속</title>
+ <title>Object Inheritance</title>
<para>
- 상속은 정착된 프로그래밍 원칙이며, PHP는 이 원칙을 객체모델에서 사용하고 있습니다.
- 이 원칙은 많은 클래스와 객체들을 연관짓는 방법에 영향을 미칩니다.
+ Inheritance is a well-established programming principle, and PHP makes use
+ of this principle in its object model. This principle will affect the way
+ many classes and objects relate to one another.
</para>
<para>
- 예를 들면, class 를 확장했을때, subcalss 는 부모의 클래스로부터 모든 public, protected 메서드를 상속받게 됩니다.
- 자식 클래스가 메서드를 재정의 하지 않는한, 원래 기능이 유지 됩니다.
+ For example, when you extend a class, the subclass inherits all of the
+ public and protected methods from the parent class. Unless a class overrides
+ those methods, they will retain their original functionality.
</para>
<para>
- 상속은 추상화된 기능을 정의하는데 유용합니다. 그리고, 공유된 기능을 위해 비슷한 객체들마다 기능을 재정의 하는 수고를 덜어줍니다.
+ This is useful for defining and abstracting functionality, and permits the
+ implementation of additional functionality in similar objects without the
+ need to reimplement all of the shared functionality.
</para>
<note>
<para>
- 자동로딩이 사용되지 않는한, 클래스는 사용되기 이전에 정의되어 있어야 합니다.
- 클래스가 다른것으로 확장된다면, 자식 클래스 구조보다 부모클래스가 앞서 선언되어 있어야 합니다.
- 이 규칙은 다른 클래스과 인터페이스를 상속받는 클래스들에게도 적용됩니다.
+ Unless autoloading is used, then classes must be defined before they are
+ used. If a class extends another, then the parent class must be declared
+ before the child class structure. This rule applies to classes that inherit
+ other classes and interfaces.
</para>
</note>
<sect2 xml:id="language.oop5.inheritance.examples">
<example xml:id="language.oop5.inheritance.examples.ex1">
- <title>상속 예제</title>
+ <title>Inheritance Example</title>
<programlisting role="php">
<![CDATA[
<?php
Modified: phpdoc/kr/trunk/language/oop5/interfaces.xml
===================================================================
--- phpdoc/kr/trunk/language/oop5/interfaces.xml 2014-12-20 02:14:41 UTC (rev 335317)
+++ phpdoc/kr/trunk/language/oop5/interfaces.xml 2014-12-20 05:47:26 UTC (rev 335318)
@@ -1,70 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
-<!-- EN-Revision: 334698 Maintainer: acidd15 Status: ready -->
-<!-- Reviewed: no -->
-
<sect1 xml:id="language.oop5.interfaces" xmlns="http://docbook.org/ns/docbook">
- <title>객체 인터페이스</title>
+ <title>Object Interfaces</title>
<para>
- 객체 인터페이스는 클래스가 반드시 구현해야할 메서드를 해당 메서드가 어떻게 동작하는지 알 필요없이 지정하는 코드를 만들수 있습니다.
+ Object interfaces allow you to create code which specifies which methods a
+ class must implement, without having to define how these methods are
+ handled.
</para>
<para>
- 인터페이스는 <literal>interface</literal> 키워드를 사용해 정의할 수 있습니다. 일반클래스와 방식이 같지만, 메서드의 구현부가 정의되지 않음이 다릅니다.
+ Interfaces are defined using the <literal>interface</literal> keyword, in the same way as a
+ standard class, but without any of the methods having their contents
+ defined.
</para>
<para>
- interface 내부의 모든 메서드는 반드시 public 이어야만 합니다; 이것은 interface 의 특성입니다.
+ All methods declared in an interface must be public; this is the nature of an
+ interface.
</para>
<sect2 xml:id="language.oop5.interfaces.implements">
- <title><literal>구현</literal></title>
+ <title><literal>implements</literal></title>
<para>
- 인터페이스를 구현하기 위해서는, <literal>implements</literal> 키워드가 사용됩니다.
- 인터페이스 내부의 모든 메서드는 클래스 안에 모두 구현되어야 합니다.; 그렇지 않을경우 fata error에 마주하게 됩니다.
- 각각의 인터페이스를 쉼표로 구분하여 지정하면 클래스는 하나 이상의 인터페이스를 구현할수 있습니다.
+ To implement an interface, the <literal>implements</literal> operator is used.
+ All methods in the interface must be implemented within a class; failure to do
+ so will result in a fatal error. Classes may implement more than one interface
+ if desired by separating each interface with a comma.
</para>
<note>
<para>
- PHP 5.3.9 이전에서는, 두개의 인터페이스가 같은 메서드명을 정의하고 있을 경우 클래스를 구현할수 없었습니다.
- 모호하기 때문입니다. 최근의 버전에서는 메서드명이 같더라도 메서드의 시그너쳐(메서드 정의 형태)가 완전히 동일할 경우에는
- 구현이 가능합니다.
+ Prior to PHP 5.3.9, a class could not implement two interfaces that
+ specified a method with the same name, since it would cause ambiguity.
+ More recent versions of PHP allow this as long as the duplicate methods
+ have the same signature.
</para>
</note>
<note>
<para>
- 인터페이스도 클래스처럼 <link linkend="language.oop5.inheritance">extends</link> 키워드를 사용해 확장이 가능합니다.
+ Interfaces can be extended like classes using the <link linkend="language.oop5.inheritance">extends</link>
+ operator.
</para>
</note>
<note>
<para>
- 인터페이스를 구현하는 클래스는 인터페이스에 정의된 메서드와 완전히 동일한 메서드 시그너쳐를 사용해야 합니다.
- 그렇지 않을 경우 fatal error 에 마주할 것입니다.
+ The class implementing the interface must use the exact same method
+ signatures as are defined in the interface. Not doing so will result in a
+ fatal error.
</para>
</note>
</sect2>
<sect2 xml:id="language.oop5.interfaces.constants">
- <title><literal>상수</literal></title>
+ <title><literal>Constants</literal></title>
<para>
- 인터페이스가 상수를 가지는것이 가능합니다.
- 인터페이스 상수는 <link linkend="language.oop5.constants">클래스 상수</link>와 완전히 동일하게 동작합니다.
- 하지만, 상속받은 클래스/인터페이스 에서 재정의 할수 없습니다.
+ It's possible for interfaces to have constants. Interface constants works exactly
+ like <link linkend="language.oop5.constants">class constants</link> except
+ they cannot be overridden by a class/interface that inherits them.
</para>
</sect2>
<sect2 xml:id="language.oop5.interfaces.examples">
&reftitle.examples;
<example xml:id="language.oop5.interfaces.examples.ex1">
- <title>인터페이스 예제</title>
+ <title>Interface example</title>
<programlisting role="php">
<![CDATA[
<?php
-// 인터페이스 선언 'iTemplate'
+// Declare the interface 'iTemplate'
interface iTemplate
{
public function setVariable($name, $var);
public function getHtml($template);
}
-// 인터페이스 구현
-// 동작합니다.
+// Implement the interface
+// This will work
class Template implements iTemplate
{
private $vars = array();
@@ -84,7 +90,7 @@
}
}
-// 동작하지 않습니다.
+// This will not work
// Fatal error: Class BadTemplate contains 1 abstract methods
// and must therefore be declared abstract (iTemplate::getHtml)
class BadTemplate implements iTemplate
@@ -101,7 +107,7 @@
</programlisting>
</example>
<example xml:id="language.oop5.interfaces.examples.ex2">
- <title>확장가능한 인터페이스</title>
+ <title>Extendable Interfaces</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -115,7 +121,7 @@
public function baz(Baz $baz);
}
-// 동작합니다.
+// This will work
class c implements b
{
public function foo()
@@ -127,7 +133,7 @@
}
}
-// 동작하지 않고 fatal error 가 납니다.
+// This will not work and result in a fatal error
class d implements b
{
public function foo()
@@ -143,7 +149,7 @@
</programlisting>
</example>
<example xml:id="language.oop5.interfaces.examples.ex3">
- <title>인터페이스 다중 상속</title>
+ <title>Multiple interface inheritance</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -181,7 +187,7 @@
</programlisting>
</example>
<example xml:id="language.oop5.interfaces.examples.ex4">
- <title>인터페이스 상수</title>
+ <title>Interfaces with constants</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -194,8 +200,8 @@
echo a::b;
-// 원하는데로 동작하지 않습니다.
-// 왜냐하면 재정의를 허용하지 않기 때문입니다.
+// This will however not work because it's not allowed to
+// override constants.
class b implements a
{
const b = 'Class constant';
@@ -205,9 +211,10 @@
</programlisting>
</example>
<para>
- 인터페이스에서, 타입힌팅을 사용하면, 특정 객체에 특정 메서드를 가지게 하는 좋은 방법을 제공합니다.
- <link linkend="language.operators.type">instanceof</link> 와
- <link linkend="language.oop5.typehinting">타입 힌트</link>를 보시기 바랍니다.
+ An interface, together with type-hinting, provides a good way to make sure
+ that a particular object contains particular methods. See
+ <link linkend="language.operators.type">instanceof</link> operator and
+ <link linkend="language.oop5.typehinting">type hinting</link>.
</para>
</sect2>