Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99796 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67382 invoked from network); 6 Jul 2017 13:34:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jul 2017 13:34:09 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 84.19.169.162 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 84.19.169.162 mail.experimentalworks.net Received: from [84.19.169.162] ([84.19.169.162:58072] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2A/82-47109-F4C3E595 for ; Thu, 06 Jul 2017 09:34:08 -0400 Received: from kuechenschabe.fritz.box (ppp-46-244-162-200.dynamic.mnet-online.de [46.244.162.200]) by mail.experimentalworks.net (Postfix) with ESMTPSA id B50105E0D7; Thu, 6 Jul 2017 15:34:04 +0200 (CEST) Message-ID: <1499348044.19635.101.camel@schlueters.de> To: "Khawer ." , internals@lists.php.net Date: Thu, 06 Jul 2017 15:34:04 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Partial Classes From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Do, 2017-07-06 at 13:11 +0500, Khawer . wrote: > Partial Classes > > If we are using same class for different purposes we can extend it, > and add new properties and methods. But we will also have to use new > class name, when we create objects. C# provides a better concept > "Partial Classes". Why not to also implement it in PHP? > > Example: > > Partial Class abc { > >   public function sayhi() { >    echo "Hi"; >   } > > } > > Partial Class abc { > >   public function sayhello() { >    echo "Hello"; >   } > > } My understanding is that C# mostly uses this for GUI stuff where forms/widgets are designed in a visual editor and code is written in text. By using partial classes those can be in different files, thus developers don't touch generated files. Except for that a need for splitting this up indicates a design issue to me. Like a class doing too many things. PHP has traits which you eventually can use to emulate such a system in a more explicit way. http://php.net/traits > Q: What will happen if both classes contain same method names? > A: We will show error method already exists. > > Q: Will it break any existing code? > A: No, there will be no impact on any existing coding because we are > not changing anything. It would break usage of "partial" which is not a keywor, yet. johannes