67 Assert::parameterType( self::class, $other,
'$other' );
70 '@phan-var self $other';
71 foreach ( $other->factoryFunctions as $name => $otherFunc ) {
72 if ( !isset( $this->factoryFunctions[$name] ) ) {
78 if ( isset( $other->configs[$name] )
79 && $this->factoryFunctions[$name] == $otherFunc
81 $this->configs[$name] = $other->configs[$name];
82 unset( $other->configs[$name] );
87 $other->factoryFunctions = [];
107 public function register( $name, $callback ) {
108 if ( !is_callable( $callback ) && !( $callback instanceof
Config ) ) {
109 if ( is_array( $callback ) ) {
110 $callback =
'[ ' . implode(
', ', $callback ) .
' ]';
111 } elseif ( is_object( $callback ) ) {
112 $callback =
'instanceof ' . get_class( $callback );
114 throw new InvalidArgumentException(
'Invalid callback \'' . $callback .
'\' provided
' );
117 unset( $this->configs[$name] );
118 $this->factoryFunctions[$name] = $callback;