Skip to content

Commit 9483a2f

Browse files
committed
- Readd support for ynamic access of static members (Etienne)
1 parent 0e5d551 commit 9483a2f

File tree

6 files changed

+94
-72
lines changed

6 files changed

+94
-72
lines changed

NEWS

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,8 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3-
?? ??? 20??, PHP 5.2.5
4-
- Upgraded PCRE to version 7.3 (Nuno)
5-
- Added optional parameter $provide_object to debug_backtrace(). (Sebastian)
6-
- Added alpha support for imagefilter() IMG_FILTER_COLORIZE. (Pierre)
7-
8-
- Improved speed of array_intersect_key(), array_intersect_assoc(),
9-
array_uintersect_assoc(), array_diff_key(), array_diff_assoc() and
10-
array_udiff_assoc(). (Dmitry)
11-
12-
- Fixed regression in glob() when enforcing safe_mode/open_basedir checks on
13-
paths containing '*'. (Ilia)
14-
- Fixed "mail.force_extra_parameters" php.ini directive not to be modifiable
15-
in .htaccess due to the security implications - reported by SecurityReason.
16-
(Stas)
17-
- Fixed PDO crash when driver returns empty LOB stream. (Stas)
18-
- Fixed dl() to only accept filenames - reported by Laurent Gaffie. (Stas)
19-
- Fixed dl() to limit argument size to MAXPATHLEN (CVE-2007-4887).
20-
(Christian Hoffmann)
21-
- Fixed iconv_*() functions to limit argument sizes as workaround to libc
22-
bug (CVE-2007-4783, CVE-2007-4840). (Christian Hoffmann, Stas)
23-
- Fixed missing brackets leading to build warning and error in the log.
24-
Win32 code). (Andrey)
25-
- Fixed leaks with multiple connects on one mysqli object. (Andrey)
26-
- Fixed endianness detection on MacOS when building universal binary.
27-
(Uwe Schindler, Christian Speich, Tony)
28-
- Fixed possible triggering of buffer overflows inside glibc
29-
implementations of the fnmatch(), setlocale() and glob() functions.
30-
Reported by Laurent gaffie. (Ilia)
31-
- Fixed imagerectangle regression with 1x1 rectangle (libgd #106). (Pierre)
32-
33-
- Fixed bug #42767 (highlight_string() truncates trailing comment). (Ilia)
34-
- Fixed bug #42739 (mkdir() doesn't like a trailing slash when safe_mode is
35-
enabled). (Ilia)
36-
- Fixed bug #42699 (PHP_SELF duplicates path). (Dmitry)
37-
- Fixed bug #42643 (CLI segfaults if using ATTR_PERSISTENT). (Ilia)
38-
- Fixed bug #42629 (Dynamically loaded PHP extensions need symbols exported
39-
on MacOSX). (jdolecek at NetBSD dot org)
40-
- Fixed bug #42627 (bz2 extension fails to build with -fno-common).
41-
(dolecek at netbsd dot org)
42-
- Fixed Bug #42596 (session.save_path MODE option does not work). (Ilia)
43-
- Fixed bug #42590 (Make the engine recognize \v and \f escape sequences).
44-
(Ilia)
45-
- Fixed bug #42587 (behavior change regarding symlinked .php files). (Dmitry)
46-
- Fixed bug #42579 (apache_reset_timeout() does not exist). (Jani)
47-
- Fixed bug #42549 (ext/mysql failed to compile with libmysql 3.23). (Scott)
48-
- Fixed bug #42523 (PHP_SELF duplicates path). (Dmitry)
49-
- Fixed bug #42512 (ip2long('255.255.255.255') should return 4294967295 on
50-
64-bit PHP). (Derick)
51-
- Fixed bug #42506 (php_pgsql_convert() timezone parse bug) (nonunnet at
52-
gmail dot com, Ilia)
53-
- Fixed bug #42462 (Segmentation when trying to set an attribute in a
54-
DOMElement). (Rob)
55-
- Fixed bug #42453 (CGI SAPI does not shut down cleanly with -i/-m/-v cmdline
56-
options). (Dmitry)
57-
- Fixed bug #42452 (PDO classes do not expose Reflection API information).
58-
(Hannes)
59-
- Fixed bug #42468 (Write lock on file_get_contents fails when using a
60-
compression stream). (Ilia)
61-
- Fixed bug #42488 (SoapServer reports an encoding error and the error itself
62-
breaks). (Dmitry)
63-
- Fixed bug #42378 (mysqli_stmt_bind_result memory exhaustion). (Andrey)
64-
- Fixed bug #42359 (xsd:list type not parsed). (Dmitry)
65-
- Fixed bug #42326 (SoapServer crash). (Dmitry)
66-
- Fixed bug #42214 (SoapServer sends clients internal PHP errors). (Dmitry)
67-
- Fixed bug #42189 (xmlrpc_set_type() crashes php on invalid datetime
68-
values). (Ilia)
69-
- Fixed bug #42139 (XMLReader option constants are broken using XML()). (Rob)
70-
- Fixed bug #42086 (SoapServer return Procedure '' not present for WSIBasic
71-
compliant wsdl). (Dmitry)
72-
- Fixed bug #41561 (Values set with php_admin_* in httpd.conf can be overwritten
73-
with ini_set()). (Stas, Jani)
74-
- Fixed bug #39651 (proc_open() append mode doesn't work on windows). (Nuno)
3+
?? ??? 20??, PHP 5.3.0
4+
- Added support for dynamic access of static members using $foo::myFunc().
5+
(Etienne Kneuss)
756

