Skip to content

feat: singles — List arrival, never, parameter properties and defaults, toString templates - #156

Merged
heyJordanParker merged 27 commits into
masterfrom
feat/singles
Oct 17, 2026
Merged

heyJordanParker merged 27 commits into
masterfrom
feat/singles

Conversation

@heyJordanParker

@heyJordanParker heyJordanParker commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Completes: §9, §18, §19

The last v1 feature PR: every approved single change that has no section PR of its own. Design note: docs/architecture/slices/singles.md.

What a PHP# developer can now write

  • A plain PHP int-keyed array arrives as a List, renumbered where it crosses into PHP#: a plain PHP return, a property read and a plain caller's argument. A write through such a property, as users.names.add("cy") or users.names[0] = "zed", renumbers the property first and changes it in place. A List value where a Map is declared is a compile error; a plain PHP value stays exempt, and a PHP# function value returns the Map its type writes.
  • never is the return type of a method that never returns, and only the whole return type: List<never> is a compile error. A path that reaches the closing brace is a compile error at that brace, and an expression body that returns a value says so. Process.exit is a never method.
  • A constructor parameter's property is a property like one in the class body: a default after its accessors, accessor bodies, willSet/didSet and via, with the body property's behavior checks and generic behaviors, as via Trimmed, Shouted<int>. A default before the accessors is one error that says to move it. required on any parameter is one error.
  • A parameter's default is any expression, run each time a call leaves the argument out, from PHP# and plain PHP, by position or by name, a property of a new object included. It reads no this and no other parameter.
  • A template shows a type that declares string toString(), and plain PHP's string conversion calls it too, a toString() from an interface's default body included. Any other toString() is a compile error that names the signature to write.
  • A missing class is one error by its PHP# name, with "Did you mean OutOfRangeException?" for an Error/Exception ending, a static read or call through it included, with no follow-on error.
  • @ before a name makes a keyword a name, as in C#: @event, @match, and @this in every name position, and the named argument this: passes @this. A bare keyword is "match is a keyword; write @match.", a lone lambda parameter included. PHP# has no @ before a value: a PHP built-in's failure is the value it returns.
  • A local named as a PHP superglobal, such as _SERVER, is a name like any other.
  • An override of a typed plain PHP property may narrow its type. It links with the parent's type, and each write checks its own.
  • A Map keyed by a backed enum passes to a plain PHP array parameter with each case's backing value as its key, passed or spread.
  • A plain PHP class's method of the same name as its property is its value where the code takes a function the property's type does not fit.
  • Int.MAX and Int.MIN replace PHP's PHP_INT_MAX and PHP_INT_MIN: a read of either, bare or through global, is a compile error that names the library's constant. The spec names Process.run where it said shell_exec() stays.
  • Messages: a default body's call names its interface, a field pattern drops its false "Redundant &&", continue outside a loop and an impossible list element speak PHP#.

The bridge and the library

  • The bridge silences PHP's warning on every call of a PHP built-in whose declared return type holds false, null, bool or mixed. The failure is the value the call returns, so an error handler that skips silenced warnings, as Laravel's, Symfony's and PHPUnit's do, never turns it into an exception, and Hex.decode("zz") throws the library's ValueError. A built-in that takes a function, as call_user_func and array_reduce, keeps its warnings, since that function's own code runs inside the call. A plain PHP library's own functions are left as they are.
  • The library's 24 @global. calls drop their @.
  • The analyzer issue code silence-outside-library is deleted, with no alias.
  • feat: section 29, effects #151's Sharp/Net constructor properties write their defaults after their accessors.

Engine

  • ext/sharp: the three crossings renumber an int-keyed array where a List is declared.
  • Zend/zend_compile.c, Zend/zend_ast.c: a .sharp file's computed default, (static function () { return …; })(), compiles in a constant expression and runs each time it is evaluated.
  • ext/opcache/jit/zend_jit_ir.c: the function JIT checked a typed property write against the property info it knew at compile time, so a plain PHP parent's method let null into a PHP# override narrowed to string. Each typed write now checks the info of the object's own class, unless no subclass can redeclare the property.

