1111use phpsap \exceptions \IncompleteConfigException ;
1212use phpsap \exceptions \SapLogicException ;
1313use phpsap \exceptions \UnknownFunctionException ;
14+ use phpsap \interfaces \Config \IConfiguration ;
1415use phpsap \interfaces \exceptions \IIncompleteConfigException ;
1516use phpsap \interfaces \exceptions \IInvalidArgumentException ;
1617use phpsap \saprfc \Traits \ApiTrait ;
2021use SAPNWRFC \ConnectionException as ModuleConnectionException ;
2122use SAPNWRFC \FunctionCallException as ModuleFunctionCallException ;
2223use SAPNWRFC \RemoteFunction ;
24+ use TypeError ;
2325
2426use function array_merge ;
2527use function get_object_vars ;
@@ -133,14 +135,19 @@ protected function getConnection(): Connection
133135 try {
134136 if ($ config ->getTrace () !== null ) {
135137 /**
136- * \SAPNWRFC\Connection::TRACE_LEVEL_* uses the same values
137- * as \phpsap\interfaces\Config\IConfigCommon::TRACE_*.
138- * Therefore, no mapping is necessary.
138+ * SAPNWRFC introduced TRACE_DETAILED (3) in v2.1.0 which
139+ * is not available via the interface.
139140 */
140- Connection::setTraceLevel ($ config ->getTrace ());
141+ $ trace = match ($ config ->getTrace ()) {
142+ IConfiguration::TRACE_FULL => 4 ,
143+ IConfiguration::TRACE_VERBOSE => 2 ,
144+ IConfiguration::TRACE_BRIEF => 1 ,
145+ default => 0 ,
146+ };
147+ Connection::setTraceLevel ($ trace );
141148 }
142149 $ this ->connection = new Connection ($ moduleConfig );
143- } catch (ModuleConnectionException $ exception ) {
150+ } catch (TypeError | ModuleConnectionException $ exception ) {
144151 throw new ConnectionFailedException (sprintf (
145152 'Connection creation failed: %s ' ,
146153 $ exception ->getMessage ()
@@ -155,9 +162,6 @@ protected function getConnection(): Connection
155162 */
156163 public function extractApi (): RemoteApi
157164 {
158- /**
159- * InvalidArgumentException is never thrown, because no parameter is given.
160- */
161165 $ api = new RemoteApi ();
162166 foreach ($ this ->saprfcFunctionInterface () as $ name => $ element ) {
163167 try {
@@ -192,13 +196,7 @@ public function extractApi(): RemoteApi
192196 */
193197 public function saprfcFunctionInterface (): array
194198 {
195- $ function = $ this ->getFunction ();
196- if (method_exists ($ function , 'getFunctionDescription ' )) {
197- return $ function ->getFunctionDescription ();
198- }
199- $ result = get_object_vars ($ function );
200- unset($ result ['name ' ]);
201- return $ result ;
199+ return $ this ->getFunction ()->getFunctionDescription ();
202200 }
203201
204202 /**
@@ -227,7 +225,7 @@ public function invoke(): array
227225 $ result = $ this
228226 ->getFunction ()
229227 ->invoke ($ params , self ::$ invokeOptions );
230- } catch (ModuleFunctionCallException $ exception ) {
228+ } catch (TypeError | ModuleFunctionCallException $ exception ) {
231229 throw new FunctionCallException (sprintf (
232230 'Function call %s failed: %s ' ,
233231 $ this ->getName (),
0 commit comments