Repository navigation
Conversation
The origin intention is to set all the elements to NULL?
heyJordanParker
added a commit
to heyJordanParker/php-sharp
that referenced
this pull request
Oct 13, 2026
Problem A plain PHP file that called a plain PHP parent's method through a PHP# subclass was checked against a weaker parameter type than the same call through the parent. With `Lib\Store::keep` declared as `/** @PARAM list<int> $rows */ public function keep(array $rows)` and the PHP# class `Demo\Rows` extending it, `$store->keep(['a' => 'b'])` reported invalid-argument and `$rows->keep(['a' => 'b'])` reported nothing. The analyzer chose the PHP declaration over the docblock type because the receiver's class was PHP#, though the method was plain PHP. The same decision went the other way through a plain PHP subclass of a PHP# class: `Coin::op_Equality($coin, null)` reported null-argument, though `Money::op_Equality($money, null)` takes the null it lifts. The effect summary of a `new` made the same mistake. `new Rows()` ran plain PHP `Store::__construct` but was recorded as a PHP# body that does not exist, so a getter creating it passed with an unknown effect. `new Coin(5)` ran PHP# `Money`'s constructor but was recorded as plain PHP with an unknown effect, so a getter creating it was refused. Solution The called method decides. A plain PHP caller reads the PHP declaration only of a method a PHP# file declares, as the literal rules in `analyze_invocation` already decide by the method's flags. A `new` decides by the class that declares the constructor, and by the named class when none declares one. A plain PHP constructor's effect names the class that declares it, so the help names an `extern` the project can write. .php results through a plain PHP class, and through a PHP# class for a method PHP# declares, are unchanged. crates/analyzer/ src/invocation/analyzer.rs get_parameter_type takes the invocation target and decides by the method's flags src/effects/summary.rs instantiate decides by the constructor's declaring class tests/sharp.rs a_call_is_checked_by_the_class_that_declares_the_member_not_the_class_it_goes_through Fixes php#151
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Error to submit