[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/sapi/fpm/php-fpm.conf.in trunk/sapi/fpm/php-fpm.conf.in
fat Sat, 29 May 2010 10:39:35 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299932 Log: typo (thx to Brian P. Mercer) Changed paths: U php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in U php/php-src/trunk/sapi/fpm/php-fpm.conf.in Modified: php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in === --- php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in 2010-05-29 04:55:04 UTC (rev 299931) +++ php/php-src/branches/PHP_5_3/sapi/fpm/php-fpm.conf.in 2010-05-29 10:39:35 UTC (rev 299932) @@ -1,285 +1,272 @@ -; -; All relative paths in this config are relative to php's install prefix -; -; -; Include one or more files. -; If glob(3) exists, it's used to include a bunch of files from a glob(3) pattern -; This directive can be used everywhere in the file. -; +; +; FPM Configuration ; +; + +; All relative paths in this configuration file are relative to PHP's install +; prefix. + +; Include one or more files. If glob(3) exists, it is used to include a bunch of +; files from a glob(3) pattern. This directive can be used everywhere in the +; file. ;inclu...@expanded_sysconfdir@/fpm.d/*.conf -; -; +;; +; Global Options ; +;; + [global] ; Pid file -; default: none -; +; Default Value: none ;pid = @EXPANDED_LOCALSTATEDIR@/run/php-fpm.pid ; Error log file -; default: @EXPANDED_LOCALSTATEDIR@/log/php-fpm.log -; +; Default Value: @EXPANDED_LOCALSTATEDIR@/log/php-fpm.log ;error_log = @EXPANDED_LOCALSTATEDIR@/log/php-fpm.log ; Log level -; alert, error, warning, notice, debug -; default: notice -; +; Possible Values: alert, error, warning, notice, debug +; Default Value: notice ;log_level = notice -; When this amount of php processes exited with SIGSEGV or SIGBUS, -; php-fpm will restart -; 0 means 'Off' -; default: 0 -; +; If this number of child processes exit with SIGSEGV or SIGBUS within the time +; interval set by emergency_restart_interval then FPM will restart. A value +; of '0' means 'Off'. +; Default Value: 0 ;emergency_restart_threshold = 0 -; ... in a less than this interval of time, a graceful restart will be initiated. -; Useful to work around accidental curruptions in accelerator's shared memory. -; available units are s(econd)(default), m(inute), h(hour), or d(day) -; default : 0 -; +; Interval of time used by emergency_restart_interval to determine when +; a graceful restart will be initiated. This can be useful to work around +; accidental corruptions in an accelerator's shared memory. +; Available Units: s(econds), m(inutes), h(ours), or d(ays) +; Default Unit: seconds +; Default Value: 0 ;emergency_restart_interval = 0 -; Time limit on waiting child's reaction on signals from master -; available units are s(econd)(default), m(inute), h(hour), or d(day) -; default : 0 -; +; Time limit for child processes to wait for a reaction on signals from master. +; Available units: s(econds), m(inutes), h(ours), or d(ays) +; Default Unit: seconds +; Default Value: 0 ;process_control_timeout = 0 -; send fpm to backgound -; set to 'no' to keep FPM in foreground for debugging -; default : yes -; +; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. +; Default Value: yes ;daemonize = yes -; Start a new pool named 'www' -; The name is used in logs and stats -; There is no limitation on the number of pool FPM can handle. Your system will tell you anyway :) + +; Pool Definitions ; + + +; Multiple pools of child processes may be started with different listening +; ports and different management options. The name of the pool will be +; used in logs and stats. There is no limitation on the number of pools which +; FPM can handle. Your system will tell you anyway :) + +; Start a new pool named 'www'. [www] -; Address to accept fastcgi requests on. +; The address on which to accept FastCGI requests. ; Valid syntaxes are: -; - 'ip.add.re.ss:port' to listen on a TCP scoket to the specific address on the specific port -; - 'port' to listen on a TCP socket to all addreses on the specific port -; - '/path/to/unix/socket' to listen on a unix socket -; it's mandatory -; +; 'ip.add.re.ss:port'- to listen on a TCP socket to a specific address on +;a specific port; +; 'port' - to listen on a TCP socket to all addresses on a +;specific port; +; '/path/to/unix/socket' - to listen on a unix socket. +; Note: This value is mandatory. listen = 127.0.0.1:9000 -; Set listen(2) backlog -; -1 means unlimited -; default : -1 -; +; Set listen(2) backlog. A value of '-1' means unlimited. +; Default Value: -1 ;listen.backlog = -1 ; List of ipv4 addresses of FastCGI clients which are allowed to connect. -; Equivalent to FCGI_WEB_SERVER_ADDRS environment in original
[PHP-CVS] svn: /php/php-src/trunk/Zend/ tests/traits/noctor001.phpt zend_compile.c
johannes Sat, 29 May 2010 20:01:08 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299936 Log: - A method called like a trait is no constructor Changed paths: A php/php-src/trunk/Zend/tests/traits/noctor001.phpt U php/php-src/trunk/Zend/zend_compile.c Added: php/php-src/trunk/Zend/tests/traits/noctor001.phpt === --- php/php-src/trunk/Zend/tests/traits/noctor001.phpt (rev 0) +++ php/php-src/trunk/Zend/tests/traits/noctor001.phpt 2010-05-29 20:01:08 UTC (rev 299936) @@ -0,0 +1,28 @@ +--TEST-- +Don't mark trait methods as constructor +--FILE-- +?php +trait Foo { +public function Foo() { +} +} + +class Bar { +use Foo; +public function Bar() { +} +} + +$rfoofoo = new ReflectionMethod('Foo::Foo'); +var_dump($rfoofoo-isConstructor()); + +$rbarfoo = new ReflectionMethod('Bar::Foo'); +var_dump($rbarfoo-isConstructor()); + +$rbarbar = new ReflectionMethod('Bar::Bar'); +var_dump($rbarbar-isConstructor()); +? +--EXPECT-- +bool(false) +bool(false) +bool(true) Property changes on: php/php-src/trunk/Zend/tests/traits/noctor001.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native Modified: php/php-src/trunk/Zend/zend_compile.c === --- php/php-src/trunk/Zend/zend_compile.c 2010-05-29 18:36:51 UTC (rev 299935) +++ php/php-src/trunk/Zend/zend_compile.c 2010-05-29 20:01:08 UTC (rev 299936) @@ -1591,7 +1591,7 @@ zend_str_tolower_copy(class_lcname, CG(active_class_entry)-name, CG(active_class_entry)-name_length); /* Improve after RC: cache the lowercase class name */ - if ((CG(active_class_entry)-name_length == name_len) (!memcmp(class_lcname, lcname, name_len))) { + if ((CG(active_class_entry)-name_length == name_len) ((CG(active_class_entry)-ce_flags ZEND_ACC_TRAIT) != ZEND_ACC_TRAIT) (!memcmp(class_lcname, lcname, name_len))) { if (CG(active_class_entry)-constructor) { zend_error(E_STRICT, Redefining already defined constructor for class %s, CG(active_class_entry)-name); } else { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/tests/ ReflectionClass_newInstanceArgs_002.phpt ReflectionMethod_invokeArgs_error2.phpt
johannes Sat, 29 May 2010 20:34:25 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299937 Log: - Fix tests Changed paths: U php/php-src/trunk/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt U php/php-src/trunk/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt Modified: php/php-src/trunk/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt === --- php/php-src/trunk/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt 2010-05-29 20:01:08 UTC (rev 299936) +++ php/php-src/trunk/ext/reflection/tests/ReflectionClass_newInstanceArgs_002.phpt 2010-05-29 20:34:25 UTC (rev 299937) @@ -17,4 +17,4 @@ ? --EXPECTF-- -Catchable fatal error: Argument 1 passed to ReflectionClass::newInstanceArgs() must be an array, string given in %s on line 8 +Catchable fatal error: Argument 1 passed to ReflectionClass::newInstanceArgs() must be of the type array, string given in %s on line 8 Modified: php/php-src/trunk/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt === --- php/php-src/trunk/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt 2010-05-29 20:01:08 UTC (rev 299936) +++ php/php-src/trunk/ext/reflection/tests/ReflectionMethod_invokeArgs_error2.phpt 2010-05-29 20:34:25 UTC (rev 299937) @@ -24,4 +24,4 @@ ? --EXPECTF-- -Catchable fatal error: Argument 2 passed to ReflectionMethod::invokeArgs() must be an array, boolean given in %s on line %d +Catchable fatal error: Argument 2 passed to ReflectionMethod::invokeArgs() must be of the type array, boolean given in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/ReflectionClass_toString_001.phpt tests/traits001.phpt
johannes Sat, 29 May 2010 20:40:58 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299938 Log: - Make reflection aware of traits Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c U php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt A php/php-src/trunk/ext/reflection/tests/traits001.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 20:34:25 UTC (rev 299937) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 20:40:58 UTC (rev 299938) @@ -355,7 +355,13 @@ if (obj) { string_printf(str, %sObject of class [ , indent); } else { - string_printf(str, %s%s [ , indent, (ce-ce_flags ZEND_ACC_INTERFACE) ? Interface : Class); + char *kind = Class; + if (ce-ce_flags ZEND_ACC_INTERFACE) { + kind = Interface; + } else if (ce-ce_flags ZEND_ACC_TRAIT) { + kind = Trait; + } + string_printf(str, %s%s [ , indent, kind); } string_printf(str, (ce-type == ZEND_USER_CLASS) ? user : internal); if (ce-module) { @@ -367,6 +373,8 @@ } if (ce-ce_flags ZEND_ACC_INTERFACE) { string_printf(str, interface ); + } else if (ce-ce_flags ZEND_ACC_TRAIT) { + string_printf(str, trait ); } else { if (ce-ce_flags (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { string_printf(str, abstract ); @@ -3974,6 +3982,14 @@ } /* }}} */ +/* {{{ proto public bool ReflectionClass::isTrait() + Returns whether this is a trait */ +ZEND_METHOD(reflection_class, isTrait) +{ + _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT); +} +/* }}} */ + /* {{{ proto public bool ReflectionClass::isFinal() Returns whether this class is final */ ZEND_METHOD(reflection_class, isFinal) @@ -5605,6 +5621,7 @@ ZEND_ME(reflection_class, getInterfaces, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getInterfaceNames, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isInterface, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, isTrait, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isAbstract, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isFinal, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getModifiers, arginfo_reflection__void, 0) Modified: php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt === --- php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt 2010-05-29 20:34:25 UTC (rev 299937) +++ php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt 2010-05-29 20:40:58 UTC (rev 299938) @@ -34,7 +34,7 @@ Property [ default public $name ] } - - Methods [43] { + - Methods [44] { Method [ internal:Reflection final private method __clone ] { - Parameters [0] { @@ -188,6 +188,12 @@ } } +Method [ internal:Reflection public method isTrait ] { + + - Parameters [0] { + } +} + Method [ internal:Reflection public method isAbstract ] { - Parameters [0] { Added: php/php-src/trunk/ext/reflection/tests/traits001.phpt === --- php/php-src/trunk/ext/reflection/tests/traits001.phpt (rev 0) +++ php/php-src/trunk/ext/reflection/tests/traits001.phpt 2010-05-29 20:40:58 UTC (rev 299938) @@ -0,0 +1,71 @@ +--TEST-- +ReflectionClass and Traits +--FILE-- +?php +trait Foo { +public function someMethod() { } +} + +class Bar { +use Foo; + +public function someOtherMethod() { } +} + +$rFoo = new ReflectionClass('Foo'); +$rBar = new ReflectionClass('Bar'); + +var_dump($rFoo-isTrait()); +var_dump($rBar-isTrait()); +echo $rFoo; +echo $rBar; +--EXPECTF-- +bool(true) +bool(false) +Trait [ user trait Foo ] { + @@ %straits001.php 2-4 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [1] { +Method [ user public method someMethod ] { + @@ %straits001.php 3 - 3 +} + } +} +Class [ user class Bar ] { + @@ %straits001.php 6-10 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [2] { +Method [ user public method someOtherMethod ] { + @@ %straits001.php 9 - 9 +} + + +Method [ user public method someMethod ] { + @@ %straits001.php 3 - 3 +} + } +} Property changes on:
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c
johannes Sat, 29 May 2010 21:28:24 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299939 Log: - Add some folding marks Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 20:40:58 UTC (rev 299938) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:28:24 UTC (rev 299939) @@ -178,6 +178,8 @@ } /* }}} */ +/* {{{ Object structure */ + /* Struct for properties */ typedef struct _property_reference { zend_class_entry *ce; @@ -209,9 +211,11 @@ unsigned int ignore_visibility:1; } reflection_object; +/* }}} */ + static zend_object_handlers reflection_object_handlers; -static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) +static void _default_get_entry(zval *object, char *name, int name_len, zval *return_value TSRMLS_DC) /* {{{ */ { zval **value; @@ -221,6 +225,7 @@ MAKE_COPY_ZVAL(value, return_value); } +/* }}} */ #ifdef ilia_0 static void _default_lookup_entry(zval *object, char *name, int name_len, zval **return_value TSRMLS_DC) /* {{{ */ @@ -236,13 +241,14 @@ /* }}} */ #endif -static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) +static void reflection_register_implement(zend_class_entry *class_entry, zend_class_entry *interface_entry TSRMLS_DC) /* {{{ */ { zend_uint num_interfaces = ++class_entry-num_interfaces; class_entry-interfaces = (zend_class_entry **) realloc(class_entry-interfaces, sizeof(zend_class_entry *) * num_interfaces); class_entry-interfaces[num_interfaces - 1] = interface_entry; } +/* }}} */ static zend_function *_copy_function(zend_function *fptr TSRMLS_DC) /* {{{ */ { @@ -274,7 +280,7 @@ } /* }}} */ -static void reflection_free_objects_storage(void *object TSRMLS_DC) +static void reflection_free_objects_storage(void *object TSRMLS_DC) /* {{{ */ { reflection_object *intern = (reflection_object *) object; parameter_reference *reference; @@ -302,8 +308,9 @@ } zend_objects_free_object_storage(object TSRMLS_CC); } +/* }}} */ -static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) +static zend_object_value reflection_objects_new(zend_class_entry *class_type TSRMLS_DC) /* {{{ */ { zend_object_value retval; reflection_object *intern; @@ -317,8 +324,9 @@ retval.handlers = reflection_object_handlers; return retval; } +/* }}} */ -static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) +static zval * reflection_instantiate(zend_class_entry *pce, zval *object TSRMLS_DC) /* {{{ */ { if (!object) { ALLOC_ZVAL(object); @@ -329,6 +337,7 @@ Z_SET_ISREF_P(object); return object; } +/* }}} */ static void _const_string(string *str, char *name, zval *value, char *indent TSRMLS_DC); static void _function_string(string *str, zend_function *fptr, zend_class_entry *scope, char* indent TSRMLS_DC); @@ -945,7 +954,7 @@ } /* }}} */ -static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_ini_string(zend_ini_entry *ini_entry TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@ -979,8 +988,9 @@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ -static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@ -994,8 +1004,9 @@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ -static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) +static int _extension_const_string(zend_constant *constant TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */ { string *str = va_arg(args, string *); char *indent = va_arg(args, char *); @@ -1008,6 +1019,7 @@ } return ZEND_HASH_APPLY_KEEP; } +/* }}} */ /* {{{ _extension_string */ static void _extension_string(string *str, zend_module_entry *module, char *indent TSRMLS_DC) @@ -1126,7 +1138,7 @@ } /* }}} */ -static void _zend_extension_string(string *str, zend_extension *extension, char *indent TSRMLS_DC) +static void _zend_extension_string(string *str, zend_extension *extension, char
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/traits002.phpt
felipe Sat, 29 May 2010 21:48:56 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299940 Log: - Fixed wrong abstract class identification (it was identified as a Trait) Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c A php/php-src/trunk/ext/reflection/tests/traits002.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:28:24 UTC (rev 299939) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:48:56 UTC (rev 299940) @@ -367,7 +367,7 @@ char *kind = Class; if (ce-ce_flags ZEND_ACC_INTERFACE) { kind = Interface; - } else if (ce-ce_flags ZEND_ACC_TRAIT) { + } else if ((ce-ce_flags ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { kind = Trait; } string_printf(str, %s%s [ , indent, kind); Added: php/php-src/trunk/ext/reflection/tests/traits002.phpt === --- php/php-src/trunk/ext/reflection/tests/traits002.phpt (rev 0) +++ php/php-src/trunk/ext/reflection/tests/traits002.phpt 2010-05-29 21:48:56 UTC (rev 299940) @@ -0,0 +1,54 @@ +--TEST-- +ReflectionClass and Traits +--FILE-- +?php + +abstract class foo { +} + +trait bar { + +} + +reflectionclass::export('foo'); +reflectionclass::export('bar'); + +? +--EXPECTF-- +Class [ user trait foo ] { + @@ %s 3-4 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [0] { + } +} + +Trait [ user trait bar ] { + @@ %s 6-8 + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [0] { + } +} Property changes on: php/php-src/trunk/ext/reflection/tests/traits002.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/traits002.phpt
felipe Sat, 29 May 2010 21:55:19 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299941 Log: - Missing Trait check fix Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c U php/php-src/trunk/ext/reflection/tests/traits002.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:48:56 UTC (rev 299940) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 21:55:19 UTC (rev 299941) @@ -382,7 +382,7 @@ } if (ce-ce_flags ZEND_ACC_INTERFACE) { string_printf(str, interface ); - } else if (ce-ce_flags ZEND_ACC_TRAIT) { + } else if ((ce-ce_flags ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { string_printf(str, trait ); } else { if (ce-ce_flags (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { Modified: php/php-src/trunk/ext/reflection/tests/traits002.phpt === --- php/php-src/trunk/ext/reflection/tests/traits002.phpt 2010-05-29 21:48:56 UTC (rev 299940) +++ php/php-src/trunk/ext/reflection/tests/traits002.phpt 2010-05-29 21:55:19 UTC (rev 299941) @@ -15,7 +15,7 @@ ? --EXPECTF-- -Class [ user trait foo ] { +Class [ user abstract class foo ] { @@ %s 3-4 - Constants [0] { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/traits003.phpt
felipe Sat, 29 May 2010 22:08:51 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299943 Log: - Fixed ReflectionClass::isTrait() checking (to not identify abstract class as Trait) Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c A php/php-src/trunk/ext/reflection/tests/traits003.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 22:00:43 UTC (rev 299942) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-29 22:08:51 UTC (rev 299943) @@ -3999,7 +3999,7 @@ Returns whether this is a trait */ ZEND_METHOD(reflection_class, isTrait) { - _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT); + _class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_TRAIT ~ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); } /* }}} */ Added: php/php-src/trunk/ext/reflection/tests/traits003.phpt === --- php/php-src/trunk/ext/reflection/tests/traits003.phpt (rev 0) +++ php/php-src/trunk/ext/reflection/tests/traits003.phpt 2010-05-29 22:08:51 UTC (rev 299943) @@ -0,0 +1,30 @@ +--TEST-- +Reflection and Traits +--FILE-- +?php + +abstract class foo { +} + +trait bar { + +} + +final class baz { + +} + +$x = new ReflectionClass('foo'); +var_dump($x-isTrait()); + +$x = new ReflectionClass('bar'); +var_dump($x-isTrait()); + +$x = new ReflectionClass('baz'); +var_dump($x-isTrait()); + +? +--EXPECT-- +bool(false) +bool(true) +bool(false) Property changes on: php/php-src/trunk/ext/reflection/tests/traits003.phpt ___ Added: svn:keywords + Id Rev Revision Added: svn:eol-style + native -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] svn: /php/php-src/trunk/ext/reflection/ php_reflection.c tests/ReflectionClass_toString_001.phpt tests/traits004.phpt tests/traits005.phpt
johannes Sun, 30 May 2010 01:00:45 + Revision: http://svn.php.net/viewvc?view=revisionrevision=299946 Log: - More trait reflection work #- I'm not happy about ReflectionClass::getTraitAliases, yet Changed paths: U php/php-src/trunk/ext/reflection/php_reflection.c U php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt A php/php-src/trunk/ext/reflection/tests/traits004.phpt A php/php-src/trunk/ext/reflection/tests/traits005.phpt Modified: php/php-src/trunk/ext/reflection/php_reflection.c === --- php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-30 00:51:55 UTC (rev 299945) +++ php/php-src/trunk/ext/reflection/php_reflection.c 2010-05-30 01:00:45 UTC (rev 299946) @@ -4254,6 +4254,80 @@ } /* }}} */ +/* {{{ proto public ReflectionClass[] ReflectionClass::getTraits() + Returns an array of traits used by this class */ +ZEND_METHOD(reflection_class, getTraits) +{ + reflection_object *intern; + zend_class_entry *ce; + zend_uint i; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + for (i=0; i ce-num_traits; i++) { + zval *trait; + ALLOC_ZVAL(trait); + zend_reflection_class_factory(ce-traits[i], trait TSRMLS_CC); + add_assoc_zval_ex(return_value, ce-traits[i]-name, ce-traits[i]-name_length + 1, trait); + } +} +/* }}} */ + +/* {{{ proto public String[] ReflectionClass::getTraitNames() + Returns an array of names of traits used by this class */ +ZEND_METHOD(reflection_class, getTraitNames) +{ + reflection_object *intern; + zend_class_entry *ce; + zend_uint i; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + for (i=0; i ce-num_traits; i++) { + add_next_index_stringl(return_value, ce-traits[i]-name, ce-traits[i]-name_length, 1); + } +} +/* }}} */ + +/* {{{ proto public arra ReflectionClass::getTraitaliases() + Returns an array of trait aliases */ +ZEND_METHOD(reflection_class, getTraitAliases) +{ + reflection_object *intern; + zend_class_entry *ce; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + GET_REFLECTION_OBJECT_PTR(ce); + + array_init(return_value); + + if (ce-trait_aliases) { + zend_uint i = 0; + while (ce-trait_aliases[i]) { + char *method_name; + int method_name_len; + zend_trait_method_reference *cur_ref = ce-trait_aliases[i]-trait_method; + + method_name_len = spprintf(method_name, 0, %s::%s, cur_ref-class_name, cur_ref-method_name); + add_assoc_stringl_ex(return_value, ce-trait_aliases[i]-alias, ce-trait_aliases[i]-alias_len + 1, method_name, method_name_len, 0); + i++; + } + } +} +/* }}} */ + /* {{{ proto public ReflectionClass ReflectionClass::getParentClass() Returns the class' parent class, or, if none exists, FALSE */ ZEND_METHOD(reflection_class, getParentClass) @@ -5636,6 +5710,9 @@ ZEND_ME(reflection_class, getInterfaces, arginfo_reflection__void, 0) ZEND_ME(reflection_class, getInterfaceNames, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isInterface, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraits, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraitNames, arginfo_reflection__void, 0) + ZEND_ME(reflection_class, getTraitAliases, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isTrait, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isAbstract, arginfo_reflection__void, 0) ZEND_ME(reflection_class, isFinal, arginfo_reflection__void, 0) Modified: php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt === --- php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt 2010-05-30 00:51:55 UTC (rev 299945) +++ php/php-src/trunk/ext/reflection/tests/ReflectionClass_toString_001.phpt 2010-05-30 01:00:45 UTC (rev 299946) @@ -34,7 +34,7 @@ Property [ default public $name ] } - - Methods [44] { + - Methods [47] { Method [ internal:Reflection final private method __clone ] { - Parameters [0] { @@ -188,6 +188,24 @@ } } +Method [ internal:Reflection public method getTraits ] { + + - Parameters [0] { + } +} + +Method [ internal:Reflection public method getTraitNames ] { + + - Parameters [0] { + } +} + +Method [