Psl is a standard library for PHP, inspired by hhvm/hsl

Overview

Psl - PHP Standard Library

Unit tests status Static analysis status Security analysis status Coding standards status Coding standards status CII Best Practices Coverage Status MSI Type Coverage Total Downloads Latest Stable Version License

Psl is a standard library for PHP, inspired by hhvm/hsl.

The goal of Psl is to provide a consistent, centralized, well-typed set of APIs for PHP programmers.

Example

writeAll($message); } $connection->close(); return 0; });">


declare(strict_types=1);

use Psl\Async;
use Psl\TCP;
use Psl\IO;
use Psl\Shell;
use Psl\Str;

Async\main(static function(): int {
    IO\write_line('Hello, World!');

    [$version, $connection] = Async\concurrently([
        static fn() => Shell\execute('php', ['-v']),
        static fn() => TCP\connect('localhost', 1337),
    ]);

    $messages = Str\split($version, "\n");
    foreach($messages as $message) {
        $connection->writeAll($message);
    }

    $connection->close();

    return 0;
});

Installation

Supported installation method is via composer:

composer require azjezz/psl

Psalm Integration

Please refer to the php-standard-library/psalm-plugin repository.

PHPStan Integration

Please refer to the php-standard-library/phpstan-extension repository.

Documentation

You can read through the API documentation in docs/ directory.

Interested in contributing?

Have a look at CONTRIBUTING.md.

Sponsors

Thanks to our sponsors and supporters:

JetBrains

License

The MIT License (MIT). Please see LICENSE for more information.

