@@ -104,6 +104,10 @@ class Connection extends BaseConnection
104
104
*/
105
105
private function isValidDSN (): bool
106
106
{
107
+ if ($ this ->DSN === null || $ this ->DSN === '' ) {
108
+ return false ;
109
+ }
110
+
107
111
foreach ($ this ->validDSNs as $ regexp ) {
108
112
if (preg_match ($ regexp , $ this ->DSN )) {
109
113
return true ;
@@ -120,13 +124,13 @@ private function isValidDSN(): bool
120
124
*/
121
125
public function connect (bool $ persistent = false )
122
126
{
123
- if (empty ( $ this -> DSN ) && ! $ this ->isValidDSN ()) {
127
+ if (! $ this ->isValidDSN ()) {
124
128
$ this ->buildDSN ();
125
129
}
126
130
127
131
$ func = $ persistent ? 'oci_pconnect ' : 'oci_connect ' ;
128
132
129
- return empty ($ this ->charset )
133
+ return ($ this ->charset === '' )
130
134
? $ func ($ this ->username , $ this ->password , $ this ->DSN )
131
135
: $ func ($ this ->username , $ this ->password , $ this ->DSN , $ this ->charset );
132
136
}
@@ -632,7 +636,7 @@ protected function buildDSN()
632
636
}
633
637
634
638
$ 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 : '' ;
636
640
$ easyConnectableDatabase = $ this ->database !== '' ? '/ ' . ltrim ($ this ->database , '/ ' ) : '' ;
637
641
638
642
if ($ isEasyConnectableHostName && ($ easyConnectablePort !== '' || $ easyConnectableDatabase !== '' )) {
0 commit comments