Not in this PR

  • A Map passed to a plain PHP by-reference array parameter is refused today, whatever its keys. That waits until after v1.
  • A host error handler that ignores silencing still turns a built-in's failure warning into an exception. Suppressing it in the engine waits until after v1.
  • An enum's toString() doesn't reach plain PHP's string conversion, since PHP refuses __toString() on an enum.
  • Laravel's typed keyBy cases need a generic Collection and an Eloquent Model stub.
  • super<HasLabel>.label() as a whole expression body panics mago compile, on master too.

Problem
- The last v1 feature PR builds every approved change with no section
  PR of its own, and the §9, §18 and §19 examples that still fail. It
  had no design note to review against.

Solution
- docs/architecture/slices/singles.md gives each change's state on
  master bda1b92, observed with a release mago and the engine built
  from it, its mechanism and the code it reuses.
- It records team-lead's answers to its eight questions, the spec
  sweep of rules that make PHP# code work around PHP, what waits on
  #151 and feat/output-calls, the files that change, and the bugs found
  outside the slice.

docs/architecture/slices
└── singles.md    new
… converts it the same way

Problem
- Spec section 18 lets a template show any type that declares
  `string toString()`. The checker refused it: "A template shows `int`,
  `float`, `string` or `bool`, and `Sku` is none of them."
- Plain PHP's `(string) $sku` failed on a PHP# object, so a Blade view
  could not print one.
- §19 `operators` failed on its setup: the harness `Order` has no
  `: super(…)`, and the example's `DatabaseEntity` takes `int id`.

Solution
- composite_string.rs accepts a type whose classes declare
  `toString()`, themselves, through a parent or an interface, and its
  message and help take spec line 1995's wording.
- The bridge lowers such a template part to `$value->toString()`, which
  an enum case needs, and gives a class or struct that declares
  `toString()` PHP's `__toString()`, which calls it.
- The `operators` example declares its own `Order` in its setup, as the
  design note's question 6 answered.
- Decision 070 and section 18 say what plain PHP's conversion gives.

docs
├── spec.md                          §18 plain PHP conversion, §19 setup
└── decisions/070-template-values.md toString
sharp/baseline/spec                  drops §18 and §19 entries
sharp/mago/crates
├── analyzer/src/expression/composite_string.rs   toString shown
├── analyzer/tests/sharp.rs                        its rows
├── sharp-bridge/src/lower.rs                      the call, __toString
└── sharp-bridge/tests/lower.rs                    its row
Zend/tests/sharp
├── Templates/                       new fixture
└── template_to_string.phpt          new
Problem
- `public static never fail(string message) => throw …;` was "This type
  is not supported yet in PHP#.", so a PHP# helper that always throws
  had to declare a return type it never returns.
- A `never` parameter or property got two errors, Mago's PHP one and
  the PHP# one.
- A `never` method that could return got PHP's "Missing return
  statement … change the method's return type to 'never?'".

Solution
- check_slice takes `never` as a method's and an interface method's
  return type. PHP's own check reports `never?` and `never` in a union,
  and a `.sharp` file's `never` parameter or property gets the PHP#
  error alone.
- The analyzer reports a `never` method that reaches its closing brace
  there: "`Errors.stop` is `never`, and it reaches its closing brace
  when no `throw` runs before it."
- The bridge gives the method PHP's `never`.
- Section 7 states the rule, with the `never-methods` example.
- One more template row, in the test of a function type's effects,
  still read the template's old message.

docs/spec.md                         §7 never
sharp/mago/crates
├── semantics/src/internal/checker/sharp.rs                 never at Method and Signature
├── semantics/src/internal/checker/function_like/parameter.rs  one error
├── semantics/src/internal/checker/class_like/property.rs      one error
├── semantics/tests/sharp.rs                                 its rows
├── analyzer/src/statement/function_like/mod.rs              report_never_returning
├── analyzer/tests/sharp.rs                                  never_is_a_method_return_type
├── sharp-bridge/src/lower.rs                                erase: never
└── sharp-bridge/tests/lower.rs                              a_never_method_is_php_never
Zend/tests/sharp
├── Nevers/                          new fixture
├── never_methods.phpt               new
├── never_methods_preload.{phpt,inc} new
└── template_to_string_preload.{phpt,inc} new
… Map

