public static PhpStream GetValid(PhpResource handle) { var result = handle as PhpStream; if (result != null && result.IsValid) { return result; } else { PhpException.Throw(PhpError.Warning, ErrResources.invalid_stream_resource); return null; } }