Repository navigation
docs: the spec states Jordan's round 7 rulings, and every older example follows every ruling - #116
Merged
Merged
Conversation
…le follows every ruling
Problem
Jordan ruled I1, I3, I4, I6, I7, I8, I9 and I10 in round 7, and the spec did
not state them. Older text contradicted the rulings: section 5 made private
the default for every member, interface members included; section 19 let `==`
compare a class value only through a declared `operator ==`; section 26 let an
extension apply only where its class is imported; section 21 named a local
`event`, a keyword; sections 8 and 29 kept PHP's built-in functions callable;
and sections 29 and 32 promised Laravel declarations and a Laravel adapter.
Errata waited too: section 12's List index line, section 11's reflection and
static-member lines, and section 29's native-body example and its language.
Solution
Each ruling is written where it belongs, with a checked example where it has
one. Every older line that contradicted a ruling now follows it. The examples
that call PHP functions stay until the standard library's effect members are
designed. The six new examples fail on the pinned Mago, which lacks each rule,
so they join sharp/baseline/spec.
docs/
└── spec.md
├── §2 I3: any word names a member; example keyword-members
├── §2 I4: keywords are lowercase only; example keyword-case
├── §5 I1: an interface member is always public; example interface-members;
│ the table's private row; its reach is its interface's, and the
│ too-wide warning skips it
├── §6 I6: a static that isn't T? needs an initial value;
│ example static-initial-values
├── §8 I9: every PHP built-in function is a standard library method
├── §11 errata: one reflection line; a static member names its type arguments
├── §12 erratum: the List index line
├── §19 I7: class values compare by value with ==
├── §21 ruling 6: property-patterns' local event, a keyword, becomes payment
├── §23 I8: a class in the file's own namespace shadows the default one;
│ example own-namespace-shadows
├── §25 I7: two class values are equal by class and type arguments;
│ example class-value-equality
├── §26 I8: an extension applies in the files of its own namespace
├── §29 I9 and I10: the effect classes replace PHP's functions, and no
│ framework's declarations ship; errata: the native-body example is
│ the library's Text.slug, and names no language
└── §32 I10: no Laravel adapter; any framework's container reaches PHP#'s
through PSR-11
sharp/
└── baseline/spec + 6 entries, one per new example
…s included
Problem
Jordan ruled I2: a function type is a type like any other, so `is`, `as` and
`match` test it as they test `List<int>`. A test whose type the value's source
never declares, such as a plain PHP library's untyped `Closure`, can't be
answered and must say so. The spec stated neither.
Solution
Section 21 states the rule once, for every type, with an example that tests a
PHP# lambda against two function types and refuses the test on a plain PHP
`Closure`. No example refused a function-type test, so nothing else changes.
The example fails on the pinned Mago, which refuses function types in a
pattern, so it joins sharp/baseline/spec.
docs/
└── spec.md
└── §21 I2: every type answers is, as and match the same way; example type-tests
sharp/
└── baseline/spec + 1 entry, type-tests
…ace, and the spec states only user rules
Problem
Jordan ruled I5 and I11. Section 19 let only a class declare `operator ==`,
section 23 let an import end in a plain PHP function, and five examples called
the harness's plain PHP functions by bare name. An audit also found the spec
describing its implementation as language (inlining, native bodies, PHP arrays,
array_replace, the .sharpc layout, php.ini), using PHP or a framework as the
reason for a rule, a standard library API that took Any? and a List.wrap that
match already covers, and a few contradictions and unclear lines. Seven rules
also had no mainstream precedent: nested ternaries were refused, a stored
function was read after its arguments, tuple names were required, Result's
failure case was named Error, templates refused every type but four, two
null rules refused code no other language refuses, and nothing said what
happens to a get-only property that is never set. Jordan approved eleven more
audit proposals: the collections model, extension choice, the plain PHP
boundary under readonly and in property overrides, what a pattern takes, parse
on classes, and what a constructor parameter declares.
Solution
Section 19 states one equality rule, and section 23 calls a library's function
through its namespace. The implementation lines are gone, so every remaining
line states what a user writes and sees. Reasons cite C#, Kotlin, Swift, Java,
Go or Rust instead of PHP or Laravel. Int.parse takes a string, List.wrap is
gone, Environment.require is an instance member that a module binding calls
on the Environment it takes and throws ValueError on a missing variable. A
module binding names the services it needs as parameters and its value is one
expression over them, as Dagger's provider methods do, so Factory<T> is gone
and a foreign object is created in a module binding. The module lifetimes are
defined by the host. A type test against a plain PHP
generic's type argument is a compile error. The seven precedent rules follow
C#, Java, TypeScript, Swift, Dart and Rust. Jordan's eleven approvals follow
Kotlin, Swift, Rust, C#, Java and TypeScript. New examples that fail on the
pinned Mago join sharp/baseline/spec, and a refused line that the pinned Mago
accepts sits in its own example, so the lines beside it stay checked.
docs/
└── spec.md
├── intro a language on PHP's engine, as Kotlin is on the JVM
├── §2 a keyword can't name a local; a capitalized keyword is a name
├── §6 no public fields; initial values run before the parent's
│ constructor and can't read this, as in C#; a get-only T? is set
│ once, by its initial value or the constructor; a get-only
│ property with no initial value is set on every path through the
│ main constructor, as Swift's let and Kotlin's val are;
│ nullable-members shows both in a Profile class
├── §6.1 a plain PHP parent's property is overridden with a property;
│ no constant-value rule
├── §6.5 static lazy lives for the host's app lifetime
├── §8 no inlining bullet, no runs-as comment
├── §9 a constructor parameter takes access levels and attributes
│ only, as TypeScript and Kotlin parameter properties do; example
│ parameter-member-limits
├── §10 a struct keys a Map when every field has ==; classes get parse
│ and tryParse too
├── §11 one sentence for carried type arguments; plain PHP generics
│ are erased, as Java's are, so x is Collection<Order> is a
│ compile error
├── §12 values like Swift's collections; no PHP-array, spread or
│ key-text implementation; plain PHP gets an enum key's backing
│ value and a generated key text for any other key; a List read throws and getOrNull is
│ the safe read; a Map read is TValue?; x[i] = v replaces a List
│ element and set is gone; anything with == and hash() keys a Map;
│ a Map is an Iterable of [key, value] entries; only a literal
│ takes its collection type, and a List variable where a Set is
│ expected names toSet(); a List index takes changing methods;
│ Kotlin's collection names; map-reads calls this.charge
├── §13 readonly holds only types PHP# checks; no platform-types line
├── §14.3 a stored function is read before the arguments run
├── §14.4 leave-on-null calls this.charge; no rule against a nullable
│ parameter rejected on every path
├── §15 no build-step lines; Order.Paid can only be the named constructor
├── §17 a Map loop gives [key, value] entries, values() gives values;
│ example map-values
├── §18 + is chosen from the operand types; a template takes any type
│ that declares toString(); example template-to-string
├── §19 I5: one equality rule; example struct-equality; ? : groups
│ to the right
├── §20 Swift raw-value enums; no Schema
├── §21 match-forms, narrowing and is-not-scope call members;
│ a ? b : c ? d : e means a ? b : (c ? d : e); a pattern takes
│ types and constants, and a local's value is compared in when;
│ example pattern-locals
├── §23 I11: a library function is called through its namespace;
│ example library-functions; own-namespace-shadows no longer
│ uses require
├── §24 / chosen from the operand types; Int.parse takes a string;
│ List.wrap gone; a naming warning stated as the user sees it
├── §25 no getAttribute; a property named by a variable has no form
├── §26 an extension is chosen from the type the line shows; example
│ extension-static-choice
├── §27 type files only; Java's one class per file; no .sharpc layout
│ or php.ini line
├── §29 no native bodies; one list of the ten effect classes; PHP's
│ built-in classes refused; superglobal errors name Environment
│ or a parameter; Environment.require is an instance member a
│ module binding calls, and throws ValueError; a foreign object
│ is created in a module binding; extern Pdf.render and extern
│ global.now
├── §30 tuple element names are optional
├── §31 Result's failure case is Err
└── §32 no implicit environment: a binding names the services it needs
as parameters and its value is one expression over them;
Factory<T> and the factory example are gone; module-errors
refuses a statement in a module; every binding parameter needs
a binding; lifetimes by the host; SHARP_ENV
README.md a language on PHP's engine, as Kotlin is on the JVM
sharp/
└── baseline/spec + 9 entries: struct-equality, library-functions,
template-to-string, plain-php-property-override,
parameter-member-limits, set-variable-arguments,
map-values, pattern-locals, extension-static-choice;
parameter-members passes and leaves, and factory
leaves with its example
… class
Problem
typeof(order) read a bare name as a local's value when a local with that
name was in scope, and as a type otherwise. Jordan ruled that a pattern takes
types and constants only, and that typeof follows the same rule, so
typeof(order) on a local had no meaning left and the runtime class of an
object had no form.
Solution
typeof takes a type only. Class.of(value) gives an object's runtime class, as
Swift's type(of:) and Python's type() do. The bare-name bullet is gone, and
typeof(order) is a compile error that names Class.of(order).
docs/
└── spec.md
└── §25 typeof takes a type only; Class.of(value) gives an object's
class; typeof-values uses Class.of(order) and refuses
typeof(order); a class value comes from typeof or Class.of
…spec drops what plain PHP receives
Problem
Environment's currentDirectory was a get-only property, which reads as a value
fixed when the object is made. The directory a process runs in changes while
it runs, and PHP# had no way to change it, since PHP's chdir is a built-in
function the standard library replaces. The spec also described what plain
PHP receives from PHP# code, which no PHP# user writes. Jordan: "What PHP
receives from PHP# is not part of the specimen or how users use php#."
Solution
currentDirectory() is a method that reads the directory on every call, as Go's
os.Getwd() and Rust's env::current_dir() do. changeDirectory(path) changes it.
arguments stays a get-only property. Every sentence about what plain PHP
receives from PHP# is deleted. Every sentence about what PHP# code receives
from plain PHP stays, because PHP# users write that code.
docs/
└── spec.md
├── §10 "Plain PHP sees a generated key text." deleted
├── §11 the reflection bullet on what plain PHP reads deleted
├── §12 "Plain PHP receives an enum key's backing value, and a generated
│ key text for any other key." deleted
├── §13 "`readonly` is enforced by the checker. The engine sees ordinary
│ methods, so plain PHP callers are not checked." deleted
├── §25 both class-name-string sentences and the typeof-values comment
├── §27 the __CLASS__ comment's receive clause, and "A plain PHP caller
│ gets the position where the parameter is declared…" deleted
└── §29 Environment: string currentDirectory(), read on every call;
void changeDirectory(string path)
heyJordanParker
added a commit
that referenced
this pull request
Oct 13, 2026
Problem: the generics slice branched from master c3a4a3c. Master since gained effects on function types (#126), private fields with no modifier (#128), union collections (#116), the sortedBy key rule (#125), macOS and Linux CI (#127), function uses (#122) and message fixes (#117). Ten files conflicted, and one master test named a syntax field the slice renamed. Solution: every conflict keeps both sides' behavior. - A refused expression has the error type in PHP# and `never` in PHP, as master types it, and `is_refused` keeps the slice's wider set of refused generic expressions. - An argument is a possible mismatch only when the parts it may share with the parameter, as `shareable_part` takes them, fit through master's `can_argument_be_identical`, and `verify_argument_type` returns whether the argument fits, as master's effect rules read it. - A method value's signature names the class it is read through, as master needs for `extern` lookups, while the slice still specializes it for its receiver and fixes its type arguments. - A PHP# literal's backed enum key and master's other new calls pass the dialect `get_backing_key_type` takes on the slice. - Comparisons master added use the slice's `ComparisonResult::for_dialect`. crates/ ├── analyzer/src/ │ ├── artifacts.rs tested_types beside function_values │ ├── expression/ │ │ ├── array.rs master's PHP# key branch, with the dialect │ │ ├── assignment/array_assignment.rs every declared element, for_dialect │ │ └── mod.rs slice's is_refused, master's error type │ ├── invocation/arguments.rs shareable_part over can_argument_be_identical │ ├── resolver/ │ │ ├── method.rs declared collections, paired with their written atomic │ │ └── property.rs method value source is the read-through class │ └── statement/ │ ├── class_like/property.rs for_dialect, records fitting function values │ └── function_like/mod.rs passes tested_types and function_values up ├── codex/src/scanner/ttype.rs function type keeps its effects and its type parameters └── syntax/tests/sharp.rs effects test reads type_arguments.arguments
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.
Problem
Jordan ruled I1 to I11 in round 7, and the spec did not state them. A read-only audit then found the spec describing its implementation as language, using PHP or a framework as the reason for a rule, and contradicting itself. Jordan approved eleven audit proposals and ruled modules and
typeof. team-lead ruled seven more items from mainstream precedent. Older examples contradicted every one of these rulings.Solution
Each ruling is written as the spec's rule, in the section it belongs to, with a checked example. Every older line and example that contradicted a ruling now follows it. Every reason cites a mainstream language (C#, Java, Kotlin, Swift, TypeScript, Go, Rust, Python or Dart), never PHP. A new example that the pinned Mago (625c278) fails joins
sharp/baseline/spec. A refused line that the pinned Mago accepts sits in its own example, so the lines beside it stay checked.Every change, by ruling
Round 7: I1 to I11
interface-members.is,asandmatchtest every type the same way, function types included. A test on a value whose type its source never declares is a compile error that says the type is unknown. Exampletype-tests.catchor pattern variable can't take a keyword's name. Examplekeyword-members.keyword-case.operator ==withhash().==with no code when every field or element has it.==only when it or a parent declares one.==.struct-equality.T?needs an initial value. Examplestatic-initial-values.==, equal when they name the same class with the same type arguments. Exampleclass-value-equality.own-namespace-shadows.import Vendor.Pdf;thenPdf.render(html).global.now().extern Pdf.render uses Files;andextern global.now uses Clock;declare their effects.library-functions.charge,deliverandrenderby bare name now call members their setup declares.The audit's implementation and PHP lines
array_replaceand the engine's key text;.sharpctree and thephp.iniline.SHARP_ENV;static lazyfor the host's app lifetime;+and/: each is chosen from the operand types the checker sees, as C# and Kotlin resolve operators.Int.parseandFloat.parsetake astring.List.wrapis gone.Environment.requireis an instance member that throwsValueErrorwith "Environment.require: the environment variable "NAME" is not set".Environment.currentDirectory()is a method that reads the directory on every call, as Go'sos.Getwd()and Rust'senv::current_dir()do, andchangeDirectory(path)changes it.What plain PHP receives from PHP# is not part of the spec
Jordan: "What PHP receives from PHP# is not part of the specimen or how users use php#." Every sentence that said so is deleted:
ReflectionObject::getTypeArguments(), as C#'sType.GetGenericArguments()does. AReflectionTypeshows PHP's own type, sogetName()stays what dependency injection containers and proxy generators read."readonlyis enforced by the checker. The engine sees ordinary methods, so plain PHP callers are not checked."typeof(X)rule.Class.of(value)rule.Every sentence about what PHP# code receives from plain PHP stays, because PHP# users write that code, such as where collection elements are checked as they enter PHP#.
team-lead's precedent rulings
a ? b : c ? d : emeansa ? b : (c ? d : e), as in C#, Java, TypeScript, Swift and Dart.Err, as Rust'sResult::Errsits beside itsErrortrait.int,float,string,booland any type that declarestoString(), as Rust'sformat!takes anyDisplaytype. Exampletemplate-to-string.T?is set once, like every other get-only property.letand Kotlin'svalare.Jordan's approved audit proposals
names[0] = xreplaces a List element and throws past the end.set(i, v)is gone.names[i]throws when the index is missing, andgetOrNull(i)is the safe read.names[i] ?? xis a compile error that namesgetOrNull.TValue?.[key, value]tuples, andvalues()gives the values. Examplemap-values.==andhash()keys a Map and joins a Set.toSet(). Exampleset-variable-arguments.extension-static-choice.readonly: a plain PHP class underreadonlyis a compile error.this, as in C#.when, as in C#. Examplepattern-locals.typeoftakes a type only.Class.of(value)gives an object's class, as Swift'stype(of:)and Python'stype()do.parse: classes getparseandtryParsethe same way structs do.parameter-member-limits.Modules: a binding names the services it needs as parameters, and its value is one expression over them, as Dagger's provider methods do:
Factory<T>and every factory example are gone.The list
php sharp/bin/spec --base b1fa0fdb0d: "16 entries join sharp/baseline/spec, 2 leave it."keyword-members,keyword-case,interface-members,static-initial-values,own-namespace-shadows,class-value-equality,type-tests,struct-equality,library-functions,template-to-string,plain-php-property-override,parameter-member-limits,set-variable-arguments,map-values,pattern-localsandextension-static-choice. Each states a rule the pinned Mago lacks.plain-php-property-overridepassed before. It now overrides with a property, which the pinned Mago reports as "Overriding a property is not supported yet in PHP#."parameter-memberspasses, because it no longer putsviaon a parameter.factoryleaves with its example.The full check: "Checked 179 examples, ignored 1, and 113 fail.", all listed. The self-test: 17 of 17.