facebookarchive / pfff

Tools for code analysis, visualizations, or style-preserving source transformation.
http://github.com/facebook/pfff/wiki/Main
Other
2.44k stars 205 forks source link

cant use namespace in spatch(in scan for, can use in substitute) #67

Open Techmind opened 10 years ago

Techmind commented 10 years ago

test case:

echo '<?php $x = a\b::instance();' > 1.error.php && spatch -e 's/core\A/core\A+1/' 1.error.php

output: Fatal error: exception Astphp.TodoNamespace()

used commit - pfff@6733eb3aac345cb601586d117085e2edbea96027

Techmind commented 10 years ago

also works:

echo '<?php $x = b::instance();' > 1.error.php && spatch -e 's/core\a;/core\a+1;/' 1.error.php

echo '<?php $x = b::instance();' > 1.error.php && spatch -e 's/core\A;/core\A+1;/' 1.error.php

echo '<?php $x = a\b::instance();' > 1.error.php && spatch -e 's/core\A;/core\A+1;/' 1.error.php

echo '<?php $x = A\b::instance();' > 1.error.php && spatch -e 's/A/core\A+1/' 1.error.php

Techmind commented 10 years ago

echo '<?php $x = A\b::instance()->doY();' > 1.error.php && spatch -e 's/A = SClass::get(B, C);/A = \name\Class::instance()->get(B, C);/' 1.error.php

echo '<?php $x = A\b::instance(); $x->doY();' > 1.error.php && spatch -e 's/A = SClass::get(B, C);/A = \name\Class::instance()->get(B, C);/' 1.error.php

antonbabenko commented 10 years ago

+1 . I've met this problem on Symfony2 project, which turn down benefits of scheck.

Does anybody know when this will be fixed ? Any plans on this ?

aryx commented 10 years ago

what is the bug in scheck related to namespace? Can you give me a file so I can try to reproduce the problem?

antonbabenko commented 10 years ago

@aryx Here we go (as minimum as I can make it to fail). File test.php:

<?php namespace A;

Run:

$ ./scheck /Users/Bob/Sites/symfony2_pfff/app/test.php

Output:

using /Users/Bob/Sites/symfony2_pfff for php_root
1 / 1PB with /Users/Bob/Sites/symfony2_pfff/app/test.php, exn = Ast_php.TodoNamespace(_)
Drarok commented 10 years ago

Came here after installing scheck to report this bug. PSR2 (or is it PSR1) warns when namespaces aren't used, but scheck fails if they are. Catch 22.

ghost commented 9 years ago

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.