Comments
  • Not installable without ARGON2 support

    Not installable without ARGON2 support

    Is your feature request related to a problem? Please describe. Hi there,

    This library is not install-able unless argon2 support has been compiled into php.

    Otherwise, we will receive:

    PHP Fatal error:  Uncaught Error: Undefined constant 'PASSWORD_ARGON2I'
    

    Describe the solution you'd like Would you be open to conditionally supporting the argon2 password hashing, only if argon 2 support is available?

    I want to use the iter/arr methods of this library - i don't really care about not having argon2 support.

    Describe alternatives you've considered compile in argon2 support before requiring psl.

    Type: Enhancement 
    opened by bendavies 14
  • [Regex] Introduce *_match() functions to fetch captured data groups

    [Regex] Introduce *_match() functions to fetch captured data groups

    This PR introduces a first_match() and every_match() function in which you can specify the shape of the result:

    /** @var array{0: string, name: string}|null $matches */
    $matches = Regex\first_match(
        'Hello world',
        '/(hello) (?<name>world)/i',
        Regex\capture_groups(['name'])
    );
    
    /** @var list<array{0: string, name: string, digit: string}>|null $matches */
    $matches = Regex\every_match(
        <<<EODATA
        a: 1
        b: 2
        c: 3
        EODATA,
        '@(?P<name>\w+): (?P<digit>\d+)@i',
        Regex\capture_groups(['name', 'digit'])
    );
    
    Priority: High Status: Completed Type: Enhancement 
    opened by veewee 13
  • [DataStructures] Set

    [DataStructures] Set

    This PR can be used to discuss the syntax of a new Set datastructure.

    https://en.wikipedia.org/wiki/Set_(abstract_data_type) https://www.php.net/manual/en/class.ds-set.php

    Additionally, we can introduce Vec\unique and Vec\unique_by functions based on this data structure.

    Priority: Medium Status: Revision Needed Type: Enhancement 
    opened by veewee 12
  • Union for variadic types

    Union for variadic types

    There are a lot of situations may occur when we need to define union from several cases. For example: need to define enum of states.

    This would look like:

    use Psl\Type as T;
    
    $codec = T\shape([
        // ... rest of fields
        'state' => T\union(
            T\literal_scalar('NEW'),
            T\union(
                T\literal_scalar('APPROVED'),
                T\union(
                    T\literal_scalar('REJECTED'),
                    T\union(
                        T\literal_scalar('COMPLETED'),
                        T\union(
                            T\literal_scalar('FROZEN'),
                            T\literal_scalar('ERROR')
                        )
                    )
                )
            )
        ),
    ]);
    

    Inferred type would be:

    array{id: string, state: "APPROVED"|"COMPLETED"|"ERROR"|"FROZEN"|"NEW"|"REJECTED"}
    

    I guess it would be great to have better solution like:

    use Psl\Type as T;
    
    $codec = T\shape([
        'id' => T\string(),
        'state' => T\union_of(
            T\literal_scalar('NEW'),
            T\literal_scalar('APPROVED'),
            T\literal_scalar('REJECTED'),
            T\literal_scalar('COMPLETED'),
            T\literal_scalar('FROZEN'),
            T\literal_scalar('ERROR'),
        ),
    ]);
    

    I do understand that Psl\Type\Internal\UnionType has only 2 branches: left and right That's why propose just implement a function with signature:

    /**
     * @template T
     *
     * @param TypeInterface<T> $left_type
     * @param TypeInterface<T> $right_type
     * @param TypeInterface<T> ...$others
     * @return TypeInterface<T>
     *
     * @no-named-arguments
     */
    function union_of(
        TypeInterface $left_type,
        TypeInterface $right_type,
        TypeInterface ...$others
    ): TypeInterface { // actually Psl\Type\Internal\UnionType returns here
        ...
    }
    

    As alternatives I may guess there is more suitable name for function. This may be named like literals or one_of or etc.

    This function may also be implemented in user land, but I think it would be great to have unified solution inside core of the library.


    Want to hear other guys thoughts. If this would be approved, I may produce PR. As I can see, this is very light enhancement.

    Priority: Medium Status: Accepted Status: In Progress Type: Enhancement 
    opened by nzour 11
  • Backport static analysis fixes to 1.6

    Backport static analysis fixes to 1.6

    Backported these fixes to resolve Type\shape() issues:

    • https://github.com/azjezz/psl/commit/821391fe0539b2158efff4c72916d18d829be9a0
    • https://github.com/azjezz/psl/commit/0118dbcd97660723af918999f0d4db4eca43292b
    Priority: Medium Status: Completed Type: Maintenance 
    opened by veewee 10
  • Uncaught RuntimeException on Psl\Iter\Iterator::current()

    Uncaught RuntimeException on Psl\Iter\Iterator::current()

    Describe the bug When running tests I get following error:

    PHP Fatal error:  During inheritance of Iterator: Uncaught RuntimeException: PHP Error: Return type of Psl\Iter\Iterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/runner/work/http-tools/http-tools/vendor/azjezz/psl/src/Psl/Iter/Iterator.php:90 in phar:///home/runner/work/http-tools/http-tools/tools/psalm.phar/src/Psalm/Internal/ErrorHandler.php:53
    Stack trace:
    #0 /home/runner/work/http-tools/http-tools/vendor/azjezz/psl/src/Psl/Iter/Iterator.php(18): Psalm\Internal\ErrorHandler::Psalm\Internal\{closure}()
    #1 /home/runner/work/http-tools/http-tools/vendor/azjezz/psl/src/Psl/Internal/Loader.php(683): require_once('...')
    #2 /home/runner/work/http-tools/http-tools/vendor/azjezz/psl/src/Psl/Internal/Loader.php(690): Psl\Internal\Loader::load()
    #3 [internal function]: Psl\Internal\Loader::Psl\Internal\{closure}()
    #4 /home/runner/work/http-tools/http-tools/vendor/azjezz/psl/src/Psl/Internal/Loader.php(750): class_exists()
    #5 /home/runner/work/http-tools/http-tools/vendor/azjezz/psl/src/Psl/Internal/Loader.php(675): Psl\Internal\Loader::loadClasses()
    #6 /home/runner/work/http-tools/http-tools/vendor/azjezz/psl/src/Psl/Internal/Loader.php(699): Psl\Internal\Loader::Psl\Internal\{closure}()
    

    To Reproduce GitHub Actions:

    Environment (please complete the following information):

    • OS: Ubuntu
    • PHP: 8.1
    • Version: 1.6.0
    Priority: High Status: Completed Type: Bug 
    opened by pottink 10
  • [Type] Introduce the Type API

    [Type] Introduce the Type API

    closes #42

    <?php
    
    require_once __DIR__ . '/../vendor/autoload.php';
    
    use Psl\Type;
    use Psl\Collection;
    
    /** @psalm-var Type<iterable<array<int, array<int|string, string>>, Collection\ICollection&Collection\IIndexAccess> $spec */
    $spec = Type\iterable(
        Type\arr(Type\int(), Type\arr(Type\array_key(), Type\string())),
        Type\intersection(
            Type\instance_of(Collection\ICollection::class),
            Type\instance_of(Collection\IIndexAccess::class)
        )
    );
    
    /**
     * @var null|iterable<array<int, array<int|string, string>>, Collection\ICollection&Collection\IIndexAccess> $value
     */
    $value = Type\nullable($spec)->assert(null);
    
    $value = Type\nullable($spec)->assert((static function () {
        yield [4 => ['bar' => 'baz', 1337 => 'qux']] => new Collection\Map([]);
    })());
    
    $value = $spec->assert((static function () {
        yield [4 => ['bar' => 'baz', 1337 => 'qux']] => new Collection\Map([]);
    })());
    
    try {
        $value = $spec->assert((static function () {
            yield [4 => ['bar' => 'baz', 1337 => 13]] => new Collection\Vector([]);
        })());
    } catch (Type\Exception\TypeAssertException $e) {
        //    Expected "string", got "integer".
        print $e->getMessage();
    }
    
    try {
        $value = $spec->assert((static function () {
            yield [4 => ['bar' => 'baz', 1337 => 'f']] => new stdClass();
        })());
    } catch (Type\Exception\TypeAssertException $e) {
        //    Expected "Psl\Collection\ICollection&Psl\Collection\IIndexAccess", got "stdClass".
        print $e->getMessage();
    }
    
    // iterable<array<int, array<array-key, string>>, Psl\Collection\ICollection&Psl\Collection\IIndexAccess>
    print $spec->toString();
    
    Status: Accepted Status: Completed Type: Enhancement 
    opened by azjezz 10
  • Benchmarks and performance improvements

    Benchmarks and performance improvements

    Scope of work

    This patch attempts to improve happy-path execution time for Psl\Type components, and specifically:

    • Psl\Type\TypeInterface#coerce()
    • Psl\Type\TypeInterface#assert()
    • Psl\Type\TypeInterface#matches()

    Results

    Results as per 2021-09-08 (af6d3784a7f58aa7f24577caec95c2a160ac3412) are as follows:

    root@6d63f978332e:/app# ./tools/phpbench/vendor/bin/phpbench run --config tools/phpbench/phpbench.json --ref=benchmark_reference --iterations=15 --revs=8
    PHPBench (1.1.0) running benchmarks...
    with configuration file: /app/tools/phpbench/phpbench.json
    with PHP version 8.0.10, xdebug ✔, opcache ✔
    comparing [actual vs. benchmark_reference]
    
    \Psl\Tests\Benchmark\Type\StringTypeBench
    
        benchCoerce # string....................R1 I5 - [Mo1.000μs vs. Mo1.000μs] 0.00% (±0.00%)
        benchCoerce # int.......................R1 I1 - [Mo1.125μs vs. Mo1.125μs] 0.00% (±0.00%)
        benchCoerce # instanceof Stringable (ex.R1 I8 - [Mo1.375μs vs. Mo1.875μs] -26.67% (±0.00%)
        benchCoerce # instanceof Stringable (im.R1 I7 - [Mo1.375μs vs. Mo1.875μs] -26.67% (±0.00%)
        benchAssert.............................R1 I5 - [Mo1.125μs vs. Mo1.125μs] 0.00% (±0.00%)
        benchMatch..............................R2 I14 - [Mo1.000μs vs. Mo1.000μs] 0.00% (±0.00%)
    
    \Psl\Tests\Benchmark\Type\ShapeTypeBench
    
        benchCoerce # empty shape, empty array .R1 I1 - [Mo3.125μs vs. Mo17.202μs] -81.83% (±1.00%)
        benchCoerce # empty shape, empty iterab.R2 I7 - [Mo5.497μs vs. Mo17.548μs] -68.68% (±1.40%)
        benchCoerce # empty shape, non-empty ar.R1 I4 - [Mo3.502μs vs. Mo23.732μs] -85.24% (±2.32%)
        benchCoerce # empty shape, non-empty it.R1 I14 - [Mo7.004μs vs. Mo24.129μs] -70.97% (±1.27%)
        benchCoerce # complex shape with option.R1 I14 - [Mo5.625μs vs. Mo62.697μs] -91.03% (±1.21%)
        benchCoerce # complex shape with option.R1 I10 - [Mo29.472μs vs. Mo64.065μs] -54.00% (±0.86%)
        benchCoerce # complex shape with option.R1 I12 - [Mo8.672μs vs. Mo93.012μs] -90.68% (±1.57%)
        benchCoerce # complex shape with option.R1 I14 - [Mo39.567μs vs. Mo94.873μs] -58.30% (±0.94%)
        benchAssert # empty shape, empty array .R1 I0 - [Mo1.250μs vs. Mo15.543μs] -91.96% (±0.00%)
        benchAssert # empty shape, non-empty ar.R1 I7 - [Mo2.000μs vs. Mo18.186μs] -89.00% (±2.89%)
        benchAssert # complex shape with option.R1 I2 - [Mo22.480μs vs. Mo49.896μs] -54.95% (±1.44%)
        benchAssert # complex shape with option.R1 I2 - [Mo29.613μs vs. Mo63.770μs] -53.56% (±1.22%)
        benchMatch # empty shape, empty array v.R1 I3 - [Mo1.500μs vs. Mo15.995μs] -90.62% (±0.00%)
        benchMatch # empty shape, non-empty arr.R2 I7 - [Mo2.500μs vs. Mo18.625μs] -86.58% (±1.24%)
        benchMatch # complex shape with optiona.R1 I7 - [Mo22.995μs vs. Mo50.246μs] -54.24% (±0.97%)
        benchMatch # complex shape with optiona.R1 I3 - [Mo30.085μs vs. Mo64.037μs] -53.02% (±0.44%)
    
    \Psl\Tests\Benchmark\Type\VecTypeBench
    
        benchCoerce # mixed, empty array........R1 I14 - [Mo3.753μs vs. Mo5.125μs] -26.77% (±2.02%)
        benchCoerce # mixed, empty iterable.....R1 I14 - [Mo4.116μs vs. Mo5.125μs] -19.69% (±2.44%)
        benchCoerce # mixed, non-empty array....R1 I14 - [Mo5.602μs vs. Mo6.749μs] -17.00% (±2.27%)
        benchCoerce # mixed, non-empty iterable.R1 I14 - [Mo5.750μs vs. Mo7.000μs] -17.85% (±0.96%)
        benchCoerce # mixed, large array........R1 I14 - [Mo48.082μs vs. Mo49.339μs] -2.55% (±1.26%)
        benchCoerce # mixed, large iterable.....R1 I14 - [Mo51.736μs vs. Mo52.998μs] -2.38% (±2.04%)
        benchCoerce # int, empty array..........R1 I10 - [Mo3.770μs vs. Mo5.125μs] -26.45% (±2.76%)
        benchCoerce # int, empty iterable.......R2 I8 - [Mo3.998μs vs. Mo5.191μs] -22.99% (±2.05%)
        benchCoerce # int, non-empty array......R2 I4 - [Mo5.620μs vs. Mo6.699μs] -16.10% (±1.89%)
        benchCoerce # int, non-empty iterable...R2 I14 - [Mo5.779μs vs. Mo7.000μs] -17.45% (±2.14%)
        benchAssert # mixed, empty array........R1 I10 - [Mo3.625μs vs. Mo5.125μs] -29.26% (±2.52%)
        benchAssert # mixed, non-empty array....R1 I14 - [Mo5.750μs vs. Mo7.245μs] -20.64% (±0.87%)
        benchAssert # mixed, large array........R1 I14 - [Mo64.692μs vs. Mo66.096μs] -2.12% (±1.18%)
        benchAssert # int, empty array..........R1 I14 - [Mo3.741μs vs. Mo5.125μs] -27.00% (±2.38%)
        benchAssert # int, non-empty array......R13 I14 - [Mo5.752μs vs. Mo7.269μs] -20.86% (±1.41%)
        benchMatch # mixed, empty array.........R1 I13 - [Mo1.125μs vs. Mo1.250μs] -10.00% (±0.00%)
        benchMatch # mixed, non-empty array.....R1 I4 - [Mo2.875μs vs. Mo3.125μs] -8.03% (±2.21%)
        benchMatch # mixed, large array.........R2 I6 - [Mo54.026μs vs. Mo53.978μs] +0.09% (±0.69%)
        benchMatch # int, empty array...........R1 I0 - [Mo1.125μs vs. Mo1.250μs] -10.00% (±0.00%)
        benchMatch # int, non-empty array.......R1 I4 - [Mo2.875μs vs. Mo3.125μs] -8.01% (±2.49%)
    
    \Psl\Tests\Benchmark\Type\DictTypeBench
    
        benchCoerce # generic array, empty arra.R3 I7 - [Mo6.128μs vs. Mo8.708μs] -29.63% (±1.45%)
        benchCoerce # generic array, empty iter.R1 I1 - [Mo6.376μs vs. Mo8.850μs] -27.95% (±1.33%)
        benchCoerce # generic array, non-empty .R1 I2 - [Mo7.374μs vs. Mo10.614μs] -30.53% (±1.70%)
        benchCoerce # generic array, non-empty .R1 I14 - [Mo7.600μs vs. Mo10.875μs] -30.12% (±1.80%)
        benchCoerce # generic array, large arra.R1 I5 - [Mo99.035μs vs. Mo3.702ms] -97.33% (±2.06%)
        benchCoerce # generic array, large iter.R1 I5 - [Mo103.920μs vs. Mo3.086ms] -96.63% (±1.47%)
        benchCoerce # int array, empty array....R1 I3 - [Mo6.103μs vs. Mo8.436μs] -27.65% (±1.67%)
        benchCoerce # int array, empty iterable.R1 I10 - [Mo6.153μs vs. Mo8.760μs] -29.77% (±1.85%)
        benchCoerce # int array, non-empty arra.R1 I13 - [Mo9.011μs vs. Mo11.639μs] -22.58% (±1.40%)
        benchCoerce # int array, non-empty iter.R1 I6 - [Mo9.428μs vs. Mo12.013μs] -21.52% (±1.26%)
        benchCoerce # int array, large array....R2 I9 - [Mo100.810μs vs. Mo102.101μs] -1.26% (±2.02%)
        benchCoerce # int array, large iterable.R1 I4 - [Mo104.550μs vs. Mo107.096μs] -2.38% (±1.10%)
        benchCoerce # map, empty array..........R2 I8 - [Mo6.082μs vs. Mo8.475μs] -28.24% (±1.93%)
        benchCoerce # map, empty iterable.......R2 I13 - [Mo6.246μs vs. Mo8.604μs] -27.40% (±1.44%)
        benchCoerce # map, non-empty array......R1 I9 - [Mo9.001μs vs. Mo11.503μs] -21.75% (±0.82%)
        benchCoerce # map, non-empty iterable...R2 I13 - [Mo9.575μs vs. Mo11.875μs] -19.38% (±1.56%)
        benchCoerce # map, large array..........R2 I14 - [Mo102.754μs vs. Mo104.467μs] -1.64% (±2.33%)
        benchCoerce # map, large iterable.......R1 I2 - [Mo106.440μs vs. Mo109.807μs] -3.07% (±1.45%)
        benchAssert # generic array, empty arra.R1 I14 - [Mo5.750μs vs. Mo8.248μs] -30.29% (±0.54%)
        benchAssert # generic array, non-empty .R1 I14 - [Mo6.986μs vs. Mo9.750μs] -28.35% (±1.45%)
        benchAssert # generic array, large arra.R4 I10 - [Mo98.287μs vs. Mo3.511ms] -97.20% (±1.85%)
        benchAssert # int array, empty array....R3 I12 - [Mo5.750μs vs. Mo8.250μs] -30.31% (±1.10%)
        benchAssert # int array, non-empty arra.R3 I13 - [Mo8.737μs vs. Mo11.286μs] -22.59% (±1.64%)
        benchAssert # int array, large array....R2 I8 - [Mo98.272μs vs. Mo101.161μs] -2.86% (±1.21%)
        benchAssert # map, empty array..........R2 I14 - [Mo5.745μs vs. Mo8.250μs] -30.36% (±1.49%)
        benchAssert # map, non-empty array......R6 I11 - [Mo8.702μs vs. Mo11.181μs] -22.17% (±1.47%)
        benchAssert # map, large array..........R1 I7 - [Mo102.052μs vs. Mo104.321μs] -2.17% (±1.40%)
        benchMatch # generic array, empty array.R1 I14 - [Mo6.148μs vs. Mo8.651μs] -28.93% (±2.49%)
        benchMatch # generic array, non-empty a.R7 I13 - [Mo7.375μs vs. Mo10.256μs] -28.09% (±1.77%)
        benchMatch # generic array, large array.R1 I6 - [Mo100.021μs vs. Mo4.486ms] -97.77% (±1.98%)
        benchMatch # int array, empty array.....R1 I14 - [Mo6.227μs vs. Mo8.699μs] -28.41% (±2.21%)
        benchMatch # int array, non-empty array.R1 I14 - [Mo9.000μs vs. Mo11.664μs] -22.83% (±0.69%)
        benchMatch # int array, large array.....R1 I1 - [Mo98.781μs vs. Mo101.539μs] -2.72% (±1.67%)
        benchMatch # map, empty array...........R6 I14 - [Mo6.248μs vs. Mo8.625μs] -27.57% (±2.31%)
        benchMatch # map, non-empty array.......R6 I14 - [Mo9.017μs vs. Mo11.552μs] -21.95% (±1.28%)
        benchMatch # map, large array...........R6 I14 - [Mo102.852μs vs. Mo105.609μs] -2.61% (±1.44%)
    
    \Psl\Tests\Benchmark\Type\ArrayKeyTypeBench
    
        benchCoerce # string....................R1 I0 - [Mo1.000μs vs. Mo1.750μs] -42.86% (±0.00%)
        benchCoerce # int.......................R1 I12 - [Mo1.000μs vs. Mo19.582μs] -94.89% (±0.00%)
        benchCoerce # instanceof Stringable (ex.R2 I7 - [Mo61.066μs vs. Mo53.186μs] +14.82% (±1.27%)
        benchCoerce # instanceof Stringable (im.R1 I4 - [Mo61.126μs vs. Mo52.867μs] +15.62% (±1.32%)
        benchAssert # string....................R1 I0 - [Mo1.125μs vs. Mo1.500μs] -25.00% (±0.00%)
        benchAssert # int.......................R2 I4 - [Mo1.125μs vs. Mo17.236μs] -93.47% (±0.00%)
        benchMatch # string.....................R1 I11 - [Mo1.000μs vs. Mo1.375μs] -27.27% (±0.00%)
        benchMatch # int........................R1 I10 - [Mo1.000μs vs. Mo1.875μs] -46.67% (±0.00%)
    
    \Psl\Tests\Benchmark\Type\NonEmptyStringTypeBench
    
        benchCoerce # string....................R2 I8 - [Mo1.000μs vs. Mo1.375μs] -27.27% (±0.00%)
        benchCoerce # int.......................R2 I13 - [Mo1.125μs vs. Mo1.500μs] -25.00% (±0.00%)
        benchCoerce # instanceof Stringable (ex.R1 I5 - [Mo1.625μs vs. Mo2.500μs] -35.01% (±3.89%)
        benchCoerce # instanceof Stringable (im.R1 I11 - [Mo1.625μs vs. Mo2.500μs] -34.99% (±0.00%)
        benchAssert.............................R1 I7 - [Mo1.125μs vs. Mo1.375μs] -18.18% (±0.00%)
        benchMatch..............................R1 I7 - [Mo1.000μs vs. Mo1.250μs] -20.00% (±0.00%)
    
    \Psl\Tests\Benchmark\Type\IntTypeBench
    
        benchCoerce # int.......................R1 I2 - [Mo1.000μs vs. Mo1.000μs] 0.00% (±0.00%)
        benchCoerce # string....................R3 I13 - [Mo1.250μs vs. Mo1.875μs] -33.32% (±0.00%)
        benchCoerce # float.....................R2 I5 - [Mo1.125μs vs. Mo1.250μs] -10.00% (±0.00%)
        benchCoerce # instanceof Stringable (ex.R5 I11 - [Mo1.750μs vs. Mo2.625μs] -33.35% (±3.69%)
        benchCoerce # instanceof Stringable (im.R2 I12 - [Mo1.750μs vs. Mo2.500μs] -30.01% (±0.00%)
        benchAssert.............................R1 I2 - [Mo1.125μs vs. Mo1.125μs] 0.00% (±0.00%)
        benchMatch..............................R1 I7 - [Mo0.875μs vs. Mo1.000μs] -12.50% (±0.00%)
    
    Subjects: 21, Assertions: 0, Failures: 0, Errors: 0
    
    

    Dependencies

    • [ ] https://github.com/phpbench/phpbench/pull/918
    Priority: High Status: Completed Type: Enhancement 
    opened by Ocramius 9
  • Feature/variadic union type improvemence

    Feature/variadic union type improvemence

    #183

    Changelog

    • function Psl\Type\union now takes variadic third parameter
    • function Psl\Type\union arguments $left_type and $right_type were renamed to $first and $second This is a breaking change, because if somebody uses PHP8+ and does union(left_type: $left, right_type: $right) - this would trigger runtime Error.

    Future scope

    • I think we should use @no-named-arguments psalm's annotation I haven't used this in my PR, cause I think it should be discussed and (if accepted) added atomically for all possible functions and methods
    • As @azjezz mentioned in #183, we should also make variadic function Psl\Type\intersection
    Priority: Medium Status: Accepted Status: Completed Type: Enhancement 
    opened by nzour 9
  • Feature - support for maglnet/ComposerRequireChecker

    Feature - support for maglnet/ComposerRequireChecker

    Not sure which way round this should go, whether azjezz/psl should add support, or the other way round. If i use maglnet/ComposerRequireChecker on a project that also depends on azjezz/psl, because of the custom autoloader, there are several symbols which cannot be guessed by maglnet/ComposerRequireChecker.

    $ php composer-require-checker.phar check composer.json
    ComposerRequireChecker 3.8.0@537138b833ab0f9ad72b667a72bece2a765e88ab
    The following 43 unknown symbols were found:
    +-----------------------------+--------------------+
    | Unknown Symbol              | Guessed Dependency |
    +-----------------------------+--------------------+
    | Psl\Dict\associate          |                    |
    | Psl\Dict\diff               |                    |
    | Psl\Dict\diff_by_key        |                    |
    | Psl\Dict\filter             |                    |
    | Psl\Dict\intersect_by_key   |                    |
    | Psl\Dict\map                |                    |
    | Psl\Dict\map_keys           |                    |
    | Psl\Env\current_dir         |                    |
    | Psl\Env\set_current_dir     |                    |
    | Psl\Env\temp_dir            |                    |
    | Psl\Filesystem\canonicalize |                    |
    | Psl\Filesystem\exists       |                    |
    | Psl\Filesystem\is_directory |                    |
    | Psl\Filesystem\is_file      |                    |
    | Psl\Filesystem\read_file    |                    |
    | Psl\invariant               |                    |
    | Psl\Iter\all                |                    |
    | Psl\Iter\any                |                    |
    | Psl\Iter\contains           |                    |
    | Psl\Iter\count              |                    |
    | Psl\Json\encode             |                    |
    | Psl\Regex\matches           |                    |
    | Psl\Shell\execute           |                    |
    | Psl\Str\format              |                    |
    | Psl\Str\join                |                    |
    | Psl\Str\lowercase           |                    |
    | Psl\Str\replace_every       |                    |
    | Psl\Str\split               |                    |
    | Psl\Str\trim                |                    |
    | Psl\Str\trim_right          |                    |
    | Psl\Str\uppercase           |                    |
    | Psl\Type\bool               |                    |
    | Psl\Type\dict               |                    |
    | Psl\Type\non_empty_string   |                    |
    | Psl\Type\object             |                    |
    | Psl\Type\string             |                    |
    | Psl\Type\vec                |                    |
    | Psl\Vec\concat              |                    |
    | Psl\Vec\filter              |                    |
    | Psl\Vec\filter_nulls        |                    |
    | Psl\Vec\keys                |                    |
    | Psl\Vec\map                 |                    |
    | Psl\Vec\values              |                    |
    +-----------------------------+--------------------+
    

    A reasonable workaround (and maybe indeed, the final "recommendation", given the custom autoloader) may be to explicitly ignore these symbols as long as azjezz/psl is explicitly in composer.json (although, the point of maglnet/ComposerRequireChecker is to check that really!), for example:

    {
        "symbol-whitelist" : [
            "null", "true", "false",
            "static", "self", "parent",
            "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "mixed", "never",
            "Psl\\Dict\\associate",
            "Psl\\Dict\\diff",
            "Psl\\Dict\\diff_by_key",
            "Psl\\Dict\\filter",
            "Psl\\Dict\\intersect_by_key",
            "Psl\\Dict\\map",
            "Psl\\Dict\\map_keys",
            "Psl\\Env\\current_dir",
            "Psl\\Env\\set_current_dir",
            "Psl\\Env\\temp_dir",
            "Psl\\Filesystem\\canonicalize",
            "Psl\\Filesystem\\exists",
            "Psl\\Filesystem\\is_directory",
            "Psl\\Filesystem\\is_file",
            "Psl\\Filesystem\\read_file",
            "Psl\\invariant",
            "Psl\\Iter\\all",
            "Psl\\Iter\\any",
            "Psl\\Iter\\contains",
            "Psl\\Iter\\count",
            "Psl\\Json\\encode",
            "Psl\\Regex\\matches",
            "Psl\\Shell\\execute",
            "Psl\\Str\\format",
            "Psl\\Str\\join",
            "Psl\\Str\\lowercase",
            "Psl\\Str\\replace_every",
            "Psl\\Str\\split",
            "Psl\\Str\\trim",
            "Psl\\Str\\trim_right",
            "Psl\\Str\\uppercase",
            "Psl\\Type\\bool",
            "Psl\\Type\\dict",
            "Psl\\Type\\non_empty_string",
            "Psl\\Type\\object",
            "Psl\\Type\\string",
            "Psl\\Type\\vec",
            "Psl\\Vec\\concat",
            "Psl\\Vec\\filter",
            "Psl\\Vec\\filter_nulls",
            "Psl\\Vec\\keys",
            "Psl\\Vec\\map",
            "Psl\\Vec\\values"
        ],
        "php-core-extensions" : [
            "Core",
            "date",
            "pcre",
            "Phar",
            "Reflection",
            "SPL",
            "standard"
        ],
        "scan-files" : []
    }
    

    When used, will work properly:

    $ php composer-require-checker.phar check --config-file `pwd`/composer-require-checker-config.json composer.json
    ComposerRequireChecker 3.8.0@537138b833ab0f9ad72b667a72bece2a765e88ab
    There were no unknown symbols found.
    
    Type: Enhancement 
    opened by asgrim 8
  • Added repro for #212

    Added repro for #212

    Because I removed a global suppression there would be errors around the codebase, but I think those should addressed particularly in every specific case.

    opened by zerkms 8
  • [Type] introduce new integer/float functions

    [Type] introduce new integer/float functions

    Introduce the following functions into the type component:

    • i64
    • i32
    • i16
    • i8
    • u64
    • u32
    • u16
    • u8
    • f64
    • f32

    These types will be used by ara, therefore we would need a way in PSL to check for them at runtime.

    Type: Enhancement 
    opened by azjezz 0
  • rename all parameters to use snake_case everywhere.

    rename all parameters to use snake_case everywhere.

    currently, functions use $snake_case for parameters, and methods use $camelCase, IMO, parameters should be $snake_case everywhere.

    e.g:

    $semaphore = new Async\Semaphore(concurrency_limit: $a, operation: $b);
    

    instead of

    $semaphore = new Async\Semaphore(concurrencyLimit: $a, operation: $b);
    
    Priority: Medium Status: Available Type: Enhancement Type: BC Break 
    opened by azjezz 3
  • doc(async): add documentation

    doc(async): add documentation

    we will start adding a README.md to every component, slowly fazing out docs/ directory.

    rendered: https://github.com/azjezz/psl/tree/doc/async/src/Psl/Async

    Priority: Medium Status: Accepted Status: Review Needed Type: Enhancement Type: Documentation 
    opened by azjezz 1
  • add `Vec\flatten` and `Vec\flatten_by`

    add `Vec\flatten` and `Vec\flatten_by`

    namespace Psl\Vec {
      function flatten<T>(vec<vec<T>> $vec): Vec<T> { ... }
    
      function flatten_by<Tin, Tout>(vec<Tin> $vec, (fn(Tin): Vec<Tout>) $fun): Vec<Tout> { ... }
    }
    
    
    Priority: Medium Type: Enhancement 
    opened by azjezz 0
  • andThen()

    andThen()

    Introduce new andThen method: https://doc.rust-lang.org/rust-by-example/error/option_unwrap/and_then.html This method can be used to e.g. map an Option into another option:

    some(1)->andThen(fn(int $value) => $value > 1 ? some($value) : none())  == none();
    

    They apply to:

    • Result
    • Option
    • maybe: Promise?

    ❗ Currently Result::then() allows returning a promise which automatically gets unwrapped. That logic should be deprecated and removed in v3 since it's rather magically. The new andThen function should be used for this purpose. We'll have to add a note for that in the code and release notes.

    (to investigate: if it makes sense to keep on supporting it during runtime, but make psalm fail)

    Type: Enhancement 
    opened by veewee 0
  • add `Vec\get`, `Vec\get_typed`, `Dict\get` and `Dict\get_typed` functions.

    add `Vec\get`, `Vec\get_typed`, `Dict\get` and `Dict\get_typed` functions.

    API:

    namespace Psl\Dict {
      use Psl\Type;
      use Psl\Option;
      use Psl\Iter;
    
      function get<Tk, Tv>(dict<Tk, Tv> $d, Tk $k): Option\Option<Tv> {
        return Iter\contains_key($d, $k) ? Option\some($d[$k]) : Option\none();
      }
    
      function get_typed<T>(dict<array-key, mixed> $d, array-key $k, Type\TypeInterface<T> $t): Option\Option<T> {
        return Iter\contains_key($d, $k) ? Option\some($t->coerce($d[$k])) : Option\none();
      }
    }
    
    namespace Psl\Vec {
      use Psl\Type;
      use Psl\Option;
      use Psl\Iter;
    
      function get<T>(vec<T> $v, int $k): Option\Option<T> {
        return Iter\contains_key($v, $k) ? Option\some($v[$k]) : Option\none();
      }
    
      function get_typed<T>(vec<mixed> $v, int $k, Type\TypeInterface<T> $t): Option\Option<T> {
        return Iter\contains_key($v, $k) ? Option\some($t->coerce($v[$k])) : Option\none();
      }
    }
    
    Priority: Low Status: Accepted Type: Enhancement 
    opened by azjezz 10
