You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrated Black-box Testing from Sharness to PHPUnit. #2492
Fixed
Fixed method return-type enforcement at runtime for return this->property: methods declared with a strict scalar return type (-> string, -> int, -> double, -> array) now throw TypeError when the property holds a mismatching value instead of silently returning it. PHP only verifies internal-function return types in ZEND_DEBUG=1 builds, so the generated C code now emits a runtime check via new RETURN_MEMBER_TYPED / RETURN_MM_MEMBER_TYPED kernel macros. The error message matches PHP's userland format: Class::method(): Return value must be of type X, Y returned. Nullable return types (string | null) and union/mixed returns are left unchecked, as before. #1991, #2196
Fixed built-in array methods called on a var-typed variable (e.g. let b = b->join(""); where b is declared var). Previously these were emitted as ZEPHIR_CALL_METHOD(b, "join", …) and surfaced as a RuntimeException: Trying to call method join on a non-object (originally a segfault, reduced to an exception over time). When the method name is one of the array-specific built-in names that can't meaningfully be a real object method (join, reversed, rev, tojson, haskey, mergerecursive, replacerecursive, sortbykey, reversesort, reversesortbykey), the compiler now dispatches via ArrayType — lowering to the matching PHP function call (e.g. join(glue, array)), just like statically-typed array variables already did. Common Iterator/Countable-style method names (count, push, pop, shift, sort, next, current, end, key, reset, each) are deliberately excluded so object dispatch on those is preserved. #733, #2228
Fixed let this->prop = value inside closures: the closure-binding detector from NFR: Closure this and use support #2497 caught property reads but missed let-statement writes (different AST shape), so writes were rejected as "Property not defined on stub\NN__closure". #1873, #2203
Reorganised populate_fcic() to pin calling/called scope earlier for direct call paths (zephir_fcall_ce and closures). [BUG]: preg_replace_callback cannot find method #2321 is NOT fixed by this change. The original symptom — preg_replace_callback(..., [this, 'privateMethod'], ...) failing with "cannot access private method" — remains; PHP's callable-argument validation walks prev_execute_data for the nearest ZEND_USER_CODE frame and Zephir methods are ZEND_INTERNAL_FUNCTION so they're skipped. Workaround: wrap the callback in a Zephir closure that captures this — function (m) { return this->privateMethod(m); } — closures aren't re-validated by PHP. #2321, #2325
This discussion was created from the release 0.20.1.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Changed
Fixed
return this->property: methods declared with a strict scalar return type (-> string,-> int,-> double,-> array) now throwTypeErrorwhen the property holds a mismatching value instead of silently returning it. PHP only verifies internal-function return types inZEND_DEBUG=1builds, so the generated C code now emits a runtime check via newRETURN_MEMBER_TYPED/RETURN_MM_MEMBER_TYPEDkernel macros. The error message matches PHP's userland format:Class::method(): Return value must be of type X, Y returned. Nullable return types (string | null) and union/mixedreturns are left unchecked, as before. #1991, #2196var-typed variable (e.g.let b = b->join("");wherebis declaredvar). Previously these were emitted asZEPHIR_CALL_METHOD(b, "join", …)and surfaced as aRuntimeException: Trying to call method join on a non-object(originally a segfault, reduced to an exception over time). When the method name is one of the array-specific built-in names that can't meaningfully be a real object method (join,reversed,rev,tojson,haskey,mergerecursive,replacerecursive,sortbykey,reversesort,reversesortbykey), the compiler now dispatches viaArrayType— lowering to the matching PHP function call (e.g.join(glue, array)), just like statically-typed array variables already did. Common Iterator/Countable-style method names (count,push,pop,shift,sort,next,current,end,key,reset,each) are deliberately excluded so object dispatch on those is preserved. #733, #2228let this->prop = valueinside closures: the closure-binding detector from NFR: Closurethisandusesupport #2497 caught property reads but missed let-statement writes (different AST shape), so writes were rejected as "Property not defined on stub\NN__closure". #1873, #2203populate_fcic()to pin calling/called scope earlier for direct call paths (zephir_fcall_ceand closures). [BUG]:preg_replace_callbackcannot find method #2321 is NOT fixed by this change. The original symptom —preg_replace_callback(..., [this, 'privateMethod'], ...)failing with "cannot access private method" — remains; PHP's callable-argument validation walksprev_execute_datafor the nearestZEND_USER_CODEframe and Zephir methods areZEND_INTERNAL_FUNCTIONso they're skipped. Workaround: wrap the callback in a Zephir closure that capturesthis—function (m) { return this->privateMethod(m); }— closures aren't re-validated by PHP. #2321, #2325This discussion was created from the release 0.20.1.
Beta Was this translation helpful? Give feedback.
All reactions