Skip to content

Commit 860e7e6

Browse files
committed
php-generator: v4.2.2
1 parent 3e6aa03 commit 860e7e6

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

php-generator/cs/@home.texy

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ class MyPrinter extends Nette\PhpGenerator\Printer
512512
public bool $singleParameterOnOneLine = false;
513513
// omits namespaces that do not contain any class or function
514514
public bool $omitEmptyNamespaces = true;
515+
// umístí declare(strict_types) na stejný řádek jako <?php
516+
public bool $declareOnOpenTag = false;
515517
// oddělovač mezi pravou závorkou a návratovým typem funkcí a metod
516518
public string $returnTypeColon = ': ';
517519
}
@@ -727,7 +729,7 @@ $class = $namespace->addClass('Task');
727729
$interface = $namespace->addInterface('Countable');
728730
$trait = $namespace->addTrait('NameAware');
729731

730-
// nebo vložíme existující třídu do namespace
732+
// nebo vložíme existující třídu nebo funkci do namespace
731733
$class = new Nette\PhpGenerator\ClassType('Task');
732734
$namespace->add($class);
733735
```
@@ -840,14 +842,12 @@ echo $file;
840842
Výsledek:
841843

842844
```php
843-
<?php
845+
<?php declare(strict_types=1);
844846

845847
/**
846848
* This file is auto-generated.
847849
*/
848850

849-
declare(strict_types=1);
850-
851851
namespace Foo;
852852

853853
class A
@@ -859,6 +859,14 @@ function foo()
859859
}
860860
```
861861

862+
Do souboru lze vkládat i existující objekty tříd, funkcí a jmenných prostorů pomocí metody `add()`:
863+
864+
```php
865+
$file = new Nette\PhpGenerator\PhpFile;
866+
$class = new Nette\PhpGenerator\ClassType('Demo');
867+
$file->add($class);
868+
```
869+
862870
**Upozornění:** Do souborů není možné přidávat žádný další kód mimo funkce a třídy.
863871

864872

php-generator/en/@home.texy

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ class MyPrinter extends Nette\PhpGenerator\Printer
512512
public bool $singleParameterOnOneLine = false;
513513
// omits namespaces that do not contain any class or function
514514
public bool $omitEmptyNamespaces = true;
515+
// places declare(strict_types) on the same line as <?php
516+
public bool $declareOnOpenTag = false;
515517
// separator between the right parenthesis and the return type of functions and methods
516518
public string $returnTypeColon = ': ';
517519
}
@@ -727,7 +729,7 @@ $class = $namespace->addClass('Task');
727729
$interface = $namespace->addInterface('Countable');
728730
$trait = $namespace->addTrait('NameAware');
729731

730-
// or insert an existing class into the namespace
732+
// or insert an existing class or function into the namespace
731733
$class = new Nette\PhpGenerator\ClassType('Task');
732734
$namespace->add($class);
733735
```
@@ -840,14 +842,12 @@ echo $file;
840842
Result:
841843

842844
```php
843-
<?php
845+
<?php declare(strict_types=1);
844846

845847
/**
846848
* This file is auto-generated.
847849
*/
848850

849-
declare(strict_types=1);
850-
851851
namespace Foo;
852852

853853
class A
@@ -859,6 +859,14 @@ function foo()
859859
}
860860
```
861861

862+
You can also insert existing class, function, and namespace objects into the file using the `add()` method:
863+
864+
```php
865+
$file = new Nette\PhpGenerator\PhpFile;
866+
$class = new Nette\PhpGenerator\ClassType('Demo');
867+
$file->add($class);
868+
```
869+
862870
**Please note:** No additional code (like `echo 'hello'`) can be added to the files outside of functions, classes, or namespaces.
863871

864872

0 commit comments

Comments
 (0)