From e15991d299499ba0b4b8c25776114270347cbf53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Halberstadt?= Date: Tue, 13 Oct 2026 17:15:46 +0200 Subject: [PATCH] Rename namespace to Tezmanian and prepare for Packagist - Namespace Tez\Utils -> Tezmanian\Utils, package tez/* -> tezmanian/* - Add keywords, homepage, authors and support metadata - Drop VCS repositories (resolved via Packagist) - Remove stale composer.lock, set license holder --- LICENSE | 2 +- README.md | 36 ++++++++++++++++++++++++++---------- composer.json | 24 +++++++++++++++++++++--- src/Compose.php | 2 +- src/Memoize.php | 2 +- src/Once.php | 2 +- src/Partial.php | 2 +- src/Pipeline.php | 2 +- src/Retry.php | 2 +- src/Tap.php | 2 +- tests/ComposeTest.php | 4 ++-- tests/MemoizeTest.php | 6 +++--- tests/OnceTest.php | 6 +++--- tests/PartialTest.php | 6 +++--- tests/PipelineTest.php | 4 ++-- tests/RetryTest.php | 4 ++-- tests/TapTest.php | 4 ++-- 17 files changed, 72 insertions(+), 38 deletions(-) diff --git a/LICENSE b/LICENSE index ff3a818..f0a8205 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2026 Development +Copyright (c) 2026 René Halberstadt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including diff --git a/README.md b/README.md index e9237e1..af5017a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,20 @@ # tez-utils-fn +[![CI](https://github.com/tezmanian/tez-utils-fn/actions/workflows/php.yml/badge.svg)](https://github.com/tezmanian/tez-utils-fn/actions/workflows/php.yml) +[![Packagist Version](https://img.shields.io/packagist/v/tezmanian/utils-fn)](https://packagist.org/packages/tezmanian/utils-fn) +[![PHP](https://img.shields.io/packagist/php-v/tezmanian/utils-fn)](https://packagist.org/packages/tezmanian/utils-fn) +[![License: MIT](https://img.shields.io/packagist/l/tezmanian/utils-fn)](LICENSE) + Functional programming primitives for PHP: pipelines, composition, memoization, partial application, once-guards, retry with backoff, and tap for side-effects. PHP 8.3+, no dependencies. ## Installation ```bash -composer require tez/utils-fn +composer require tezmanian/utils-fn ``` +Package: [`tezmanian/utils-fn`](https://packagist.org/packages/tezmanian/utils-fn) · Namespace: `Tezmanian\Utils\Fn` + ## Components | Class | Purpose | @@ -27,7 +34,7 @@ composer require tez/utils-fn Passes a value through an ordered sequence of callables left-to-right. Each stage receives the output of the previous one. ```php -use Tez\Utils\Fn\Pipeline; +use Tezmanian\Utils\Fn\Pipeline; // Immediate execution Pipeline::process( @@ -58,7 +65,7 @@ Right-to-left composition — the mathematical counterpart to `Pipeline`. The ri `Compose::build(f, g, h)` is equivalent to `Pipeline::build(h, g, f)`. ```php -use Tez\Utils\Fn\Compose; +use Tezmanian\Utils\Fn\Compose; // Immediate execution — applies right-to-left: trim → strtolower → str_replace Compose::apply( @@ -87,7 +94,7 @@ $process(' FOO BAR '); // 'foo-bar' Wraps a callable and caches its return value per unique argument signature. `null` return values are cached correctly and do not trigger a second invocation. ```php -use Tez\Utils\Fn\Memoize; +use Tezmanian\Utils\Fn\Memoize; $expensiveCalc = Memoize::wrap(function (int $n): int { // called only once per unique $n @@ -116,7 +123,7 @@ $expensiveCalc(5); // computed again Executes a callable exactly once. Every subsequent call returns the cached return value without re-invoking the callable. Each `Once` instance is independent. ```php -use Tez\Utils\Fn\Once; +use Tezmanian\Utils\Fn\Once; $init = Once::wrap(function (): string { // executed only on the first call @@ -140,7 +147,7 @@ $once(); // null — from cache, callable NOT called again Pre-fills the leading arguments of a callable and returns a new `Closure` that accepts the remaining arguments. ```php -use Tez\Utils\Fn\Partial; +use Tezmanian\Utils\Fn\Partial; $multiply = fn(int $a, int $b): int => $a * $b; @@ -172,7 +179,7 @@ $pipeline('hello'); // '>>> HELLO' Retries a callable on exception. Supports linear and exponential backoff, exception allowlists (`only`), and exception blocklists (`except`). Throws the last exception when all attempts are exhausted. ```php -use Tez\Utils\Fn\Retry; +use Tezmanian\Utils\Fn\Retry; // Basic retry — up to 3 attempts (default) $result = Retry::run(fn() => fetchFromApi()); @@ -212,8 +219,8 @@ Executes a side-effect callable on a value and returns the value unchanged. The Useful for logging, debugging, or triggering side-effects inside a pipeline without breaking the chain. ```php -use Tez\Utils\Fn\Tap; -use Tez\Utils\Fn\Pipeline; +use Tezmanian\Utils\Fn\Tap; +use Tezmanian\Utils\Fn\Pipeline; Tap::value('hello', fn($v) => strtoupper($v)); // 'hello' — callable return discarded @@ -232,6 +239,15 @@ $pipeline = Pipeline::build( - PHP 8.3+ - No runtime dependencies +## Development + +```bash +make build && make install +make ci # audit, PHPStan, code style, tests +``` + ## License -MIT +MIT — see [LICENSE](LICENSE). + +Author: René Halberstadt diff --git a/composer.json b/composer.json index 18f493c..767bc3b 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,34 @@ { - "name": "tez/utils-fn", + "name": "tezmanian/utils-fn", "type": "library", "description": "Functional programming primitives for PHP: pipelines, composition, memoization, partial application, once-guards, retry with backoff, and tap for side-effects. PHP 8.3+, no dependencies.", + "keywords": [ + "functional", + "pipeline", + "memoize", + "retry", + "php" + ], + "homepage": "https://github.com/tezmanian/tez-utils-fn", "license": "MIT", + "authors": [ + { + "name": "René Halberstadt", + "email": "tezmanian@gmail.com" + } + ], + "support": { + "issues": "https://github.com/tezmanian/tez-utils-fn/issues", + "source": "https://github.com/tezmanian/tez-utils-fn" + }, "autoload": { "psr-4": { - "Tez\\Utils\\Fn\\": "src/" + "Tezmanian\\Utils\\Fn\\": "src/" } }, "autoload-dev": { "psr-4": { - "Tez\\Utils\\Tests\\Fn\\": "tests/" + "Tezmanian\\Utils\\Tests\\Fn\\": "tests/" } }, "require": { diff --git a/src/Compose.php b/src/Compose.php index 0c28c47..91cd1df 100644 --- a/src/Compose.php +++ b/src/Compose.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tez\Utils\Fn; +namespace Tezmanian\Utils\Fn; /** * Combines callables using right-to-left mathematical composition (f∘g∘h). diff --git a/src/Memoize.php b/src/Memoize.php index 74e53ae..11902b4 100644 --- a/src/Memoize.php +++ b/src/Memoize.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tez\Utils\Fn; +namespace Tezmanian\Utils\Fn; /** * Wraps a callable and caches its return value per unique argument signature. diff --git a/src/Once.php b/src/Once.php index 6be9a9c..f8bbc3d 100644 --- a/src/Once.php +++ b/src/Once.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tez\Utils\Fn; +namespace Tezmanian\Utils\Fn; /** * Wraps a callable so it is executed exactly once. diff --git a/src/Partial.php b/src/Partial.php index 8449e03..a061f3b 100644 --- a/src/Partial.php +++ b/src/Partial.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tez\Utils\Fn; +namespace Tezmanian\Utils\Fn; /** * Pre-fills the leading arguments of a callable and returns a new Closure diff --git a/src/Pipeline.php b/src/Pipeline.php index 5771799..8916697 100644 --- a/src/Pipeline.php +++ b/src/Pipeline.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tez\Utils\Fn; +namespace Tezmanian\Utils\Fn; /** * Pipes a value through an ordered sequence of callables left-to-right. diff --git a/src/Retry.php b/src/Retry.php index b771a24..359139e 100644 --- a/src/Retry.php +++ b/src/Retry.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tez\Utils\Fn; +namespace Tezmanian\Utils\Fn; final class Retry { diff --git a/src/Tap.php b/src/Tap.php index 417a323..d131e28 100644 --- a/src/Tap.php +++ b/src/Tap.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tez\Utils\Fn; +namespace Tezmanian\Utils\Fn; /** * Executes a side-effect callable on a value and returns the value unchanged. diff --git a/tests/ComposeTest.php b/tests/ComposeTest.php index d1d9c8e..a6c0cc0 100644 --- a/tests/ComposeTest.php +++ b/tests/ComposeTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Tez\Utils\Tests\Fn; +namespace Tezmanian\Utils\Tests\Fn; use PHPUnit\Framework\TestCase; -use Tez\Utils\Fn\Compose; +use Tezmanian\Utils\Fn\Compose; final class ComposeTest extends TestCase { diff --git a/tests/MemoizeTest.php b/tests/MemoizeTest.php index cc8668d..078c97e 100644 --- a/tests/MemoizeTest.php +++ b/tests/MemoizeTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Tez\Utils\Tests\Fn; +namespace Tezmanian\Utils\Tests\Fn; use PHPUnit\Framework\TestCase; -use Tez\Utils\Fn\Memoize; +use Tezmanian\Utils\Fn\Memoize; final class MemoizeTest extends TestCase { @@ -109,7 +109,7 @@ final class MemoizeTest extends TestCase }); self::assertSame(3, $memoized(1, 2)); - self::assertSame(3, $memoized(1, 2)); + self::assertSame(3, $memoized(1, 2)); // @phpstan-ignore staticMethod.alreadyNarrowedType self::assertSame(5, $memoized(2, 3)); self::assertSame(2, $calls); } diff --git a/tests/OnceTest.php b/tests/OnceTest.php index 6a13f0e..f34b664 100644 --- a/tests/OnceTest.php +++ b/tests/OnceTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Tez\Utils\Tests\Fn; +namespace Tezmanian\Utils\Tests\Fn; use PHPUnit\Framework\TestCase; -use Tez\Utils\Fn\Once; +use Tezmanian\Utils\Fn\Once; final class OnceTest extends TestCase { @@ -45,7 +45,7 @@ final class OnceTest extends TestCase $once = Once::wrap(fn(): string => 'hello'); self::assertSame('hello', $once()); - self::assertSame('hello', $once()); + self::assertSame('hello', $once()); // @phpstan-ignore staticMethod.alreadyNarrowedType } public function testNullReturnIsCachedCorrectly(): void diff --git a/tests/PartialTest.php b/tests/PartialTest.php index 59cd8a9..073b454 100644 --- a/tests/PartialTest.php +++ b/tests/PartialTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Tez\Utils\Tests\Fn; +namespace Tezmanian\Utils\Tests\Fn; use PHPUnit\Framework\TestCase; -use Tez\Utils\Fn\Partial; +use Tezmanian\Utils\Fn\Partial; final class PartialTest extends TestCase { @@ -64,7 +64,7 @@ final class PartialTest extends TestCase { $addPrefix = Partial::apply(fn(string $prefix, string $s) => $prefix . $s, '>>> '); - $pipeline = \Tez\Utils\Fn\Pipeline::build( + $pipeline = \Tezmanian\Utils\Fn\Pipeline::build( 'strtoupper', $addPrefix, ); diff --git a/tests/PipelineTest.php b/tests/PipelineTest.php index 9a11365..59d37bd 100644 --- a/tests/PipelineTest.php +++ b/tests/PipelineTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Tez\Utils\Tests\Fn; +namespace Tezmanian\Utils\Tests\Fn; use PHPUnit\Framework\TestCase; -use Tez\Utils\Fn\Pipeline; +use Tezmanian\Utils\Fn\Pipeline; final class PipelineTest extends TestCase { diff --git a/tests/RetryTest.php b/tests/RetryTest.php index 9a5fcea..1fd69fa 100644 --- a/tests/RetryTest.php +++ b/tests/RetryTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Tez\Utils\Tests\Fn; +namespace Tezmanian\Utils\Tests\Fn; use PHPUnit\Framework\TestCase; -use Tez\Utils\Fn\Retry; +use Tezmanian\Utils\Fn\Retry; final class RetryTest extends TestCase { diff --git a/tests/TapTest.php b/tests/TapTest.php index 89d387c..f5327dd 100644 --- a/tests/TapTest.php +++ b/tests/TapTest.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace Tez\Utils\Tests\Fn; +namespace Tezmanian\Utils\Tests\Fn; use PHPUnit\Framework\TestCase; -use Tez\Utils\Fn\Tap; +use Tezmanian\Utils\Fn\Tap; final class TapTest extends TestCase {