A small set of traits that can be used to prevent misuse of your objects

1.1.0 2019-04-16 10:22 UTC

This package is auto-updated.

Last update: 2020-05-07 09:23:23 UTC


roave/dont is a small PHP package aimed at enforcing good practices when it comes to designing defensive code.

Build Status Scrutinizer Code Quality Code Coverage Packagist Packagist


composer require roave/dont


The package currently provides the following traits:

  • Dont\DontDeserialise
  • Dont\DontSerialise
  • Dont\DontClone
  • Dont\DontGet
  • Dont\DontSet
  • Dont\DontCall
  • Dont\DontCallStatic
  • Dont\JustDont

Usage is straightforward:

use Dont\DontSerialise;

class MyClass
    use DontSerialise;

serialize(new MyClass); // will throw an exception

The same applies to DontDeserialise, but this time with unserialize().

Dont\JustDont includes other seven traits and is the recommended one to use.