{"id":36253070,"url":"https://github.com/eventjet/ausdruck","last_synced_at":"2026-01-11T07:02:39.037Z","repository":{"id":199627437,"uuid":"700801870","full_name":"eventjet/ausdruck","owner":"eventjet","description":"A small generic expression engine for PHP","archived":false,"fork":false,"pushed_at":"2025-10-16T05:01:31.000Z","size":189,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"0.2.x","last_synced_at":"2025-10-17T07:45:38.297Z","etag":null,"topics":["expressionengine","hacktoberfest","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eventjet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-05T10:20:10.000Z","updated_at":"2025-10-16T05:00:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"67496b0d-96dd-4d11-8b22-f952add6f70a","html_url":"https://github.com/eventjet/ausdruck","commit_stats":null,"previous_names":["eventjet/ausdruck"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/eventjet/ausdruck","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eventjet%2Fausdruck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eventjet%2Fausdruck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eventjet%2Fausdruck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eventjet%2Fausdruck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eventjet","download_url":"https://codeload.github.com/eventjet/ausdruck/tar.gz/refs/heads/0.2.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eventjet%2Fausdruck/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28296941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T04:44:51.577Z","status":"ssl_error","status_checked_at":"2026-01-11T04:44:44.232Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expressionengine","hacktoberfest","php"],"created_at":"2026-01-11T07:02:38.326Z","updated_at":"2026-01-11T07:02:38.991Z","avatar_url":"https://github.com/eventjet.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ausdruck\n\nA small expression engine for PHP.\n\n## Quick start\n\n```\ncomposer require eventjet/ausdruck\n```\n\n```php\nuse Eventjet\\Ausdruck\\Parser\\ExpressionParser;\nuse Eventjet\\Ausdruck\\Parser\\Types;\nuse Eventjet\\Ausdruck\\Type;\n\n$expression = ExpressionParser::parse(\n    'joe:MyPersonType.name:string()',\n    new Types(['MyPersonType' =\u003e Type::listOf(Type::string())]),\n);\n$scope = new Scope(\n    // Passing values to the expression\n    ['joe' =\u003e ['joe']],\n    // Custom function definitions\n    ['name' =\u003e static fn (array $person): string =\u003e $person[0]],\n);\n$name = $expression-\u003eevaluate($scope);\nassert($name === 'Joe');\n```\n\n## Documentation\n\n### Accessing scope variables\n\nSyntax: `varName:type`\n\nScope variables are passed from PHP when it calls `evaluate()` on the expression:\n\n```php\nuse Eventjet\\Ausdruck\\Parser\\ExpressionParser;\nuse Eventjet\\Ausdruck\\Scope;\n\n$x = ExpressionParser::parse('foo:int')\n    -\u003eevaluate(new Scope(['foo' =\u003e 123]));\nassert($x === 123); \n```\n\n#### Examples\n\n`foo:int`, `foo:list\u003cstring\u003e`\n\nSee [Types](#types)\n\n### Literals\n\n- `123`: Integer\n- `\"foo\"`: String\n- `1.23`: Float\n- `[1, myInt:int, 3]`: List of integers\n- `[\"foo\", myString:string, \"bar\"]`: List of strings\n\n### Operators\n\nBoth operands must be of the same type.\n\n| Operator | Description  | Example                  | Note                                      |\n|----------|--------------|--------------------------|-------------------------------------------|\n| `===`    | Equality     | `foo:string === \"bar\"`   |                                           |\n| `-`      | Subtraction  | `foo:int - bar:int`      | Operands must be of type `int` or `float` |\n| `\u003e`      | Greater than | `foo:int \u003e bar:int`      | Operands must be of type `int` or `float` |\n| `\\|\\|`   | Logical OR   | `foo:bool \\|\\| bar:bool` | Operands must be of type `bool`           |\n| \u0026\u0026       | Logical AND  | `foo:bool \u0026\u0026 bar:bool`   | Operands must be of type `bool`           |\n\nWhere's the rest? We're implementing more as we need them.\n\n### Types\n\nThe following types are supported:\n\n- `int`: Integer\n- `string`: String\n- `bool`: Boolean\n- `float`: Floating point number\n- `list\u003cT\u003e`: List of type T\n- `map\u003cK, V\u003e`: Map with key type K and value type V\n- Any other type will be treated as an alias that you will have to provide when parsing the expression:\n  ```php\n  use Eventjet\\Ausdruck\\Parser\\ExpressionParser;\n  use Eventjet\\Ausdruck\\Type;\n  \n  ExpressionParser::parse('foo:MyType', ['MyType' =\u003e Type::alias(Type::listOf(Type::string()))]);\n  ```\n\n### Functions\n\nSyntax: `target.functionName:returnType(arg1, arg2, ...)`\n\nThe target can be any expression. It will be passed as the first argument to the function.\n\n#### Example\n\n`haystack:list\u003cstring\u003e.contains:bool(needle:string)`\n\n#### Built-In Functions\n\n| Function   | Description                                                            | Example                                          |\n|------------|------------------------------------------------------------------------|--------------------------------------------------|\n| `count`    | Returns the number of elements in a list                               | `foo:list\u003cstring\u003e.count:int()`                   |\n| `contains` | Returns whether a list contains a value                                | `foo:list\u003cstring\u003e.contains:bool(\"bar\")`          |\n| `head`     | Returns the first element of a list as an `Option`                     | `foo:list\u003cstring\u003e.head:Option\u003cstring\u003e()`         |\n| `isSome`   | Takes an Option and returns whether it is `Some`                       | `foo:Option\u003cint\u003e.isSome:bool()`                  |\n| `map`      | Returns a new list with the results of applying a [function](#lambdas) | `foo:list\u003cint\u003e.map:list\u003cint\u003e(\\|i\\| i:int - 2)`   |\n| `some`     | Returns whether any element matches a [predicate](#lambdas)            | `foo:list\u003cint\u003e.some:bool(\\|item\\| item:int \u003e 5)` |\n| `substr`   | Returns a substring of a string                                        | `foo:string.substr:string(0, 5)`                 |\n| `tail`     | Returns all elements of a list except the first                        | `foo:list\u003cstring\u003e.tail:list\u003cstring\u003e()`           |\n| `take`     | Returns the first n elements of a list                                 | `foo:list\u003cstring\u003e.take:list\u003cstring\u003e(5)`          |\n| `unique`   | Returns a list with duplicate elements removed                         | `foo:list\u003cstring\u003e.unique:list\u003cstring\u003e()`         |\n\n#### Custom Functions\n\nYou can pass custom functions along with the scope variables:\n\n```php\nuse Eventjet\\Ausdruck\\Parser\\ExpressionParser;use Eventjet\\Ausdruck\\Scope;\n\n$scope = new Scope(\n    ['foo' =\u003e 'My secret'],\n    ['mask' =\u003e fn (string $str, string $mask) =\u003e str_repeat($mask, strlen($str))]\n);\n$result = ExpressionParser::parse('foo:string.mask(\"x\")')-\u003eevaluate($scope);\nassert($result === 'xxxxxxxxx');\n```\n\nThe target of the function/method call (`foo:string` in the example above) will be passed as the first argument to the\nfunction.\n\n### Lambdas\n\nSyntax: `|arg1, arg2, ... | expression`\n\nTo access an argument, you must specify its type, just like when accessing scope variables.\n\n#### Example\n\n`|item| item:int \u003e 5`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feventjet%2Fausdruck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feventjet%2Fausdruck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feventjet%2Fausdruck/lists"}