Skip to content

Conversation

mvriel
Copy link
Member

@mvriel mvriel commented Jun 6, 2015

Contexts are necessary for factories to resolve QSEN into FQSENs based
on partial namespaces and namespace aliases. These provide DocBlocks
with the namespace name and namespace aliases.

The new ContextFactory will enable third parties who don't use
phpDocumentor's Reflection component to construct a Context based on
a class reflector or namespace name (and file contents).

Contexts are necessary for factories to resolve QSEN into FQSENs based
on partial namespaces and namespace aliases. These provide DocBlocks
with the namespace name and namespace aliases.

The new ContextFactory will enable third parties who don't use
phpDocumentor's Reflection component to construct a Context based on
a class reflector or namespace name (and file contents).
@mvriel
Copy link
Member Author

mvriel commented Jun 6, 2015

@jaapio can you review this item?

*/
public function __construct($namespace, array $namespaceAliases = [])
{
$this->namespace = ('global' !== $namespace && 'default' !== $namespace)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global and default should be class consts, But I don't get it yet why global and default are not allowed as namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backwards compatibility with parts of phpDocumentor that have been there for a long time; I cannot predict what will break if I remove them. Perhaps after we have cleaned up the rest of the app?

mvriel added a commit that referenced this pull request Jun 6, 2015
Make Context leaner and enable third parties to create them
@mvriel mvriel merged commit afd2520 into phpDocumentor:master Jun 6, 2015
@mvriel mvriel removed the in progress label Jun 6, 2015
@mnapoli
Copy link

mnapoli commented Jun 7, 2015

This looks good!

A little note: the code I used from Doctrine that parsed the class didn't read the whole file. I expect this to make a noticeable difference (reading whole file + token_get_all()). Here is the method that read only the part of the file that is above the class: https://github.com/PHP-DI/PhpDocReader/blob/master/src/PhpDocReader/PhpParser/UseStatementParser.php#L49-L67

I wonder though if their solution works with multi-namespace files.

@mvriel
Copy link
Member Author

mvriel commented Jun 7, 2015

@mnapoli I already found a bug in their solution that was not optimal :)

@mnapoli
Copy link

mnapoli commented Jun 7, 2015

ok great :)

@mvriel
Copy link
Member Author

mvriel commented Jun 7, 2015

@mnapoli also: i will be profiling this package before release; for phpDocumentor it is equally important that this is fast ;)

@mnapoli
Copy link

mnapoli commented Jun 7, 2015

Awesome!

@barryvdh
Copy link
Contributor

barryvdh commented Jun 7, 2015

Why is the Context class moved from src/phpDocumentor/Reflection/DocBlock/Context.php to src/DocBlock/Context.php. And the ContextFactory is also wrong (src/DocBlock/ContextFactory.php) This doesn't work with the PSR-0 autoloading you currently have configured.

Also, the tests are cleary failing:

PHP Fatal error: Class 'phpDocumentor\Reflection\DocBlock\ContextFactory' not found in ..

The same goes for my package using this library, class Context can't be found.. Could you please fix this issue?

* @param string $namespace The namespace where this DocBlock resides in.
* @param array $namespaceAliases List of namespace aliases => Fully Qualified Namespace.
*/
public function __construct($namespace, array $namespaceAliases = [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is $namespace required? This is a BC break, the previous default was ''

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the short array syntax isn't supported in 5.3. So if this was intentional, bump the composer.json requirements.

@mvriel
Copy link
Member Author

mvriel commented Jun 7, 2015

@barryvdh The changes to the composer.json are on my machine; I didn't want to submit a huge PR :)

Also: you might want to fix your package to a tag instead of dev-master; we are working towards version 2 of this component which will have significant BC breaks

@mvriel
Copy link
Member Author

mvriel commented Jun 7, 2015

In addition to the BC breaks might master have some instability in the next two weeks until the refactoring is complete

@barryvdh
Copy link
Contributor

barryvdh commented Jun 7, 2015

@mvriel I have 2.0.x as tag. Assuming this is SemVer, it should still work with ~2.0 even. But you have a branch-alias of dev-master to 2.0.x-dev.

In my specific case, I do require a tag, but people are sometimes using a global dev-stability, eg. for testing Laravel 5.1 a few weeks before stable (with dev Symfony versions etc.)

If you plan to break BC, could you please update your branch-alias to 3.0.x, or use a seperate branch for the 3.0 changes?

@mvriel
Copy link
Member Author

mvriel commented Jun 7, 2015

@barryvdh my apologies; I was mistaken with another component (I was deleting my comments because I just found out)

@mvriel
Copy link
Member Author

mvriel commented Jun 7, 2015

@barryvdh sorry about the mix up; I have changed the branch-alias of dev-master to 3.0 as you suggested. If all is well that should fix any issues that you experience?

@barryvdh
Copy link
Contributor

barryvdh commented Jun 7, 2015

Yeah I guess so :) Thanks!

mvriel added a commit that referenced this pull request Jun 23, 2015
Make Context leaner and enable third parties to create them
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.

4 participants