Display block based on main content type with view
In your case you don't need to provide any default value with PHP code.

Remove your contextual filter and add new one: Content: nid.

"WHEN THE FILTER VALUE IS NOT AVAILABLE" 

Provide default value -> content ID from URL

"When the filter value IS available or a default is provided" 

Specify validation criteria

Validator -> Content -> book