phpfn / placeholder
Simple placeholder implementation for functional constructions
2.0.1
2020-11-22 21:17 UTC
Requires
- php: >=7.4
- phpfn/symbol: ^2.0.1
- symfony/polyfill-php80: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-12-23 06:28:02 UTC
README
Library provides a placeholder implementation for currying functions, partial applications, pipe operator, and other syntactic structures hat allow specifying default values.
Installation
Library can be installed into any PHP application:
$ composer require phpfn/placeholder
In order to access library make sure to include vendor/autoload.php
in your file.
<?php require __DIR__ . '/vendor/autoload.php';
Usage
What is "placeholder"?
<?php var_dump(is_placeholder('_')); // expected output: false var_dump(is_placeholder(_)); // expected output: true
For example we can replace each of the placeholders in the array with the required value.
<?php use Fun\Placeholder\Placeholder; $array = [1, _, 3, _]; $result = Placeholder::map($array, fn() => ' map '); echo implode(', ', $result); // expected output: "1, map, 3, map"
And... Thats all =)