Use (int) cast instead of intval() function for performance reasons and to unify it.
Take care of more int casts.
Manually correct remaining casts.
Merge pull request #4570 from cakephp/master-casting

Use (int) instead of intval() for performance reasons and to unify it.