<commit_before># phpfmt

The **phpfmt** project went _closed source_ on June 13, 2016 [Source](https://news.ycombinator.com/item?id=11896851).

As the code had BSD license, someone forked it and kept it working, without updating it. And the source got lost. This is the result of extracting a phar file. And many changes.

## What Is It ?

**phpfmt** formats PHP code by making it readable and following a specific coding guideline.

## Before it is considered stable
- Finish cleaning up _phpfmt.php_.
- Migrate to some console package.
- Check if compiling to phar is needed and automate it.
- _tests, tests, tests_.

## Requires

* PHP 7.0 or newer

## Usage

```
php src/phpfmt.php <args>
```

## Arguments

| Argument | Description |
| -------- | ----------- |
| --cache[=FILENAME] | cache file. Default: .php.tools.cache |
| --cakephp | Apply CakePHP coding style |
| --config=FILENAME | configuration file. Default: .phpfmt.ini |
| --constructor=type | analyse classes for attributes and generate constructor - camel, snake, golang |
| --dry-run | Runs the formatter without atually changing files; returns exit code 1 if changes would have been applied |
| --enable_auto_align | disable auto align of ST_EQUAL and T_DOUBLE_ARROW |
| --exclude=pass1,passN,... | disable specific passes |
| --help-pass | show specific information for one pass |
| --ignore=PATTERN-1,PATTERN-N,... | ignore file names whose names contain any PATTERN-N |
| --indent_with_space=SIZE | use spaces instead of tabs for indentation. Default 4 |
| --lint-before | lint files before pretty printing (PHP must be declared in %PATH%/$PATH) |
| --list | list possible transformations |
| --list-simple | list possible transformations - greppable |
| --no-backup | no backup file (original.php~) |
| --passes=pass1,passN,... | call specific compiler pass |
| --profile=NAME | use one of profiles present in configuration file |
| --psr | activate PSR1 and PSR2 styles |
| --psr1 | activate PSR1 style |
| --psr1-naming | activate PSR1 style - Section 3 and 4.3 - Class and method names case. |
| --psr2 | activate PSR2 style |
| --setters_and_getters=type | analyse classes for attributes and generate setters and getters - camel, snake, golang |
| --smart_linebreak_after_curly | convert multistatement blocks into multiline blocks |
| --visibility_order | fixes visibiliy order for method in classes - PSR-2 4.2 |
| --yoda | yoda-style comparisons |
| -h, --help | this help message |
| -o=- | output the formatted code to standard output |
| -o=file | output the formatted code to "file" |<commit_msg>added todo to the readme<commit_after># phpfmt

The **phpfmt** project went _closed source_ on June 13, 2016 [Source](https://news.ycombinator.com/item?id=11896851).

As the code had BSD license, someone forked it and kept it working, without updating it. And the source got lost. This is the result of extracting a phar file. And many changes.

## What Is It ?

**phpfmt** formats PHP code by making it readable and following a specific coding guideline.

## TODO:
- Move help from the actual fixer class to a FixerHelp class?
- Move the `--help-pass` option to a new `help` subcommand? `phpfmt help OrderAndRemoveUseClauses`

## Before it is considered stable
- Finish cleaning up _phpfmt.php_.
- Migrate to some console package.
- Check if compiling to phar is needed and automate it.
- _tests, tests, tests_.

## Usage

```
php phpfmt <opt> <args>
```

## Example

```bash
php phpfmt --psr2 --exclude=OrderAndRemoveUseClauses src/
```

## Arguments
As many file or folders as you want.

## Options

| Argument | Description |
| -------- | ----------- |
| --cakephp | Apply CakePHP coding style |
| --config=FILENAME | configuration file. Default: .phpfmt.ini |
| --constructor=type | analyse classes for attributes and generate constructor - camel, snake, golang |
| --dry-run | Runs the formatter without atually changing files; returns exit code 1 if changes would have been applied |
| --enable_auto_align | disable auto align of ST_EQUAL and T_DOUBLE_ARROW |
| --exclude=pass1,passN,... | disable specific passes |
| --help-pass | show specific information for one pass |
| --ignore=PATTERN-1,PATTERN-N,... | ignore file names whose names contain any PATTERN-N |
| --indent_with_space=SIZE | use spaces instead of tabs for indentation. Default 4 |
| --lint-before | lint files before pretty printing (PHP must be declared in %PATH%/$PATH) |
| --list | list possible transformations |
| --list-simple | list possible transformations - greppable |
| --no-backup | no backup file (original.php~) |
| --passes=pass1,passN,... | call specific compiler pass |
| --profile=NAME | use one of profiles present in configuration file |
| --psr | activate PSR1 and PSR2 styles |
| --psr1 | activate PSR1 style |
| --psr1-naming | activate PSR1 style - Section 3 and 4.3 - Class and method names case. |
| --psr2 | activate PSR2 style |
| --setters_and_getters=type | analyse classes for attributes and generate setters and getters - camel, snake, golang |
| --smart_linebreak_after_curly | convert multistatement blocks into multiline blocks |
| --visibility_order | fixes visibiliy order for method in classes - PSR-2 4.2 |
| --yoda | yoda-style comparisons |
| -h, --help | this help message |
| -o=- | output the formatted code to standard output |
| -o=file | output the formatted code to "file" |
{'fraction_non_alphanumeric': 0.11565637783562663, 'fraction_numerical': 0.012830048345109707, 'mean_word_length': 3.657142857142857, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2415680', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1552, 'n_words': 643}