for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Roave\BackwardCompatibility\DetectChanges\BCBreak\ClassBased;
use Roave\BackwardCompatibility\Change;
use Roave\BackwardCompatibility\Changes;
use Roave\BetterReflection\Reflection\ReflectionClass;
use function Safe\sprintf;
/**
* A class cannot become a trait without introducing an explicit BC break, since
* all child classes or implementors need to be changed from `extends` to `use`,
* and all instantiations start failing
*/
final class ClassBecameTrait implements ClassBased
{
public function __invoke(ReflectionClass $fromClass, ReflectionClass $toClass) : Changes
if ($fromClass->isTrait() || ! $toClass->isTrait()) {
return Changes::empty();
}
return Changes::fromList(Change::changed(
sprintf('Class %s became a trait', $fromClass->getName()),
true
));