File tree Expand file tree Collapse file tree 10 files changed +31
-18
lines changed
Expand file tree Collapse file tree 10 files changed +31
-18
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,10 @@ class Anything extends Type
3333 * @param string $value The new value
3434 * @throws \UnexpectedValueException When the supplied value is outside the valid length range 0 - 65535
3535 */
36- public function setValue (string $ value )
36+ public function setValue ($ value )
3737 {
38+ $ value = (string )$ value ;
39+
3840 if (\strlen ($ value ) > 65535 ) {
3941 throw new \UnexpectedValueException ('Untyped string length must be in the range 0 - 65535 ' );
4042 }
Original file line number Diff line number Diff line change @@ -32,9 +32,9 @@ class BitMap extends Type
3232 *
3333 * @param string $value The new value
3434 */
35- public function setValue (string $ value )
35+ public function setValue ($ value )
3636 {
37- $ this ->value = $ value ;
37+ $ this ->value = ( string ) $ value ;
3838 }
3939
4040 /**
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ class Char extends Type
3434 * @throws \UnderflowException When the supplied value is less than 0
3535 * @throws \OverflowException When the supplied value is greater than 255
3636 */
37- public function setValue (string $ value )
37+ public function setValue ($ value )
3838 {
3939 $ value = (int ) $ value ;
4040
Original file line number Diff line number Diff line change @@ -33,8 +33,10 @@ class CharacterString extends Type
3333 * @param string $value The new value
3434 * @throws \UnexpectedValueException When the supplied value is outside the valid length range 0 - 255
3535 */
36- public function setValue (string $ value )
36+ public function setValue ($ value )
3737 {
38+ $ value = (string )$ value ;
39+
3840 if (\strlen ($ value ) > 255 ) {
3941 throw new \UnexpectedValueException ('Character string length must be in the range 0 - 255 ' );
4042 }
Original file line number Diff line number Diff line change @@ -51,12 +51,21 @@ public function __construct($value = null)
5151 self ::$ labelPreProcessor = \function_exists ('idn_to_ascii ' )
5252 ? static function ($ label ) {
5353 if (false === $ result = \idn_to_ascii ($ label , 0 , INTL_IDNA_VARIANT_UTS46 )) {
54- throw new \InvalidArgumentException (' Label ' . $ label . ' could not be processed for IDN ' );
54+ throw new \InvalidArgumentException (" Label ' { $ label} ' could not be processed for IDN " );
5555 }
5656
5757 return $ result ;
5858 }
59- : 'strtolower ' ;
59+ : static function ($ label ) {
60+ if (\preg_match ('/[\x80-\xff]/ ' , $ label )) {
61+ throw new \RuntimeException (
62+ "Label ' {$ label }' contains non-ASCII characters and IDN support is not available. "
63+ . " Verify that ext/intl is installed for IDN support. "
64+ );
65+ }
66+
67+ return \strtolower ($ label );
68+ };
6069 }
6170
6271 if (\is_array ($ value )) {
@@ -72,9 +81,9 @@ public function __construct($value = null)
7281 * @param string $value The new value
7382 * @throws \UnexpectedValueException When the supplied value is not a valid domain name
7483 */
75- public function setValue (string $ value )
84+ public function setValue ($ value )
7685 {
77- $ this ->setLabels (\explode ('. ' , $ value ));
86+ $ this ->setLabels (\explode ('. ' , ( string ) $ value ));
7887 }
7988
8089 /**
Original file line number Diff line number Diff line change @@ -53,9 +53,9 @@ public function __construct($value = null)
5353 * @param string $value The new value
5454 * @throws \UnexpectedValueException When the supplied value is outside the valid length range 0 - 65535
5555 */
56- public function setValue (string $ value )
56+ public function setValue ($ value )
5757 {
58- $ this ->setOctets (\explode ('. ' , $ value ));
58+ $ this ->setOctets (\explode ('. ' , ( string ) $ value ));
5959 }
6060
6161 /**
Original file line number Diff line number Diff line change @@ -104,9 +104,9 @@ public function __construct($value = null)
104104 * @param string $value The new value
105105 * @throws \UnexpectedValueException When the supplied value is outside the valid length range 0 - 65535
106106 */
107- public function setValue (string $ value )
107+ public function setValue ($ value )
108108 {
109- $ shorts = \explode (': ' , $ value );
109+ $ shorts = \explode (': ' , ( string ) $ value );
110110
111111 $ count = \count ($ shorts );
112112 if ($ count < 3 || $ count > 8 ) {
Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ class Long extends Type
3434 * @throws \UnderflowException When the supplied value is less than 0
3535 * @throws \OverflowException When the supplied value is greater than 4294967296
3636 */
37- public function setValue (string $ value )
37+ public function setValue ($ value )
3838 {
39- $ value = (int ) $ value ;
39+ $ value = (int )$ value ;
4040
4141 if ($ value < 0 ) {
4242 throw new \UnderflowException ('Long integer value must be in the range 0 - 4294967296 ' );
Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ class Short extends Type
3434 * @throws \UnderflowException When the supplied value is less than 0
3535 * @throws \OverflowException When the supplied value is greater than 65535
3636 */
37- public function setValue (string $ value )
37+ public function setValue ($ value )
3838 {
39- $ value = (int ) $ value ;
39+ $ value = (int )$ value ;
4040
4141 if ($ value < 0 ) {
4242 throw new \UnderflowException ('Short integer value must be in the range 0 - 65535 ' );
Original file line number Diff line number Diff line change @@ -66,5 +66,5 @@ public function getValue()
6666 * @param string $value The new value
6767 * @throws \RuntimeException When the supplied value is invalid
6868 */
69- abstract public function setValue (string $ value );
69+ abstract public function setValue ($ value );
7070}
You can’t perform that action at this time.
0 commit comments