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
20082026
-
…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.
comment by PlutoIsAPlanet · 2023-07-21 · in NativePHP: A framework for building desktop apps using PHP -
…= "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 -
…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) -
…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,…
comment by hearth · 2013-02-08 · in Php-o: metaprogramming PHP to give it a saner API