767
30 Aug 2007, PHP 5.2.4
778
- Removed --enable-versioning configure option. (Jani)

Zend/zend_language_parser.y

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,12 @@ function_call:
630630
| fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
631631
function_call_parameter_list
632632
')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
633+
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
634+
function_call_parameter_list
635+
')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
636+
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); }
637+
function_call_parameter_list
638+
')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
633639
| variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_dynamic_function_call(&$1 TSRMLS_CC); }
634640
function_call_parameter_list ')'
635641
{ zend_do_end_function_call(&$1, &$$, &$4, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);}
@@ -781,8 +787,13 @@ variable_without_objects:
781787

782788
static_member:
783789
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); }
790+
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); }
791+
784792
;
785793

794+
variable_class_name:
795+
reference_variable { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_fetch_class(&$$, &$1 TSRMLS_CC); }
796+
;
786797

787798
base_variable_with_function_calls:
788799
base_variable { $$ = $1; }
@@ -907,6 +918,7 @@ isset_variables:
907918

908919
class_constant:
909920
fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT TSRMLS_CC); }
921+
| variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT TSRMLS_CC); }
910922
;
911923

912924
%%

tests/lang/041.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Dynamic access of static members
3+
--FILE--
4+
<?php
5+
class A {
6+
public static $b = 'foo';
7+
}
8+
9+
$classname = 'A';
10+
$wrongClassname = 'B';
11+
12+
echo $classname::$b."\n";
13+
echo $wrongClassname::$b."\n";
14+
15+
?>
16+
===DONE===
17+
--EXPECTF--
18+
foo
19+
20+
Fatal error: Class 'B' not found in %s041.php on line %d

tests/lang/042.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Dynamic access of constants
3+
--FILE--
4+
<?php
5+
class A {
6+
const B = 'foo';
7+
}
8+
9+
$classname = 'A';
10+
$wrongClassname = 'B';
11+
12+
echo $classname::B."\n";
13+
echo $wrongClassname::B."\n";
14+
?>
15+
===DONE===
16+
--EXPECTF--
17+
foo
18+
19+
Fatal error: Class 'B' not found in %s042.php on line %d

tests/lang/043.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Dynamic call for static methods
3+
--FILE--
4+
<?php
5+
class A {
6+
static function foo() { return 'foo'; }
7+
}
8+
9+
$classname = 'A';
10+
$wrongClassname = 'B';
11+
12+
echo $classname::foo()."\n";
13+
echo $wrongClassname::foo()."\n";
14+
?>
15+
===DONE===
16+
--EXPECTF--
17+
foo
18+
19+
Fatal error: Class 'B' not found in %s043.php on line %d

tests/lang/044.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Dynamic call for static methods dynamically named
3+
--FILE--
4+
<?php
5+
class A {
6+
static function foo() { return 'foo'; }
7+
}
8+
$classname = 'A';
9+
$wrongClassname = 'B';
10+
11+
$methodname = 'foo';
12+
13+
echo $classname::$methodname()."\n";
14+
15+
echo $wrongClassname::$methodname()."\n";
16+
?>
17+
===DONE===
18+
--EXPECTF--
19+
foo
20+
21+
Fatal error: Class 'B' not found in %s044.php on line %d

0 commit comments

Comments
 (0)