Giter Site home page Giter Site logo

khalyomede / php-typo Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 1.29 MB

A command line tool to validate files do not have English typo in variables, methods, functions, ...

Home Page: https://packagist.org/packages/khalyomede/php-typo

License: MIT License

PHP 96.99% Dockerfile 3.01%
command-line php spellcheck typo

php-typo's Introduction

php-typo/php-typo

A command line tool to validate files do not have English typo in variables, methods, functions, ...

Summary

About

I searched for a tool to correct english typos across a code base, but only ended up finding VSCode plugins. I know there is PHPStorm plugins as well (and probably similar tools on others code editors), but I need a single, unique way to correct my english typos so that other contributors to my code base will also have the same results, and do not need to install anything on their editor.

English words list based on dwyl/english-words.

Features

  • Validates your code do not have typos in
    • class names and their properties, methods and their parameters
    • interfaces names
    • enum names and their cases
    • variables names
    • function names and their parameters
    • constants and class constants
  • Shipped with a list of known english words for fast quick start
  • Dead simple way to ignore/whitelist additional words

Installation

On your root folder, on the terminal type this command:

./vendor/bin/php-typo init

This will create a file php-typo.json at the root of your folder with the following content:

{
  "include": [
    "src"
  ],
  "exclude": [],
  "whitelist": [
    "vendor/khalyomede/php-typo/src/words/english.json"
  ]
}

Examples

1. Run your first check

In this example, we will just run the command, which by default will search on the files you specified in your "php-typo.json" config file.

We will assume we have the following file content in "src/index.php":

require __DIR__ . "/../vendor/autoload.php";

$gretingMessage = "Hello, world";

echo $gretingMessage . PHP_EOL;

Run the command:

khalyomede@ubuntu:~/programming/php-typo$ ./vendor/bin/php-typo check

Getting config...
Config found (0.08 ms.). Getting file list...
File list found with 1 files to scan (0.26 ms.). Scanning...

public/index.php:3
  variable "gretingMessage" contains an unknown word "greting".

public/index.php:5
  variable "gretingMessage" contains an unknown word "greting".

Total typos  2
Total files  1
Time spent   125.94 ms.
Memory used  98.18 MB

2. Add more words/whitelist words

In this example, we will use an additional list of English words to extend the base list of words shipped with this package. This is equivalent to "ignoring" some words.

In the config file at "php-typo.json", add your custom JSON word list:

{
  "include": [
    "src"
  ],
  "exclude": [],
  "whitelist": [
    "vendor/khalyomede/php-typo/src/words/english.json",
    "custom.json"
  ]
}

The list of words should be an array of strings. Here is what you could have in your file "custom.json":

[
  "greting",
  "php"
]

On the next check, the words "greting" and "php" will be counted as correct words.

Tests

composer run test
composer run analyse
composer run lint
composer run updates
composer run scan
composer run check

Or

composer run all

php-typo's People

Contributors

khalyomede avatar

Watchers

 avatar  avatar

php-typo's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.