nette / php-generator

🐘 Generates neat PHP code for you. Supports new PHP 8.3 features.

Home Page:https://doc.nette.org/php-generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jojo1981 opened this issue · comments

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');

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

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?

I'll release a new version soon.

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