Skip to content

Conversation

stephanniewerth
Copy link
Contributor

If you have the same named classes in different namespaces, there will be duplicated symbol declarations in the generated php files.

namespace Foo;

# [...]
use Foo\Bar\SomeThing; # Duplicated symbol declaration

class SomeThing extends ClassStructure  # Duplicated symbol declaration
{
    /** @var SomeThing[]|array */
    public $elements;

    # [...]
}

This throws the following exception:

PHP Fatal error: Cannot declare class Foo\SomeThing because the name is already in use ...

With this pull request the fully qualified name of the class will be added to the PhpNamespace object of each added class to the PhpApp object. The output will be the following:

namespace Foo;

# [...]
use Foo\Bar\Something as SomeThing1;

class SomeThing extends ClassStructure
{
    /** @var SomeThing1[]|array */
    public $elements;

    # [...]
}

@codecov
Copy link

codecov bot commented Aug 31, 2020

Codecov Report

Merging #33 into master will increase coverage by 0.15%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #33      +/-   ##
============================================
+ Coverage     89.43%   89.58%   +0.15%     
  Complexity      517      517              
============================================
  Files            38       38              
  Lines          1363     1364       +1     
============================================
+ Hits           1219     1222       +3     
+ Misses          144      142       -2     
Impacted Files Coverage Δ Complexity Δ
src/App/PhpApp.php 72.22% <100.00%> (+0.79%) 11.00 <0.00> (ø)
src/PhpNamespaces.php 95.45% <0.00%> (+4.54%) 17.00% <0.00%> (ø%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e657b1...f635cab. Read the comment docs.

@vearutop vearutop merged commit f8ed5cc into swaggest:master Aug 31, 2020
@vearutop
Copy link
Member

Thank you, v0.2.27 tagged.

@reflexxion reflexxion deleted the feature/avoid-duplicate-symbol-declaration branch September 1, 2020 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants