PHPackages                             roave/you-are-using-it-wrong - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. roave/you-are-using-it-wrong

AbandonedArchivedComposer-plugin[Utility &amp; Helpers](/categories/utility)

roave/you-are-using-it-wrong
============================

Composer plugin enforcing strict type checks in downstream package dependants

1.15.0(2y ago)24062.9k↓100%10[1 issues](https://github.com/Roave/you-are-using-it-wrong/issues)[5 PRs](https://github.com/Roave/you-are-using-it-wrong/pulls)1MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0CI passing

Since May 20Pushed 4mo ago8 watchersCompare

[ Source](https://github.com/Roave/you-are-using-it-wrong)[ Packagist](https://packagist.org/packages/roave/you-are-using-it-wrong)[ RSS](/packages/roave-you-are-using-it-wrong/feed)WikiDiscussions 1.16.x Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (35)Used By (1)

roave/you-are-using-it-wrong
============================

[](#roaveyou-are-using-it-wrong)

Archived: no longer necessary
-----------------------------

[](#archived-no-longer-necessary)

This project has been initially introduced to educate the PHP community about type checkers, their importance, and also to bother those that don't rely on them.

This project won't be updated to support `vimeo/psalm:^6`, since it is both technically challenging, and no longer necessary, as type-checkers are now unequivocally part of the minimum toolkit of every professional PHP developer.

Since the [first release of this package](https://github.com/Roave/you-are-using-it-wrong/releases/tag/1.0.0)in 2019, the community has grown, and we are proud of the work we've done to advocate for type-checkers.

We've been noisy, annoying, cheeky about it: it has actually helped a lot!

To everyone that now pushes for better coding practices through [`vimeo/psalm`](https://github.com/vimeo/psalm) and [`phpstan/phpstan`](https://github.com/phpstan/phpstan-src/): thank you ♥️.

Overview
--------

[](#overview)

[![Mutation testing badge](https://camo.githubusercontent.com/191db3711fcbe2d738ca28641191988ef844edeee8c5b91e1ae898b5de380498/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246726f617665253246796f752d6172652d7573696e672d69742d77726f6e67)](https://dashboard.stryker-mutator.io/reports/github.com/roave/you-are-using-it-wrong/master)[![Type Coverage](https://camo.githubusercontent.com/95130dbf47700a07484189f16b671e369d1c7bcc1118f7362c0dfe7c7d31a7e2/68747470733a2f2f73686570686572642e6465762f6769746875622f726f6176652f796f752d6172652d7573696e672d69742d77726f6e672f636f7665726167652e737667)](https://shepherd.dev/github/roave/you-are-using-it-wrong)[![Packagist](https://camo.githubusercontent.com/e0789b5160b6091d52f19e78e940cbcdd8a1e6c46113b1ea45816bba742f28df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6176652f796f752d6172652d7573696e672d69742d77726f6e672e737667)](https://packagist.org/packages/roave/you-are-using-it-wrong)

This package enforces type checks during composer installation in downstream consumers of your package. This only applies to usages of classes, properties, methods and functions declared within packages that directly depend on *roave/you-are-using-it-wrong*.

Issues that the static analyser finds that do not relate to these namespaces will not be reported.

`roave/you-are-using-it-wrong` comes with a zero-configuration out-of-the-box setup.

By default, it hooks into `composer install` and `composer update`, preventing a successful command execution if there are type errors in usages of protected namespaces.

The usage of this plugin is highly endorsed for authors of new PHP libraries who appreciate the advantages of static types.

This project is built with the hope that libraries with larger user-bases will raise awareness of type safety (or current lack thereof) in the PHP ecosystem.

As annoying as it might sound, it is not uncommon for library maintainers to respond to support questions caused by lack of type checks in downstream projects. In addition to that, relying more on static types over runtime checks, it is possible to reduce code size and maintenance burden by strengthening the API boundaries of a library.

### Installation

[](#installation)

This package is designed to be installed as a dependency of PHP **libraries**.

In your library, add it to your `composer.json`:

```
composer require roave/you-are-using-it-wrong
```

No further changes are needed for this tool to start operating as per its design, if your declared types are already reflecting your library requirements.

Please also note that this should **not** be used in `"require-dev"`, but specifically in `"require"` in order for the type checks to be applied to downstream consumers of your code.

### Examples

[](#examples)

You can experiment with the following example by running `cd examples && ./run-example.sh`.

Given you are the author of `my/awesome-library`, which has following `composer.json`:

```
{
    "name": "my/awesome-library",
    "type": "library",
    "autoload": {
        "psr-4": {
            "My\\AwesomeLibrary\\": "src"
        }
    },
    "require": {
        "roave/you-are-using-it-wrong": "^1.0.0"
    }
}
```

Given following `my/awesome-library/src/MyHelloWorld.php`:

```
