File tree Expand file tree Collapse file tree 2 files changed +2
-1
lines changed Expand file tree Collapse file tree 2 files changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class XMLElement extends SimpleXMLElement
1616 */
1717 public function attribute (string $ name , mixed $ default = null ): mixed
1818 {
19- return $ this ->attributes ()->{$ name } ?? $ default ;
19+ return ! is_null ( $ this ->attributes ()->{$ name }) ? ( string ) $ this -> attributes ()->{ $ name } : $ default ;
2020 }
2121
2222 /**
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ public function test_can_get_element_attributes()
3030 $ path = __DIR__ .'/../Features/Import/stubs/notes.xml ' ;
3131 $ xml = XML ::import ($ path )->get ()->note ;
3232
33+ $ this ->assertIsString ($ xml ->attribute ('completed ' ));
3334 $ this ->assertEquals ('true ' , $ xml ->attribute ('completed ' ));
3435 $ this ->assertEquals ('0 ' , $ xml ->attribute ('stars ' , '2 ' ));
3536 $ this ->assertEquals ('1 ' , $ xml ->attribute ('shares ' , '2 ' ));
You can’t perform that action at this time.
0 commit comments