Splitting Nette to parts – discussion to 1038 issue

Notice: This thread is very old.
Milo
Nette Core | 1175
+
0
-

Continuation of https://github.com/…/issues/1038 discussion.

Last edited by Milo (2013-04-15 19:54)

Milo
Nette Core | 1175
+
0
-

Okay, the catch is the case, you can try it yourself, for example:

class FooException extends TestException
{}
try {
    throw new \RuntimeException();
} catch (\FooException $e) {

}

It will be transformed to the extends dependency.

I don't undestand…

Milo
Nette Core | 1175
+
0
-

And one important thing… you must distinguish between class and file dependencies.

# Content of file.php

Foo::bar(); // file.php depends on Foo class

class Any {
	function __construct()
	{
		Foo::bar();  // Class Any depends on Foo class
	}
}

Class-extractor detects the file dependencies and parses them to tree, but do not consider them (now) during exporting. File dependencies are not used in Nette.

Last edited by Milo (2013-04-15 20:03)

hinikato
Member | 4
+
0
-

For example, let's say that we have the following code in the \Nette\Foo package:

namespace Nette\Foo;

class MyClass
{
    public function doSomething()
    {
        try {
            throw new \Nette\Bar\MyException;
        } catch (\Nette\Bar\MyException1 $e) {

        }
    }
}

and let's say that we have the \Nette\Bar package also:

namespace Nette\Bar;

class MyException1 extends \RuntimeException
{}

class MyException extends MyException1
{}

There is a dependency of the \Nette\Foo\MyClass from the \Nette\Bar\MyException and the \Nette\Bar\MyException1 class.

Last edited by hinikato (2013-04-15 20:15)

hinikato
Member | 4
+
0
-

Personally I would like to have some tool that works with all the mentioned cases. There is nikic/php-parser package that can help a lot.

Also it is helpful that you mentioned about class/file level dependencies. I think class level dependency can be expanded to file level dependency, no need to distinguish of them because if we have class level dependency we have file level dependency and we work with files.

Milo
Nette Core | 1175
+
0
-

To the catch topic… when you throw in MyClass MyException

MyClass depends on MyException
MyException depends on MyException1

so dependency chain is preserved. You cannot catch child exception of thrown one. If you are catching some exception of class which must be extracted too, you must throw it somewhere else in dependent classes code.

Personally I would like to have some tool that works with all the mentioned cases

Sure, I agree.

Also it is helpful that you mentioned about class/file level dependencies. I think class level dependency can be expanded to file level dependency, no need to distinguish of them because if we have class level dependency we have file level dependency and we work with files.

I'm trying to wrote class-extractor universally, not only for Nette libs. I saw in other frameworks things like:

# File MyClass.php
App::require('something');

class MyClass
{
}
# File OtherClass.php
App::require('something_else');

class OthersClass
{
}

Obviously App class file only dependencies.

Last edited by Milo (2013-04-15 20:57)

hinikato
Member | 4
+
0
-

Okay, I have implemented tracking of all cases of dependencies excluding the ‘require’ case, you can find the repo here: https://github.com/myak/splitter

What need to be implemented farther is grouping files (keys of array of dependencies) by directory and excluding of classes that belongs to directory that is passed as argument – we don't need to include files and directories of the current package, for example if package is nette/database we don't need to include all files under the Nette/Database/* directory.

If you have some propositions or code please contribute and we will discuss of a capability to include changes.

I would like use this tool to resolve of the issue #1038 (https://github.com/…/issues/1038) also.

Last edited by hinikato (2013-04-16 00:06)

Milo
Nette Core | 1175
+
0
-

Nice. I'll take a look sometimes.

hinikato
Member | 4
+
0
-

The repository was renamed to packager, a new URI is: https://github.com/…packager.git