@@ -40,10 +40,10 @@ public function __construct(ContainerBuilder $container, FileLocatorInterface $l
4040 /**
4141 * Registers a set of classes as services using PSR-4 for discovery.
4242 *
43- * @param Definition $prototype A definition to use as template
44- * @param string $namespace The namespace prefix of classes in the scanned directory
45- * @param string $resource The directory to look for classes, glob-patterns allowed
46- * @param string $ exclude A globed path of files to exclude
43+ * @param Definition $prototype A definition to use as template
44+ * @param string $namespace The namespace prefix of classes in the scanned directory
45+ * @param string $resource The directory to look for classes, glob-patterns allowed
46+ * @param string|string[]|null $exclude A globbed path of files to exclude or an array of globbed paths of files to exclude
4747 */
4848 public function registerClasses (Definition $ prototype , $ namespace , $ resource , $ exclude = null )
4949 {
@@ -54,7 +54,7 @@ public function registerClasses(Definition $prototype, $namespace, $resource, $e
5454 throw new InvalidArgumentException (sprintf ('Namespace is not a valid PSR-4 prefix: %s. ' , $ namespace ));
5555 }
5656
57- $ classes = $ this ->findClasses ($ namespace , $ resource , $ exclude );
57+ $ classes = $ this ->findClasses ($ namespace , $ resource , ( array ) $ exclude );
5858 // prepare for deep cloning
5959 $ serializedPrototype = serialize ($ prototype );
6060 $ interfaces = array ();
@@ -101,14 +101,14 @@ protected function setDefinition($id, Definition $definition)
101101 }
102102 }
103103
104- private function findClasses ($ namespace , $ pattern , $ excludePattern )
104+ private function findClasses ($ namespace , $ pattern , array $ excludePatterns )
105105 {
106106 $ parameterBag = $ this ->container ->getParameterBag ();
107107
108108 $ excludePaths = array ();
109109 $ excludePrefix = null ;
110- if ( $ excludePattern ) {
111- $ excludePattern = $ parameterBag -> unescapeValue ( $ parameterBag -> resolveValue ( $ excludePattern ));
110+ $ excludePatterns = $ parameterBag -> unescapeValue ( $ parameterBag -> resolveValue ( $ excludePatterns ));
111+ foreach ( $ excludePatterns as $ excludePattern ) {
112112 foreach ($ this ->glob ($ excludePattern , true , $ resource ) as $ path => $ info ) {
113113 if (null === $ excludePrefix ) {
114114 $ excludePrefix = $ resource ->getPrefix ();
0 commit comments