Hacker GitHub

← All repos

nikic/scalar_objects

View on GitHub ↗ ★ 1,144 PHP

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

6 mentions on Hacker News by 6 people: 2 stories, 4 comments · first 2013-02-08 · latest 2023-07-21

Mentions per year 6 mentions · busiest year 2022 (2)
20082026
  1. …strings - instead of str_contains, strtr, substr_compare you can do $myString->contains("test"); https://github.com/nikic/scalar_objects provides it as a plugin, but its not fully fleshed out.
  2. …= "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.
    comment by Isinlor · 2022-10-27 · in Modern PHP features – PHP 8.0 and 8.1
  3. ▲ 1
    Extension that adds support for method calls on primitive types in PHP
    story by psychoslave · 2022-06-28 · 1 comment
  4. …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,…
    comment by tored · 2021-08-06 · in PHP: A fractal of bad design (2012)
  5. ▲ 2
    PHP Extension for Method Calls on Primitive Types
    story by allendoerfer · 2016-05-22 · 0 comments
  6. …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,…