Giter Site home page Giter Site logo

Comments (6)

dg avatar dg commented on May 18, 2024

What about to preserve class names when no namespace is passed to class constructor?

from php-generator.

mrtnzlml avatar mrtnzlml commented on May 18, 2024

It would be satisfactory i guess. Namespace doesn't change anyway in this particular case. In other words it means return name immediately if there is no namespace (passed through constructor), right? If so, I'll prepare PR.

from php-generator.

dg avatar dg commented on May 18, 2024

I already have PR :)

from php-generator.

mrtnzlml avatar mrtnzlml commented on May 18, 2024

It's much more better than my naive implementation. Thank you.

from php-generator.

ignasbernotas avatar ignasbernotas commented on May 18, 2024

@mrtnzlml @dg due to this change I am unable to extend a class with another class on a separate namespace. the only workaround is to use the full namespace after the extends keyword (which sucks :/).

I'm on v2.6 since I need php 5.6 support.

Example:

namespace App\Http\Controllers\Users;

use App\Http\Controllers\Controller;

class UserController extends \Controller
{
}

from php-generator.

dg avatar dg commented on May 18, 2024

Why not?

$namespace = new PhpNamespace('Foo');
$class = $namespace->addClass('A');
$class->addExtend('B');
echo $namespace;

generates

namespace Foo;

class A extends \B
{
}

or

$namespace = new PhpNamespace('Foo');
$namespace->addUse('B');
$class = $namespace->addClass('A');
$class->addExtend('B');
echo $namespace;

generates

namespace Foo;        
                      
use B;                
                      
class A extends B     
{                     
}                     

from php-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.