Giter Club home page Giter Club logo

typhp's Introduction

TYPHP

Build Status

typhp is a simple tool checks whether type hint for arguments or return type declared. Unlike static analysis tools, it doesn't point out possible errors and issues but suggests typehint everything possible.

For whom?

  • Who works projects using PHP 7.1 and higher.
  • Who doesn't want to point out missing type hint and return type declarations in code review process by using it as part of CI pipeline.
  • Who love strict typing and defensive programming.

Features

  • Respects phpdoc; there are some rare cases mixed or compound types are needed. If such cases documented in phpdoc, typhp doesn't complain. For example: @return array|bool, @param mixed $foo, etc.
  • Takes magic methods into account.
  • Analyses based on configuration. Include/exclude files and directories to be analysed. For optional config file, see the current project example
  • Does NOT modifies your code

Installation

There are several ways to install typhp. The recommended one is to use phar distribution. Thus you won't have possible dependency conflict.

Phar

Direct download from the latest Github release

wget https://github.com/seferov/typhp/releases/download/v0.2.0/typhp.phar -O typhp
chmod +x typhp

You can install phar distribution by Phive

phive install seferov/typhp --global

Composer

typhp can be installed by composer globally.

composer global require seferov/typhp

If you prefer, you can it add dev dependency to your project.

composer require require seferov/typhp --dev

Usage

typhp analyse path

If config file (.typhp.yml) is present in project root, it can be run just by vendor/bin/typhp

Example output

Example

Todo

  • Analyse closures

  • Check by PHP version. For example, don't suppress @param object for >= PHP 7.2

  • Better configuration

  • Check declare(strict_types=1) by config

  • Phar file

  • Auto deploy phar file to release assets & add self-update command

  • Github Actions

Issues

Since it is a beta release, there might be some issues. If you found one, please submit it here

typhp's People

Contributors

seferov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

typhp's Issues

Tool show result for Magic Methods

For example:

File: src/ExampleWithMagicMethods.php has 2 issues
+------+------------+----------------+
| Line | Name       | Issue          |
+------+------------+----------------+
| 30   | __destruct | untyped return |
| 35   | __clone    | untyped return |
+------+------------+----------------+

Saying interface vs. using a class

    private function analyseFunctionLike(Node\FunctionLike $functionLike): void
    {
        $name = $functionLike->name;

Hello!

Is it okay to typehint FunctionLike and expecting a class implementing that interface in $functionLike?

FunctionLike does not have a->name.

.

.

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.