Skip to content

[RFC] Implement scalar extensions (WIP) #5535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

iluuu1994
Copy link
Member

@iluuu1994 iluuu1994 commented May 6, 2020

RFC draft: https://github.com/iluuu1994/scalar-extensions-rfc/pull/1/files
Based on https://github.com/nikic/scalar_objects

  • Allow passing self by reference
  • Multiple handlers
  • Dump extensions in opcache dumper
  • Get rid of extension keyword BC break
  • Restruct use extension to top of file
  • Implement __callStatic
  • Clean up VM
  • Provide basic standard library?

@iluuu1994 iluuu1994 force-pushed the scalar-extensions branch from a4f0116 to 3ac07d7 Compare May 6, 2020 23:38
@HallofFamer
Copy link

Its an interesting idea, though I suggest bringing it to PECL first? I cant do this myself, and Nikita does seem to be interested in hosting it on PECL either. Maybe someone else can make this happen.

Anyway I think we can expand the idea into for not just scalars, but also classes. I feel that the approach is very similar to C#'s extension methods, using static methods and passing the value as the first argument in these methods:

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods

@iluuu1994
Copy link
Member Author

We're probably gonna take a different approach and implement a fixed API for scalar values.

@iluuu1994 iluuu1994 closed this May 15, 2020
@JWprogrammer
Copy link

Hi.
Thank you for your hard work in developing PHP.
@iluuu1994, is there any progress on this issue?
It's very inconvenient to write like this: trim(strrev(str_replace('_', '-', $string)));
$string->replace('_', '-')->reverse()->trim(); is much better.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants