Bug #55321 [NEW]: PHP Notice: Use of undefined constant self

From: Date: Fri, 29 Jul 2011 22:13:48 +0000
Subject: Bug #55321 [NEW]: PHP Notice: Use of undefined constant self
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-162281@lists.php.net to get a copy of this message
From:             
Operating system: Ubuntu 11.04 (64 bit)
PHP version:      5.3.6
Package:          Variables related
Bug Type:         Bug
Bug description:PHP Notice:  Use of undefined constant self

Description:
------------
When running the test script with PHP 5.3.6 (and PHP 5.3.5) on Ubuntu 11.04
(64 bit) from command line, following message shown up.

PHP Notice:  Use of undefined constant self - assumed 'self' in
/path_to_the_PHP_script on line 5
PHP Stack trace:
PHP   1. {main}() /path_to_the_PHP_script:0
PHP   2. TestArray::flatten() /path_to_the_PHP_script:25

The test script runs fine with PHP 5.3.5 on Ubuntu 11.04 (32 bit).

Test script:
---------------
<?php
class TestArray {
	public static function flatten(array $arr) {
		$data = array();
		array_walk_recursive($arr, array(self, 'appendToArray'), &$data);
		return $data;
	}

	protected static function appendToArray($val, $key, array &$arr) {
		$arr[] = $val;
	}
}

$arr = array(
	'a',
	array(
		'b',
		array(
			'c',
			'd',
		),
	),
);

print_r(TestArray::flatten($arr));
?>


Expected result:
----------------
Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
)


Actual result:
--------------
PHP Notice:  Use of undefined constant self - assumed 'self' in
/path_to_the_PHP_script on line 5
PHP Stack trace:
PHP   1. {main}() /path_to_the_PHP_script:0
PHP   2. TestArray::flatten() /path_to_the_PHP_script:25
Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => d
)


-- 
Edit bug report at https://bugs.php.net/bug.php?id=55321&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=55321&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=55321&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=55321&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=55321&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55321&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=55321&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=55321&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=55321&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=55321&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=55321&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=55321&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=55321&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=55321&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=55321&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=55321&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55321&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=55321&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=55321&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=55321&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=55321&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=55321&r=mysqlcfg



Thread (2 messages)

« previous php.bugs (#162281) next »