How to display php source code inside a post using visual editor?

That may be a bit problematic. I use the plugin SyntaxHighlighter Evolved, but as the plugin description says (my emphasis):

TIP: Don’t use the Visual editor if you don’t want your code mangled. TinyMCE will “clean up” your HTML.

Another option is to embed Gists (or similar) using a Shortcode to pass the URL and let PHP render the script tag (as suggested by Marco Berrocal).

<script src="https://gist.github.com/user/GistID.js"></script>

And the Shortcode path could also be used with Custom Fields. Paste the script in the CF and pass its name to the Shortcode for rendering. The plugin Advanced Custom Fields comes to mind.