Skip to content
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

Consistent standard library #345

Open
thekid opened this issue Feb 17, 2023 · 1 comment
Open

Consistent standard library #345

thekid opened this issue Feb 17, 2023 · 1 comment

Comments

@thekid
Copy link
Member

thekid commented Feb 17, 2023

Scope of Change

This RFC suggests creating a consistent standard library, which will be transpiled to the current function-based PHP standard library.

Rationale

Consistency when authoring without speed decrease at runtime.

Functionality

The API uses [group]::[function] as a principle, where group is one of:

  • str - Handling strings
  • array - Handling arrays

...and function is represented by the methods from JavaScript, a language every PHP programmer knows anyhow.

$s= 'Test,the,west';

// What we write
$l= str::length($s);
$p= str::indexOf($s, ',');

// What gets emitted
$l= \strlen($s);
$p= false === ($_p= \strpos($s, ',')) ? -1 : $_p;

Security considerations

Speed impact

Dependencies

Related documents

@thekid
Copy link
Member Author

thekid commented Apr 9, 2023

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

No branches or pull requests

1 participant