Problem
- Plain PHP's `array<int, Person>`, such as `array_filter` gives, read as
  a `Map<int, Person>`: `for (const person of users.all())` gave
  `[int, Person]` entries, and `List<Person> people = users.all();` was
  refused.
- A plain PHP caller's `[5 => 1, 9 => 2]` passed to a `List<int>`
  parameter threw `TypeError`, as did a gappy array written to a `List`
  property or returned through a checked call.
- `Map<int, int> m = items;` with `items` a `List<int>` compiled, and
  `m.get(1)` threw at run time.

Solution
- codex `get_sharp_received_type`, the mirror of `get_php_received_type`:
  a plain `array<int, T>` without a shape is a `List<T>`. The analyzer
  applies it to a plain call's return and a plain property's read; the
  prelude's `Sharp` stubs are PHP#'s own.
- The bridge renumbers such a value where PHP# reads it,
  `\is_array($renumbered#1 = call) ? \array_values($renumbered#1) : …`.
  A `Map` place keeps the keys and checks the value as that `Map`, and an
  argument of plain PHP takes the array as plain PHP gave it. A library
  body that renumbers runs as a call, not an inline form.
- The engine renumbers a plain int-keyed array entering a `List` at the
  three crossings: an argument from plain PHP, a checked plain result
  and a plain property write.
- `check_sharp_literal_kind` refuses a `List` value where only a `Map` is
  declared: "A `List` is not a `Map`: its keys are only its positions."
  A local or property counts by its declared type, and a plain PHP value
  is exempt. Returns and expression bodies check after their analysis.
- Section 12 states both rules with two examples.
- Tests that relied on a plain `array<int, T>` being a `Map` key their
  arrays by `string` or `int|string`, and `ControlFlow` declares its
  `Map` place.

docs/spec.md                         §12 arrival and List-not-Map
ext/sharp/sharp.c                    sharp_type_renumber at three crossings
sharp/mago/crates
├── codex/src/ttype/mod.rs           get_sharp_received_type
├── analyzer/src/invocation/return_type_fetcher.rs
├── analyzer/src/resolver/{property,static_property}.rs
├── analyzer/src/expression/array.rs report_list_in_map_place, is_plain_php_value
├── analyzer/src/…                   check_sharp_literal_kind call sites
├── analyzer/tests/sharp.rs          two new tests, one fixture rekeyed
├── sharp-bridge/src/lower.rs        Arrival, renumbered
├── sharp-bridge/src/lower/types.rs  arrives_as_list, call_check_as
├── sharp-bridge/src/lower/inline.rs a form reads only its slots
└── sharp-bridge/tests/lower.rs      a new test, two fixtures rekeyed
Zend/tests/sharp
├── Arrivals/Roster.sharp, harness/Users.inc   new fixture
├── plain_array_arrival.phpt         new
├── ControlFlow.{sharp,inc}          a Map place for Prices.all()
└── opcodes.phpt                     ControlFlow's listing
…e class body

Problem
- `public string rawBody { get; } = "",` was 14 parse errors: a `.sharp`
  parameter read its default before its accessors, as PHP writes it.
- Accessor bodies, `willSet`, `didSet` and `via` on a parameter were
  refused ("Declare `x` in the class body to give it …"), and `required`
  on one was "This modifier is not supported yet in PHP#."
- §9 `parameter-member-limits` failed: the `via` parse error stopped the
  semantic check of the next line.

Solution
- The parser reads a `.sharp` parameter's accessors, then its `via`
  list, then its default. `FunctionLikeParameter` gains `behaviors`, as
  a hooked property has, and `ParseError::BehaviorParameterInSharp`
  leaves.
- The checker runs a parameter's accessors through the body property's
  checks: accessor bodies, storage and `via`'s rules. `required` on a
  parameter is "A constructor parameter is required unless it has a
  default: remove `required`."
