File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public static function formattedConstruct($args): array
7979 {
8080 $ code = 0 ;
8181 $ previous = null ;
82- $ format = array_shift ($ args );
82+ $ format = array_shift ($ args ) ?? '' ;
8383
8484 if (is_array ($ format ))
8585 {
Original file line number Diff line number Diff line change @@ -104,6 +104,42 @@ public function testFormattingMissingArgs1(): void
104104 }
105105 }
106106
107+ //--------------------------------------------------------------------------------------------------------------------
108+ /**
109+ * Test formatting null string.
110+ */
111+ public function testFormattingNull1 (): void
112+ {
113+ try
114+ {
115+ $ format = null ;
116+
117+ throw new self::$ class ($ format );
118+ }
119+ catch (Exception $ e )
120+ {
121+ self ::assertSame ('' , $ e ->getMessage ());
122+ }
123+ }
124+
125+ //--------------------------------------------------------------------------------------------------------------------
126+ /**
127+ * Test formatting null string and bogus arguments.
128+ */
129+ public function testFormattingNull2 (): void
130+ {
131+ try
132+ {
133+ $ format = null ;
134+
135+ throw new self::$ class ($ format , 'bogus ' , 123 );
136+ }
137+ catch (Exception $ e )
138+ {
139+ self ::assertSame ('' , $ e ->getMessage ());
140+ }
141+ }
142+
107143 //--------------------------------------------------------------------------------------------------------------------
108144 /**
109145 * Test formatting string with missing arguments.
You can’t perform that action at this time.
0 commit comments