azjezz / Psl
Licence: mit
PHP Standard Library - a modern, consistent, centralized, well-typed set of APIs for PHP programmers.
Stars: ✭ 329
Projects that are alternatives of or similar to Psl
Buckets Js
A complete, fully tested and documented data structure library written in pure JavaScript.
Stars: ✭ 1,128 (+242.86%)
Mutual labels: data-structures, collection
Libchef
🍀 c++ standalone header-only basic library. || c++头文件实现无第三方依赖基础库
Stars: ✭ 178 (-45.9%)
Mutual labels: data-structures, encoding
Algorithm
📌 Notes and Codes for studying data structures and algorithm
Stars: ✭ 71 (-78.42%)
Mutual labels: data-structures, math
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+130.7%)
Mutual labels: data-structures, json
algorithm
📌 Notes and Codes for studying data structures and algorithm
Stars: ✭ 72 (-78.12%)
Mutual labels: math, data-structures
Sanest
sane nested dictionaries and lists for python
Stars: ✭ 19 (-94.22%)
Mutual labels: data-structures, json
Datagene
DataGene - Identify How Similar TS Datasets Are to One Another (by @firmai)
Stars: ✭ 156 (-52.58%)
Mutual labels: data-structures, encoding
Config
🛠 A configuration library for Go that parses environment variables, JSON files, and reloads automatically on SIGHUP
Stars: ✭ 203 (-38.3%)
Mutual labels: environment-variables, json
Boltons
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.
Stars: ✭ 5,671 (+1623.71%)
Mutual labels: data-structures, json
Newton Api
➗ A really micro micro-service for advanced math.
Stars: ✭ 358 (+8.81%)
Mutual labels: json, math
Adblockfast
Adblock Fast is a new, faster ad blocker for Android, iOS, Chrome, and Opera.
Stars: ✭ 582 (+76.9%)
Mutual labels: data-structures, json
Shon
A simple tool to convert json or yaml into a shell-compliant data structure.
Stars: ✭ 47 (-85.71%)
Mutual labels: data-structures, json
Algodeck
An Open-Source Collection of 200+ Algorithmic Flash Cards to Help you Preparing your Algorithm & Data Structure Interview 💯
Stars: ✭ 4,441 (+1249.85%)
Mutual labels: data-structures, math
Containers
This library provides various containers. Each container has utility functions to manipulate the data it holds. This is an abstraction as to not have to manually manage and reallocate memory.
Stars: ✭ 125 (-62.01%)
Mutual labels: data-structures, collection
Node Convict
Featureful configuration management library for Node.js
Stars: ✭ 1,855 (+463.83%)
Mutual labels: environment-variables, json
Fig
A minimalist Go configuration library
Stars: ✭ 142 (-56.84%)
Mutual labels: environment-variables, json
Serpent
A protocol to serialize Swift structs and classes for encoding and decoding.
Stars: ✭ 281 (-14.59%)
Mutual labels: json, encoding
Psl - PHP Standard Library
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
<?php
declare(strict_types=1);
use Psl\{Dict, Str, Vec};
/**
* @psalm-param iterable<?int> $codes
*/
function foo(iterable $codes): string
{
$codes = Vec\filter_nulls($codes);
$chars = Dict\map($codes, fn(int $code): string => Str\chr($code));
return Str\join($chars, ', ');
}
foo([95, 96, null, 98]);
// 'a, b, d'
Installation
Supported installation method is via composer:
$ composer require azjezz/psl
Psalm Integration
PSL comes with a Psalm plugin, that improves return type for PSL functions that psalm cannot infer from source code.
To enable the Psalm plugin, add the Psl\Integration\Psalm\Plugin
class to your psalm configuration file plugins list as follows:
<psalm>
...
<plugins>
...
<pluginClass class="Psl\Integration\Psalm\Plugin" />
</plugins>
</psalm>
Documentation
You can read through the API documentation in docs/README.md
.
Principles
- All functions should be typed as strictly as possible
- The library should be internally consistent
- References may not be used
- Arguments should be as general as possible. For example, for
array
functions, preferiterable
inputs where practical, falling back toarray
when needed. - Return types should be as specific as possible
- All files should contain
declare(strict_types=1);
Consistency Rules
This is not exhaustive list.
- Functions argument order should be consistent within the library
- All iterable-related functions take the iterable as the first argument ( e.g.
Iter\map
andIter\filter
) -
$haystack
,$needle
, and$pattern
are in the same order for all functions that take them
- All iterable-related functions take the iterable as the first argument ( e.g.
- Functions should be consistently named.
- If an operation can conceivably operate on either keys or values, the default is to operate on the values - the version that operates on keys should have
_key
suffix (e.g.Iter\last
,Iter\last_key
,Iter\contains
,Iter\contains_key
) - Find-like operations that can fail should return
?T
; a second function should be added with anx
suffix that uses an invariant to returnT
(e.g.Arr\last
,Arr\lastx
) - Iterable functions that do an operation based on a user-supplied keying function for each element should be suffixed with
_by
(e.g.Arr\sort_by
,Iter\group_by
,Math\max_by
)
Sponsors
Thanks to our sponsors and supporters:
JetBrains |
---|
License
The MIT License (MIT). Please see LICENSE
for more information.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].