@@ -20,8 +20,6 @@ class Connection extends IlluminateConnection
2020{
2121 /**
2222 * All types without quotes in Sybase's query.
23- *
24- * @var array
2523 */
2624 private array $ numeric = [
2725 'int ' , 'numeric ' , 'bigint ' , 'integer ' , 'smallint ' , 'tinyint ' , 'decimal ' , 'double ' , 'float ' , 'real ' , 'bit ' ,
@@ -31,7 +29,6 @@ class Connection extends IlluminateConnection
3129 /**
3230 * Execute a Closure within a transaction.
3331 *
34- * @param Closure $callback
3532 * @param int $attempts
3633 * @return mixed
3734 *
@@ -54,9 +51,9 @@ public function transaction(Closure $callback, $attempts = 1)
5451 $ this ->pdo ->exec ('COMMIT TRAN ' );
5552 }
5653
57- // If we catch an exception, we will roll back so nothing gets messed
58- // up in the database. Then we'll re-throw the exception so it can
59- // be handled how the developer sees fit for their applications.
54+ // If we catch an exception, we will roll back so nothing gets messed
55+ // up in the database. Then we'll re-throw the exception so it can
56+ // be handled how the developer sees fit for their applications.
6057 catch (Exception $ e ) {
6158 $ this ->pdo ->exec ('ROLLBACK TRAN ' );
6259
@@ -101,7 +98,7 @@ public function select($query, $bindings = [], $useReadPdo = true)
10198 $ result = [...$ result ];
10299
103100 $ application_encoding = config ('database.sybase.application_encoding ' );
104- if (!$ application_encoding ) {
101+ if (! $ application_encoding ) {
105102 return $ result ;
106103 }
107104 $ database_charset = config ('database.sybase.database_charset ' );
@@ -129,39 +126,37 @@ public function select($query, $bindings = [], $useReadPdo = true)
129126 *
130127 * @link http://stackoverflow.com/questions/2718628/pdoparam-for-type-decimal
131128 *
132- * @param string $query
133- * @param array $bindings
134129 * @return string $query
130+ *
135131 * @throws Exception
136132 */
137133 private function compileNewQuery (string $ query , array $ bindings )
138134 {
139135 $ bindings = $ this ->compileBindings ($ query , $ bindings );
140136 $ partQuery = explode ('? ' , $ query );
141137
142- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? str_replace ('\'' , '\'\'' , $ v ) : $ v , $ bindings );
143- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? "' {$ v }' " : $ v , $ bindings );
144- $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'NULL ' ? 'NULL ' : $ v , $ bindings );
138+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? str_replace ('\'' , '\'\'' , $ v ) : $ v , $ bindings );
139+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'string ' ? "' {$ v }' " : $ v , $ bindings );
140+ $ bindings = array_map (fn ($ v ) => gettype ($ v ) === 'NULL ' ? 'NULL ' : $ v , $ bindings );
145141
146- $ newQuery = join (array_map (fn ($ k1 , $ k2 ) => $ k1 .$ k2 , $ partQuery , $ bindings ));
142+ $ newQuery = implode (array_map (fn ($ k1 , $ k2 ) => $ k1 .$ k2 , $ partQuery , $ bindings ));
147143 $ newQuery = str_replace ('[] ' , '' , $ newQuery );
148144 $ application_encoding = config ('database.sybase.application_encoding ' );
149- if (!$ application_encoding ) {
145+ if (! $ application_encoding ) {
150146 return $ newQuery ;
151147 }
152148 $ database_charset = config ('database.sybase.database_charset ' );
153149 $ application_charset = config ('database.sybase.application_charset ' );
154150 if (is_null ($ database_charset ) || is_null ($ application_charset )) {
155151 throw new Exception ('[SYBASE] Database Charset and App Charset not set ' );
156152 }
153+
157154 return mb_convert_encoding ($ newQuery , $ database_charset , $ application_charset );
158155 }
159156
160157 /**
161158 * Set new bindings with specified column types to Sybase.
162159 *
163- * @param string $query
164- * @param array $bindings
165160 * @return array $newBinds
166161 */
167162 private function compileBindings (string $ query , array $ bindings )
@@ -183,15 +178,14 @@ private function compileBindings(string $query, array $bindings)
183178 /**
184179 * Compile the bindings for select/insert/update/delete.
185180 *
186- * @param Builder $builder
187181 * @return array
188182 */
189183 private function compile (Builder $ builder )
190184 {
191185 $ arrTables = [];
192186
193187 $ arrTables [] = $ builder ->from ;
194- if (!empty ($ builder ->joins )) {
188+ if (! empty ($ builder ->joins )) {
195189 foreach ($ builder ->joins as $ join ) {
196190 $ arrTables [] = $ join ->table ;
197191 }
@@ -223,7 +217,7 @@ private function compile(Builder $builder)
223217 }
224218
225219 if ($ cache ) {
226- $ cacheTime = key_exists ('cache_time ' ,
220+ $ cacheTime = array_key_exists ('cache_time ' ,
227221 $ builder ->connection ->config ) ? $ builder ->connection ->config ['cache_time ' ] : 3600 ;
228222 $ aux = cache ()->remember ("sybase_columns. $ tables.columns_info " , $ cacheTime , function () use ($ tables ) {
229223 $ queryString = $ this ->queryString ($ tables );
@@ -243,7 +237,7 @@ private function compile(Builder $builder)
243237 $ types [strtolower ($ row ['name ' ])] = $ row ['type ' ];
244238 $ types [strtolower ($ tables .'. ' .$ row ['name ' ])] = $ row ['type ' ];
245239
246- if (!empty ($ alias ['alias ' ])) {
240+ if (! empty ($ alias ['alias ' ])) {
247241 $ types [strtolower ($ alias ['alias ' ].'. ' .$ row ['name ' ])] = $ row ['type ' ];
248242 }
249243 }
@@ -312,15 +306,14 @@ private function compile(Builder $builder)
312306 /**
313307 * Query string.
314308 *
315- * @param string $tables
316309 * @return string
317310 */
318311 private function queryString (string $ tables )
319312 {
320313 $ tables = str_replace ('.. ' , '.dbo. ' , $ tables );
321314 $ explicitDB = explode ('.dbo. ' , $ tables );
322315
323- // Has domain.table
316+ // Has domain.table
324317 if (isset ($ explicitDB [1 ])) {
325318 return <<<SQL
326319 SELECT
@@ -451,7 +444,6 @@ protected function getDefaultPostProcessor()
451444 *
452445 * @param string $query
453446 * @param array $bindings
454- * @param Closure $callback
455447 * @return mixed
456448 *
457449 * @throws QueryException
@@ -469,6 +461,7 @@ protected function runQueryCallback($query, $bindings, Closure $callback)
469461 throw new PDOException ($ finalErrorMessage , (int ) $ errorInfo [1 ]);
470462 }
471463 }
464+
472465 return $ result ;
473466
474467 } catch (Throwable $ e ) {
0 commit comments