- The bridge declares a parameter's property beside the constructor when
  its writes run through accessor bodies, observers or behaviors, as it
  already does for a `Map` or `Set` one: the property carries its hooks,
  the constructor creates the behaviors and then writes the argument
  through `set`, and a copy gets new behaviors.
- Section 9 states the rule, rewrites `parameter-member-limits`, adds
  `optional-parameter-properties` with a run line, and section 6.4
  drops the parameter's `via` refusal.

docs/spec.md                          §6.4, §9
sharp/baseline/spec                   drops §9/parameter-member-limits
sharp/mago/crates
├── syntax/src/cst/cst/function_like/parameter.rs   behaviors
├── syntax/src/cst/node.rs, walker/mod.rs           walk them
├── syntax/src/parser/internal/function_like/{parameter,arrow_function}.rs
├── syntax/src/parser/internal/class_like/property.rs   parse_optional_parameter_behavior_list
├── syntax/src/error.rs, hir/src/lower/error/mod.rs     the refusal leaves
├── syntax/tests/sharp.rs             a_parameter_default_follows_its_accessors_and_behaviors
├── semantics/src/internal/checker/sharp.rs           parameter checks, required
├── semantics/tests/sharp.rs          a_parameter_property_takes_every_body_property_feature
├── sharp-bridge/src/lower.rs         runs_its_accessors, promoted_property hooks
└── sharp-bridge/tests/lower.rs       two sources write the default last
Zend/tests/sharp
├── ParameterProperties/              new fixture
└── parameter_properties.phpt         new
Problem
- `catch (OutOfRangeError e)` in namespace `App.Probe` gave two PHP-worded
  errors, "Attempting to catch an undefined class or interface" and "None
  of the types specified in the `catch` declaration are valid catchable
  exceptions", and no suggestion.
- Nine other places fell back to Mago's PHP message for a class no file
  declares: `new`, an attribute, a behavior, a base class, an interface,
  a trait, a class constant read, `nameof` and a written type.

Solution
- `report_missing_class` runs the spec's cases in
  `report_unknown_sharp_class`, and otherwise reports
  "Cannot find type `App.Probe.OutOfRangeError`." Each fallback calls it.
- The help is "Did you mean `OutOfRangeException`?" when the short name
  with `Error` and `Exception` swapped names a class the file reaches by
  its bare name.
- A `new` of a missing class has the refused type, so a use of the object
  adds no second error.

Test
- `a_missing_class_is_one_error_that_names_it_as_php_sharp_does` replaces
  the test that kept each place's PHP error, with a row per place.
- Fourteen tests that quoted the PHP messages now quote the new one.
…eaves the argument out

Problem
- `int at = global.time()` and `Money m = new Money(0, "USD")` as a method
  parameter's default were "This expression is not supported yet in
  PHP#." A default was held to PHP's constant expressions.
- `int end = start + 1` as a default panicked `mago analyze` with
  "resolved name not found at position": the scan of a default read the
  resolved name of a local, which has none.

Solution
- Semantics checks a default as any body expression, and refuses a read
  of `this`, `field`, another parameter or a type parameter: "A
  parameter's default runs before the method, so `start` is not there
  yet."
- The analyzer analyzes a PHP# default as a body expression, so
  `Class.name` reads the static property as it does in a body.
- The bridge keeps a default PHP takes as a constant expression as
  written, and lowers any other to a static closure the default calls,
  `(static function () { return \time(); })()`.
- The engine compiles that call in a .sharp file's constant expression,
  and evaluating it runs the closure, with no caching, each time a call
  leaves the argument out, by position or by name, from PHP# and from
  plain PHP. `zend_compiling_sharp_file` replaces the two copies of the
  .sharp file test.
- The codex scan of a name with no resolved name infers no constant.
- Section 7 states the rule, with the `parameter-defaults` example and a
  run line.

Tests
- Semantics `a_parameter_default_is_any_expression_that_reads_no_object_or_parameter`
  replaces the constant-expression refusals, with a row per form.
- Analyzer `a_parameter_default_is_analyzed_as_any_expression`, and the
  data case default row now compiles.
