use not supported in classes
Bug report
| Question | Answer |
|---|---|
| PHP-Scoper version | 0.14.0 |
| PHP version | 7.4.14 |
| Platform with version | Manjaro Linux 20.2.1 |
| Github Repo | - |
PHP Scoper does not currently seem to support changing references for traits inside classes. Example:
<?php
namespace A\B;
class A {
use SomeTraitC;
}
None of the namespace or trait-related visitor classes seem to deal with TraitUse.
Revisiting this issue, what would be the desired output here? SomeTraitC is not imported via a use statement hence belongs to the current namespace so it should not be changed
Sorry, I dont follow your question/what your saying?
That traits looks to be handled at first glance and that I'm not sure what is expected there in the sample you provided
If I remember right it was that the trait was not copied to the new namespace and the references properly updated. I would have to test again to get details.
Hi I also have encountered this problem.
And I have a nice way to reproduce it:
composer require "ivopetkov/html5-dom-document-php:2.*"
composer require humbug/php-scoper
./vendor/bin/php-scoper init
mkdir src
./vendor/bin/php-scoper add-prefix
head build/vendor/ivopetkov/html5-dom-document-php/src/HTML5DOMDocument.php -n20
You will see the class like this:
<?php
/*
* HTML5 DOMDocument PHP library (extends DOMDocument)
* https://github.com/ivopetkov/html5-dom-document-php
* Copyright (c) Ivo Petkov
* Free to use under the MIT license.
*/
namespace _PhpScoper56249b31f25a\IvoPetkov;
/**
* Represents a live (can be manipulated) representation of a HTML5 document.
*/
class HTML5DOMDocument extends \DOMDocument
{
use \IvoPetkov\HTML5DOMDocument\Internal\QuerySelectors;
/**
* An option passed to loadHTML() and loadHTMLFile() to disable duplicate element IDs exception.
*/
const ALLOW_DUPLICATE_IDS = 67108864;
The namespace is nicely updated. But the trait included with use is not.