---
title: "[Pre-RFC] Scalar object methods (with a working implementation)"
url: https://daily.dev/posts/pre-rfc-scalar-object-methods-with-a-working-implementation--j65oyhuep
source_url: https://externals.io/message/131773
type: article
source: "externals.io"
published: 2026-07-05T01:57:31.978Z
updated: 2026-07-05T01:58:01.212Z
tags: ["php", "phpstan"]
reading_time: 7
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# [Pre-RFC] Scalar object methods (with a working implementation)

**[externals.io](https://daily.dev/sources/externals)** · 7 min read · 0 upvotes · 0 comments

## Summary

A PHP internals mailing list thread discussing a Pre-RFC proposal for scalar object methods in PHP, where scalar types like strings and integers could use method-call syntax (e.g., $s->trim()). The proposal author Michal Kral clarifies that dispatch is syntactic and compile-time only, requiring typed locals or literals as receivers — not runtime type inference. Critic Seifeddine Gmati (maintainer of Mago static analyzer) argues the design is too restrictive and inconsistent: identical AST may or may not dispatch depending on file order and surrounding declarations, making it hard to reason about and difficult for static analyzers to model soundly. He also disputes the claim that PHP's .stub.php files are consumed by PHPStan, Psalm, or Mago — each ships its own stubs. The debate centers on whether compile-time-only dispatch with typed locals is a workable tradeoff or an unacceptable inconsistency compared to full runtime dispatch as in Nikita's scalar_objects extension.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://externals.io/message/131773>

## Similar posts on daily.dev

- [\[Pre-RFC\] Scalar object methods \(with a working implementation\)](https://daily.dev/posts/pre-rfc-scalar-object-methods-with-a-working-implementation--g56edwffm) · externals.io · 0 upvotes · 0 comments
- [\[Pre-RFC\] Scalar object methods \(with a working implementation\)](https://daily.dev/posts/pre-rfc-scalar-object-methods-with-a-working-implementation--smq0sahal) · externals.io · 0 upvotes · 0 comments
- [\[Pre-RFC\] Scalar object methods \(with a working implementation\)](https://daily.dev/posts/pre-rfc-scalar-object-methods-with-a-working-implementation--evi9ihl2r) · externals.io · 0 upvotes · 0 comments

---

Tags: [#php](https://daily.dev/tags/php), [#phpstan](https://daily.dev/tags/phpstan)

[View this post on daily.dev](https://daily.dev/posts/pre-rfc-scalar-object-methods-with-a-working-implementation--j65oyhuep)