Releases(2.3.1)
  • 2.3.1(Dec 20, 2022)

    What's Changed

    • chore: update license copyright year by @azjezz in https://github.com/azjezz/psl/pull/371
    • fix(vec): reproduce and range return type is always non-empty-list @dragosprotung in https://github.com/azjezz/psl/pull/383

    Full Changelog: https://github.com/azjezz/psl/compare/2.3.0...2.3.1

    Source code(tar.gz)
    Source code(zip)
  • 2.3.0(Dec 1, 2022)

    What's Changed

    • Support psalm v5 by @veewee in https://github.com/azjezz/psl/pull/369

    Full Changelog: https://github.com/azjezz/psl/compare/2.2.0...2.3.0

    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Nov 26, 2022)

    What's Changed

    features

    • feat(option): introduce option component by @azjezz in https://github.com/azjezz/psl/pull/356

    Full Changelog: https://github.com/azjezz/psl/compare/2.1.0...2.2.0

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Nov 4, 2022)

    What's Changed

    features

    • introduced a new Psl\Type\unit_enum function - @19d1230 by @azjezz
    • introduced a new Psl\Type\backed_enum function - @19d1230 by @azjezz
    • introduced a new Psl\Type\mixed_vec function - #362 by @BackEndTea
    • introduced a new Psl\Type\mixed_dict function - #362 by @BackEndTea

    fixes, and improvements

    • improved Psl\Type\vec performance - #364 by @BackEndTea
    • improved Psl\Type\float, and Psl\Type\num - #367 by @bcremer

    other

    • updated revolt-php/event-loop to 1.0.0 - @c7bf866 by @azjezz
    • introduced scope-able loader - #361 by @veewee
    • fixed wrong function names in examples - #354 by @jrmajor
    • added reference to PHPStan integration in README.md - #353 by @ondrejmirtes

    New Contributors

    • @bcremer made their first contribution in https://github.com/azjezz/psl/pull/367

    Full Changelog: https://github.com/azjezz/psl/compare/2.0.4...2.1.0

    Source code(tar.gz)
    Source code(zip)
  • 2.0.4(Oct 10, 2022)

    What's Changed

    • chore(php): fix PHP 8.2 deprecations by @jrmajor in https://github.com/azjezz/psl/pull/363

    Full Changelog: https://github.com/azjezz/psl/compare/2.0.3...2.0.4

    Source code(tar.gz)
    Source code(zip)
  • 2.0.3(Jun 7, 2022)

    What's Changed

    • Fix file truncate writing mode by @dragosprotung in https://github.com/azjezz/psl/pull/352

    Full Changelog: https://github.com/azjezz/psl/compare/2.0.2...2.0.3

    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(May 30, 2022)

    What's Changed

    • Fix Filesystem\get_extension() returning empty string by @dragosprotung in https://github.com/azjezz/psl/pull/350

    Full Changelog: https://github.com/azjezz/psl/compare/2.0.1...2.0.2

    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(May 11, 2022)

    What's Changed

    • Use Revolt EventLoop stable version (0.2) by @simPod in https://github.com/azjezz/psl/pull/348

    New Contributors

    • @simPod made their first contribution in https://github.com/azjezz/psl/pull/348

    Full Changelog: https://github.com/azjezz/psl/compare/2.0.0...2.0.1

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(May 7, 2022)

    What's Changed

    • chore: remove deprecated functions by @azjezz in https://github.com/azjezz/psl/pull/241
    • chore: remove deprecated psalm plugin by @azjezz in https://github.com/azjezz/psl/pull/242
    • chore: refactor project structure by @azjezz in https://github.com/azjezz/psl/pull/243
    • chore(deps): bump phpbench/phpbench from 1.1.2 to 1.1.3 by @dependabot in https://github.com/azjezz/psl/pull/245
    • chore: drop support for PHP 8.0 by @azjezz in https://github.com/azjezz/psl/pull/246
    • chore: update configuration files by @azjezz in https://github.com/azjezz/psl/pull/247
    • feat(type): add instance_of() function by @azjezz in https://github.com/azjezz/psl/pull/248
    • feat(async): add async I/O support by @azjezz in https://github.com/azjezz/psl/pull/244
    • feat(io): refactor IO component to use Async component by @azjezz in https://github.com/azjezz/psl/pull/249
    • feat(file): introduce File component by @azjezz in https://github.com/azjezz/psl/pull/250
    • feat(filesystem): refactor Psl\Filesystem\write_file, Psl\Filesystem\append_file, and Psl\Filesystem\read_file to use Psl\File component. by @azjezz in https://github.com/azjezz/psl/pull/251
    • feat(shell): refactor Shell\execute to use async streams by @azjezz in https://github.com/azjezz/psl/pull/252
    • fix(async): always cancel timeout watcher after suspension is finished. by @azjezz in https://github.com/azjezz/psl/pull/253
    • chore(stream): refactor stream component by @azjezz in https://github.com/azjezz/psl/pull/254
    • feat(async): throw if resource is closed while waiting by @azjezz in https://github.com/azjezz/psl/pull/256
    • feat(runtime): introduce runtime component by @azjezz in https://github.com/azjezz/psl/pull/258
    • feat(str): use enum for encoding by @azjezz in https://github.com/azjezz/psl/pull/259
    • feat(network): introduce network, tcp, and unix components by @azjezz in https://github.com/azjezz/psl/pull/257
    • chore(deps): bump vimeo/psalm from 4.11.2 to 4.12.0 by @dependabot in https://github.com/azjezz/psl/pull/261
    • chore(io/tcp/unix): improve performance, and closed handle/server condition by @azjezz in https://github.com/azjezz/psl/pull/264
    • ci(unit-tests): test on macos by @azjezz in https://github.com/azjezz/psl/pull/266
    • chore(io): do not throw on non-blocking resource by @azjezz in https://github.com/azjezz/psl/pull/267
    • fix: fix windows support by @azjezz in https://github.com/azjezz/psl/pull/268
    • fix(io): fix readAll() blocks by @azjezz in https://github.com/azjezz/psl/pull/270
    • feat(io-stream): add getStream() method to access underlying stream by @azjezz in https://github.com/azjezz/psl/pull/273
    • chore(io): do not throw already closed exception when closing twice by @azjezz in https://github.com/azjezz/psl/pull/274
    • chore(internal): relay on autoloading when not using preloading by @azjezz in https://github.com/azjezz/psl/pull/275
    • chore(deps): bump friendsofphp/php-cs-fixer from 3.2.1 to 3.3.2 by @dependabot in https://github.com/azjezz/psl/pull/276
    • feat(io): queue operations instead of throwing by @azjezz in https://github.com/azjezz/psl/pull/277
    • chore(io): simplify write/read queue implementation by @azjezz in https://github.com/azjezz/psl/pull/278
    • feat(udp/tcp): queue operations instead of throwing by @azjezz in https://github.com/azjezz/psl/pull/279
    • chore(async): extend scheduler wrapper by @azjezz in https://github.com/azjezz/psl/pull/280
    • chore(deps): bump vimeo/psalm from 4.12.0 to 4.13.0 by @dependabot in https://github.com/azjezz/psl/pull/281
    • chore(ga): bump actions/cache from 2.1.6 to 2.1.7 by @dependabot in https://github.com/azjezz/psl/pull/282
    • feat(channel): introduce new channel component by @azjezz in https://github.com/azjezz/psl/pull/283
    • fix(channel): return immediately after cancelling send/recieve callbacks by @azjezz in https://github.com/azjezz/psl/pull/284
    • fix(channel): fix performance issue by @azjezz in https://github.com/azjezz/psl/pull/285
    • chore(deps): bump vimeo/psalm from 4.13.0 to 4.13.1 by @dependabot in https://github.com/azjezz/psl/pull/287
    • chore(channel): improve performance by @azjezz in https://github.com/azjezz/psl/pull/289
    • chore(shell): use exec to avoid spawning a grandchild process by @azjezz in https://github.com/azjezz/psl/pull/290
    • feat(async): introduce more async helper functions by @azjezz in https://github.com/azjezz/psl/pull/291
    • chore(shell): improve type coverage by @azjezz in https://github.com/azjezz/psl/pull/292
    • chore(channel): improve performance by @azjezz in https://github.com/azjezz/psl/pull/294
    • chore(async): run event loop on main(); by @azjezz in https://github.com/azjezz/psl/pull/295
    • fix(io): do not throw on close. by @azjezz in https://github.com/azjezz/psl/pull/296
    • feat(io): introduce write(), write_line(), write_error(), and write_error_line() functions by @azjezz in https://github.com/azjezz/psl/pull/297
    • feat(html): use Str\Encoding instead of string|null for $encoding argument by @azjezz in https://github.com/azjezz/psl/pull/298
    • chore(deps): bump phpbench/phpbench from 1.2.0 to 1.2.1 by @dependabot in https://github.com/azjezz/psl/pull/300
    • chore(deps): bump vimeo/psalm from 4.13.1 to 4.14.0 by @dependabot in https://github.com/azjezz/psl/pull/301
    • chore(deps): bump php-coveralls/php-coveralls from 2.5.1 to 2.5.2 by @dependabot in https://github.com/azjezz/psl/pull/302
    • chore(deps): bump vimeo/psalm from 4.14.0 to 4.15.0 by @dependabot in https://github.com/azjezz/psl/pull/303
    • chore(async): remove await_readable, await_writable, await_signal, and wrap functions by @azjezz in https://github.com/azjezz/psl/pull/305
    • chore(deps): bump revolt/event-loop from 0.1.0 to 0.1.1 by @dependabot in https://github.com/azjezz/psl/pull/309
    • chore(network,tcp,udp): implement socket server, and socket by @azjezz in https://github.com/azjezz/psl/pull/313
    • chore(io): rename readImmediately to tryRead, and writeImmediately to tryWrite by @azjezz in https://github.com/azjezz/psl/pull/314
    • chore: enable mutation tests by @azjezz in https://github.com/azjezz/psl/pull/286
    • chore: remove type verification at runtime by @azjezz in https://github.com/azjezz/psl/pull/317
    • chore(iter): optimize iterator by @azjezz in https://github.com/azjezz/psl/pull/318
    • chore: remove more type verification at runtime, and narrow down argument/return types by @azjezz in https://github.com/azjezz/psl/pull/319
    • chore(str): throw out-of-bounds exception instead of invariant violation for invalid offset by @azjezz in https://github.com/azjezz/psl/pull/320
    • chore(collection): throw out-of-bounds exception instead of invariant violation for invalid offset by @azjezz in https://github.com/azjezz/psl/pull/321
    • chore(collection): improve performance by @azjezz in https://github.com/azjezz/psl/pull/322
    • chore: remove all references to callable, replace by closure by @azjezz in https://github.com/azjezz/psl/pull/323
    • feat(async): introduce semaphore by @azjezz in https://github.com/azjezz/psl/pull/324
    • chore(data-structure): rework exceptions by @azjezz in https://github.com/azjezz/psl/pull/325
    • chore(filesystem): rework exceptions by @azjezz in https://github.com/azjezz/psl/pull/328
    • chore(deps): bump vimeo/psalm from 4.16.1 to 4.17.0 by @dependabot in https://github.com/azjezz/psl/pull/331
    • chore(deps): bump php-standard-library/psalm-plugin from 1.1.1 to 1.1.2 by @dependabot in https://github.com/azjezz/psl/pull/332
    • Add static analysis checks for the new psalm pipe hook by @veewee in https://github.com/azjezz/psl/pull/333
    • [Collection] add CollectionInterface::chunk() by @azjezz in https://github.com/azjezz/psl/pull/211
    • [Result] Collect stats from result sets by @veewee in https://github.com/azjezz/psl/pull/336
    • feat(network): support idle connections by @azjezz in https://github.com/azjezz/psl/pull/338
    • chore(ga): bump actions/cache from 2.1.7 to 3 by @dependabot in https://github.com/azjezz/psl/pull/341
    • feat(vec): introduce slice(), take() and drop() functions by @jrmajor in https://github.com/azjezz/psl/pull/344
    • Fix source doc function summary by @Zerogiven in https://github.com/azjezz/psl/pull/346
    • feat(shell): introduce error output behavior feature by @azjezz in https://github.com/azjezz/psl/pull/334
    • feat(io): add streaming function by @azjezz in https://github.com/azjezz/psl/pull/335
    • chore(filesystem): improve docblock descriptions by @jrmajor in https://github.com/azjezz/psl/pull/345
    • chore(ga): bump actions/checkout from 2 to 3 by @dependabot in https://github.com/azjezz/psl/pull/340

    New Contributors

    • @jrmajor made their first contribution in https://github.com/azjezz/psl/pull/344
    • @Zerogiven made their first contribution in https://github.com/azjezz/psl/pull/346

    Full Changelog: https://github.com/azjezz/psl/compare/1.9.2...2.0.0

    Source code(tar.gz)
    Source code(zip)
  • 1.6.3(Feb 23, 2022)

    What's Changed

    • Backport static analysis fixes to 1.6 by @veewee in https://github.com/azjezz/psl/pull/337

    Full Changelog: https://github.com/azjezz/psl/compare/1.6.2...1.6.3

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-rc2(Jan 15, 2022)

    What's Changed

    • chore(io): improve resource handle performance by @azjezz in 7e438a3db4e8baee2da1d7ad2b20809e0589aa58
    • chore(channel): use phpstorm compatible tuple type annotation by @azjezz in bbbd3193edcb68fd754032442495b8684d91a4d6
    • chore(io): cleanup internal resource handle by @azjezz in 2bc1d76cec44e19af0c2fc86b8f7d1f8b63f235e
    • chore(network): ignore server closed externally by @azjezz in 13fd1a0b4dbcd813e0ce9e5efa5cd35a80c0841d
    • chore(network): close socket connection on destruct by @azjezz in e9ae21d950491bcb9fcf1ba54fd553b38ce8d292
    • chore: update to revolt 0.2 by @azjezz in 1f94455396a19589c8b5c3e8030e4f6a68a15b83
    • chore(io): drop support for object resource handles by @azjezz in c3fa1282e8c09923ef3168e981076f03346b6a16
    • chore(promise): catch throwable instead of exceptions by @azjezz in bfbdef7fa8918c4bffdc30b64bf3e765ffd25f91
    • chore(result): move Async\reflect to Result\reflect by @azjezz in 21bf0cd3d6d6055fc88541e9b24f3140bd179b2d

    Full Changelog: https://github.com/azjezz/psl/compare/2.0.0-rc1...2.0.0-rc2

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0-rc1(Jan 8, 2022)

    What's Changed

    • chore: remove deprecated functions by @azjezz in https://github.com/azjezz/psl/pull/241
    • chore: remove deprecated psalm plugin by @azjezz in https://github.com/azjezz/psl/pull/242
    • chore: refactor project structure by @azjezz in https://github.com/azjezz/psl/pull/243
    • chore(deps): bump phpbench/phpbench from 1.1.2 to 1.1.3 by @dependabot in https://github.com/azjezz/psl/pull/245
    • chore: drop support for PHP 8.0 by @azjezz in https://github.com/azjezz/psl/pull/246
    • chore: update configuration files by @azjezz in https://github.com/azjezz/psl/pull/247
    • feat(type): add instance_of() function by @azjezz in https://github.com/azjezz/psl/pull/248
    • feat(async): add async I/O support by @azjezz in https://github.com/azjezz/psl/pull/244
    • feat(io): refactor IO component to use Async component by @azjezz in https://github.com/azjezz/psl/pull/249
    • feat(file): introduce File component by @azjezz in https://github.com/azjezz/psl/pull/250
    • feat(filesystem): refactor Psl\Filesystem\write_file, Psl\Filesystem\append_file, and Psl\Filesystem\read_file to use Psl\File component. by @azjezz in https://github.com/azjezz/psl/pull/251
    • feat(shell): refactor Shell\execute to use async streams by @azjezz in https://github.com/azjezz/psl/pull/252
    • fix(async): always cancel timeout watcher after suspension is finished. by @azjezz in https://github.com/azjezz/psl/pull/253
    • chore(stream): refactor stream component by @azjezz in https://github.com/azjezz/psl/pull/254
    • feat(async): throw if resource is closed while waiting by @azjezz in https://github.com/azjezz/psl/pull/256
    • feat(runtime): introduce runtime component by @azjezz in https://github.com/azjezz/psl/pull/258
    • feat(str): use enum for encoding by @azjezz in https://github.com/azjezz/psl/pull/259
    • feat(network): introduce network, tcp, and unix components by @azjezz in https://github.com/azjezz/psl/pull/257
    • chore(deps): bump vimeo/psalm from 4.11.2 to 4.12.0 by @dependabot in https://github.com/azjezz/psl/pull/261
    • chore(io/tcp/unix): improve performance, and closed handle/server condition by @azjezz in https://github.com/azjezz/psl/pull/264
    • ci(unit-tests): test on macos by @azjezz in https://github.com/azjezz/psl/pull/266
    • chore(io): do not throw on non-blocking resource by @azjezz in https://github.com/azjezz/psl/pull/267
    • fix: fix windows support by @azjezz in https://github.com/azjezz/psl/pull/268
    • fix(io): fix readAll() blocks by @azjezz in https://github.com/azjezz/psl/pull/270
    • feat(io-stream): add getStream() method to access underlying stream by @azjezz in https://github.com/azjezz/psl/pull/273
    • chore(io): do not throw already closed exception when closing twice by @azjezz in https://github.com/azjezz/psl/pull/274
    • chore(internal): relay on autoloading when not using preloading by @azjezz in https://github.com/azjezz/psl/pull/275
    • chore(deps): bump friendsofphp/php-cs-fixer from 3.2.1 to 3.3.2 by @dependabot in https://github.com/azjezz/psl/pull/276
    • feat(io): queue operations instead of throwing by @azjezz in https://github.com/azjezz/psl/pull/277
    • chore(io): simplify write/read queue implementation by @azjezz in https://github.com/azjezz/psl/pull/278
    • feat(udp/tcp): queue operations instead of throwing by @azjezz in https://github.com/azjezz/psl/pull/279
    • chore(async): extend scheduler wrapper by @azjezz in https://github.com/azjezz/psl/pull/280
    • chore(deps): bump vimeo/psalm from 4.12.0 to 4.13.0 by @dependabot in https://github.com/azjezz/psl/pull/281
    • chore(ga): bump actions/cache from 2.1.6 to 2.1.7 by @dependabot in https://github.com/azjezz/psl/pull/282
    • feat(channel): introduce new channel component by @azjezz in https://github.com/azjezz/psl/pull/283
    • fix(channel): return immediately after cancelling send/recieve callbacks by @azjezz in https://github.com/azjezz/psl/pull/284
    • fix(channel): fix performance issue by @azjezz in https://github.com/azjezz/psl/pull/285
    • chore(deps): bump vimeo/psalm from 4.13.0 to 4.13.1 by @dependabot in https://github.com/azjezz/psl/pull/287
    • chore(channel): improve performance by @azjezz in https://github.com/azjezz/psl/pull/289
    • chore(shell): use exec to avoid spawning a grandchild process by @azjezz in https://github.com/azjezz/psl/pull/290
    • feat(async): introduce more async helper functions by @azjezz in https://github.com/azjezz/psl/pull/291
    • chore(shell): improve type coverage by @azjezz in https://github.com/azjezz/psl/pull/292
    • chore(channel): improve performance by @azjezz in https://github.com/azjezz/psl/pull/294
    • chore(async): run event loop on main(); by @azjezz in https://github.com/azjezz/psl/pull/295
    • fix(io): do not throw on close. by @azjezz in https://github.com/azjezz/psl/pull/296
    • feat(io): introduce write(), write_line(), write_error(), and write_error_line() functions by @azjezz in https://github.com/azjezz/psl/pull/297
    • feat(html): use Str\Encoding instead of string|null for $encoding argument by @azjezz in https://github.com/azjezz/psl/pull/298
    • chore(deps): bump phpbench/phpbench from 1.2.0 to 1.2.1 by @dependabot in https://github.com/azjezz/psl/pull/300
    • chore(deps): bump vimeo/psalm from 4.13.1 to 4.14.0 by @dependabot in https://github.com/azjezz/psl/pull/301
    • chore(deps): bump php-coveralls/php-coveralls from 2.5.1 to 2.5.2 by @dependabot in https://github.com/azjezz/psl/pull/302
    • chore(deps): bump vimeo/psalm from 4.14.0 to 4.15.0 by @dependabot in https://github.com/azjezz/psl/pull/303
    • chore(async): remove await_readable, await_writable, await_signal, and wrap functions by @azjezz in https://github.com/azjezz/psl/pull/305
    • chore(deps): bump revolt/event-loop from 0.1.0 to 0.1.1 by @dependabot in https://github.com/azjezz/psl/pull/309
    • chore(network,tcp,udp): implement socket server, and socket by @azjezz in https://github.com/azjezz/psl/pull/313
    • chore(io): rename readImmediately to tryRead, and writeImmediately to tryWrite by @azjezz in https://github.com/azjezz/psl/pull/314
    • chore: enable mutation tests by @azjezz in https://github.com/azjezz/psl/pull/286
    • chore: remove type verification at runtime by @azjezz in https://github.com/azjezz/psl/pull/317
    • chore(iter): optimize iterator by @azjezz in https://github.com/azjezz/psl/pull/318
    • chore: remove more type verification at runtime, and narrow down argument/return types by @azjezz in https://github.com/azjezz/psl/pull/319
    • chore(str): throw out-of-bounds exception instead of invariant violation for invalid offset by @azjezz in https://github.com/azjezz/psl/pull/320
    • chore(collection): throw out-of-bounds exception instead of invariant violation for invalid offset by @azjezz in https://github.com/azjezz/psl/pull/321
    • chore(collection): improve performance by @azjezz in https://github.com/azjezz/psl/pull/322
    • chore: remove all references to callable, replace by closure by @azjezz in https://github.com/azjezz/psl/pull/323
    • feat(async): introduce semaphore by @azjezz in https://github.com/azjezz/psl/pull/324
    • chore(data-structure): rework exceptions by @azjezz in https://github.com/azjezz/psl/pull/325
    • chore(filesystem): rework exceptions by @azjezz in https://github.com/azjezz/psl/pull/328
    • chore(deps): bump vimeo/psalm from 4.16.1 to 4.17.0 by @dependabot in https://github.com/azjezz/psl/pull/331
    • chore(deps): bump php-standard-library/psalm-plugin from 1.1.1 to 1.1.2 by @dependabot in https://github.com/azjezz/psl/pull/332
    • Add static analysis checks for the new psalm pipe hook by @veewee in https://github.com/azjezz/psl/pull/333
    • [Collection] add CollectionInterface::chunk() by @azjezz in https://github.com/azjezz/psl/pull/211

    Full Changelog: https://github.com/azjezz/psl/compare/1.9.2...2.0.0-rc1

    Source code(tar.gz)
    Source code(zip)
  • 1.9.3(Dec 10, 2021)

    What's Changed

    • fix(composer): add Psl namespace mapped to src/Psl by @asgrim in https://github.com/azjezz/psl/pull/311

    New Contributors

    • @asgrim made their first contribution in https://github.com/azjezz/psl/pull/311

    Full Changelog: https://github.com/azjezz/psl/compare/1.9.2...1.9.3

    Source code(tar.gz)
    Source code(zip)
  • 1.8.2(Dec 8, 2021)

    What's Changed

    • chore(php): fix PHP 8.1 deprecations by @azjezz in https://github.com/azjezz/psl/commit/346978e07e188ba7d2186b3bca1a622539b5830e

    Full Changelog: https://github.com/azjezz/psl/compare/1.8.1...1.8.2

    Source code(tar.gz)
    Source code(zip)
  • 1.7.4(Dec 8, 2021)

    What's Changed

    • chore(php): fix PHP 8.1 deprecations by @azjezz in https://github.com/azjezz/psl/commit/f4c9a191e87f62059117bf183d1010e50c389b44

    Full Changelog: https://github.com/azjezz/psl/compare/1.7.3...1.7.4

    Source code(tar.gz)
    Source code(zip)
  • 1.6.2(Dec 8, 2021)

    What's Changed

    • chore(php): fix PHP 8.1 deprecations by @azjezz in https://github.com/azjezz/psl/pull/304

    Full Changelog: https://github.com/azjezz/psl/compare/1.6.1...1.6.2

    Source code(tar.gz)
    Source code(zip)
  • 1.9.2(Nov 10, 2021)

    What's Changed

    • fix(filesystem): call clearstatcache after writing to a file to reset file stat by @dragosprotung in https://github.com/azjezz/psl/pull/262
    • fix(shell): fix windows support by @azjezz in https://github.com/azjezz/psl/pull/269

    Full Changelog: https://github.com/azjezz/psl/compare/1.9.1...1.9.2

    Source code(tar.gz)
    Source code(zip)
  • 1.9.1(Nov 6, 2021)

    What's Changed

    • chore(php): fix PHP 8.1 deprecations by @azjezz in https://github.com/azjezz/psl/pull/255

    Full Changelog: https://github.com/azjezz/psl/compare/1.9.0...1.9.1

    Source code(tar.gz)
    Source code(zip)
  • 1.9.0(Oct 29, 2021)

    Features: - [Str] add reverse() function ( #238 by @yivi ) - [Str][Grapheme] add reverse() function ( #239 by @yivi ) - [Fun] add tap() function ( #234 by @veewee ) - [Type] performance improvements ( #223 by @Ocramius )

    Other: - add benchmarks ( #223 by @Ocramius ) - add documentation functions to makefile ( #235 by @veewee )

    Source code(tar.gz)
    Source code(zip)
  • 1.8.1(Oct 3, 2021)

    Features:

    • N/A

    Fixes:

    • [Shell] fixed missing shell output from exception message ( #232 by @azjezz )

    Other:

    • apply coding standards fix ( #232 @azjezz )
    Source code(tar.gz)
    Source code(zip)
  • 1.7.3(Aug 25, 2021)

    • [Str][Byte] remove unnecessary @var annotation ( https://github.com/azjezz/psl/commit/aacfcf691ab8a9d68e116ab829a146c5683696a0 )
    • [Regex] fix replace_with() signature ( thanks @caugner - https://github.com/azjezz/psl/pull/219 )
    • [Math] don't perform operations on possible numeric-string ( thanks @orklah - https://github.com/azjezz/psl/pull/220 )
    Source code(tar.gz)
    Source code(zip)
  • 1.8.0(Sep 5, 2021)

    Features:

    • [Type] Introduce new Type\non_empty_dict ( #200 by @ntzm )
    • [Type] Introduce new Type\non_empty_vec ( #201 by @ntzm )
    • [Type] correct type signature for vec ( #202 by @ntzm )
    • [Type] correct type signature for dict ( #203 by @ntzm )
    • [Filesystem] add argument values to exception message ( #205 by @vaclavvanik )
    • [Fun] add lazy() for doing lazy evaluations ( #215 by @veewee )
    • [Iter] Improved performance of Iter\shuffle ( https://github.com/azjezz/psl/commit/6f5c992f4054ad08449cd170d18060d4e5c620b6 by @azjezz )
    • Introduced new Psl\Ref class ( https://github.com/azjezz/psl/commit/2d0b3c537a4685f123b9019975ef64d858fa2d7b by @azjezz )

    Fixes:

    • [Vec] fixed example of Vec\reproduce ( #218 by @hvt )
    • [Math] don't perform operations on possible numeric-string ( #220 by @orklah )
    • [Regex] fix replace_with() signature ( #219 by @caugner )

    Other:

    • Suggest php-standard-library/psalm-plugin package ( #217 by @weirdan )
    Source code(tar.gz)
    Source code(zip)
  • 1.7.2(May 24, 2021)

  • 1.7.1(May 19, 2021)

  • 1.6.1(May 19, 2021)

  • 1.7.0(May 15, 2021)

  • 1.6.0(Apr 7, 2021)

    Features:

    • added Psl\Type\positive_int function ( @michaelpetri - #177 )
    • added Psl\Dict\unique_scalar function ( @pencil-dog and @yivi - #168 )
    • simplified Psl\Str\Byte\reverse implementation ( @ntzm - #160 )

    BC breaks:

    • changed return type of Psl\Str\metaphone from ?string to string ( @ntzm - #159 )
    • Psl\Str\metaphone now throws Psl\Exception\InvariantViolationException if $phonemes is negative ( @ntzm - #159 )
    • require non-empty-string instead of string when applicable ( @ntzm - #162 )
    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Mar 19, 2021)

    Components:

    Features:

    • added Psl\Shell\execute function
    • added Psl\Shell\escape_argument function
    • added Psl\Shell\escape_command function
    • added Psl\Filesystem\SEPARATOR constant
    • added Psl\Filesystem\change_group function
    • added Psl\Filesystem\change_owner function
    • added Psl\Filesystem\change_permissions function
    • added Psl\Filesystem\copy function
    • added Psl\Filesystem\create_directory function
    • added Psl\Filesystem\create_file function
    • added Psl\Filesystem\delete_directory function
    • added Psl\Filesystem\delete_file function
    • added Psl\Filesystem\exists function
    • added Psl\Filesystem\file_size function
    • added Psl\Filesystem\get_group function
    • added Psl\Filesystem\get_owner function
    • added Psl\Filesystem\get_permissions function
    • added Psl\Filesystem\get_basename function
    • added Psl\Filesystem\get_directory function
    • added Psl\Filesystem\get_extension function
    • added Psl\Filesystem\get_filename function
    • added Psl\Filesystem\is_directory function
    • added Psl\Filesystem\is_file function
    • added Psl\Filesystem\is_symbolic_link function
    • added Psl\Filesystem\is_readable function
    • added Psl\Filesystem\is_writable function
    • added Psl\Filesystem\canonicalize function
    • added Psl\Filesystem\is_executable function
    • added Psl\Filesystem\read_directory function
    • added Psl\Filesystem\read_file function
    • added Psl\Filesystem\read_symbolic_link function
    • added Psl\Filesystem\append_file function
    • added Psl\Filesystem\write_file function
    • added Psl\Filesystem\create_temporary_file function
    • added Psl\Filesystem\create_hard_link function
    • added Psl\Filesystem\create_symbolic_link function
    • added Psl\Filesystem\get_access_time function
    • added Psl\Filesystem\get_change_time function
    • added Psl\Filesystem\get_modification_time function
    • added Psl\Filesystem\get_inode function
    • added a new Psl\Regex\replace_by function.
    • added an optional ?int $limit = null parameter to Psl\Regex\replace
    • added an optional ?int $limit = null parameter to Psl\Regex\replace_every
    • added Psl\Html\encode function
    • added Psl\Html\encode_special_characters function
    • added Psl\Html\decode function
    • added Psl\Html\decode_special_characters function
    • added Psl\Html\strip_tags function
    • added Psl\Type\literal_scalar function
    • added Psl\Type\optional function
    • added Psl\Type\TypeInterface::isOptional method
    • added Psl\IO\input_handle function
    • added Psl\IO\output_handle function
    • added Psl\IO\error_handle function
    • added Psl\IO\CloseHandleInterface interface
    • added Psl\IO\CloseReadHandleInterface interface
    • added Psl\IO\CloseReadWriteHandleInterface interface
    • added Psl\IO\CloseSeekHandleInterface interface
    • added Psl\IO\CloseSeekReadHandleInterface interface
    • added Psl\IO\CloseSeekReadWriteHandleInterface interface
    • added Psl\IO\CloseSeekWriteHandleInterface interface
    • added Psl\IO\CloseWriteHandleInterface interface
    • added Psl\IO\HandleInterface interface
    • added Psl\IO\ReadHandleInterface interface
    • added Psl\IO\ReadWriteHandleInterface interface
    • added Psl\IO\SeekHandleInterface interface
    • added Psl\IO\SeekReadHandleInterface interface
    • added Psl\IO\SeekReadWriteHandleInterface interface
    • added Psl\IO\SeekWriteHandleInterface interface
    • added Psl\IO\WriteHandleInterface interface
    • added Psl\IO\Writer class
    • added Psl\IO\Reader class
    • added Psl\IO\MemoryHandle class
    Source code(tar.gz)
    Source code(zip)
  • 1.4.1(Feb 21, 2021)

  • 1.3.1(Feb 21, 2021)

Owner
Saif Eddin Gmati
@coopTilleuls / @toraido ( previously at @symfonycorp / @SmartTeamTN ). 39AC CCA4 FD30 0D04 C840 6EB3 B00E 0A46 B3F1 C157 ~ [email protected]
Saif Eddin Gmati
This shell script and PHP file create a browseable HTML site from the Zig standard library source.

Browseable Zig standard library This shell script and PHP file create a browseable HTML site from the Zig standard library source. The idea is to inve

Dave Gauer 3 Mar 20, 2022
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Minibase 16 Jun 7, 2022
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Minibase 16 Jun 7, 2022
Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.DeepEqual().

Deeper Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.De

Joubert RedRat 4 Feb 12, 2022
Check modules in app/code and vendor for PHP 8 compatibility status - PHP_CodeSniffer & php-compatibility standard

M2 PHP version compatibility check How To use Requires PHP 7.3+ | PHP 8 This app will run PHP_CodeSniffer with phpcompatibility/php-compatibility on t

William Tran 24 Oct 13, 2022
Igbinary is a drop in replacement for the standard php serializer.

igbinary Igbinary is a drop in replacement for the standard php serializer. Instead of the time and space consuming textual representation used by PHP

Igbinary development 727 Dec 21, 2022
Magento 1.x Coding Standard

Magento Extension Quality Program Coding Standard ⚠️ Versions 3.0.0 and above of the MEQP Coding Standard are for Magento 1.x code only. To check Mage

Magento 224 Nov 29, 2022
Magento Coding Standard

Magento Coding Standard A set of Magento rules for PHP_CodeSniffer tool. Installation within a Magento 2 site To use within your Magento 2 project you

Magento 290 Dec 31, 2022
A Symfony2 bundle that integrates Select2 as a drop-in replacement for a standard entity field on a Symfony form.

select2entity-bundle Introduction This is a Symfony bundle which enables the popular Select2 component to be used as a drop-in replacement for a stand

Ross Keatinge 214 Nov 21, 2022
This package provides a set of factories to be used with containers using the PSR-11 standard for an easy Doctrine integration in a project

psr-container-doctrine: Doctrine Factories for PSR-11 Containers Doctrine factories for PSR-11 containers. This package provides a set of factories to

Roave, LLC 84 Dec 14, 2022
This tool can write the monolog standard log directly to clickhouse in real time via the tcp protocol

log2ck This tool can write the monolog standard log directly to clickhouse in real time via the tcp protocol. If you can write regular rules, other st

Hisune 9 Aug 15, 2022
Easy Coding Standard configurations for Craft CMS projects.

Easy Coding Standard config for Craft CMs This package provides Easy Coding Standard configurations for Craft CMS plugins and projects. In general, we

Craft CMS 10 Dec 18, 2022
Pattern Lab Standard Edition for Twig

Pattern Lab Standard Edition for Twig The Standard Edition for Twig gives developers and designers a clean and stable base from which to develop a Twi

Pattern Lab 102 Oct 24, 2022
Automate aggregation tools to standard alerts from SAP PI/PO (CBMA) for internal support team

✅ PiAlert PiAlert is system for automating the work of SAP PI/PO support team via aggregation of alerts (CBMA messages). Language support: English Рус

Ivan Shashurin 3 Dec 2, 2022
A wrapper around symplify/config-transformer used to update recipes and using easy coding standard for generating readable config files.

Symfony Recipes Yaml to PHP Converter This is a wrapper around the symplify/config-transformer used to convert Symfony core recipes which uses .yaml c

Alexander Schranz 3 Nov 24, 2022
Standard WordPress Plugin Autoloader

The autoloader standard and maintain code quality, You can use your WordPress plugins project. Basically, the autoloader I made for Envato and all premium WordPress plugin marketplace.

Md Mizanur Ali 2 Aug 9, 2022
A simple ByteBuffer implementation for PHP (Node.js inspired)

Bytebuffer A simple ByteBuffer implementation for PHP (Node.js inspired) Installation composer require labalityowo/bytebuffer:dev-stable Why? I made t

labalityowo 3 May 24, 2022
High performance view templating API for PHP applications using tags & expressions inspired by Java JSTL and C compiler

View Language API Table of contents: About Expressions Tags Configuration Compilation Installation Unit Tests Examples Reference Guide About This API

Lucian Gabriel Popescu 0 Jan 9, 2022
A data transfer object inspired by Rust's serde

Data Transfer Object Want to deserialize an object with data on the fly? Go for it by using the From trait. How is this package any different from spa

Randy Schütt 37 Dec 15, 2022