- Bridge `a_parameter_default_that_is_no_constant_expression_runs_in_a_static_closure`.
- `parameter_defaults.phpt` and its preload twin, and a preload twin of
  `parameter_properties.phpt`.
…rn and continue speak PHP#

Problem
- A call of an interface's default body named the trait that holds it:
  `super<HasLabel>.label(5)` gave "Too many arguments provided for method
  `Defaults.label`."
- `ChargeError.Declined(string reason)` in a `match (this)` or an `is`
  gave a "Redundant `&&`" hint: the field test the pattern runs after its
  type test is always true.
- `continue;` outside a loop gave "Continue statement used outside of
  loop.", where `break;` gives "A `break` stands only inside a loop."

Solution
- `sharp_class_like_name` names a `Defaults` trait by its interface,
  through `CodebaseMetadata::get_defaults_interface`.
- `analyze_php_shape` drops the redundant `&&` of a type pattern with
  fields whose test can hold. A field test that can never hold keeps it.
- `continue` outside a loop in a `.sharp` file reads "A `continue` stands
  only inside a loop."

Tests
- `a_default_body_call_names_the_method_by_its_interface`
- `a_data_case_arm_that_binds_its_fields_reports_no_redundant_test`
- the `break` row of the `??` test gains a `continue` row
Problem
- `values is [...List<int> before, string tail]` on a `List<int>` gave
  "Impossible type assertion: `tail` of type `int` can never be
  `string`.", with the help "Check that the correct variable is being
  passed, or update the assertion type." Both describe the PHP the
  pattern runs as.

Solution
- `analyze_php_shape` rewords the PHP's report on a list pattern's typed
  element: "`tail` is an `int` in a `List<int>`, so it is never a
  `string`.", with the help "Test the element against a type an `int`
  can be." An element with no name is "This element".

Test
- `list_patterns_test_the_count_and_each_element` gains a row after a
  rest and a row before one.
…achinery

Problem
- Spec lines 500, 2884, 2885 and 3062 had users read `global.PHP_EOL`,
  `global.PHP_INT_MAX` and `global.PHP_INT_MIN`, PHP's names for values
  the standard library could give.
- A constant whose value reads `global.PHP_INT_MAX` was `Any?` where read:
  the scan inferred `global` as a class.
- Spec line 827 and the checker's help pointed a generic class's
  `Serializable` refusal to `__serialize` and `__unserialize`, which a
  `.sharp` file can't declare.
- The spec's opening paragraph did not state that no PHP# rule makes code
  write around PHP.

Solution
- `Sharp.Int` gains `MAX` and `MIN`. Section 23's example reads PHP's
  curl constant through `global.` and the bounds through `Int`, and
  section 24 writes `Int.MIN / -1`.
- The codex scan infers `global.NAME` as PHP's constant `NAME`.
  `read_type` replaces the two copies of a constant read's type choice.
- The `Serializable` help reads "Leave `Serializable` out: an object
  serialized as it is keeps its type arguments.", and line 827 says so.
- The opening paragraph gains the rule.

Tests
- Analyzer `a_constant_read_from_a_plain_php_constant_has_its_type`.
- `int_bounds.phpt` reads `Int.MAX` and `Int.MIN` from PHP#.
- `get_sharp_received_type` clones the element type through `Arc::clone`.
- `spec_syntax_outside_the_slice_is_one_not_supported_error_where_it_starts`
  has one row since `via` on a parameter parses, so it drops its loop.
PHP# reads a PHP built-in's failure from its return value, with a type
test, so the warning PHP raises for the same failure only repeats it.
The bridge lowers a call of a built-in function whose declared return
type holds `false` or `null` (`bool` and `mixed` hold them too) with
PHP's silence operator. A plain PHP library's own functions keep their
warnings.

The standard library's eleven `@global.` calls drop their `@`, and
`Hex.decode("zz")` gives the library's ValueError under an error handler
that turns warnings into exceptions.

The opcode twins write `@` where the bridge silences. The bridge test of
a static property or method in a parameter default now shows the static
closure it runs in, as the parameter-defaults commit made it valid.
…e a value

