Repository navigation
fix bug #53432 (Assignment via string index access on an empty string converts to array) - #463
Closed
bixuehujin wants to merge 1 commit into
Closed
bixuehujin wants to merge 1 commit into
bixuehujin wants to merge 1 commit into
Conversation
… converts to array) see https://bugs.php.net/bug.php?id=53432 - Assignment via string index on an empty string will produce a Illegal string offset warning now. - Split Zend/tests/indexing_001.phpt into multiple files for readability improvement.
Contributor
|
This is a serious change in how conversions work, so I don't think it can be done in 5.x |
Contributor
|
May be PHP 6? |
heyJordanParker
added a commit
to heyJordanParker/php-sharp
that referenced
this pull request
Oct 13, 2026
Problem: a property written `required` was "not supported yet", and a
struct created without one of its properties compiled: `new Point { x:
1 }` left `y` unset until the engine threw on the first read. Jordan's
Q2 rules that a struct's property without an initial value is set at
creation, a `T?` one too. Task php#463: a get-only property that no
constructor sets compiled.
Solution: `MetadataFlags::REQUIRED` marks a property written `required`,
and a struct's property without an initial value that is not a main
constructor parameter. Neither takes a `null` default. The codex scanner
records on each constructor, main or named, the properties it assigns on
every path, as `MethodMetadata::assigned_properties`: both arms of an
`if`/`else`, every `match` arm, and a path that throws counts as done. A
call to a helper method counts for nothing, as in C# and Swift. At each
`new`, the required properties that the constructor running (a named
constructor together with the main constructor) does not assign must be
named by the object initializer: "`new Point` must set `y` and `label`."
A `required` property without `init` or `set` is refused where it is
written. A get-only property with no initial value that no constructor
assigns is an error: "`count` is get-only and never set: set it in the
main constructor, or give it an initial value."
crates/
├── syntax/
│ ├── src/parser/internal/class_like/method.rs <- `required` goes on a property
│ ├── src/cst/cst/with.rs <- doc paragraphs clippy asks for
│ └── tests/sharp.rs <- `required` rows name a method
├── codex/src/
│ ├── metadata/flags.rs <- MetadataFlags::REQUIRED
│ ├── metadata/function_like.rs <- MethodMetadata::assigned_properties
│ ├── scanner/property.rs <- `required` sets REQUIRED, no null default
│ ├── scanner/class_like.rs <- require_struct_properties
│ ├── scanner/function_like.rs <- definitely_assigned_properties
│ └── scanner/mod.rs <- a named constructor's assigned set
├── semantics/
│ ├── src/internal/checker/sharp.rs <- `required` needs `init` or `set`
│ └── tests/sharp.rs <- a_required_property_has_init_or_set
├── analyzer/
│ ├── src/expression/instantiation.rs <- check_required_properties at `new`
│ ├── src/statement/class_like/initialization.rs <- check_get_only_initialization
│ ├── src/statement/class_like/mod.rs <- runs it
│ └── tests/sharp.rs <- every_required_property_is_set_where_its_object_is_created,
│ a_get_only_property_no_constructor_sets_is_an_error
└── sharp-bridge/tests/lower.rs <- fixtures set their get-only properties;
parse reports a missing `owner`
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.
see https://bugs.php.net/bug.php?id=53432
warning now.