62 public function salvage( SalvageableService $other ) {
63 Assert::parameterType( self::class, $other,
'$other' );
66 '@phan-var self $other';
67 foreach ( $other->factoryFunctions as $name => $otherFunc ) {
68 if ( !isset( $this->factoryFunctions[$name] ) ) {
74 if ( isset( $other->configs[$name] )
75 && $this->factoryFunctions[$name] == $otherFunc
77 $this->configs[$name] = $other->configs[$name];
78 unset( $other->configs[$name] );
83 $other->factoryFunctions = [];
103 public function register( $name, $callback ) {
104 if ( !is_callable( $callback ) && !( $callback instanceof
Config ) ) {
105 if ( is_array( $callback ) ) {
106 $callback =
'[ ' . implode(
', ', $callback ) .
' ]';
107 } elseif ( is_object( $callback ) ) {
108 $callback =
'instanceof ' . get_class( $callback );
110 throw new InvalidArgumentException(
'Invalid callback \'' . $callback .
'\' provided
' );
113 unset( $this->configs[$name] );
114 $this->factoryFunctions[$name] = $callback;