Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Format php code stored in string #23

Closed
rizrmd opened this issue Jul 3, 2016 · 7 comments
Closed

Format php code stored in string #23

rizrmd opened this issue Jul 3, 2016 · 7 comments

Comments

@rizrmd
Copy link

rizrmd commented Jul 3, 2016

How do i format php code stored in string?

@viscat
Copy link

viscat commented Sep 13, 2016

+1

@matt-usurp
Copy link
Contributor

I recently took a look at the tests and found that sorting a string would be this easy:

https://github.com/mmoreram/php-formatter/blob/master/tests/PHPFormatter/Sorter/UseSorterTest.php#L64

I am guessing its exactly the same for header formatting, so may I suggest you take a look at the tests yourself? Logically it needs to be tested somehow so thats where I would go first.

@mmoreram
Copy link
Owner

closing as @matt-usurp already answered it properly :)

@rizrmd
Copy link
Author

rizrmd commented Nov 27, 2016 via email

@onet4
Copy link

onet4 commented Feb 19, 2022

The above link is dead. Would be nice to see examples.

@rizrmd
Copy link
Author

rizrmd commented Feb 19, 2022

@onet4
Copy link

onet4 commented Feb 20, 2022

Thanks but it's hard to figure out how to use it.

$code = file_get_contents( __DIR__ .'/test-code.php' );
use Mmoreram\PHPFormatter\Fixer\UseSortFixer;
use Mmoreram\PHPFormatter\Fixer\StrictFixer;
$useSortFixer = new UseSortFixer();
print_r($useSortFixer->fix($code));
$strictFixer  = new StrictFixer(true);
print_r($strictFixer->fix($code));

But this doesn't seem to fix anything, especially indents.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants