nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.
https://doc.nette.org/php-generator
Other
2.11k stars 138 forks source link

Add use statements to import global functions is not backwards compatible anymore #92

Closed jojo1981 closed 3 years ago

jojo1981 commented 3 years ago

Since Version: 3.6.2

The Nette\PhpGenerator\PhpNamespace::addUse method can only handle namespaces.

So the following code snippet is not working anymore while it was working in version <= 3.6.1:

<?php

use Nette\PhpGenerator\ClassType;
use Nette\PhpGenerator\PhpNamespace;

require 'vendor/autoload.php';

$class = new ClassType('MyClass', new PhpNamespace('MyNamespace\MySubNamespace'));
$class->getNamespace()->addUse('function strtoupper');
dg commented 3 years ago

It wasn't designed for this use, but I added addUseFunction() and addUseConstant()

jojo1981 commented 3 years ago

Hi thanks for your quick response.

I didn't know that it wasn't designed for the way I used this functionality. For now I have pinpointed the library on version: 3.6.1 in my project. When can I expect that the new functionality will be released? Can I expect a new patch release: 3.6.3 in the nearby future?

dg commented 3 years ago

I'll release a new version soon.

jojo1981 commented 3 years ago

Seen that it is fixed in v3.6.3-RC. Nice thanks again!