Giter Site home page Giter Site logo

mondrian's Introduction

Mondrian Build Status

Ok guyz, you have a master degree in Graph Theory, you follow Law of Demeter and you live on S.O.L.I.D principles ?

Let's have some Fun ! (^ฯ‰^)

What

It is a set of CLI tools to help you to analyse and refactor highly coupled classes. As you know Law of Demeter and S.O.L.I.D guidances, you need your classes loosely coupled. And for this, there is one only rule : ABSTRACTION

From Hell To Kiss

This app provides some helpers to add abstraction into concrete classes with minimum pain.

Getting started

Download the PHAR : mondrian.phar

Try to run a simple command with a few files (or a small part of a project)

$ mondrian.phar digraph /home/dev/project

This command produces a DOT file for GraphViz. Other formats are available :

  • html : interactive graph with the d3.js awesome library
  • svg : open standard for vector graphics (requires GraphViz)
  • json : format for d3.js for example

Example with html format

$ php mondrian.php d --ignore=tests --ignore=vendor --format=html ./MyPhpProject/

html-report

Note: The generated html file does not require any dependencies nor a connection.

Ecosystem

Running unit tests with PHPUnit

$ phpunit.phar

Building the documentation with phpDocumentor

$ phpDocumentor.phar

Building mondrian.phar from the sources with box2

$ box.phar b

Examples

Default digraph on trismegiste/dokudoki

digraph1

Which components are bottleneck ?

digraph2

Reduced graph to LSP violations on trismegiste/prolog

digraph3

How

Read the concept here

Read the online documentation here

And the API here (not up to date)

Extensible

You can easily add plugins to this tool to make your own algorithm, coloring scheme or new generator. I try to make the API mostly decoupled, re-usable and with great SRP and OCP concerns. Look into the "About" plugin to understand a basic stub of plugin.

Third party

Packages used in this project :

Special thanks

  • William Gibson
  • JS Bach
  • Dream Theater

mondrian's People

Contributors

sebastianbergmann avatar tothimre avatar trismegiste avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mondrian's Issues

Digraph::addEdge() must be an instance of Vertex, null given

Hi there,

I'm getting the following error:
PHP Catchable fatal error: Argument 2 passed to Trismegiste\Mondrian\Graph\Digraph::addEdge() must be an instance of Trismegiste\Mondrian\Graph\Vertex, null given, called in phar:///usr/local/bin/mondrian/src/Visitor/EdgeCollector.php on line 118 and defined in phar:///usr/local/bin/mondrian/src/Graph/Digraph.php on line 59

Any idea why this might happen?

PHP Parse error: parse error in phar:.../mondrian.phar/src/Transform/ReflectionContext.php on line 32

Downloaded the .phar thinking/hoping this would be real easy to use.

[39] 13:04:40 2585 .../htdocs/php.tools$ ./mondrian.phar digraph ../afp1
#!/usr/bin/env php
Parsing 3 files...
PHP Parse error:  parse error in phar:///Applications/MAMP/htdocs/php.tools/mondrian.phar/src/Transform/ReflectionContext.php on line 32

just a simple check to make sure the phar isn't corrupted or something:

[40] 13:04:51 2586 .../htdocs/php.tools$ ./mondrian.phar digraph wtf?
#!/usr/bin/env php

  [InvalidArgumentException]            
  The "wtf?" directory does not exist.  

digraph [-i|--ignore="..."] [-f|--format="..."] dir [report]

Is this a Mondrian problem or something in my environment?
The message could be more informative.

Colors on edges

From @tothimre :

Each source of the arrows shall have a color code and all arrows coming form this
source will be this color (this shall be a commandline switch I suppose).

Composer package PHP-Parser is not stable

When installing via composer, it currently complains that the package nikic/PHP-Parser is not stable. This forces you to set your minimum-stabilty to dev which is not good.

This was attempted to be fixed here, but it now looks to be outdated: #35.

It's likely that we'll want to upgrade this package to version 1.1, as suggested by @Trismegiste in the PR.

Refactoring

  • Better design for refactor pass interface : too many if in Contractor
  • Where to save the file ? in the "afterTraverse" visitor or in "leaveNode" for PhpFile node

Abstraction for the persistence to the filesystem ?

The 3 visitors for refactoring need to be fully unit and functional tested

Generating default confg

writing the .mondrian.yml is a boring task, make a default generation with a new command.

Is that parsing or refactoring ? Depending on the issue #16 this command will be inherit from AbstractParse or AbstractRefactor...

Compatibility with PHP 8.x

The latest phar file does not seem compatible with PHP8.

Is there a new release coming soon?

RectorPHP may be considered to help with refactoring up to PHP 8.0.

Doc

  • doc for Liskov command
  • doc for Contractor

Are "@var" for variables supported

In my project a class factory is used to create objects. This means, that in the code I have Factory::create('someName') and Factory::create('someOtherName'), which indirectly maps to actual object class, that will be created.

To make IDE auto-complete work I do this:

/** @var ActualClassName $object */
$object = Factory::create('someName');

Are such @var annotations being processed?

warnings and notices

I'm using php 5.5 and getting:
Warning: Invalid argument supplied for foreach() in /Mondrian/Transform/ReflectionContext.php on line 65

Warning: Invalid argument supplied for foreach() in /Mondrian/Transform/ReflectionContext.php on line 65

Catchable fatal error: Argument 1 passed to Trismegiste\Mondrian\Graph\Digraph::addEdge() must be an instance of Trismegiste\Mondrian\Graph\Vertex, null given, called in /Mondrian/Visitor/EdgeCollector.php on line 107 and defined in /Mondrian/Graph/Digraph.php on line 59

Missing src/Transform/Format/template.html

I am using the PHP version 7 fork, and downloaded the bin/box/mondrian.phar. On executing
mondrian.phar d --ignore=tests --ignore=vendor --format=html project-dir, I get the following warning, and the generated html is blank.

PHP Warning: file_get_contents(phar:///mondrian.phar/src/Transform/Format/template.html): failed to open stream: phar error: "src/Transform/Format/template.html" is not a file in phar "mondrian.phar" in phar:///mondrian.phar/src/Transform/Format/Html.php on line 20

Cannot use 'PhpParser\Node\Scalar\String' as class name as it is reserved in phar://...

Hello!

It appears you have an older version of nikic/php-parser as a dependency. Versions earlier than 1.3 cause the following error under PHP 7:

PHP Fatal error: Cannot use 'PhpParser\Node\Scalar\String' as class name as it is reserved in phar:///usr/local/bin/mondrian.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php on line 86

More info: nikic/PHP-Parser#182 (comment)

Would it be possible to update to at least v1.3 of nikic/php-parser?

Thanks!

Ian

Bug in FactoryGenerator

The PhpFile is not Modified after modified() when in the method afterTraversing

It does not make sense ?!? cloning in Traverser ? Otherwise, why other refactoring passes do work ?

Digraph building fails when Trait are involved

Trait are not parsed but method within trait are parsed.

Therefore they are added by ReflectionContext with an empty FQCN and generation fails at the digraph building (the second pass)

Need to process trait, at least, skip them in the first time

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.