68 public function salvage( SalvageableService $other ) {
69 Assert::parameterType( self::class, $other,
'$other' );
72 '@phan-var self $other';
73 foreach ( $other->factoryFunctions as $name => $otherFunc ) {
74 if ( !isset( $this->factoryFunctions[$name] ) ) {
80 if ( isset( $other->configs[$name] )
81 && $this->factoryFunctions[$name] == $otherFunc
83 $this->configs[$name] = $other->configs[$name];
84 unset( $other->configs[$name] );
89 $other->factoryFunctions = [];
109 public function register( $name, $callback ) {
110 if ( !is_callable( $callback ) && !( $callback instanceof
Config ) ) {
111 if ( is_array( $callback ) ) {
112 $callback =
'[ ' . implode(
', ', $callback ) .
' ]';
113 } elseif ( is_object( $callback ) ) {
114 $callback =
'instanceof ' . get_class( $callback );
116 throw new InvalidArgumentException(
'Invalid callback \'' . $callback .
'\' provided
' );
119 unset( $this->configs[$name] );
120 $this->factoryFunctions[$name] = $callback;