<commit_before>--TEST--
XHProf: Transaction Name Detection in Hierachical Profiling Mode
--FILE--
<?php

use Symfony\Component\HttpKernel\Controller\ControllerResolver;
use Zend\MVC\Controller\ControllerManager;

require "tideways_023_classes.php";

abstract class Zend_Controller_Action {
    public function dispatch($method)
    {
    }
}
class MyController extends Zend_Controller_Action {
}
class oxView {
    public function setClassName($sClass) {
    }
}
abstract class Enlight_Controller_Action {
    public function dispatch($method)
    {
    }
}
class ShopController extends Enlight_Controller_Action {
}
function get_query_template($name) {
}

function transaction_symfony2() {
    tideways_enable(0, array(
        'transaction_function' => 'Symfony\Component\HttpKernel\Controller\ControllerResolver::createController',
    ));

    $resolver = new ControllerResolver();
    $resolver->createController("foo::bar");

    echo "Symfony2: " . tideways_transaction_name() . "\n";
    tideways_disable();
}

function transaction_zf1() {
    tideways_enable(0, array(
        'transaction_function' => 'Zend_Controller_Action::dispatch',
    ));
    $controller = new MyController();
    $controller->dispatch("fooAction");

    echo "Zend Framework 1: " . trim(tideways_transaction_name()) . "\n";
    $data = tideways_disable();
}

function transaction_zf2() {
    tideways_enable(0, array(
        'transaction_function' => 'Zend\\MVC\\Controller\\ControllerManager::get',
    ));
    $manager = new ControllerManager();
    $manager->get("FooCtrl", array("foo" => "bar"), false);

    echo "Zend Framework 2: " . tideways_transaction_name() . "\n";
    $data = tideways_disable();
}

function transaction_oxid() {
    tideways_enable(0, array(
        'transaction_function' => 'oxView::setClassName',
    ));

    $shop = new oxView();
    $shop->setClassName("alist");

    echo "Oxid: " . tideways_transaction_name() . "\n";
    $data = tideways_disable();
}

function transaction_shopware() {
    tideways_enable(0, array(
        'transaction_function' => 'Enlight_Controller_Action::dispatch',
    ));

    $controller = new ShopController();
    $controller->dispatch('listAction');

    echo "Shopware: " . trim(tideways_transaction_name()) . "\n";
    $data = tideways_disable();
}

function transaction_wordpress() {
    tideways_enable(0, array(
        'transaction_function' => 'get_query_template',
    ));

    get_query_template("home");

    echo "Wordpress: " . tideways_transaction_name() . "\n";
    $data = tideways_disable();
}

function transaction_laravel() {
    tideways_enable(0, array(
        'transaction_function' => 'Illuminate\Routing\Controller::callAction',
    ));

    $ctrl = new \CachetHQ\Cachet\Http\Controllers\RssController();
    $ctrl->callAction('indexAction', array());

    echo "Laravel: " . tideways_transaction_name() . "\n";
    $data = tideways_disable();
}

transaction_symfony2();
transaction_zf2();
transaction_oxid();
transaction_shopware();
transaction_wordpress();
transaction_zf1();
transaction_laravel();

--EXPECTF--
Symfony2: foo::bar
Zend Framework 2: FooCtrl
Oxid: alist
Shopware: ShopController::listAction
Wordpress: home
Zend Framework 1: MyController::fooAction
Laravel: CachetHQ\Cachet\Http\Controllers\RssController::indexAction
<commit_msg>Fix test<commit_after>--TEST--
XHProf: Transaction Name Detection in Hierachical Profiling Mode
--FILE--
<?php

use Symfony\Component\HttpKernel\Controller\ControllerResolver;
use Zend\MVC\Controller\ControllerManager;

require "tideways_023_classes.php";

abstract class Zend_Controller_Action {
    public function dispatch($method)
    {
    }
}
class MyController extends Zend_Controller_Action {
}
class oxView {
    public function setClassName($sClass) {
    }
}
abstract class Enlight_Controller_Action {
    public function dispatch($method)
    {
    }
}
class ShopController extends Enlight_Controller_Action {
}
function get_query_template($name) {
}

function transaction_symfony2() {
    tideways_enable(TIDEWAYS_FLAGS_NO_SPANS, array(
        'transaction_function' => 'Symfony\Component\HttpKernel\Controller\ControllerResolver::createController',
    ));

    $resolver = new ControllerResolver();
    $resolver->createController("foo::bar");

    echo "Symfony2: " . tideways_transaction_name() . "\n";
    tideways_disable();
}

function transaction_zf1() {
    tideways_enable(TIDEWAYS_FLAGS_NO_SPANS, array(
        'transaction_function' => 'Zend_Controller_Action::dispatch',
    ));
    $controller = new MyController();
    $controller->dispatch("fooAction");

    echo "Zend Framework 1: " . trim(tideways_transaction_name()) . "\n";
    $data = tideways_disable();
}

function transaction_zf2() {
    tideways_enable(TIDEWAYS_FLAGS_NO_SPANS, array(
        'transaction_function' => 'Zend\\MVC\\Controller\\ControllerManager::get',
    ));
    $manager = new ControllerManager();
    $manager->get("FooCtrl", array("foo" => "bar"), false);

    echo "Zend Framework 2: " . tideways_transaction_name() . "\n";
    $data = tideways_disable();
}

function transaction_oxid() {
    tideways_enable(TIDEWAYS_FLAGS_NO_SPANS, array(
        'transaction_function' => 'oxView::setClassName',
    ));

    $shop = new oxView();
    $shop->setClassName("alist");

    echo "Oxid: " . tideways_transaction_name() . "\n";
    $data = tideways_disable();
}

function transaction_shopware() {
    tideways_enable(TIDEWAYS_FLAGS_NO_SPANS, array(
        'transaction_function' => 'Enlight_Controller_Action::dispatch',
    ));

    $controller = new ShopController();
    $controller->dispatch('listAction');

    echo "Shopware: " . trim(tideways_transaction_name()) . "\n";
    $data = tideways_disable();
}

function transaction_wordpress() {
    tideways_enable(TIDEWAYS_FLAGS_NO_SPANS, array(
        'transaction_function' => 'get_query_template',
    ));

    get_query_template("home");

    echo "Wordpress: " . tideways_transaction_name() . "\n";
    $data = tideways_disable();
}

function transaction_laravel() {
    tideways_enable(TIDEWAYS_FLAGS_NO_SPANS, array(
        'transaction_function' => 'Illuminate\Routing\Controller::callAction',
    ));

    $ctrl = new \CachetHQ\Cachet\Http\Controllers\RssController();
    $ctrl->callAction('indexAction', array());

    echo "Laravel: " . tideways_transaction_name() . "\n";
    $data = tideways_disable();
}

transaction_symfony2();
transaction_zf2();
transaction_oxid();
transaction_shopware();
transaction_wordpress();
transaction_zf1();
transaction_laravel();

--EXPECTF--
Symfony2: foo::bar
Zend Framework 2: FooCtrl
Oxid: alist
Shopware: ShopController::listAction
Wordpress: home
Zend Framework 1: MyController::fooAction
Laravel: CachetHQ\Cachet\Http\Controllers\RssController::indexAction

{'fraction_non_alphanumeric': 0.13560817767318722, 'fraction_numerical': 0.005441976761288425, 'mean_word_length': 4.564648117839607, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4857808', 'n_tokens_mistral': 2137, 'n_tokens_neox': 2084, 'n_words': 373}