phpfn/placeholder

Simple placeholder implementation for functional constructions

Maintainers

👁 Serafim

Package info

github.com/phpfn/placeholder

Homepage

Issues

pkg:composer/phpfn/placeholder

Statistics

Installs: 68

Dependents: 2

Suggesters: 0

Stars: 3

2.0.1 2020-11-22 21:17 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT c9a3e58bd9fe816077a94528fa8e03d00e3234b8

  • Kirill Nesmeyanov <nesk.woop@xakep.ru>

placeholderfunctionalcurrypartial applicationhigh order

This package is auto-updated.

Last update: 2026-06-23 09:54:47 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 =)