Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

Fix code reflection - getBody/getContents method#5245

Closed
blanchonvincent wants to merge 15 commits into
zendframework:masterfrom
blanchonvincent:feature/zend-code-generator-functiongenerator
Closed

Fix code reflection - getBody/getContents method#5245
blanchonvincent wants to merge 15 commits into
zendframework:masterfrom
blanchonvincent:feature/zend-code-generator-functiongenerator

Conversation

@blanchonvincent
Copy link
Copy Markdown
Contributor

Zend\Code\Reflection getBody function is often broken with some code format

  • implement getBody in FunctionReflection
  • fix getBody in MethodReflection
  • fix getContents in FunctionReflection
  • fix getContents in MethodReflection

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove @Package

@blanchonvincent
Copy link
Copy Markdown
Contributor Author

@Ocramius can you confirm that on this function :

function1()
{
    return 'foo';
}

getBody is :

return 'foo';

getContent is :

function1()
{
    return 'foo';
}

?

@Ocramius
Copy link
Copy Markdown
Member

@blanchonvincent never used that API - are there no other tests for it?

@blanchonvincent
Copy link
Copy Markdown
Contributor Author

@Ocramius The prototype is

public function getContents($includeDocBlock = true)

So, if the contents is :

{
   return ....;
}

what is the contents with docblock ? I think there is a bug, and the contents must be :

function foo()
{
   return ....;
}

and with docblock :

/**
 * bla bla bla
 */
function foo()
{
   return ....;
}

@Ocramius
Copy link
Copy Markdown
Member

@blanchonvincent yep, I agree on that. I'd just first check what the consumers of that method are before applying any change.

@blanchonvincent
Copy link
Copy Markdown
Contributor Author

@Ocramius, Ok, let me know

@Ocramius
Copy link
Copy Markdown
Member

@blanchonvincent no, I was suggesting you to grep for its usage :)

@blanchonvincent
Copy link
Copy Markdown
Contributor Author

@Ocramius, Look never used, and $useDockBlock param doesn't work, and lot of time, the function return an empty result ... so I fix that.

@blanchonvincent
Copy link
Copy Markdown
Contributor Author

PR is finished -- better code coverage & lot of fixs

@mwillbanks
Copy link
Copy Markdown
Contributor

@Ocramius since you did original review; could you please review a last time?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Woah, this witchcraft needs a comment :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this handle also closures containing closures?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Ocramius I don't see any reason why it wouldn't -- the body regex is looking for any number of terminated statements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Ocramius, yep, look at the tests

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same remarks as above

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also: these regexes look constant. Can you move them to either a class constant or a private property?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

They're not -- there are subtle differences in what each is matching.

@Maks3w
Copy link
Copy Markdown
Member

Maks3w commented Oct 29, 2013

@blanchonvincent Please rebase the PR for fix merge conflicts

weierophinney added a commit that referenced this pull request Oct 30, 2013
…ator-functiongenerator

Fix code reflection - getBody/getContents method

Conflicts:
	library/Zend/Code/Reflection/FunctionReflection.php
	library/Zend/Code/Reflection/MethodReflection.php
	tests/ZendTest/Code/Reflection/FunctionReflectionTest.php
	tests/ZendTest/Code/Reflection/MethodReflectionTest.php
weierophinney added a commit that referenced this pull request Oct 30, 2013
- trailing whitespace, braces
- Added functions.php to the exclude list for php-cs-fixer, as the tests are
  testing specific formatting issues.
weierophinney added a commit that referenced this pull request Oct 30, 2013
@ghost ghost assigned weierophinney Oct 30, 2013
@weierophinney
Copy link
Copy Markdown
Member

Merged to develop for release with 2.3.0, as it represents new functionality. I took care of the merge conflicts.

stefanotorresi pushed a commit to stefanotorresi/zf2 that referenced this pull request Oct 31, 2013
@stefanotorresi stefanotorresi mentioned this pull request Oct 31, 2013
weierophinney added a commit that referenced this pull request Nov 1, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants