<?php 
/**
 * Plugin Name: Test Did Filter
 * Plugin URI: https://core.trac.wordpress.org/ticket/35357
 * Author: Chris Christoff
 * Version: 1.0
 */

/**
 * Based on patch 3 for ticket 35357. Requires
 * patch has been applied before activating this plugin.
 *
 * The first function that hooks in will output 0, as no
 * functions have run on the filter before it. The second
 * function outputs 1, as test_did_filter_filter1 has run
 * before it. The third function outputs 2, as test_did_filter_filter1
 * and test_did_filter_filter2 has run before it.
 *
 * Finally the script dies and outputs 3, as 3 functions total
 * executed on the filter.
 *
 * The result is a var_dump of (ints) 0 then 1 then 2 then 3.
 */

add_action( 'init', 'test_did_filter' );
function test_did_filter(){
	$string = 'test';
	$string = apply_filters( 'test_did_filter', $string );
	var_dump( did_filter( 'test_did_filter' ) ); // Outputs 3
	wp_die();
}

function test_did_filter_filter1( $string ){
	var_dump( did_filter( 'test_did_filter' ) ); // Outputs 0
	return $string . '1';
}
add_filter( 'test_did_filter', 'test_did_filter_filter1', 10, 1 );

function test_did_filter_filter2( $string ){
	var_dump( did_filter( 'test_did_filter' ) ); // Outputs 1
	return $string . '1';
}
add_filter( 'test_did_filter', 'test_did_filter_filter2', 11, 1 );

function test_did_filter_filter3( $string ){
	var_dump( did_filter( 'test_did_filter' ) ); // Outputs 2
	return $string . '1';
}
add_filter( 'test_did_filter', 'test_did_filter_filter3', 12, 1 );