Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91000 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56984 invoked from network); 28 Jan 2016 19:18:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2016 19:18:02 -0000 Authentication-Results: pb1.pair.com header.from=fontanalorenz@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=fontanalorenz@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: fontanalorenz@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wm0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:32977] helo=mail-wm0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/20-53831-8696AA65 for ; Thu, 28 Jan 2016 14:18:01 -0500 Received: by mail-wm0-f49.google.com with SMTP id l66so38954963wml.0 for ; Thu, 28 Jan 2016 11:18:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=X9aznUYlsdDB+CHRwWhlHJaTbkkC6Pl8KhTDDXd8lG0=; b=E+l+YFCI7H+MP3NYdPi64qktL0vHNFI+IhKnvlKMOGYPiQEs3dO5VQUQyyB5Ox8TDR zUl5SJKvPUwT6cAAVKWxIf4ivFmIdlGWkPlDM9zU4AT1aLKNpvI7KT/YvnfeY9ChreSk ZEEumn96q8A/V+rU+03bewFaWzP8+QvrbhMaYsmhJn6NDTqLc7iR/daMxCh/v4lm/eRu 6e/pidOeaSMnd82q4llI99siVDRkvU+9LG1Ocl1Jj2A4vgq6wZlZ9G+CuVOPmp1u6Txn LJ5rjqKHDhzzg+6g0IqZZGgo9ywHsEOCsMvYCdDyXeG4dwGKraTikEbFR1x/cpb5jVD8 OMAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=X9aznUYlsdDB+CHRwWhlHJaTbkkC6Pl8KhTDDXd8lG0=; b=OkyRHJ1n8o5zlO8YYbhpTJ2ZU0ukRbO07HvfrKO6Xq+RwScfYv0Zpy9Ixk7tFYdVux b0Go10ACr4fgpZCcN+y3kxaD/uaqVDmvyD2hjaJ0WprUUc5bumm+0XBmhRsyzxpvEn26 6m6ighbRVqAsvA+8Z0ZU84SI36jvDDeQ3HRVBtptU9WC7Jj86VFsswbyhbOKG0vGPGum GcHCDCH+pjYrUOoEF4um/CQojbjlTyAUHZmXP8fYv0hH/VY27lkBsgR0v/+a5RJwHjWm WAZP7jvptpNAESTC8BPhdL92AiWC6e0bhoNMilc+WmmwTUWqfe90AOW+Wevh/onh3EZb K0hw== X-Gm-Message-State: AG10YOQlr10OBtKNMweBpN+uhTG3xw9VT9qc+NdLKvO/wu5B111hQ5QPwATi1C0EA6m82OBbMD7GfU3GQksUdA== MIME-Version: 1.0 X-Received: by 10.194.20.5 with SMTP id j5mr4759600wje.71.1454008677505; Thu, 28 Jan 2016 11:17:57 -0800 (PST) Received: by 10.28.183.132 with HTTP; Thu, 28 Jan 2016 11:17:57 -0800 (PST) Date: Thu, 28 Jan 2016 20:17:57 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=047d7b5d3830b9225d052a69c6ac Subject: get_class behavior From: fontanalorenz@gmail.com (Lorenzo Fontana) --047d7b5d3830b9225d052a69c6ac Content-Type: text/plain; charset=UTF-8 Hello everybody! At the moment the *get_class *function has three possible behaviors - *get_class* is called with the instance of the class and return the name of the class name of the instance; - *get_class* is called without any parameters inside a class and return the containing class name - *get_class* is called without any parameters outside a class, trigger a warning complaining about this and return false At the state of art of PHP the second behavior is not needed anymore because the name of the containing class can be easily obtained via *__CLASS__ or via get_class($this)* or via *get_called_class() *when extending a class in a static method. Moreover *get_class* without any parameters is a possible source of bugs in situations like this: *$result = $repository->find(100);* *echo get_class($result);* If *$result* is *null* the output of *get_class* is the name of the containing class instead of the name of the object I wanted. I would like to a change to the *get_class* behavior in order to support only the first behavior, unfortunately this is a huge BC, so we could start triggering a deprecation warning at first. What do you think? I'm missing something? References: Implementation of *get_class* http://lxr.php.net/xref/PHP_MASTER/Zend/zend_builtin_functions.c#995 Thanks Lorenzo --047d7b5d3830b9225d052a69c6ac--