xf-dev:class-use-function sometimes generates bad 'use function' statements

Xon

Well-known member
Affected version
2.2.8 Patch 1
It looks like xf-dev:class-use-function gets confused if there are comments before the namespace declaration, and when non-white listed functions are in an existing 'use function' statement.

Given this code;
PHP:
<?php
/**
 * @noinspection PhpMissingReturnTypeInspection
 */

namespace SV\Example;

use \XF\App;

I've seen it generate;
PHP:
<?php
const USE_FUNCTION_PLACEHOLDER = true;
/**
 * @noinspection PhpMissingReturnTypeInspection
 */

namespace SV\Example;

use \XF\App;
or
PHP:
<?php
use function count;
/**
 * @noinspection PhpMissingReturnTypeInspection
 */

namespace SV\Example;

use \XF\App;

If a non-whitelisted function is in the 'use function' list it strips it out, and can generate undesired code;
PHP:
<?php

namespace SV\Example;

use \XF\App;
use function is_callable;

Results in;
PHP:
<?php

namespace SV\Example;

use \XF\App;
const USE_FUNCTION_PLACEHOLDER = true;
 
Top Bottom