Nette Documentation Preview

syntax
Nette Code Checker
******************

.[perex]
The tool called [Code Checker |https://github.com/nette/code-checker] checks and optionally repairs some of the formal errors in your source code.


Installation
============

Code Checker should be installed as a project, not added as a dependency.

```shell
composer create-project nette/code-checker
```

Or install it globally via:

```shell
composer global require nette/code-checker
```

and make sure your global vendor binaries directory is in [your `$PATH` environment variable|https://getcomposer.org/doc/03-cli.md#global].


Usage
=====

```
Usage: php code-checker [options]

Options:
	-d <path>             Folder or file to scan (default: current directory)
	-i | --ignore <mask>  Files to ignore
	-f | --fix            Fixes files
	-l | --eol            Convert newline characters
	--no-progress         Do not show progress dots
	--strict-types        Checks whether PHP 7.0 directive strict_types is enabled
```

Without parameters, it checks the current working directory in read-only mode; with the `-f` parameter, it fixes files.

Before you get familiar with the tool, be sure to back up your files first.

You can create a batch file, e.g., `code.bat`, for easier execution of Code Checker under Windows:

```shell
php path_to\Nette_tools\Code-Checker\code-checker %*
```


What Does Code Checker Do?
==========================

- removes [BOM |nette:glossary#BOM]
- checks the validity of [Latte |latte:] templates
- checks the validity of `.neon`, `.php`, and `.json` files
- checks for [control characters |nette:glossary#Control Characters]
- checks whether the file is encoded in UTF-8
- checks for misspelled `/* @annotations */` (missing second asterisk)
- removes PHP ending tags `?>` in PHP files
- removes trailing whitespace and unnecessary blank lines from the end of a file
- normalizes line endings to the system default (with the `-l` parameter)

{{leftbar: www:@menu-common}}

Nette Code Checker

The tool called Code Checker checks and optionally repairs some of the formal errors in your source code.

Installation

Code Checker should be installed as a project, not added as a dependency.

composer create-project nette/code-checker

Or install it globally via:

composer global require nette/code-checker

and make sure your global vendor binaries directory is in your $PATH environment variable.

Usage

Usage: php code-checker [options]

Options:
	-d <path>             Folder or file to scan (default: current directory)
	-i | --ignore <mask>  Files to ignore
	-f | --fix            Fixes files
	-l | --eol            Convert newline characters
	--no-progress         Do not show progress dots
	--strict-types        Checks whether PHP 7.0 directive strict_types is enabled

Without parameters, it checks the current working directory in read-only mode; with the -f parameter, it fixes files.

Before you get familiar with the tool, be sure to back up your files first.

You can create a batch file, e.g., code.bat, for easier execution of Code Checker under Windows:

php path_to\Nette_tools\Code-Checker\code-checker %*

What Does Code Checker Do?

  • removes BOM
  • checks the validity of Latte templates
  • checks the validity of .neon, .php, and .json files
  • checks for control characters
  • checks whether the file is encoded in UTF-8
  • checks for misspelled /* @annotations */ (missing second asterisk)
  • removes PHP ending tags ?> in PHP files
  • removes trailing whitespace and unnecessary blank lines from the end of a file
  • normalizes line endings to the system default (with the -l parameter)