The first one won’t work because only some of the Particle callback function handlers can accept a non-static member function as the callback. You can tell because they take a this pointer as an argument as well as the method.
WiFi.scan() is one that doesn’t. But the technique used in the second bit of code, a static member function that takes the this parameter in the data field, is the way to work around it.
I didn’t see anything obviously wrong with the second code sample, though I didn’t look that closely. And actually it worked without crashing for me.
Adding a delay of 800 microseconds to the end of the setup() function solves the crash. Any idea why?
The same happens with the example from the documentation. In my test Photon there is one credential stored with a wrong password (by purpose), so it keeps connecting.