As C#'s `@class` does, `@` directly before a name in a .sharp file is one
name token. The name spans the `@`, and its value is the word after it,
so `@event` runs as PHP's `$event`: an override keeps a plain PHP
parent's `$event` parameter, and a named argument `event:` reaches it.
`@this` keeps its `@`, so the name differs from the object `this` in the
names walker, the analyzer and PHP, which takes `@this` as a variable
name and never sees `$this`. It works for a local, a parameter, a lambda
parameter, a catch, pattern or loop variable.

A bare keyword as such a name is "`event` is a keyword; write `@event`.",
`this` included, and incompatible-parameter-name's help names `@event`
when the parent's name is a keyword.

PHP# has no `@` before a value, in the standard library too: a call's
failure is the value it returns. The analyzer's silence-outside-library
check and its issue code go, as the checker refuses `@` everywhere.

Spec section 2 documents the escape, and section 23 a built-in's failure
read from its value, with a run line.
The checker refused a local or parameter named `_SERVER` or `GLOBALS`
with a message about PHP's variables. The bridge now runs such a name
as `@` before it, as `@this` is written, a PHP name no PHP code writes,
so the local never reads or replaces PHP's superglobal. Variables,
parameters, closure uses, catch variables and named-argument labels take
the hidden name, and a promoted parameter of such a name is declared
beside its property, which keeps its PHP# name.

The superglobal list moves to the names crate, beside php_local_name,
so the checker and the bridge read one list.
Spec section 6.1 asked an override of a typed plain PHP parent's
property to write exactly the parent's type, because PHP checks
property types for invariance as the class links. Now the written type
only has to be assignable to the parent's, `@var` included, as an
untyped parent's override already did: `string` over `?string`, or
`List<string>` over `array`.

The bridge declares such a property with the type its typed plain PHP
root declares, which PHP keeps through every override, and the engine
checks each write against the PHP# type's text, so a null the parent's
code writes to a `string` override is a TypeError. The analyzer's two
"does not fit" reports share one helper.
…in PHP array

Plain PHP's array parameter takes a Map keyed by a backed enum, passed or
spread, with each case's backing value as its key. The bridge writes
array_combine(array_column($map->keys(), 'value'), $map->values()), and a
null passes as it is. A Map keyed by a unit enum, a struct or a float is
still refused.
Resolved by hand:
- parameter.rs: #155's `int &value` reference reading, inside this
  branch's default-after-accessors order and its behaviors field.
- semantics sharp.rs: #155 deleted the loop-capture refusal, and this
  branch's parameter-default read check stays.
- analyzer invocation/analyzer.rs: master's takes_on_effects doc beside
  this branch's takes_php_sharp_types.
- analyzer property.rs: master's expanded declared type, with this
  branch's block-context arguments to check_sharp_literal_kind.
- tests: #151 removed the ENVIRONMENT copies, and the Map crossing rows
  take #155's "function value `counter`" wording.

Follow-through so #151's library compiles under this branch:
- Sharp/Net HttpRequest, MailAddress and MailMessage write a constructor
  property's default after its accessors.
- Files.sharp and Process.sharp drop the `@` on 13 built-in calls, each
  of which declares `false` or `bool`, so the bridge silences it.
A call of process.exit ends the block it is in, as throw does. So code
after it is reported unreachable, and an int method that ends in
process.exit(1) needs no return.
…nction is taken

A plain PHP class may declare a property and a method of one name. PHP#
read the property every time, so the method could never be a value.
Now the read is the method's value where the code takes it as a
function the property's type does not fit, passed, declared or read
with ?. Reading the property there was an error, so no code that
compiles changes meaning.

The analyzer records the method as the read's call target, and the
bridge writes PHP's $object->name(...) for it, since the engine would
read the property. A ?. read now takes its expected type too, and a
read taken as a function is resolved again rather than memoized.
The spec said shell_exec() stays, while the checker refuses a bare
shell_exec and names process.run, as #151 maps it. The spec now says
so in section 18 and in section 29's list of what Process replaces, and
the replacement test pins the shell_exec row.
Resolved by hand:
- Process.sharp: #157's 0 to 254 check and comment, on this branch's
  never return type.
