Skip to content

Commit 22ab730

Browse files
committed
readme: added jumbo
1 parent 690b00d commit 22ab730

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

readme.md

+29-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
Nette PHP Generator [![Latest Stable Version](https://poser.pugx.org/nette/php-generator/v/stable)](https://github.com/nette/php-generator/releases) [![Downloads this Month](https://img.shields.io/packagist/dm/nette/php-generator.svg)](https://packagist.org/packages/nette/php-generator)
2-
===================
1+
[![Nette PHP Generator](https://github.com/nette/php-generator/assets/194960/8a2c83bd-daea-475f-994c-9c951de88501)](https://doc.nette.org/en/php-generator)
2+
3+
[![Latest Stable Version](https://poser.pugx.org/nette/php-generator/v/stable)](https://github.com/nette/php-generator/releases) [![Downloads this Month](https://img.shields.io/packagist/dm/nette/php-generator.svg)](https://packagist.org/packages/nette/php-generator)
34

45
Are you looking for a tool to generate PHP code for [classes](#classes), [functions](#global-functions), or complete [PHP files](#php-files)?
56

7+
<h3>
8+
69
✅ Supports all the latest PHP features like [enums](#enums), [attributes](#attributes), etc.<br>
710
✅ Allows you to easily modify [existing classes](#generating-from-existing-ones)<br>
811
✅ Output compliant with [PSR-12 / PER coding style](#printer-and-psr-compliance)<br>
912
✅ Highly mature, stable, and widely used library
1013

14+
</h3>
15+
16+
 <!---->
1117

1218
Installation
1319
------------
@@ -18,8 +24,9 @@ Download and install the library using the [Composer](https://doc.nette.org/en/b
1824
composer require nette/php-generator
1925
```
2026

21-
For PHP compatibility, see the [table](#compatibility-table). Documentation even for older versions can be found on the [library's website](https://doc.nette.org/php-generator).
27+
PhpGenerator 4.1 is compatible with PHP 8.0 to 8.3. Documentation can be found on the [library's website](https://doc.nette.org/php-generator).
2228

29+
 <!---->
2330

2431
[Support Me](https://github.com/sponsors/dg)
2532
--------------------------------------------
@@ -30,6 +37,7 @@ Do you like PHP Generator? Are you looking forward to the new features?
3037

3138
Thank you!
3239

40+
 <!---->
3341

3442
Classes
3543
-------
@@ -175,6 +183,7 @@ $methodRecount = $methodCount->cloneWithName('recount');
175183
$class->addMember($methodRecount);
176184
```
177185

186+
 <!---->
178187

179188
Interfaces or Traits
180189
--------------------
@@ -210,6 +219,7 @@ class Demo
210219
}
211220
```
212221

222+
 <!---->
213223

214224
Enums
215225
-----
@@ -247,6 +257,7 @@ $enum->addCase('Diamonds', '♦');
247257

248258
For each *case*, you can add a comment or [attributes](#attributes) using `addComment()` or `addAttribute()`.
249259

260+
 <!---->
250261

251262
Anonymous Classes
252263
-----------------
@@ -272,6 +283,7 @@ $obj = new class ($val) {
272283
};
273284
```
274285

286+
 <!---->
275287

276288
Global Functions
277289
----------------
@@ -298,6 +310,7 @@ function foo($a, $b)
298310
}
299311
```
300312

313+
 <!---->
301314

302315
Anonymous Functions
303316
-------------------
@@ -325,6 +338,7 @@ function ($a, $b) use (&$c) {
325338
}
326339
```
327340

341+
 <!---->
328342

329343
Short Arrow Functions
330344
---------------------
@@ -346,6 +360,7 @@ The result is:
346360
fn($a, $b) => $a + $b
347361
```
348362

363+
 <!---->
349364

350365
Method and Function Signatures
351366
------------------------------
@@ -386,6 +401,7 @@ function count(...$items)
386401
}
387402
```
388403

404+
 <!---->
389405

390406
Method and Function Bodies
391407
--------------------------
@@ -476,6 +492,7 @@ function foo($a)
476492
}
477493
```
478494

495+
 <!---->
479496

480497
Printer and PSR Compliance
481498
--------------------------
@@ -531,6 +548,7 @@ The standard `Printer` formats the code as we do throughout Nette. Since Nette w
531548
The major difference is the use of tabs instead of spaces. We know that by using tabs in our projects, we allow for width customization, which is [essential for people with visual impairments](https://doc.nette.org/en/contributing/coding-standard#toc-tabs-instead-of-spaces).
532549
An example of a minor difference is placing the curly brace on a separate line for functions and methods, always. The PSR recommendation seems illogical to us and [leads to reduced code clarity](https://doc.nette.org/en/contributing/coding-standard#toc-wrapping-and-braces).
533550

551+
 <!---->
534552

535553
Types
536554
-----
@@ -549,6 +567,7 @@ $member->setType(null); // removes the type
549567

550568
The same applies to the `setReturnType()` method.
551569

570+
 <!---->
552571

553572
Literals
554573
--------
@@ -595,6 +614,7 @@ Literal::new(Demo::class, [$a, 'foo' => $b]);
595614
// generates for example: new Demo(10, foo: 20)
596615
```
597616

617+
 <!---->
598618

599619
Attributes
600620
----------
@@ -641,6 +661,7 @@ class Demo
641661
}
642662
```
643663

664+
 <!---->
644665

645666
Namespace
646667
---------
@@ -687,6 +708,7 @@ echo $namespace->resolveName('Bar'); // 'Foo\Bar'
687708
echo $namespace->resolveName('range', $namespace::NameFunction); // 'iter\range'
688709
```
689710

711+
 <!---->
690712

691713
Class Names Resolving
692714
---------------------
@@ -741,6 +763,7 @@ $printer->setTypeResolving(false);
741763
echo $printer->printNamespace($namespace);
742764
```
743765

766+
 <!---->
744767

745768
PHP Files
746769
---------
@@ -790,6 +813,7 @@ function foo()
790813

791814
**Please note:** No additional code can be added to the files outside of functions and classes.
792815

816+
 <!---->
793817

794818
Generating from Existing Ones
795819
-----------------------------
@@ -818,6 +842,7 @@ $class = Nette\PhpGenerator\ClassType::from(Foo::class, withBodies: true);
818842
$function = Nette\PhpGenerator\GlobalFunction::from('foo', withBody: true);
819843
```
820844

845+
 <!---->
821846

822847
Loading from PHP Files
823848
----------------------
@@ -849,6 +874,7 @@ It requires `nikic/php-parser` to be installed.
849874

850875
*(If you need to manipulate global code in files or individual statements in method bodies, it's better to use the `nikic/php-parser` library directly.)*
851876
877+
 <!---->
852878
853879
Variable Dumping
854880
----------------
@@ -862,15 +888,3 @@ $var = ['a', 'b', 123];
862888
863889
echo $dumper->dump($var); // outputs ['a', 'b', 123]
864890
```
865-
866-
867-
Compatibility Table
868-
-------------------
869-
870-
- PhpGenerator 4.1 is compatible with PHP 8.0 to 8.3
871-
- PhpGenerator 4.0 is compatible with PHP 8.0 to 8.3
872-
- PhpGenerator 3.6 is compatible with PHP 7.2 to 8.2
873-
- PhpGenerator 3.2 – 3.5 is compatible with PHP 7.1 to 8.0
874-
- PhpGenerator 3.1 is compatible with PHP 7.1 to 7.3
875-
- PhpGenerator 3.0 is compatible with PHP 7.0 to 7.3
876-
- PhpGenerator 2.6 is compatible with PHP 5.6 to 7.3

0 commit comments

Comments
 (0)