Skip to content

Commit 7a71f2f

Browse files
committed
readme: added jumbo
1 parent 690b00d commit 7a71f2f

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

readme.md

+31-15
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
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)
4+
5+
 <!---->
36

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

9+
<h3>
10+
611
✅ Supports all the latest PHP features like [enums](#enums), [attributes](#attributes), etc.<br>
712
✅ Allows you to easily modify [existing classes](#generating-from-existing-ones)<br>
813
✅ Output compliant with [PSR-12 / PER coding style](#printer-and-psr-compliance)<br>
914
✅ Highly mature, stable, and widely used library
1015

16+
</h3>
17+
18+
 <!---->
1119

1220
Installation
1321
------------
@@ -18,8 +26,9 @@ Download and install the library using the [Composer](https://doc.nette.org/en/b
1826
composer require nette/php-generator
1927
```
2028

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).
29+
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).
2230

31+
 <!---->
2332

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

3140
Thank you!
3241

42+
 <!---->
3343

3444
Classes
3545
-------
@@ -175,6 +185,7 @@ $methodRecount = $methodCount->cloneWithName('recount');
175185
$class->addMember($methodRecount);
176186
```
177187

188+
 <!---->
178189

179190
Interfaces or Traits
180191
--------------------
@@ -210,6 +221,7 @@ class Demo
210221
}
211222
```
212223

224+
 <!---->
213225

214226
Enums
215227
-----
@@ -247,6 +259,7 @@ $enum->addCase('Diamonds', '♦');
247259

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

262+
 <!---->
250263

251264
Anonymous Classes
252265
-----------------
@@ -272,6 +285,7 @@ $obj = new class ($val) {
272285
};
273286
```
274287

288+
 <!---->
275289

276290
Global Functions
277291
----------------
@@ -298,6 +312,7 @@ function foo($a, $b)
298312
}
299313
```
300314

315+
 <!---->
301316

302317
Anonymous Functions
303318
-------------------
@@ -325,6 +340,7 @@ function ($a, $b) use (&$c) {
325340
}
326341
```
327342

343+
 <!---->
328344

329345
Short Arrow Functions
330346
---------------------
@@ -346,6 +362,7 @@ The result is:
346362
fn($a, $b) => $a + $b
347363
```
348364

365+
 <!---->
349366

350367
Method and Function Signatures
351368
------------------------------
@@ -386,6 +403,7 @@ function count(...$items)
386403
}
387404
```
388405

406+
 <!---->
389407

390408
Method and Function Bodies
391409
--------------------------
@@ -476,6 +494,7 @@ function foo($a)
476494
}
477495
```
478496

497+
 <!---->
479498

480499
Printer and PSR Compliance
481500
--------------------------
@@ -531,6 +550,7 @@ The standard `Printer` formats the code as we do throughout Nette. Since Nette w
531550
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).
532551
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).
533552

553+
 <!---->
534554

535555
Types
536556
-----
@@ -549,6 +569,7 @@ $member->setType(null); // removes the type
549569

550570
The same applies to the `setReturnType()` method.
551571

572+
 <!---->
552573

553574
Literals
554575
--------
@@ -595,6 +616,7 @@ Literal::new(Demo::class, [$a, 'foo' => $b]);
595616
// generates for example: new Demo(10, foo: 20)
596617
```
597618

619+
 <!---->
598620

599621
Attributes
600622
----------
@@ -641,6 +663,7 @@ class Demo
641663
}
642664
```
643665

666+
 <!---->
644667

645668
Namespace
646669
---------
@@ -687,6 +710,7 @@ echo $namespace->resolveName('Bar'); // 'Foo\Bar'
687710
echo $namespace->resolveName('range', $namespace::NameFunction); // 'iter\range'
688711
```
689712

713+
 <!---->
690714

691715
Class Names Resolving
692716
---------------------
@@ -741,6 +765,7 @@ $printer->setTypeResolving(false);
741765
echo $printer->printNamespace($namespace);
742766
```
743767

768+
 <!---->
744769

745770
PHP Files
746771
---------
@@ -790,6 +815,7 @@ function foo()
790815

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

818+
 <!---->
793819

794820
Generating from Existing Ones
795821
-----------------------------
@@ -818,6 +844,7 @@ $class = Nette\PhpGenerator\ClassType::from(Foo::class, withBodies: true);
818844
$function = Nette\PhpGenerator\GlobalFunction::from('foo', withBody: true);
819845
```
820846

847+
 <!---->
821848

822849
Loading from PHP Files
823850
----------------------
@@ -849,6 +876,7 @@ It requires `nikic/php-parser` to be installed.
849876

850877
*(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.)*
851878
879+
 <!---->
852880
853881
Variable Dumping
854882
----------------
@@ -862,15 +890,3 @@ $var = ['a', 'b', 123];
862890
863891
echo $dumper->dump($var); // outputs ['a', 'b', 123]
864892
```
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)