Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

ClassGenerator::fromReflection() breaks extends and implements #64

Closed
pburggraf opened this issue May 12, 2016 · 1 comment · Fixed by #69
Closed

ClassGenerator::fromReflection() breaks extends and implements #64

pburggraf opened this issue May 12, 2016 · 1 comment · Fixed by #69

Comments

@pburggraf
Copy link

pburggraf commented May 12, 2016

It is not possible to load a class that that extends or implements other classes without breaking the fully qualified names of the classes.

For example, if you load a reflection of this class

namespace Sample\ReflectionIssue;

class SampleClass
    extends \Sample\ReflectionIssue\ExtendableClass
    implements \Sample\ReflectionIssue\InterfaceClass
{ ... }

via $foo = ClassGenerator::fromReflection(ClassReflection(new \Sample\ReflectionIssue\SampleClass())); it will generate the following (invalid) output:

namespace Sample\ReflectionIssue;

class SampleClass
    extends Sample\ReflectionIssue\ExtendableClass
    implements Sample\ReflectionIssue\InterfaceClass
{ ... }

It's missing the leading backslash in front of the fully qualified class name.

@veewee
Copy link
Contributor

veewee commented Jun 25, 2016

I've bumped into the same issue on PHP 7.0.1 (cli).
On top of this I noticed while using the FileGenerator::fromReflectedFileName() method, that it also changes Interface names that are included with a use statement into the FQN.

For example:

Source

<?php

namespace Testing;

use Phpro\SoapClient\Type\ResultInterface;

class ArrayOfForecast implements ResultInterface
{
// OLD BODY
}

Destination:

<?php

namespace Testing;

use Phpro\SoapClient\Type\ResultInterface;

class ArrayOfForecast implements Phpro\SoapClient\Type\ResultInterface
{
// NEW BODY
}

As you can see the trailing slash is missing and it should rather use the short name of the interface like in the source file.

In the ClassGenerator, you do have access to the use statements as far as I can tell from the code. Is this something that is possible?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants