Skip to content

Eight fixes a Laravel app needed, and interface { get; init; } - #179

Merged
heyJordanParker merged 6 commits into
masterfrom
fix/real-app-findings
Oct 19, 2026
Merged

heyJordanParker merged 6 commits into
masterfrom
fix/real-app-findings

Conversation

@heyJordanParker

Copy link
Copy Markdown
Owner

Fixes the eight defects a Laravel app hit when it moved onto PHP#, and builds team-lead's ruling on the last "not supported yet" form.

The fixes

  1. An extension host reads a method that takes a function. The SDK reads the 64 flag bits as PHP's signed int, so bit 63 (TAKES_ON_EFFECTS) and every later flag cross the protocol. Precedent: protobuf-java carries a fixed64 in a Java long.
  2. mago-sharp declares replace for carthage-software/mago, so a project whose packages require upstream mago installs one checker. The plain-php CI job installs a package that requires upstream mago beside mago-sharp and checks that no second checker lands. Precedent: Gradle capabilities.
  3. Companion files stay out of git with no git to run. mago compile reads .git itself, a folder or a gitdir: file with its commondir, and warns with the fix when info/exclude can't be written or a worktree's repository is missing. Precedent: libgit2 and JGit.
  4. ReflectionProperty::isInitialized(), setValue() and getRawValue() no longer let a later getValue() skip the collection crossing. Precedent: Kotlin's KProperty1.get.
  5. A plain PHP shape keyed by int alone, as list{int, int} or array{0: int, 1: int}, arrives as a List, and so does an int-keyed array a shape's field, a Map's value or a List's element holds, renumbered by the engine and the bridge. A sealed list shape keeps its elements through a count check, so a list pattern matches it. Precedent: Kotlin reads a Java List, and TypeScript's [number, number] is a number[].
  6. List<string> has join(separator), in Sharp.Text.Text beside split, with a section 12 example. Precedent: Rust's [String].join, JavaScript's join, Swift's joined(separator:).
  7. The companion declares its type in source, in an if (false) that never runs, with the kind reflection gives it, so Composer's class map and Symfony's attribute routing find App\Billing\Order in Order.php with no hook. The engine declares the type once, from the .sharp file, and mago reads the .sharp file and never its companion. Decision 81 and section 27 say so. Precedent: TypeScript's .d.ts, which tsc never reads in place of the .ts beside it, and Kotlin's light classes.
  8. A for or while loop whose body always leaves past it (return, break orders, plain PHP's break 2) ends only when its condition fails before the first pass, so the code after it gets the locals it began with, never never. Precedent: TypeScript's and Kotlin's control-flow analysis.

Item 9: an interface property states { get; init; }

A class or a struct gives it with init, and an event through its parameter. { get; set; } or get-only in the class is refused, and so is a write through the interface after creation. Any other accessor list an interface property states, as { get; set; init; }, gets what that list gets on a class property. The interface runs as PHP's { get; }, because PHP gives an interface's set hook only a public set. is_undecided and not_supported_yet are gone, with the self-test row that used the form. Precedent: C# 9 and CS8853.

Verification

  • Each fix has a row seen failing first: server_engine.rs, compile.rs, collection_crossings.phpt, plain_shaped_lists.phpt, the analyzer's sharp.rs, library_text.phpt, discovery.phpt, interface_init*.phpt in every JIT and preload mode, and the semantics and bridge rows.
  • sharp/bin/test and --opcache --repeat: 413 of 413 in every mode. ext/reflection/tests: 540 of 540.
  • sharp/bin/spec: 259 examples, 0 fail, list-join, plain-list-arrival and interface-init among them. The self-test: 23 of 23.
  • cargo test for the analyzer, codex, database, semantics and bridge crates, and the compile and server_engine suites. cargo fmt --check and cargo clippy --workspace --all-targets --all-features -D warnings are clean. The SDK's PHPUnit suite: 126 of 126.

A Laravel app moved onto PHP# needed a workaround in each of these places.

1. An extension host reads a method that takes a function. The SDK reads the
   64 flag bits as PHP's signed int, so bit 63 (TAKES_ON_EFFECTS) and every
   later flag cross the protocol. Precedent: protobuf-java carries a fixed64 in
   a Java long.

2. mago-sharp declares `replace` for carthage-software/mago, so a project
   whose packages require upstream mago installs one checker. CI installs a
   package that requires upstream mago beside mago-sharp. Precedent: Gradle
   capabilities, where one module provides another's capability.

3. Companion files stay out of git with no git to run. mago compile reads
   .git itself, a folder or a `gitdir:` file with its `commondir`, and warns
   with the fix when the exclude file can't be written. Precedent: libgit2 and
   JGit, which read a repository without the git program.

4. ReflectionProperty::isInitialized(), setValue() and getRawValue() no
   longer let a later getValue() skip the collection crossing. Precedent:
   Kotlin's KProperty1.get, which reads what a property read gives.

5. A plain PHP shape keyed by int alone, as list{int, int} or
   array{0: int, 1: int}, arrives as a List, and so does an int-keyed array a
   shape's field, a Map's value or a List's element holds, renumbered by the
   engine and the bridge. A sealed list shape keeps its elements through a
   count check, so a list pattern matches it. Precedent: Kotlin reads a Java
   List as a List, and TypeScript's [number, number] is a number[].

6. List<string> has join(separator), in Sharp.Text.Text beside split, with a
   spec section 12 example. Precedent: Rust's [String].join, JavaScript's
   join and Swift's joined(separator:).

7. The companion declares its type in source, in an `if (false)` that never
   runs, with the kind reflection gives it, so Composer's class map and
   Symfony's attribute routing find App\Billing\Order in Order.php. The engine
   declares the type once, from the .sharp file, and mago reads the .sharp
   file and never its companion. Precedent: TypeScript's .d.ts file, which
   tools read and tsc never reads in place of the .ts beside it, and Kotlin's
   light classes.

8. A for or while loop whose body always leaves past it, through return or
   a break that names an outer loop, ends only when its condition fails before
   the first pass, so the code after it gets the locals it began with, never
   `never`. Plain PHP's break 2 is the same. Precedent: TypeScript's and
   Kotlin's control-flow analysis, where the type after a loop joins the
   states that reach its condition.
Team-lead's ruling, the last "not supported yet" in PHP#: an interface may
state `string kind { get; init; }`. A class or a struct gives it with
`init`, and an event through its parameter, which `new` sets once. A class
that gives it with `set` or get-only is refused, and so is a write through
the interface after the object is created. Any other accessor list an
interface property states, as `{ get; set; init; }`, gets the errors the
list gets on a class property. PHP gives an interface's `set` hook only a
public `set`, so the interface runs as PHP's `{ get; }`.

The checker's `is_undecided` and `not_supported_yet` go, with the
self-test row that used the form. Precedent: C# 9's `init` accessor in an
interface, and CS8853, which requires the implementing accessor to be
`init`; a C# record's positional property is `init`, as an event's
parameter is.

Also: the warning for an exclude file that can't be written names only
the files no earlier block keeps out of git, and a lint fix in the SDK
row's fixture.
Patch coverage found the `with private set` wording of item 9's refusal
unrun.
A deploy or a value that broke:

- A type named after a word PHP reserves, as Case, Match or Global, gets a
  PHP file that states no declaration, so it parses and Composer's PSR-4
  rule loads it. PHP refuses such a name in any PHP source, so no source
  scanner finds it, and decision 81 says so. mago-semantics exports
  is_php_keyword, the test its checker already used.
- A git that fails, as in a checkout another user owns or an empty .git,
  no longer fails mago compile: the block lists every PHP file and the
  compile warns once with git's first line, as cargo warns and goes on
  when it can't read a repository's status.
- A plain PHP value typed as a list or a map, as
  list<int>|array<string, int>, keeps its string keys: the lowering
  renumbers a value only when every array it may be is a List.
- A PHP# match keeps the arms the analysis finds unreachable, its
  required default included, so the analysis types them, as TypeScript
  types the default of an exhaustive switch, and drops what they report.
  A rest pattern on a plain PHP shape or a PHP# tuple no longer panics
  the lowering.

The rest:

- mago-sharp replaces carthage-software/mago at exactly 1.51.0, the
  release it left from, as a Gradle capability names one version, so a
  host that needs a later SDK gets no install. CI checks a ^1.57 host.
- A continue that names a loop around this one leaves past it, so the
  locals after the inner loop are the ones it began with.
- A loop never ends on its condition only when the condition is the
  constant true, judged from its words, as TypeScript and Kotlin judge
  it: for (let i = 0; true; i++) needs no return after it, and
  do ... while (again) on a bool local ends.
- The read-only exclude warning names the info folder the rename needs,
  and no temporary file.
- A lazy ghost or proxy of a class with an initial value that runs, a
  PHP# collection or a plain PHP constant, initializes under opcache: the
  lazy object asserts read the request's constants flag, which an
  immutable class keeps in its mutable data.
- Reflection's isInitialized() on a lazy proxy gives for a Map or Set
  property what it gives for a plain array property.
- The optimizer leaves the value ZEND_SHARP_VERIFY_TYPE_ARGS checks in
  its TMP, so a preloaded plain PHP call that returns a literal runs.
- The SDK's MetadataFlags names every flag the codex defines, and a test
  compares the two.
- An interface's `private init` gets help that names
  `{ get; private init; }` for the class.
A CI runner's system or global git config can list every folder as a
safe.directory, so git read the repository the test makes it refuse.
The compile runs with GIT_CONFIG_NOSYSTEM and an empty global config.
@heyJordanParker
heyJordanParker merged commit 342bcb4 into master Oct 19, 2026
24 checks passed
heyJordanParker added a commit that referenced this pull request Oct 20, 2026
… the call is written

The review of #185 found six gaps in the check each PHP# call of a PHP# interface's member runs on its result.

- A `never` or `void` member no longer panics mago compile: the bridge marks the member's result
  ZEND_SHARP_RESULT_CALLER_CHECKED from the attr it gives the result, never from its node kind.
- A call of a plain PHP class's untyped method, on the class or on `this` of a PHP# subclass, is a call of
  the member of the class's PHP# interface that declares it: the analyzer types it by the member, and the
  bridge checks it as a call through the interface. A class whose interfaces declare different results for
  the method is refused at the link, as Kotlin refuses conflicting inherited members.
- The error names the type the member states: the check's text carries the type the error names after the
  type it checks, so a `List<int>` member's error says `List<int>`, and a null-safe call's says `Relation`.
- The check reads each collection alone at any depth, a tuple's elements included.
- A check's text in a static member of a generic class names the class's type parameter as the static
  member's `#i`, through the rewrite its own type texts take, so it no longer asserts in the engine.
- A call that gives a generic method, or a generic class's static method, the type argument its result
  names checks the result against that type, as Java checks an erased generic method's result at its
  caller, since a check in the method's body reads the type parameter as any type.

#179's forwarder goes: the engine links a plain PHP parent's untyped method under the member itself, and a
PHP# subclass's calls take the member's type and check, so Lowering::forwarders, Types::forwarded_methods and
the analyzer's forwarded exemption are deleted.

The in-process engine test caller_checked.phpt runs every case under opcache, repeat and each optimizer pass.
@heyJordanParker
heyJordanParker deleted the fix/real-app-findings 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