sanmai/phpunit-double-colon-syntax
PHPUnit extension that adds support for “double colon” syntax in tests, improving readability when referencing classes and methods. Lightweight and focused, it helps you write clearer PHPUnit test code with a familiar static-style notation.
Install via Composer:
composer require --dev sanmai/phpunit-double-colon-syntax
No configuration is required—just require the autoloader ( Composer handles this automatically). Begin by replacing string-based method references (e.g., 'TestClass::testMethod') with the native ::class . '::method' pattern or using the provided DoubleColon::from() helper if available. The package’s main entrypoint is typically a trait like DoubleColonSyntax that can be imported into your test cases or helper classes to enable the syntax in assertions or data providers.
Class::class . '::methodName' in @depends, @group, or custom annotations to avoid brittle string concatenation and enable refactoring safety (IDE support, rename-safe).ClassName::method-style callables using the package’s helper (e.g., DoubleColon::from(Foo::class, 'bar')) to make test cases self-documenting and editable.TestResult or custom extensions to parse ::class . '::method' references for dynamic test discovery or reporting.'MyTest::testUserLogin') to typed double-colon references—especially useful when upgrading large suites where test method renaming is common.ClassLoader correctly resolves all referenced classes; the package doesn’t handle missing classes—PHPSpec will fail if a class/method doesn’t exist at reference time.DoubleColon::from()), you may need to implement your own small helper or use ReflectionClass::getMethod() to verify references exist before runtime.Class::class . '::method' as a test method—add PHPDoc hints (@test, @depends) for tooling support.@depends still string-based: PHPUnit itself doesn’t natively interpret double-colon callables—use the package to generate dependency strings (e.g., $this->doubleColonString(Foo::class, 'bar')) in test factories.TestCase.How can I help you explore Laravel packages today?