Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60485 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16758 invoked from network); 6 May 2012 00:41:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 May 2012 00:41:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=devis@oracolo.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=devis@oracolo.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain oracolo.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: devis@oracolo.com X-Host-Fingerprint: 209.85.214.42 mail-bk0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:58121] helo=mail-bk0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/9F-30075-8A8C5AF4 for ; Sat, 05 May 2012 20:41:14 -0400 Received: by bkcik5 with SMTP id ik5so3199760bkc.29 for ; Sat, 05 May 2012 17:41:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type:x-gm-message-state; bh=pL+/zzf37snHSSVr2YALvEy+KU3ytCm8Cbn4aJENKzA=; b=BVmiL6v/Erw7lGg8AJoM4uYCx0ptSDk/ZINgBCmtA01+HQRBRtvKlTElnkaemAByld JU24Ikb5llNbUa5bo4djZLaH3nwnqaoovQ+La3zVEdTQLQeDskPE0fUhy36lblKOoEHF AP4T2EaIziI4rS+Vag3h0sq39gMvAWPQrpkNcW84+PfvsWp/mGrUxMZhXFy3yD3bgDA8 MuPSE1TxI2uQtC6UNbMpOrBhYRx2yuu/avqm7IrSwkI2uSadDgZdxT2wXyL8nf+QQ0JM UTux+z93LwUyV/JJs10m6pn3Iw9XQ6QX0PJ5dhPUKPQqT+Dr2F7tMk8uKV3719CR+00j eRqw== Received: by 10.204.151.82 with SMTP id b18mr3849423bkw.132.1336264868965; Sat, 05 May 2012 17:41:08 -0700 (PDT) MIME-Version: 1.0 Sender: devis@oracolo.com Received: by 10.204.139.138 with HTTP; Sat, 5 May 2012 17:40:28 -0700 (PDT) Date: Sun, 6 May 2012 01:40:28 +0100 X-Google-Sender-Auth: kT9bPnix2ykqhlH_rF1_R4Z2u18 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=0015175cada0d72ef904bf5368da X-Gm-Message-State: ALoCoQmKxv9JwA3LI4rXET11YjaI3Yx1wrfZyKUCFdg9YdV5p2WucIx6sdO478AL48VOHvbhQZSx Subject: catching exception using a variable passed by reference From: devis@lucato.it (Devis Lucato) --0015175cada0d72ef904bf5368da Content-Type: text/plain; charset=UTF-8 Hi, I stumbled upon this code while working with a variable passed by reference, I was wondering if someone could provide some feedback before raising a ticket, just in case PHP (5.3.6) is doing what it's supposed to do. In the code below I would expect "catch" to change the variable as an assignment would do, but that doesn't happen. function foo(&$exception) > { > try { > throw new Exception('foo error'); > } catch (Exception $exception) { > var_dump(gettype($exception)); > echo $exception->getMessage() . "\n"; > } > } > foo($error); > var_dump(gettype($error)); Expected: > string(6) "object" > foo error > string(6) "object" Current result: > string(6) "object" > foo error > string(4) "NULL" It looks like "catch" is creating a completely new variable in the scope, also removing the existing one from it. I appreciate this is an edge case, if not a bug is it worth adding it to http://php.net/manual/en/language.exceptions.php or somewhere under http://www.php.net/manual/en/language.references.php ? Thank you! --0015175cada0d72ef904bf5368da--