Skip to content

Remove Type::some() — an identity function masquerading as a type constructor - #98

Merged
MidnightDesign merged 1 commit into
masterfrom
93-remove-typesome-an-identity-function-masquerading-as-a-type-constructor
Jul 23, 2026
Merged

Remove Type::some() — an identity function masquerading as a type constructor#98
MidnightDesign merged 1 commit into
masterfrom
93-remove-typesome-an-identity-function-masquerading-as-a-type-constructor

Conversation

@MidnightDesign

Copy link
Copy Markdown
Contributor

Problem

Type::some() was a public static factory that returned its argument unchanged:

public static function some(self $some): self
{
    return $some;
}

Sitting next to option() (a real Option<T> wrapper) and none() (a real None type), it read as "the Some branch of an Option" but constructed no Some type at all. Type::some(Type::int()) was exactly Type::int(), so calls like x.isSubtypeOf(Type::some(...)) behaved nothing like they read — a silent footgun. Some appears nowhere in the README's user-facing type list.

Change

  • Removed Type::some() from the public surface.
  • Removed its only test. The equalsCases provider held a single case, 'Some<T> == T', whose whole purpose was to assert the identity behavior being removed; with it gone the provider would be empty, so the provider and its testEquals consumer go together. equals()'s positive path stays covered by testAliasTypeEqualsAliasTarget, and the Some<...> type-parsing path (notEqualsCases) is untouched.

Deliberately left alone

TypeConstructor::Some and the parser's resolveSome() are legitimate — they back the Some<T> type syntax that Option<T> builds on. This PR targets only the misleading public factory.

BC impact

Structural break (public method removal). Scoped for the 0.3.0 breaking release.

Verification

  • PHPUnit: 1130 tests OK
  • Psalm / PHPStan: no errors · PHP-CS-Fixer: clean · composer check-deps: no unknown symbols
  • Infection on the diff (vs master, 100% MSI): deletion-only change, no mutants generated — passes under --ignore-msi-with-no-mutations

Closes #93

🤖 Generated with Claude Code

…tructor

Type::some() was a public static factory that returned its argument
unchanged. Sitting next to option() (a real Option<T> wrapper) and
none() (a real None type), it read as "the Some branch of an Option"
but constructed no Some type at all: Type::some(Type::int()) was
exactly Type::int(), a silent footgun for calls like isSubtypeOf().

Its only test asserted `Some<T> == T` via the identity behavior, so the
equalsCases provider and its testEquals consumer go with it; equals()'s
positive path stays covered by testAliasTypeEqualsAliasTarget, and the
Some<...> type-parsing path (notEqualsCases) is untouched.

TypeConstructor::Some and the parser's resolveSome() stay: they back the
Some<T> type syntax that Option<T> builds on.

Structural BC break scoped for the 0.3.0 breaking release.

Closes #93

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MQzPPJxpbn6z2BQ1JYnxoY
@MidnightDesign
MidnightDesign merged commit 5988406 into master Jul 23, 2026
25 checks passed
@MidnightDesign
MidnightDesign deleted the 93-remove-typesome-an-identity-function-masquerading-as-a-type-constructor branch July 23, 2026 14:26
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.

Remove Type::some() — an identity function masquerading as a type constructor

1 participant