Skip to content

Commit d2736e2

Browse files
committed
chore: simplify readme
Signed-off-by: azjezz <azjezz@protonmail.com>
1 parent 20b4ea9 commit d2736e2

File tree

1 file changed

+3
-112
lines changed

1 file changed

+3
-112
lines changed

README.md

Lines changed: 3 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ This repository contains a PHP implementation of the [Common Expression Language
3333

3434
## Quick Example
3535

36-
### Simple Usage
37-
3836
```php
3937
use Cel;
4038

@@ -43,122 +41,15 @@ $result = Cel\evaluate('1 + 2');
4341
echo $result->getRawValue(); // Output: 3
4442

4543
// With variables
46-
$result = Cel\evaluate(
47-
'user.age >= 18',
48-
['user' => ['age' => 25]]
49-
);
44+
$result = Cel\evaluate('user.age >= 18', ['user' => ['age' => 25]]);
5045
echo $result->getRawValue(); // Output: true
5146
```
5247

53-
### Full API Example
54-
55-
```php
56-
use Cel;
57-
58-
const EXPRESSION = <<<CEL
59-
account.balance >= transaction.withdrawal
60-
|| (account.overdraftProtection
61-
&& account.overdraftLimit >= transaction.withdrawal - account.balance)
62-
CEL;
63-
64-
// Create CEL instance
65-
$cel = new Cel\CommonExpressionLanguage();
66-
67-
try {
68-
// Parse the expression
69-
$expression = $cel->parseString(EXPRESSION);
70-
71-
// Evaluate with context
72-
$receipt = $cel->run($expression, [
73-
'account' => [
74-
'balance' => 500,
75-
'overdraftProtection' => true,
76-
'overdraftLimit' => 1000,
77-
],
78-
'transaction' => [
79-
'withdrawal' => 700,
80-
],
81-
]);
82-
83-
echo $receipt->result->getRawValue(); // Output: true
84-
85-
} catch (Cel\Parser\Exception\UnexpectedTokenException $e) {
86-
// Handle parsing errors
87-
} catch (Cel\Exception\IncompatibleValueTypeException $e) {
88-
// Handle type errors
89-
} catch (Cel\Exception\EvaluationException $e) {
90-
// Handle runtime errors
91-
}
92-
```
93-
94-
### Using Caching
95-
96-
```php
97-
use Cel;
98-
use Symfony\Component\Cache\Adapter\ApcuAdapter;
99-
use Symfony\Component\Cache\Psr16Cache;
100-
101-
// Create a cache instance
102-
$cache = new Psr16Cache(new ApcuAdapter());
103-
104-
// Create CEL with caching enabled
105-
$cel = Cel\CommonExpressionLanguage::cached($cache);
106-
107-
// Parsing and evaluation results will be cached automatically
108-
$expression = $cel->parseString('1 + 2');
109-
$receipt = $cel->run($expression);
110-
```
48+
See the [examples/](examples/) directory for more usage examples.
11149

11250
## Specification Compliance
11351

114-
CEL-PHP is a **production-ready, spec-compliant** implementation of the Common Expression Language specification. All core language features, operators, macros, and standard library functions are fully implemented and tested.
115-
116-
### ✅ Implemented Features
117-
118-
- **Core Language**
119-
- All primitive types (int, uint, double, bool, string, bytes, null)
120-
- Lists and Maps with full indexing support
121-
- Duration and Timestamp types
122-
- Field selection and indexing
123-
- All operators (arithmetic, comparison, logical, membership)
124-
- Conditional expressions (`? :`)
125-
- Message construction
126-
- String/bytes literals with complete escape sequence support
127-
128-
- **Macros**
129-
- `has(e.f)` - Field presence checking
130-
- `e.all(x, p)` - Universal quantification
131-
- `e.exists(x, p)` - Existential quantification
132-
- `e.exists_one(x, p)` - Unique existence
133-
- `e.map(x, t)` - Transformation
134-
- `e.filter(x, p)` - Filtering
135-
136-
- **Standard Library**
137-
- Core functions (type conversions, size, type checking)
138-
- String functions (contains, split, trim, case conversion, etc.)
139-
- List functions (chunk, flatten, reverse, sort, etc.)
140-
- Math functions (min, max, sum, mean, median, etc.)
141-
- DateTime functions (timestamp, duration, accessors)
142-
- Decimal support for arbitrary precision (optional extension)
143-
144-
- **Runtime & Tooling**
145-
- Tree-walking interpreter with full error tracking
146-
- Expression optimization (constant folding, short-circuit evaluation, etc.)
147-
- Extension system for custom functions and operators
148-
- Value resolvers for custom PHP types
149-
- Parse and evaluation result caching (PSR-16 compatible)
150-
- Comprehensive exception handling with source span information
151-
152-
### 🎯 Production Ready for 1.0.0
153-
154-
This implementation is **ready for production use** and meets all requirements for a 1.0.0 release. The following are potential future enhancements that could improve performance or developer experience, but are **not required** for the core functionality:
155-
156-
- **Compile-time Type Checking**: Static analysis of expressions before runtime (nice-to-have for catching errors earlier)
157-
- **Stack-based Interpreter**: Alternative execution engine for improved performance (current tree-walking interpreter is sufficient for most use cases)
158-
- **Protocol Buffer Integration**: Native protobuf support (manual message construction works well)
159-
- **Conformance Test Suite**: Official CEL conformance tests (current test suite of 1,080+ tests provides comprehensive coverage)
160-
161-
**Note**: Performance benchmarks show that complex expressions evaluate in ~0.001 seconds in production environments, which is acceptable for the vast majority of use cases.
52+
CEL-PHP is a **production-ready, fully spec-compliant** implementation of the [Common Expression Language specification](https://github.com/google/cel-spec). All core language features, operators, macros, and standard library functions are implemented and tested.
16253

16354
## License
16455

0 commit comments

Comments
 (0)