Can't declare uniquely named class.. because it's "in use" I'm trying to figure out how to make a processor for facets in Drupal 8.3. I've got this, but I have a couple issues. The first is a fatal error I get after activating the module, and navigating to a page with the facet on it:

Fatal error: Cannot declare class Drupal\facets_change_labels\Plugin\facets\processor\transform_labels, because the name is already in use in Drupal/modules/custom/facet_change_labels/src/Plugin/facets/processor/TransformLabels.php on line 22

It doesn't make sense, because this is the only place in the entire site that transform_labels or transformLabels is used. As an experiment, I changed the function to a completely random name, and the issue persisted. 

What am I missing, or not understanding?

The code: 

&lt;?php

namespace Drupal\facets_change_labels\Plugin\facets\processor;

use Drupal\Core\Form\FormStateInterface;
use Drupal\facets\FacetInterface;
use Drupal\facets\Processor\BuildProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginBase;

/**
 * Provides a processor for transforming labels.
 *
 * @FacetsProcessor(
 *   id = "transform_labels",
 *   label = @Translation("Transform labels"),
 *   description = @Translation("Transform labels"),
 *   stages = {
 *     "build" = 35
 *   }
 * )
 */
class transform_labels extends ProcessorPluginBase implements BuildProcessorInterface {

  /**
   * {@inheritdoc}
   */
  public function build(FacetInterface $facet, array $results) {
    $config = $this-&gt;getConfiguration();

    /** @var \Drupal\facets\Result\Result $result */
    foreach ($results as $result) {
      if ($result-&gt;getRawValue() == 'shape') {
        $result-&gt;setDisplayValue("leaf shape");
      }
      elseif ($result-&gt;getRawValue() == 'type') {
        $result-&gt;setDisplayValue("leaf type");
      }
      elseif ($result-&gt;getRawValue() == 'color') {
        $result-&gt;setDisplayValue("leaf color");
      }
    }

    return $results;
  }
}
For PS4 class autodiscovery to work, your file name needs to be the same as your class name. From reading the error message, it appears that your file name is TransformLabels.php, but you've named your class transform_labels. You need to change your class name to TransformLabels:

class TransformLabels extends ProcessorPluginBase implements BuildProcessorInterface {


One other question I have is, did you create the facets processor plugin type? Or was it a 3rd party?