@@ -51,14 +51,55 @@ private function maskSensitiveXmlString($rawString){
5151 $ maskedString = preg_replace ($ patterns , $ replacements , $ rawString );
5252 return $ maskedString ;
5353 }
54+ private function maskSensitiveProperties ($ obj )
55+ {
56+ $ reflectObj = new \ReflectionObject ($ obj );
57+ // //echo "reflection object name: " . $reflectObj->getName();
58+ // if($reflectObj->getName()=="name"){
59+ // return;
60+ // }
61+ $ props = $ reflectObj ->getParentClass ()->getProperties ();
62+ print_r ($ props );
63+ foreach ($ props as $ i => $ prop ){
64+ $ prop ->setAccessible (true );
65+ //
66+ // echo "propValue: " ;
67+ print_r ($ prop ->getValue ($ obj ));
68+ // print_r($propValue);
69+
70+ if (is_object ($ prop ->getValue ($ obj ))){
71+ echo "Is object \n" ;
72+ $ prop ->setValue ($ obj , null );
73+ // $prop->setValue($obj, $this->maskSensitiveProperties($prop->getValue($obj)));
74+ }
75+ else {
76+ echo "leaf value: " ; $ prop ->getValue ($ obj );
77+ }
5478
79+ // var_dump($obj);
80+ }
81+ //NULL even obj disp>layed print_r(get_object_vars($obj));
82+ // print_r($obj);
83+ //NULL even obj displayed print_r(get_class_vars(get_class($obj)));
84+ echo "************************ " ;
85+ print_r ($ obj );
86+ print_r ('size... ' .count ($ props ));
87+ return $ obj ;
88+ // echo"var_dump-------";
89+ // var_dump($reflectObj);
90+ // echo"var_dump-------";
91+ // return $reflectObj;
92+ }
5593 private function getMasked ($ raw )
56- {
94+ { //always returns string
5795 $ messageType = gettype ($ raw );
5896 $ message ="" ;
5997 if ($ messageType == "string " ) {
6098 $ message = $ this ->maskSensitiveXmlString ($ raw );
6199 }
100+ else if ($ messageType == "object " ){
101+ $ message = print_r ($ this ->maskSensitiveProperties ($ raw ), true ); //object to string
102+ }
62103 return $ message ;
63104 }
64105 public function debug ($ logMessage , $ flags =FILE_APPEND )
0 commit comments