@@ -104,6 +104,10 @@ class Connection extends BaseConnection
104104 */
105105 private function isValidDSN (): bool
106106 {
107+ if ($ this ->DSN === null || $ this ->DSN === '' ) {
108+ return false ;
109+ }
110+
107111 foreach ($ this ->validDSNs as $ regexp ) {
108112 if (preg_match ($ regexp , $ this ->DSN )) {
109113 return true ;
@@ -120,13 +124,13 @@ private function isValidDSN(): bool
120124 */
121125 public function connect (bool $ persistent = false )
122126 {
123- if (empty ( $ this -> DSN ) && ! $ this ->isValidDSN ()) {
127+ if (! $ this ->isValidDSN ()) {
124128 $ this ->buildDSN ();
125129 }
126130
127131 $ func = $ persistent ? 'oci_pconnect ' : 'oci_connect ' ;
128132
129- return empty ($ this ->charset )
133+ return ($ this ->charset === '' )
130134 ? $ func ($ this ->username , $ this ->password , $ this ->DSN )
131135 : $ func ($ this ->username , $ this ->password , $ this ->DSN , $ this ->charset );
132136 }
@@ -632,7 +636,7 @@ protected function buildDSN()
632636 }
633637
634638 $ isEasyConnectableHostName = $ this ->hostname !== '' && ! str_contains ($ this ->hostname , '/ ' ) && ! str_contains ($ this ->hostname , ': ' );
635- $ easyConnectablePort = ! empty ($ this ->port ) && ctype_digit ($ this ->port ) ? ': ' . $ this ->port : '' ;
639+ $ easyConnectablePort = ($ this ->port !== '' ) && ctype_digit (( string ) $ this ->port ) ? ': ' . $ this ->port : '' ;
636640 $ easyConnectableDatabase = $ this ->database !== '' ? '/ ' . ltrim ($ this ->database , '/ ' ) : '' ;
637641
638642 if ($ isEasyConnectableHostName && ($ easyConnectablePort !== '' || $ easyConnectableDatabase !== '' )) {
0 commit comments