HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
nikic
scalar_objects
PHP2013–2023
nikic / scalar_objects

scalar_objects

Extension that adds support for method calls on primitive types in PHP

6Distinct people
6Mentions
0Explicit recommenders
1.1KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Extension that adds support for method calls on primitive types in PHP

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year6 dated mentions

Observed mentions: 2013-02-08 04:47:58 UTC to 2023-07-21 23:49:06 UTC.

0122013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20132014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC101
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC000
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC000
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC110
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC000
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC000
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC101
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC211
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101

What Hacker News says

6 sources
> That would help, I would argue, with killing many of the PHP-specific criticisms I don't see why appeasing critics should be the goal of PHP. Removing $ and ; signs doesn't help me at all. I actually like the "$" sign. Maybe little bit less ;, but I don't really notice it. But I would certainly notice the mess of splitting language syntax into two separate branches. Breaking changes in language are not fun to address and take away the time from building features. I would be a lot more happy with generics. Or scalar objects, something like: $string = "abc"; var_dump($string->length()); // int(3) var_dump($string->startsWith("a")); // bool(true) https://github.com/nikic/scalar_objects That would make PHP standard library a lot easier and fun to use.
In Modern PHP features – PHP 8.0 and 8.1
It is possible to add that, one of of the core developers has done that as an extension, with one limitation, not possible for a mutable api. https://github.com/nikic/scalar_objects However scalar methods also creates a bigger discussion around the existing standard library, should functions be duplicated? Etc. Better in my opinion, because the standard library is mostly functions in the global namespace is to add pipe operator, it has been voted on but not passed yet due to some limitation. Pipe operator is more flexible because you can use your own functions when chaining. And then of course there are libraries that does this, which is similar to how Java does it, compare float vs Float.
In PHP: A fractal of bad design (2012)
A trivial example: $len = mb_strlen("wtf"); # call function mb_strlen $len = s("wtf")->len(); # call function s # allocate string object # instantiate string object # call string ctor # set property # call method len # get property # call function mb_strlen # destroy object There's no way to use a syntax like this without either massive overhead, or massive changes in the engine. There is a somewhat similar experimental project - https://github.com/nikic/scalar_objects - but that's not meant for real world use either. Personally I think the language, despite its flaws, does its job fine. I don't think it needs turning into Javascript-with-sigils.
In Php-o: metaprogramming PHP to give it a saner API

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.