After getting Zend maintainer rights, Laruence improved the 'Declaration must be compatible' fatal error so it now prints the expected signature — e.g. ArrayAccess::offsetSet($offset, $value) — instead of leaving you to look up the manual. Works for both interface and abstract-class methods. SVN r317206.
with 0 CommentWhy does echo $example->p1 call __get twice after unset($example->p1)? Laruence walks through zend_read_property: an unset private property isn't found in properties, so __get is invoked; inside __get, $this->$elmname is a read in the class scope where the property IS declared (named Example p1 ), triggering a second, differently-named guard before the in_get recursion guard finally stops it.
with 0 CommentLaruence's starter guide for anyone picking up PHP extension work: read 'Extending and Embedding PHP', mine the PHP source's ext/ directory for real Zend_API examples, use the pecl-dev mailing list and efnet #php.pecl for questions, write phpt test cases, build PHP with --enable-debug so your extension runs clean, and check for leaks with valgrind.
with 0 CommentHow PHP 5.4's 'improved Zend engine performance, reduced memory' actually works: (1) class property/static/const Hashtables are now allocated lazily only when non-empty; (2) opcode operands no longer each carry a zval but point into a per-op-array literal table, shrinking an opcode from 72 to 28 bytes on 32-bit; (3) literal strings become immutable 'internal strings' with pre-computed hashes. Includes dev-team benchmarks (19–26% on micro benches).
with 0 CommentLaruence's first task after joining the PHP dev team: implement foreach($array as $k => list($a, $b)) via a grammar rewrite. He shared the RFC and a PHP 5.4 patch, but the feature lost the 5.4 vote (9 for, 19 against). Notes that 5.4's parser data structures changed a lot — a heads-up for anyone studying the Zend engine.
with 0 CommentSince PHP 5.3, zend_parse_parameters gained new descriptors: f (callback, returns zend_fcall_info + cache), H (array or HASH_OF(object) — lets an object be accepted where an array is expected), L (clamped long), Z (raw zval**), and * / + (0-or-more / 1-or-more variadic args). Cuts down the manual validation you used to do for callbacks and objects-as-arrays.
with 0 CommentA PHP 5.4 alpha1 feature roundup: Traits (lightweight method reuse via 'use', with fixed conflict-resolution rules), array dereferencing ($a = explode(...)[0], and even lvalue use), DTrace support, plus the new built-in Webserver SAPI (php -S localhost:8000). Also notes the removals: break/continue $var, register_globals, etc.
with 0 CommentA hands-on walkthrough of pulling useful info out of a PHP core dump with gdb: read the signal/backtrace, use execute_data->function_state to get the crashing function name/file/line, inspect EG(argument_stack) for the last call's args (they don't map 1:1 to gdb frames), and lean on the .gdbinit helpers (zbacktrace, print_ht, zmemcheck).
with 0 CommentLaruence's four takeaways from a PHP performance talk: (1) optimization advice is about nipping problems in the bud while coding, not a rulebook to apply after a problem appears; (2) advice is a guard against abuse, not a law — e.g. batch assign() beats repeated __set magic calls; (3) advice is language-specific — an interpreted language does none of the compiler optimizations C does, and every symbol costs a Hash Lookup; (4) dig to the bottom — one high-level statement may compile to hundreds of lines of C.
with 0 CommentThe open source version of Ap — the framework I introduced at the 2011 PHP Technology Summit — is finally released as Yaf 2.0. Here are the source code and manual links; a dedicated documentation site is coming.
with 0 Comment