Protobuf\Extension\ExtensionRegistry::clear PHP Method

clear() public method

Remove all registered extensions
public clear ( )
    public function clear()
    {
        $this->extensions = [];
    }

Usage Example

 public function testAddAndFindByFieldNumber()
 {
     $registry = new ExtensionRegistry();
     $extension = new ExtensionField(Animal::CLASS, 'animal', 100, function () {
     }, function () {
     }, function () {
     });
     $this->assertNull($registry->findByNumber(Animal::CLASS, 100));
     $registry->add($extension);
     $this->assertSame($extension, $registry->findByNumber(Animal::CLASS, 100));
     $registry->clear();
     $this->assertNull($registry->findByNumber(Animal::CLASS, 100));
 }