From 6f7605093767a04161be2c0b36db1e3168996f43 Mon Sep 17 00:00:00 2001 From: Ahmad Zafrullah Date: Tue, 2 Feb 2016 07:34:19 +0700 Subject: [PATCH] [php/id-id] updates for ID translation --- id-id/php-id.html.markdown | 239 ++++++++++++++++++------------------- 1 file changed, 118 insertions(+), 121 deletions(-) diff --git a/id-id/php-id.html.markdown b/id-id/php-id.html.markdown index 491a190e..34d6e5f5 100644 --- a/id-id/php-id.html.markdown +++ b/id-id/php-id.html.markdown @@ -567,34 +567,34 @@ echo $kelas_saya->properti; // => "publik" echo $kelas_saya->propertiInstansi; // => "Sebuah properti instansi" $kelas_saya->methodSaya(); // => "KelasSaya" -// Extend classes using "extends" -class MyOtherClass extends MyClass +// Menurunkan kelas menggunakan kata kunci "extends" +class KelasSayaLainnya extends KelasSaya { - function printProtectedProperty() + function tampilkanPropertiTerlindungi() { - echo $this->prot; + echo $this->properti; } - // Override a method - function myMethod() + // "override" terhadap sebuah method + function methodSaya() { - parent::myMethod(); - print ' > MyOtherClass'; + parent::methodSaya(); + print ' > KelasSayaLainnya'; } } -$my_other_class = new MyOtherClass('Instance prop'); -$my_other_class->printProtectedProperty(); // => Prints "protected" -$my_other_class->myMethod(); // Prints "MyClass > MyOtherClass" +$kelas_saya_lainnya = new KelasSayaLainnya('Instansiasi properti'); +$kelas_saya_lainnya->tampilkanPropertiTerlindung(); // => Menampilkan "terlindungi" +$kelas_saya_lainnya->methodSaya(); // Menampilkan "KelasSaya > KelasSayaLainnya" -final class YouCannotExtendMe +final class SayaTidakBisaDiturunkan { } -// You can use "magic methods" to create getters and setters -class MyMapClass +// Gunakan method ajaib (magic method) untuk membuat fungsi "getters" dan "setters" +class PetaKelasSaya { - private $property; + private $properti; public function __get($key) { @@ -607,127 +607,125 @@ class MyMapClass } } -$x = new MyMapClass(); -echo $x->property; // Will use the __get() method -$x->property = 'Something'; // Will use the __set() method +$x = new PetaKelasSaya(); +echo $x->properti; // akan memanggil method __get() +$x->properti = 'Sesuatu'; // akan memanggil method __set(); -// Classes can be abstract (using the abstract keyword) or -// implement interfaces (using the implements keyword). -// An interface is declared with the interface keyword. +// Kelas dapat dijadikan abstrak (menggunakan kata kunci "abstract"), atau +// meng-implementasikan interfaces (menggunakan kata kunci "implements"). +// Sebuah interface dideklarasikan dengan perintah "interface". -interface InterfaceOne +interface InterfaceSatu { - public function doSomething(); + public function kerjakanSesuatu(); } -interface InterfaceTwo +interface InterfaceDua { - public function doSomethingElse(); + public function kerjakanYangLain(); } -// interfaces can be extended -interface InterfaceThree extends InterfaceTwo +// interface dapat diturunkan +interface InterfaceTiga extends InterfaceDua { - public function doAnotherContract(); + public function kerjakanYangBerbeda(); } -abstract class MyAbstractClass implements InterfaceOne +abstract class KelasAbstrakSaya implements InterfaceSatu { - public $x = 'doSomething'; + public $x = 'kerjakanSesuatu'; } -class MyConcreteClass extends MyAbstractClass implements InterfaceTwo +class KelasKongkritSaya extends KelasAbstrakSaya implements InterfaceTwo { - public function doSomething() + public function kerjakanSesuatu() { echo $x; } - public function doSomethingElse() + public function kerjakanYangLain() { - echo 'doSomethingElse'; + echo 'kerjakanYangLain'; } } - -// Classes can implement more than one interface -class SomeOtherClass implements InterfaceOne, InterfaceTwo +// Kelas dapat diimplementasikan pada banyak interface +class KelasLainnya implements InterfaceSatu, InterfaceDua { - public function doSomething() + public function kerjakanSesuatu() { - echo 'doSomething'; + echo 'kerjakanSesuatu'; } - public function doSomethingElse() + public function kerjakanYangLain() { - echo 'doSomethingElse'; + echo 'kerjakanYangLain'; } } /******************************** - * Traits + * Sifat (Traits) */ -// Traits are available from PHP 5.4.0 and are declared using "trait" +// Traits mulai tersedia sejak PHP 5.4.0 dan dideklarasikan menggunakan kata kunci "trait" -trait MyTrait +trait TraitSaya { - public function myTraitMethod() + public function methodTraitSaya() { - print 'I have MyTrait'; + print 'Saya menggunakan Trait'; } } -class MyTraitfulClass +class KelasTraitSaya { - use MyTrait; + use TraitSaya; } -$cls = new MyTraitfulClass(); -$cls->myTraitMethod(); // Prints "I have MyTrait" +$kls = new KelasTraitSaya(); +$kls->methodTraitSaya(); // menampilkan "Saya menggunakan Trait" /******************************** * Namespaces */ -// This section is separate, because a namespace declaration -// must be the first statement in a file. Let's pretend that is not the case +// Bagian ini telah dibatasi, karena deklarasi "namespace" +// karena harus ditempatkan diawal dokumen.