php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53267 Pass by reference on "new" throws no deprecation notice
Submitted: 2010-11-08 20:26 UTC Modified: 2010-11-08 22:02 UTC
From: enygma at phpdeveloper dot org Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.3 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: enygma at phpdeveloper dot org
New email:
PHP Version: OS:

 

 [2010-11-08 20:26 UTC] enygma at phpdeveloper dot org
Description:
------------
I don't know if this is a documentation bug or an error in PHP, but I thought I'd bring it up. There's no warning raised when the pass by reference is used on a "new" in a class definition in PHP 5.3.3 (multiple testers).

Docs are here: http://php.net/manual/en/migration53.deprecated.php

Test script:
---------------
Example code:
<?php
error_reporting(E_ALL|E_DEPRECATED);
class MyClass { }
$mc = &new MyClass();
?>

Expected result:
----------------
Expected:
Deprecated notice

Actual result:
--------------
Actual:
No warning raised

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-08 21:37 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2010-11-08 21:37 UTC] felipe@php.net
It issues an E_DEPRECATED, but in compile-time... E_DEPRECATED is not in the default error_reporting setting, so it doesn't displays the deprecated message.

$ sapi/cli/php -derror_reporting=E_DEPRECATED foo.php

Deprecated: Assigning the return value of new by reference is deprecated in ...
 [2010-11-08 22:02 UTC] enygma at phpdeveloper dot org
One problem with that...I have another example that uses ereg (it's a PHP 5.3 examples thing) and at E_ALL I *do* get a deprecated message on the same system. It's a CentOS virtual instance with the PHP packages installed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Dec 19 14:00:02 2025 UTC