- unary.rs, semantics sharp.rs and its tests, mago tests/sharp.rs:
  #157 edited the silence-outside-library rule and its tests, which this
  branch deletes. `@` before a value stays refused in every file, and
  the extern-method test already covers the native body refusal.
- analyzer tests: #157's array_sum call in the Map crossing test, with
  this branch's Pure row and Status crossing. #157's test of @ beside
  the call it silences goes with the rule.
- Accessors/Product, Collections/Cart, PhpForms and Signatures twins:
  #157 rewrote their .sharp sources, so its twins hold.
- spec: #157's global. bullets with this branch's Int.MAX constants
  bullet, and the backed-enum Map rule with #157's count wording.

Follow-through:
- global.hex2bin, global.time and global.count are refused outside the
  library now, so the @ help, the built-in-failures example and three
  tests use global.iconv, global.levenshtein and global.array_sum.
- 08-functions.md says @ before a value is refused.

Fix the merge showed: a built-in that takes a function, as
call_user_func and array_reduce, runs that function's code inside the
call, so silencing it hid the callback's own warnings. Such a built-in
keeps its warnings now, and the Cashier twin and its opcodes are back
to master's.
…te from the parent's code

A PHP# override of a typed plain PHP property keeps the parent's PHP
type and adds its own PHP# type to its own property info. The JIT wrote
a property of an immutable class with the property info it knew when it
compiled the method, so a plain PHP parent's method never saw the
child's PHP# type, and the function JIT let null into a string label.

One helper, jit_object_prop_info, now gives each of the four typed-write
sites the info of the object's own class, and keeps the compile-time
info only where no subclass can redeclare the property: a final class,
or a final or private property.
patch-coverage listed 68 lines no Rust test ran. Each is now run by a
test, or was code no PHP# file can reach and is gone.

Tests
- The bridge lowers a class's toString() to PHP's __toString(), a
  promoted parameter's behaviors, an override that narrows each PHP type a
  plain PHP parent declares, a spread of Maps keyed by a backed enum, and
  a plain PHP List of Maps that is renumbered where it arrives.
- The analyzer refuses a spread of Maps into a plain PHP variadic, a
  List from a PHP# field's function, field or type parameter where a Map
  is declared, and suggests a standard library class one Error or
  Exception ending away.

Removed
- A behavior's missing class kept Mago's PHP message after the PHP#
  report, which always reports in a .sharp file, the only file with
  behaviors.
- A class constant read on a missing class in a .sharp file never reaches
  report_non_existent_class: the binder reports the name first.
- The by-reference write-back of a Map keyed by a backed enum: a Map is
  refused by reference, which waits until after v1.
- check_default_reads kept the shortest node at each byte, which the walk
  already gives first.

An impossible arm is unreachable!, as break.rs writes the same one for
continue. Three doc comments that sat above the wrong function moved back.
- A write through a plain PHP property PHP# reads as a List sets the
  property to its renumbered value, then changes it in place, as
  users.names.add("cy"), users.names[0] = "zed" and Users.tags.add("z").
  An assignment target is never renumbered.
- Only plain PHP metadata gives the received type, so a PHP# function
  value typed Function<Map<int, V>()> returns its Map, and a lambda whose
  body is a List there is refused.
- A constructor parameter's behaviors get the body property's checks,
  and a later behavior may be generic, as via Trimmed, Shouted<int>.
- A property read in a parameter default runs in the static closure.
- toString() from an interface's default body reaches plain PHP's
  string conversion, and every toString() is string toString().
- PHP_INT_MAX and PHP_INT_MIN, bare and through global, name Int.MAX and
  Int.MIN through REPLACEMENTS.
- never as a return type's type argument, a keyword as a bare lambda
  parameter, a static member of a missing class, required outside a
  constructor and a default before the accessors each get one error.
- The named argument this: passes the parameter @this.
- The spec says a failed built-in's warning is silenced.
@heyJordanParker
heyJordanParker merged commit 754ab7c into master Oct 17, 2026
22 checks passed
@heyJordanParker
heyJordanParker deleted the feat/singles branch November 3, 2026 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant