https://github.com/xp-lang/php-compact-methods
Compact methods for PHP
https://github.com/xp-lang/php-compact-methods
arrow-functions compact compiler-plugin php7 php8 xp-compiler xp-framework
Last synced: 7 months ago
JSON representation
Compact methods for PHP
- Host: GitHub
- URL: https://github.com/xp-lang/php-compact-methods
- Owner: xp-lang
- Created: 2019-09-09T21:34:57.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-05T13:41:41.000Z (9 months ago)
- Last Synced: 2024-10-13T04:41:19.632Z (9 months ago)
- Topics: arrow-functions, compact, compiler-plugin, php7, php8, xp-compiler, xp-framework
- Language: PHP
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
Awesome Lists containing this project
README
Compact methods for PHP
=======================[](https://github.com/xp-lang/php-compact-methods/actions)
[](https://github.com/xp-framework/core)
[](https://github.com/xp-framework/core/blob/master/LICENCE.md)
[](http://php.net/)
[](http://php.net/)
[](https://packagist.org/packages/xp-lang/php-compact-methods)Plugin for the [XP Compiler](https://github.com/xp-framework/compiler/) which adds compact methods to the PHP language.
Example
-------
Compact methods use the `fn` keyword, much like [PHP 7.4 arrow functions](https://wiki.php.net/rfc/arrow_functions_v2). The RFC suggests this in its *Future Scope* section.```php
class Person {
private $name;public fn name(): string => $this->name;
}
```Installation
------------
After installing the XP Compiler into your project, also include this plugin.```bash
$ composer require xp-framework/compiler
# ...$ composer require xp-lang/php-compact-methods
# ...
```No further action is required.
See also
--------
* https://wiki.php.net/rfc/short-functions
* https://wiki.php.net/rfc/arrow_functions_v2#allow_arrow_notation_for_real_functions
* https://github.com/xp-framework/rfc/issues/241