Giter Club home page Giter Club logo

Comments (3)

lstrojny avatar lstrojny commented on May 26, 2024 1

Hah, interesting indeed. I love the "if you delete it, will it compile" heuristic, since it’s super easy to grasp. That being said, the final case is not atypical in a ports-and-adapters kinda situation.
I guess this needs more long showers and long walks before I can say something more insightful here. But I will come back.

from deptrac.

patrickkusebauch avatar patrickkusebauch commented on May 26, 2024

This is absolutely a feature. Looks what happens when you "squash" B into the final shape the class will have at runtime:

class B {
    final public function getVO(): VO { return new VO($this->generate()); }
    protected function generate(): string { return "from B"; }
}

You absolutely depend on VO. You can look at it another way:

If I deleted VO, would B lint?

Obviously, it would not, it would complain about non-existent VO.

Deptrac should provide you with a relatively nice message about this being a dependency coming from A via inheritance as well. At least with the default console formatter.

from deptrac.

patrickkusebauch avatar patrickkusebauch commented on May 26, 2024

Thinking about it a bit more.

Is the argument there that since final public function getVO(): VO { return new VO($this->generate()); } is final it is always executed in the context of A and therefore not B should not be dependent on VO? And if the method was not final it would be?

That would be an interesting case.

If that would be the case what would happen if I had:

class C {
  public function foo(): void {
    $var = new B(); //This is clear dependency on B
    $vo = $var->getVO(); //Is this dependency on B or on A?
    var_dump($vo); //This could be a dependency on VO, but it is not yet implemented in deptrac
  }
}

It creates another conundrum. I am not opposed to this, just wondering what were your expectations. It is important that deptrac behaves the way people expect it do behave.

from deptrac.

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.