Python-like context manager for PHP