├── .appveyor.yml ├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ └── integrate.yml ├── CREDITS ├── LICENSE ├── README.md ├── check-package.sh ├── config.m4 ├── config.w32 ├── configs ├── yaf_config_ini.c ├── yaf_config_ini.h ├── yaf_config_simple.c └── yaf_config_simple.h ├── package.xml ├── php_yaf.h ├── requests ├── yaf_request_http.c ├── yaf_request_http.h ├── yaf_request_simple.c └── yaf_request_simple.h ├── responses ├── yaf_response_cli.c ├── yaf_response_cli.h ├── yaf_response_http.c └── yaf_response_http.h ├── routes ├── yaf_route_interface.c ├── yaf_route_interface.h ├── yaf_route_map.c ├── yaf_route_map.h ├── yaf_route_regex.c ├── yaf_route_regex.h ├── yaf_route_rewrite.c ├── yaf_route_rewrite.h ├── yaf_route_simple.c ├── yaf_route_simple.h ├── yaf_route_static.c ├── yaf_route_static.h ├── yaf_route_supervar.c └── yaf_route_supervar.h ├── tests ├── 001.phpt ├── 002.phpt ├── 003.phpt ├── 004.phpt ├── 005.phpt ├── 006.phpt ├── 007.phpt ├── 008.phpt ├── 009.phpt ├── 010.phpt ├── 011.phpt ├── 012.phpt ├── 013.phpt ├── 014.phpt ├── 015.phpt ├── 016.phpt ├── 017.phpt ├── 018.phpt ├── 019.phpt ├── 020.phpt ├── 021.phpt ├── 022.phpt ├── 023.phpt ├── 024.phpt ├── 025.phpt ├── 026.phpt ├── 027.phpt ├── 028.phpt ├── 029.phpt ├── 030.phpt ├── 031.phpt ├── 032.phpt ├── 033.phpt ├── 034.phpt ├── 035.phpt ├── 036.phpt ├── 037.phpt ├── 038.phpt ├── 039.phpt ├── 040.phpt ├── 041.phpt ├── 042.phpt ├── 043.phpt ├── 044.phpt ├── 045.phpt ├── 046.phpt ├── 047.phpt ├── 048.phpt ├── 049.phpt ├── 050.phpt ├── 051.phpt ├── 052.phpt ├── 053.phpt ├── 054.phpt ├── 055.phpt ├── 056.phpt ├── 057.phpt ├── 058.phpt ├── 059.phpt ├── 060.phpt ├── 061.phpt ├── 062.phpt ├── 063.phpt ├── 064.phpt ├── 065.phpt ├── 066.phpt ├── 067.phpt ├── 068.phpt ├── 069.phpt ├── 070.phpt ├── 071.phpt ├── 072.phpt ├── 073.phpt ├── 074.phpt ├── 075.phpt ├── 076.phpt ├── 077.phpt ├── 078.phpt ├── 079.phpt ├── 080.phpt ├── 081.phpt ├── 082.phpt ├── 083.phpt ├── 084.phpt ├── 085.phpt ├── 086.phpt ├── 087.phpt ├── 088.phpt ├── 089.phpt ├── 090.phpt ├── 091.phpt ├── 092.phpt ├── 093.phpt ├── 094.phpt ├── 095.phpt ├── 096.phpt ├── 097.phpt ├── 098.phpt ├── 099.phpt ├── 100.phpt ├── 101.phpt ├── 102.phpt ├── 103.phpt ├── 104.phpt ├── 105.phpt ├── 106.phpt ├── 107.phpt ├── 108.phpt ├── 109.phpt ├── 110.phpt ├── bug61493.phpt ├── bug62702.phpt ├── bug63381.phpt ├── bug63438.phpt ├── bug63900.phpt ├── bug70913.phpt ├── bug76213.phpt ├── bug76217.phpt ├── build.inc ├── issue134.phpt ├── issue163.phpt ├── issue231.phpt ├── issue232.phpt ├── issue297.phpt ├── issue303.phpt ├── issue311.phpt ├── issue415.phpt ├── issue420.phpt ├── issue468.phpt ├── issue469.phpt ├── issue513.phpt ├── issue518.phpt ├── issue530.phpt ├── issue535.phpt ├── multi-section.ini ├── simple.ini └── system.ini ├── tools ├── cg │ ├── README.md │ ├── templates │ │ ├── .htaccess.tpl │ │ ├── application │ │ │ ├── Bootstrap.php.tpl │ │ │ ├── controllers │ │ │ │ ├── Error.php.tpl │ │ │ │ └── Index.php.tpl │ │ │ ├── library │ │ │ │ └── readme.txt.tpl │ │ │ ├── models │ │ │ │ └── Sample.php.tpl │ │ │ ├── plugins │ │ │ │ └── Sample.php.tpl │ │ │ └── views │ │ │ │ ├── error │ │ │ │ └── error.phtml.tpl │ │ │ │ └── index │ │ │ │ └── index.phtml.tpl │ │ ├── conf │ │ │ └── application.ini.tpl │ │ ├── index.php.tpl │ │ └── readme.txt.tpl │ └── yaf_cg ├── yaf.php └── yaf_classes.php ├── travis ├── compile.sh └── run-test.sh ├── views ├── yaf_view_interface.c ├── yaf_view_interface.h ├── yaf_view_simple.c └── yaf_view_simple.h ├── yaf.c ├── yaf.dsp ├── yaf.php ├── yaf_action.c ├── yaf_action.h ├── yaf_application.c ├── yaf_application.h ├── yaf_application.stub.php ├── yaf_application_arginfo.h ├── yaf_application_legacy_arginfo.h ├── yaf_bootstrap.c ├── yaf_bootstrap.h ├── yaf_config.c ├── yaf_config.h ├── yaf_config.stub.php ├── yaf_config_arginfo.h ├── yaf_config_legacy_arginfo.h ├── yaf_controller.c ├── yaf_controller.h ├── yaf_controller.stub.php ├── yaf_controller_arginfo.h ├── yaf_controller_legacy_arginfo.h ├── yaf_dispatcher.c ├── yaf_dispatcher.h ├── yaf_dispatcher.stub.php ├── yaf_dispatcher_arginfo.h ├── yaf_dispatcher_legacy_arginfo.h ├── yaf_exception.c ├── yaf_exception.h ├── yaf_loader.c ├── yaf_loader.h ├── yaf_loader.stub.php ├── yaf_loader_arginfo.h ├── yaf_loader_legacy_arginfo.h ├── yaf_logo.h ├── yaf_namespace.h ├── yaf_plugin.c ├── yaf_plugin.h ├── yaf_plugin.stub.php ├── yaf_plugin_arginfo.h ├── yaf_registry.c ├── yaf_registry.h ├── yaf_registry.stub.php ├── yaf_registry_arginfo.h ├── yaf_registry_legacy_arginfo.h ├── yaf_request.c ├── yaf_request.h ├── yaf_request.stub.php ├── yaf_request_arginfo.h ├── yaf_request_legacy_arginfo.h ├── yaf_response.c ├── yaf_response.h ├── yaf_response.stub.php ├── yaf_response_arginfo.h ├── yaf_response_legacy_arginfo.h ├── yaf_route.stub.php ├── yaf_route_arginfo.h ├── yaf_route_legacy_arginfo.h ├── yaf_router.c ├── yaf_router.h ├── yaf_router.stub.php ├── yaf_router_arginfo.h ├── yaf_router_legacy_arginfo.h ├── yaf_session.c ├── yaf_session.h ├── yaf_session.stub.php ├── yaf_session_arginfo.h ├── yaf_session_legacy_arginfo.h ├── yaf_view.c ├── yaf_view.h ├── yaf_view.stub.php ├── yaf_view_arginfo.h └── yaf_view_legacy_arginfo.h /.gitattributes: -------------------------------------------------------------------------------- 1 | *.phpt eol=lf 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: laruence # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: # Replace with a single Buy Me a Coffee username 14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 15 | -------------------------------------------------------------------------------- /.github/workflows/integrate.yml: -------------------------------------------------------------------------------- 1 | name: integrate 2 | on: 3 | push: 4 | branches: [ master ] 5 | pull_request: 6 | branches: [ master ] 7 | 8 | jobs: 9 | matrix: 10 | name: "PHP" 11 | runs-on: ubuntu-20.04 12 | strategy: 13 | matrix: 14 | PHP: ["7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"] 15 | ZTS: ["no"] 16 | include: 17 | - PHP: "8.4" 18 | OS: "ubuntu-latest" 19 | ZTS: true 20 | env: 21 | PHP: ${{ matrix.PHP }} 22 | GITHUB: "yes" 23 | enable_debug: "yes" 24 | enable_session: "yes" 25 | enable_maintainer_zts: ${{ matrix.ZTS }} 26 | TEST_PHP_ARGS : "--show-diff" 27 | REPORT_EXIT_STATUS: "yes" 28 | NO_INTERACTION: "yes" 29 | steps: 30 | - name: Checkout 31 | uses: actions/checkout@v2 32 | with: 33 | submodules: true 34 | - name: Setup 35 | uses: shivammathur/setup-php@v2 36 | with: 37 | php-version: ${{ matrix.PHP }} 38 | - name: Install 39 | run: | 40 | sudo apt-get install -y re2c 41 | - name: Prepare 42 | run: | 43 | phpize 44 | - name: Build 45 | run: | 46 | ./configure 47 | - name: Make 48 | run: | 49 | make 50 | - name: Test 51 | run: | 52 | make test 53 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | Yaf 2 | Xinchen Hui 3 | -------------------------------------------------------------------------------- /check-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for src in *.c */*.c *.h */*.h tests/*phpt tests/*ini 4 | do 5 | grep -q $(basename $src) package.xml || echo "Missing $src" 6 | done 7 | -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | // $Id: config.w32 765 2010-10-21 13:04:03Z huixinchen $ 2 | // vim:ft=javascript 3 | 4 | ARG_ENABLE("yaf", "enable yaf support", "no"); 5 | 6 | if (PHP_YAF == "yes") { 7 | 8 | EXTENSION("yaf", "yaf.c yaf_application.c yaf_bootstrap.c yaf_dispatcher.c yaf_exception.c yaf_config.c yaf_request.c yaf_response.c yaf_view.c yaf_controller.c yaf_action.c yaf_router.c yaf_loader.c yaf_registry.c yaf_plugin.c yaf_session.c"); 9 | 10 | ADD_FLAG("CFLAGS_YAF", "/I " + configure_module_dirname); 11 | 12 | ADD_SOURCES(configure_module_dirname + "\\configs", "yaf_config_ini.c yaf_config_simple.c", "yaf"); 13 | ADD_SOURCES(configure_module_dirname + "\\requests", "yaf_request_http.c yaf_request_simple.c", "yaf"); 14 | ADD_SOURCES(configure_module_dirname + "\\responses", "yaf_response_http.c yaf_response_cli.c", "yaf"); 15 | ADD_SOURCES(configure_module_dirname + "\\views", "yaf_view_interface.c yaf_view_simple.c", "yaf"); 16 | ADD_SOURCES(configure_module_dirname + "\\routes", "yaf_route_interface.c yaf_route_static.c yaf_route_simple.c yaf_route_supervar.c yaf_route_regex.c yaf_route_rewrite.c yaf_route_map.c", "yaf"); 17 | 18 | AC_DEFINE("HAVE_YAF", 1, "Have Yaf Support"); 19 | } 20 | -------------------------------------------------------------------------------- /configs/yaf_config_ini.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_CONFIG_INI_H 18 | #define YAF_CONFIG_INI_H 19 | 20 | #define YAF_CONFIG_INI_PARSING_START 0 21 | #define YAF_CONFIG_INI_PARSING_PROCESS 1 22 | #define YAF_CONFIG_INI_PARSING_END 2 23 | 24 | #define YAF_CONFIG_PARSER_FLAG() YAF_VAR_FLAGS(YAF_G(active_ini_file_section)) 25 | 26 | extern zend_class_entry *yaf_config_ini_ce; 27 | 28 | int yaf_config_ini_init(yaf_config_object *conf, zval *filename, zend_string *section); 29 | 30 | YAF_STARTUP_FUNCTION(config_ini); 31 | 32 | #endif 33 | /* 34 | * Local variables: 35 | * tab-width: 4 36 | * c-basic-offset: 4 37 | * End: 38 | * vim600: noet sw=4 ts=4 fdm=marker 39 | * vim<600: noet sw=4 ts=4 40 | */ 41 | -------------------------------------------------------------------------------- /configs/yaf_config_simple.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_CONFIG_SIMPLE_H 18 | #define YAF_CONFIG_SIMPLE_H 19 | 20 | extern zend_class_entry *yaf_config_simple_ce; 21 | 22 | void yaf_config_simple_init(yaf_config_object *conf, zval *values, int readonly); 23 | 24 | YAF_STARTUP_FUNCTION(config_simple); 25 | 26 | #endif 27 | /* 28 | * Local variables: 29 | * tab-width: 4 30 | * c-basic-offset: 4 31 | * End: 32 | * vim600: noet sw=4 ts=4 fdm=marker 33 | * vim<600: noet sw=4 ts=4 34 | */ 35 | -------------------------------------------------------------------------------- /requests/yaf_request_http.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_REQUEST_HTTP_H 18 | #define YAF_REQUEST_HTTP_H 19 | 20 | extern zend_class_entry *yaf_request_http_ce; 21 | 22 | void yaf_request_http_init(yaf_request_object *request, zend_string *request_uri, zend_string *base_uri); 23 | 24 | YAF_STARTUP_FUNCTION(request_http); 25 | 26 | #endif 27 | /* 28 | * Local variables: 29 | * tab-width: 4 30 | * c-basic-offset: 4 31 | * End: 32 | * vim600: noet sw=4 ts=4 fdm=marker 33 | * vim<600: noet sw=4 ts=4 34 | */ 35 | -------------------------------------------------------------------------------- /requests/yaf_request_simple.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_REQUEST_SIMPLE_H 18 | #define YAF_REQUEST_SIMPLE_H 19 | 20 | extern zend_class_entry yaf_request_simpile_ce; 21 | 22 | void yaf_request_simple_instance(yaf_request_object *request, zval *module, zval *controller, zval *action, zval *method, zval *params); 23 | YAF_STARTUP_FUNCTION(request_simple); 24 | 25 | #endif 26 | 27 | /* 28 | * Local variables: 29 | * tab-width: 4 30 | * c-basic-offset: 4 31 | * End: 32 | * vim600: noet sw=4 ts=4 fdm=marker 33 | * vim<600: noet sw=4 ts=4 34 | */ 35 | -------------------------------------------------------------------------------- /responses/yaf_response_cli.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include "php.h" 22 | 23 | #include "php_yaf.h" 24 | #include "yaf_namespace.h" 25 | #include "yaf_response.h" 26 | #include "yaf_exception.h" 27 | 28 | #include "responses/yaf_response_cli.h" 29 | 30 | zend_class_entry * yaf_response_cli_ce; 31 | 32 | /** {{{ yaf_response_methods 33 | */ 34 | zend_function_entry yaf_response_cli_methods[] = { 35 | {NULL, NULL, NULL} 36 | }; 37 | /* }}} */ 38 | 39 | /** {{{ YAF_STARTUP_FUNCTION 40 | */ 41 | YAF_STARTUP_FUNCTION(response_cli) { 42 | zend_class_entry ce; 43 | 44 | YAF_INIT_CLASS_ENTRY(ce, "Yaf_Response_Cli", "Yaf\\Response\\Cli", yaf_response_cli_methods); 45 | 46 | yaf_response_cli_ce = zend_register_internal_class_ex(&ce, yaf_response_ce); 47 | 48 | return SUCCESS; 49 | } 50 | /* }}} */ 51 | 52 | /* 53 | * Local variables: 54 | * tab-width: 4 55 | * c-basic-offset: 4 56 | * End: 57 | * vim600: noet sw=4 ts=4 fdm=marker 58 | * vim<600: noet sw=4 ts=4 59 | */ 60 | -------------------------------------------------------------------------------- /responses/yaf_response_cli.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef PHP_YAF_RESPONSE_CLI_H 18 | #define PHP_YAF_RESPONSE_CLI_H 19 | 20 | extern zend_class_entry *yaf_response_cli_ce; 21 | 22 | YAF_STARTUP_FUNCTION(response_cli); 23 | 24 | #endif 25 | 26 | /* 27 | * Local variables: 28 | * tab-width: 4 29 | * c-basic-offset: 4 30 | * End: 31 | * vim600: noet sw=4 ts=4 fdm=marker 32 | * vim<600: noet sw=4 ts=4 33 | */ 34 | -------------------------------------------------------------------------------- /responses/yaf_response_http.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | 18 | #ifndef PHP_YAF_RESPONSE_HTTP_H 19 | #define PHP_YAF_RESPONSE_HTTP_H 20 | 21 | #define YAF_RESPONSE_PROPERTY_NAME_RESPONSECODE "_response_code" 22 | 23 | extern zend_class_entry *yaf_response_http_ce; 24 | 25 | int yaf_response_alter_header(yaf_response_object *response, zend_string *name, zend_string *value, unsigned rep); 26 | zval *yaf_response_get_header(yaf_response_object *response, zend_string *name); 27 | int yaf_response_clear_header(yaf_response_object *response, zend_string *name); 28 | int yaf_response_http_send(yaf_response_object *response); 29 | 30 | YAF_STARTUP_FUNCTION(response_http); 31 | 32 | #endif 33 | 34 | /* 35 | * Local variables: 36 | * tab-width: 4 37 | * c-basic-offset: 4 38 | * End: 39 | * vim600: noet sw=4 ts=4 fdm=marker 40 | * vim<600: noet sw=4 ts=4 41 | */ 42 | -------------------------------------------------------------------------------- /routes/yaf_route_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ROUTER_INTERFACE_H 18 | #define YAF_ROUTER_INTERFACE_H 19 | 20 | #define YAF_ROUTE_ASSEMBLE_MOUDLE_FORMAT ":m" 21 | #define YAF_ROUTE_ASSEMBLE_ACTION_FORMAT ":a" 22 | #define YAF_ROUTE_ASSEMBLE_CONTROLLER_FORMAT ":c" 23 | 24 | extern zend_class_entry *yaf_route_ce; 25 | 26 | int yaf_route_instance(yaf_route_t *route, HashTable *config); 27 | 28 | YAF_STARTUP_FUNCTION(route); 29 | 30 | #endif 31 | /* 32 | * Local variables: 33 | * tab-width: 4 34 | * c-basic-offset: 4 35 | * End: 36 | * vim600: noet sw=4 ts=4 fdm=marker 37 | * vim<600: noet sw=4 ts=4 38 | */ 39 | -------------------------------------------------------------------------------- /routes/yaf_route_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ROUTER_MAP_H 18 | #define YAF_ROUTER_MAP_H 19 | 20 | #define YAF_ROUTE_MAP_CTL_PREFER (1<<0) 21 | 22 | typedef struct { 23 | zend_object std; 24 | zend_string *delim; 25 | zend_array *properties; 26 | zend_uchar flags; 27 | } yaf_route_map_object; 28 | 29 | #define Z_YAFROUTEMAPOBJ(zv) ((yaf_route_map_object*)(Z_OBJ(zv))) 30 | #define Z_YAFROUTEMAPOBJ_P(zv) Z_YAFROUTEMAPOBJ(*zv) 31 | 32 | extern zend_class_entry *yaf_route_map_ce; 33 | 34 | void yaf_route_map_instance(yaf_route_t *route, zend_bool controller_prefer, zend_string *delim); 35 | int yaf_route_map_route(yaf_route_t *route, yaf_request_t *req); 36 | 37 | YAF_STARTUP_FUNCTION(route_map); 38 | 39 | #endif 40 | /* 41 | * Local variables: 42 | * tab-width: 4 43 | * c-basic-offset: 4 44 | * End: 45 | * vim600: noet sw=4 ts=4 fdm=marker 46 | * vim<600: noet sw=4 ts=4 47 | */ 48 | -------------------------------------------------------------------------------- /routes/yaf_route_regex.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ROUTER_REGEX_H 18 | #define YAF_ROUTER_REGEX_H 19 | 20 | typedef struct { 21 | zend_object std; 22 | zend_string *match; 23 | zend_array *router; 24 | zend_array *map; 25 | zend_array *verify; 26 | zend_string *reverse; 27 | zend_array *properties; 28 | } yaf_route_regex_object; 29 | 30 | #define Z_YAFROUTEREGEXOBJ(zv) ((yaf_route_regex_object*)(Z_OBJ(zv))) 31 | #define Z_YAFROUTEREGEXOBJ_P(zv) Z_YAFROUTEREGEXOBJ(*zv) 32 | 33 | extern zend_class_entry *yaf_route_regex_ce; 34 | 35 | void yaf_route_regex_instance(yaf_route_t *route, zend_string *match, zval *router, zval *map, zval *verify, zend_string *reverse); 36 | int yaf_route_regex_route(yaf_route_t *route, yaf_request_t *req); 37 | 38 | YAF_STARTUP_FUNCTION(route_regex); 39 | 40 | #endif 41 | /* 42 | * Local variables: 43 | * tab-width: 4 44 | * c-basic-offset: 4 45 | * End: 46 | * vim600: noet sw=4 ts=4 fdm=marker 47 | * vim<600: noet sw=4 ts=4 48 | */ 49 | -------------------------------------------------------------------------------- /routes/yaf_route_rewrite.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ROUTER_REWRITE_H 18 | #define YAF_ROUTER_REWRITE_H 19 | 20 | typedef struct { 21 | zend_object std; 22 | zend_string *match; 23 | zend_array *router; 24 | zend_array *verify; 25 | zend_array *properties; 26 | } yaf_route_rewrite_object; 27 | 28 | #define Z_YAFROUTEREWRITEOBJ(zv) ((yaf_route_rewrite_object*)(Z_OBJ(zv))) 29 | #define Z_YAFROUTEREWRITEOBJ_P(zv) Z_YAFROUTEREWRITEOBJ(*zv) 30 | 31 | extern zend_class_entry *yaf_route_rewrite_ce; 32 | 33 | void yaf_route_rewrite_instance(yaf_route_t *route, zend_string *match, zval *router, zval *verify); 34 | int yaf_route_rewrite_route(yaf_route_t *route, yaf_request_t *req); 35 | 36 | YAF_STARTUP_FUNCTION(route_rewrite); 37 | 38 | #endif 39 | /* 40 | * Local variables: 41 | * tab-width: 4 42 | * c-basic-offset: 4 43 | * End: 44 | * vim600: noet sw=4 ts=4 fdm=marker 45 | * vim<600: noet sw=4 ts=4 46 | */ 47 | -------------------------------------------------------------------------------- /routes/yaf_route_simple.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ROUTER_SIMPLE_H 18 | #define YAF_ROUTER_SIMPLE_H 19 | 20 | typedef struct { 21 | zend_object std; 22 | zend_string *m; 23 | zend_string *c; 24 | zend_string *a; 25 | zend_array *properties; 26 | } yaf_route_simple_object; 27 | 28 | #define Z_YAFROUTESIMPLEOBJ(zv) ((yaf_route_simple_object*)(Z_OBJ(zv))) 29 | #define Z_YAFROUTESIMPLEOBJ_P(zv) Z_YAFROUTESIMPLEOBJ(*zv) 30 | 31 | extern zend_class_entry *yaf_route_simple_ce; 32 | 33 | void yaf_route_simple_instance(yaf_route_t *route, zend_string *m, zend_string *c, zend_string *a); 34 | int yaf_route_simple_route(yaf_route_t *route, yaf_request_t *req); 35 | 36 | YAF_STARTUP_FUNCTION(route_simple); 37 | 38 | #endif 39 | /* 40 | * Local variables: 41 | * tab-width: 4 42 | * c-basic-offset: 4 43 | * End: 44 | * vim600: noet sw=4 ts=4 fdm=marker 45 | * vim<600: noet sw=4 ts=4 46 | */ 47 | -------------------------------------------------------------------------------- /routes/yaf_route_static.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ROUTER_STATIC_H 18 | #define YAF_ROUTER_STATIC_H 19 | 20 | extern zend_class_entry *yaf_route_static_ce; 21 | 22 | void yaf_route_pathinfo_route(yaf_request_object *request, const char *req_uri, size_t req_uri_len); 23 | void yaf_route_static_route(yaf_route_t *route, yaf_request_t *req); 24 | 25 | YAF_STARTUP_FUNCTION(route_static); 26 | 27 | #endif 28 | /* 29 | * Local variables: 30 | * tab-width: 4 31 | * c-basic-offset: 4 32 | * End: 33 | * vim600: noet sw=4 ts=4 fdm=marker 34 | * vim<600: noet sw=4 ts=4 35 | */ 36 | -------------------------------------------------------------------------------- /routes/yaf_route_supervar.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ROUTER_SUPERVAR_H 18 | #define YAF_ROUTER_SUPERVAR_H 19 | 20 | typedef struct { 21 | zend_object std; 22 | zend_string *varname; 23 | zend_array *properties; 24 | } yaf_route_supervar_object; 25 | 26 | #define Z_YAFROUTESUPEROBJ(zv) ((yaf_route_supervar_object*)(Z_OBJ(zv))) 27 | #define Z_YAFROUTESUPEROBJ_P(zv) Z_YAFROUTESUPEROBJ(*zv) 28 | 29 | extern zend_class_entry *yaf_route_supervar_ce; 30 | 31 | void yaf_route_supervar_instance(yaf_route_t *route, zend_string *varname); 32 | int yaf_route_supervar_route(yaf_route_t *route, yaf_request_t *req); 33 | 34 | YAF_STARTUP_FUNCTION(route_supervar); 35 | 36 | #endif 37 | /* 38 | * Local variables: 39 | * tab-width: 4 40 | * c-basic-offset: 4 41 | * End: 42 | * vim600: noet sw=4 ts=4 fdm=marker 43 | * vim<600: noet sw=4 ts=4 44 | */ 45 | -------------------------------------------------------------------------------- /tests/001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for yaf presence 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 20 | --EXPECT-- 21 | yaf extension is available 22 | -------------------------------------------------------------------------------- /tests/003.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Loader local names 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | registerLocalNamespace("Baidu"); 14 | $loader->registerLocalNamespace("Sina"); 15 | $loader->registerLocalNamespace(array("Wb", "Inf", NULL, array(), "123")); 16 | var_dump($loader->getLocalNamespace()); 17 | var_dump($loader->isLocalName("Baidu_Name")); 18 | var_dump($loader->isLocalName("Inf\\Name")); 19 | 20 | try { 21 | var_dump($loader->autoload("Baidu_Name")); 22 | } catch (Yaf_Exception_LoadFailed $e) { 23 | var_dump($e->getMessage()); 24 | } 25 | try { 26 | var_dump($loader->autoload("Global_Name")); 27 | } catch (Yaf_Exception_LoadFailed $e) { 28 | var_dump($e->getMessage()); 29 | } 30 | 31 | ?> 32 | --EXPECTF-- 33 | array(5) { 34 | [0]=> 35 | string(5) "Baidu" 36 | [1]=> 37 | string(4) "Sina" 38 | [2]=> 39 | string(2) "Wb" 40 | [3]=> 41 | string(3) "Inf" 42 | [4]=> 43 | string(3) "123" 44 | } 45 | bool(true) 46 | bool(true) 47 | 48 | Warning: Yaf_Loader::autoload(): Failed opening script %sBaidu%cName.php: No such file or directory in %s 49 | bool(true) 50 | 51 | Warning: Yaf_Loader::autoload(): Failed opening script %sglobal%cGlobal%cName.php: No such file or directory in %s 52 | bool(true) 53 | -------------------------------------------------------------------------------- /tests/004.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Registry APIs 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | 26 | --EXPECT-- 27 | string(14) "Ageli Platform" 28 | bool(true) 29 | NULL 30 | bool(false) 31 | -------------------------------------------------------------------------------- /tests/005.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Response_Cli APIs 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | appendBody($body); 19 | $response->prependBody($string); 20 | $response->appendBody("|footer"); 21 | 22 | $body = $response->getBody(); 23 | unset($body); 24 | 25 | var_dump(Yaf_Response_Abstract::DEFAULT_BODY); 26 | print_r($response->getBody(NULL)); 27 | var_dump($response->getBody(Yaf_Response_Http::DEFAULT_BODY)); 28 | unset($string); 29 | var_dump($response->getBody()); 30 | echo($response); 31 | echo "\n"; 32 | var_dump($response->getBody()); 33 | $response->response(); 34 | echo "\n"; 35 | var_dump($response->getBody()); 36 | ?> 37 | --EXPECTF-- 38 | string(7) "content" 39 | Array 40 | ( 41 | [content] => header|yaf|footer 42 | ) 43 | string(17) "header|yaf|footer" 44 | string(17) "header|yaf|footer" 45 | header|yaf|footer 46 | string(17) "header|yaf|footer" 47 | header|yaf|footer 48 | string(17) "header|yaf|footer" 49 | -------------------------------------------------------------------------------- /tests/006.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Static routing 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | route($request)); 20 | 21 | print_r($request); 22 | ?> 23 | --EXPECTF-- 24 | bool(true) 25 | Yaf_Request_Http Object 26 | ( 27 | [method] => CLI 28 | [module] => 29 | [controller] => Controller 30 | [action] => action 31 | [uri:protected] => /prefix/controller/action/name/laruence/age/28 32 | [base_uri:protected] => /prefix 33 | [dispatched:protected] => 34 | [routed:protected] => 35 | [language:protected] => 36 | [params:protected] => Array 37 | ( 38 | [name] => laruence 39 | [age] => 28 40 | ) 41 | 42 | ) 43 | -------------------------------------------------------------------------------- /tests/008.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Router basic usages 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | addRoute("simple", $route)->addRoute("super", $sroute); 16 | print_r($router); 17 | var_dump($router->getCurrentRoute()); 18 | print_r($router->getRoutes()); 19 | print_r($router->getRoute("simple")); 20 | var_dump($router->getRoute("noexists")); 21 | ?> 22 | --EXPECTF-- 23 | Yaf_Router Object 24 | ( 25 | [routes:protected] => Array 26 | ( 27 | [_default] => Yaf_Route_Static Object 28 | ( 29 | ) 30 | 31 | [simple] => Yaf_Route_Simple Object 32 | ( 33 | [module:protected] => m 34 | [controller:protected] => c 35 | [action:protected] => a 36 | ) 37 | 38 | [super] => Yaf_Route_Supervar Object 39 | ( 40 | [varname:protected] => r 41 | ) 42 | 43 | ) 44 | 45 | [current:protected] => 46 | ) 47 | NULL 48 | Array 49 | ( 50 | [_default] => Yaf_Route_Static Object 51 | ( 52 | ) 53 | 54 | [simple] => Yaf_Route_Simple Object 55 | ( 56 | [module:protected] => m 57 | [controller:protected] => c 58 | [action:protected] => a 59 | ) 60 | 61 | [super] => Yaf_Route_Supervar Object 62 | ( 63 | [varname:protected] => r 64 | ) 65 | 66 | ) 67 | Yaf_Route_Simple Object 68 | ( 69 | [module:protected] => m 70 | [controller:protected] => c 71 | [action:protected] => a 72 | ) 73 | NULL 74 | -------------------------------------------------------------------------------- /tests/009.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_View_Simple basic usages 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | assign("name", $value); 12 | unset($value); 13 | print_r($view); 14 | var_dump(strlen($view->render(dirname(__FILE__) . "/001.phpt"))); 15 | var_dump($view->name); 16 | var_dump($view->noexists); 17 | print_r($view); 18 | ?> 19 | --EXPECTF-- 20 | Yaf_View_Simple Object 21 | ( 22 | [tpl_dir:protected] => %s 23 | [tpl_vars:protected] => Array 24 | ( 25 | [name] => laruence 26 | ) 27 | 28 | ) 29 | int(116) 30 | string(8) "laruence" 31 | NULL 32 | Yaf_View_Simple Object 33 | ( 34 | [tpl_dir:protected] => %s 35 | [tpl_vars:protected] => Array 36 | ( 37 | [name] => laruence 38 | ) 39 | 40 | ) 41 | -------------------------------------------------------------------------------- /tests/011.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Rewrite routing 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | "version", 17 | ) 18 | ); 19 | 20 | $router->addRoute("subdir", $route)->addRoute("ap", new Yaf_Route_Rewrite( 21 | "/ap/:version/*", 22 | array( 23 | "action" => 'ap', 24 | ) 25 | ))->route($request); 26 | 27 | var_dump($router->getCurrentRoute()); 28 | var_dump($request->getParam('version')); 29 | var_dump($request->getActionName()); 30 | var_dump($request->getControllerName()); 31 | var_dump($request->getParam('name')); 32 | 33 | ?> 34 | --EXPECTF-- 35 | string(2) "ap" 36 | string(3) "1.2" 37 | string(2) "ap" 38 | NULL 39 | string(5) "value" 40 | -------------------------------------------------------------------------------- /tests/012.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Regex 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | "version", 17 | ), 18 | array( 19 | ) 20 | ); 21 | 22 | $router->addRoute("subdir", $route)->addRoute("ap", new Yaf_Route_Regex( 23 | "#^/ap/([^/]*)/*#i", 24 | array( 25 | "action" => 'ap', 26 | ), 27 | array( 28 | 1 => 'version', 29 | ) 30 | ))->route($request); 31 | 32 | var_dump($router->getCurrentRoute()); 33 | var_dump($request->getParam('version')); 34 | var_dump($request->getActionName()); 35 | var_dump($request->getControllerName()); 36 | var_dump($request->getParam('name')); 37 | 38 | ?> 39 | --EXPECTF-- 40 | string(2) "ap" 41 | string(3) "1.2" 42 | string(2) "ap" 43 | NULL 44 | NULL 45 | -------------------------------------------------------------------------------- /tests/015.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Exception 3 | --SKIPIF-- 4 | 5 | 6 | --INI-- 7 | yaf.use_namespace=0 8 | --FILE-- 9 | getPrevious()); 14 | var_dump($exception->getMessage()); 15 | var_dump($exception->getPrevious()->getCode()); 16 | ?> 17 | --EXPECTF-- 18 | bool(true) 19 | string(9) "Exception" 20 | int(100) 21 | -------------------------------------------------------------------------------- /tests/016.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Session 3 | --SKIPIF-- 4 | 5 | 6 | --INI-- 7 | yaf.use_namespace=0 8 | session.save_handler=files 9 | session.save_path= 10 | --FILE-- 11 | age = $age; 18 | unset($age); 19 | 20 | unset($session); 21 | $session2 = Yaf_Session::getInstance(); 22 | $session2["company"] = "Baidu"; 23 | 24 | var_dump(isset($session2->age)); 25 | var_dump($session2->has("name")); 26 | var_dump(count($session2)); 27 | foreach ($session2 as $key => $value) { 28 | echo $key , "=>", $value, "\n"; 29 | } 30 | 31 | unset($session2); 32 | $session3 = Yaf_Session::getInstance(); 33 | 34 | $session3->del("name"); 35 | unset($session3["company"]); 36 | unset($session3->age); 37 | 38 | var_dump(count($session3)); 39 | ?> 40 | --EXPECTF-- 41 | bool(true) 42 | bool(true) 43 | int(3) 44 | name=>Laruence 45 | age=>28 46 | company=>Baidu 47 | int(0) 48 | -------------------------------------------------------------------------------- /tests/017.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug (mem leak and crash in Yaf_Config_Ini) 3 | --SKIPIF-- 4 | 9 | --INI-- 10 | yaf.use_namespace=0 11 | --FILE-- 12 | get("\0")); 17 | ?> 18 | --EXPECTF-- 19 | Fatal error: Uncaught ArgumentCountError: Yaf_Config_Ini::__construct() expects at least 1%s, 0 given in %s017.php:%d 20 | Stack trace: 21 | #0 %s017.php(%d): Yaf_Config_Ini->__construct() 22 | #1 {main} 23 | thrown in %s017.php on line %d -------------------------------------------------------------------------------- /tests/019.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Yaf_Router::getCurrent with number key 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | addConfig( 14 | array( 15 | array( 16 | "type" => "regex", 17 | "match" => "#^/ap/([^/]*)/*#i", 18 | "route" => array( 19 | array( 20 | "action" => 'ap', 21 | ), 22 | ), 23 | "map" => array( 24 | 1 => 'version', 25 | ) 26 | ) 27 | ) 28 | )->route($request); 29 | 30 | var_dump($router->getCurrentRoute()); 31 | var_dump($request->getParam("version")); 32 | 33 | ?> 34 | --EXPECT-- 35 | int(0) 36 | string(3) "1.2" 37 | -------------------------------------------------------------------------------- /tests/020.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Application errors variables 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | array( 11 | "directory" => realpath(dirname(__FILE__)), 12 | "dispatcher" => array( 13 | "catchException" => 0, 14 | "throwException" => 0, 15 | ), 16 | ), 17 | ); 18 | 19 | function error_handler($errno, $errstr, $errfile, $errline) { 20 | var_dump(Yaf_Application::app()->getLastErrorNo()); 21 | var_dump(Yaf_Application::app()->getLastErrorMsg()); 22 | Yaf_Application::app()->clearLastError(); 23 | var_dump(Yaf_Application::app()->getLastErrorNo()); 24 | var_dump(Yaf_Application::app()->getLastErrorMsg()); 25 | } 26 | 27 | $app = new Yaf_Application($config); 28 | $app->getDispatcher()->setErrorHandler("error_handler", E_RECOVERABLE_ERROR); 29 | $app->run(); 30 | ?> 31 | --EXPECTF-- 32 | int(516) 33 | string(%d) "Failed opening controller script %s: %s" 34 | int(0) 35 | string(0) "" 36 | -------------------------------------------------------------------------------- /tests/021.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Application error handler 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | getDispatcher()->setErrorHandler("error_handler", E_RECOVERABLE_ERROR); 19 | $app->run(); 20 | ?> 21 | --EXPECTF-- 22 | error occurrd instead of exception threw 23 | -------------------------------------------------------------------------------- /tests/022.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Application::get/setAppDirectory 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | array( 11 | "directory" => realpath(dirname(__FILE__)), 12 | "dispatcher" => array( 13 | "catchException" => 0, 14 | "throwException" => 0, 15 | ), 16 | ), 17 | ); 18 | 19 | $app = new Yaf_Application($config); 20 | var_dump($app->getAppDirectory()); 21 | $dir = $app->getAppDirectory() . "/tmp"; 22 | mkdir($dir); 23 | $app->setAppDirectory($dir); 24 | var_dump($app->getAppDirectory()); 25 | $app->run(); 26 | ?> 27 | --CLEAN-- 28 | 31 | --EXPECTF-- 32 | string(%d) "%stests" 33 | string(%d) "%stmp" 34 | 35 | %s fatal error: Yaf_Application::run(): Failed opening controller script %stmp%ccontrollers%cIndex.php: No such file or directory in %s022.php on line %d 36 | -------------------------------------------------------------------------------- /tests/023.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Loader::set/get(library_path) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | registerLocalNamespace(array("Foo")); 13 | 14 | $loader->autoload("Foo_Bar"); 15 | $loader->autoload("Bar_Foo"); 16 | 17 | $loader->setLibraryPath("/foobar", FALSE); 18 | $loader->autoload("Foo_Bar"); 19 | $loader->autoload("Bar_Foo"); 20 | 21 | $loader->setLibraryPath("/foobar", TRUE); 22 | $loader->autoload("Foo_Bar"); 23 | $loader->autoload("Bar_Foo"); 24 | 25 | $loader->autoload("Model"); 26 | $loader->autoload("Bar_Model"); 27 | ?> 28 | --EXPECTF-- 29 | Warning: Yaf_Loader::autoload(): Failed opening script /foo%cFoo%cBar.php: No such file or directory in %s023.php on line %d 30 | 31 | Warning: Yaf_Loader::autoload(): Failed opening script /bar%cBar%cFoo.php: No such file or directory in %s023.php on line %d 32 | 33 | Warning: Yaf_Loader::autoload(): Failed opening script /foobar%cFoo%cBar.php: No such file or directory in %s023.php on line %d 34 | 35 | Warning: Yaf_Loader::autoload(): Failed opening script /bar%cBar%cFoo.php: No such file or directory in %s023.php on line %d 36 | 37 | Warning: Yaf_Loader::autoload(): Failed opening script /foobar%cFoo%cBar.php: No such file or directory in %s023.php on line %d 38 | 39 | Warning: Yaf_Loader::autoload(): Failed opening script %cfoobar%cBar%cFoo.php: No such file or directory in %s023.php on line %d 40 | 41 | Warning: Yaf_Loader::autoload(): Failed opening script %cfoobar%cModel.php: No such file or directory in %s023.php on line %d 42 | 43 | Warning: Yaf_Loader::autoload(): Couldn't load a MVC class unless an Yaf_Application is initialized in %s023.php on line %d 44 | -------------------------------------------------------------------------------- /tests/024.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Loader::getInstace() paramters 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | --FILE-- 9 | getLibraryPath()); 13 | var_dump($loader->getLibraryPath(TRUE)); 14 | $config = array( 15 | "application" => array( 16 | "directory" => realpath(dirname(__FILE__)), 17 | ), 18 | ); 19 | 20 | $app = new Yaf_Application($config); 21 | $loader = Yaf_Loader::getInstance(NULL, '/bar'); 22 | var_dump($loader->getLibraryPath()); 23 | var_dump($loader->getLibraryPath(TRUE)); 24 | ?> 25 | --EXPECTF-- 26 | string(4) "/foo" 27 | string(15) "/php/global/dir" 28 | string(%d) "%slibrary" 29 | string(4) "/bar" 30 | -------------------------------------------------------------------------------- /tests/025.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Loader with namespace configuration 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | yaf.use_spl_autoload=0 9 | yaf.lowercase_path=0 10 | --FILE-- 11 | array( 14 | "directory" => realpath(dirname(__FILE__)), 15 | "library" => array( 16 | "directory" => "/tmp", 17 | "namespace" => "Foo, Bar", 18 | ), 19 | ), 20 | ); 21 | 22 | $app = new Yaf_Application($config); 23 | Yaf_Loader::getInstance()->registerLocalNamespace("Dummy"); 24 | print_r(Yaf_Loader::getInstance()); 25 | var_dump(Yaf_Loader::getInstance()->isLocalName("Bar_Name")); 26 | 27 | ?> 28 | --EXPECTF-- 29 | Yaf_Loader Object 30 | ( 31 | [library:protected] => /tmp 32 | [global_library:protected] => /php/global/dir 33 | [namespace:protected] => Array 34 | ( 35 | [0] => Foo 36 | [1] => Bar 37 | [2] => Dummy 38 | ) 39 | 40 | [use_spl_autoload:protected] => 41 | [lowercase_path:protected] => 42 | [is_name_suffix:protected] => 1 43 | [has_name_seperator:protected] => 44 | ) 45 | bool(true) 46 | -------------------------------------------------------------------------------- /tests/026.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Response::setBody/prependBody/appendBody 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | --FILE-- 9 | setBody("ell")->appendBody("o")->setBody(" W", "footer")->prependBody("H")->appendBody("orld", "footer"); 12 | print_r($response); 13 | echo $response; 14 | ?> 15 | --EXPECTF-- 16 | Yaf_Response_Http Object 17 | ( 18 | [response_code:protected] => 0 19 | [header_sent:protected] => 20 | [header:protected] => Array 21 | ( 22 | ) 23 | 24 | [body:protected] => Array 25 | ( 26 | [content] => Hello 27 | [footer] => World 28 | ) 29 | 30 | ) 31 | Hello World 32 | -------------------------------------------------------------------------------- /tests/027.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf autoload controller 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.library="/php/global/dir" 8 | yaf.environ="product" 9 | yaf.use_namespace=0 10 | --FILE-- 11 | array( 14 | "directory" => realpath(dirname(__FILE__)), 15 | "dispatcher" => array( 16 | "catchException" => 0, 17 | "throwException" => 0, 18 | ), 19 | ), 20 | ); 21 | 22 | function main() { 23 | $dummy = new NoExistsController(); 24 | } 25 | 26 | $app = new Yaf_Application($config); 27 | var_dump($app->environ()); 28 | var_dump(count($app->getConfig()->application)); 29 | $app->execute("main"); 30 | $app->execute(123); 31 | ?> 32 | --EXPECTF-- 33 | string(7) "product" 34 | int(2) 35 | 36 | Warning: Yaf_Loader::autoload(): Failed opening script %scontrollers%cNoExists.php: No such file or directory in %s027.php on line %d 37 | 38 | Fatal error: Uncaught Error: Class %sNoExistsController%s not found in %s027.php:%d 39 | %a 40 | 41 | -------------------------------------------------------------------------------- /tests/028.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug segfault while call exit in a view template 3 | --SKIPIF-- 4 | ='8.0.0' ) print "skip"; ?> 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | --FILE-- 9 | assign("name", "laruence"); 16 | $tpl = APPLICATION_PATH . '/tpls/foo.phtml'; 17 | 18 | file_put_contents($tpl, << 21 | HTML 22 | ); 23 | echo $view->render($tpl); 24 | ?> 25 | --CLEAN-- 26 | 31 | --EXPECTF-- 32 | okey 33 | -------------------------------------------------------------------------------- /tests/029.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_View_Simple::get and clear 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | --FILE-- 9 | assign("a", "b"); 12 | $view->assign("b", "a"); 13 | print_r($view->get("a")); 14 | print_r($view->get()); 15 | $view->clear("b"); 16 | print_r($view->get()); 17 | var_dump(empty($view->a)); 18 | var_dump(isset($view->a)); 19 | $view->clear(); 20 | print_r($view->get()); 21 | var_dump(empty($view->a)); 22 | var_dump(isset($view->a)); 23 | ?> 24 | --EXPECTF-- 25 | bArray 26 | ( 27 | [a] => b 28 | [b] => a 29 | ) 30 | Array 31 | ( 32 | [a] => b 33 | ) 34 | bool(false) 35 | bool(true) 36 | Array 37 | ( 38 | ) 39 | bool(true) 40 | bool(false) 41 | -------------------------------------------------------------------------------- /tests/030.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Config_Ini::__construct with section 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | --FILE-- 9 | getMessage()); 16 | } 17 | 18 | ?> 19 | --EXPECTF-- 20 | There is no section 'ex' in '%ssimple.ini' 21 | -------------------------------------------------------------------------------- /tests/031.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for application.dispatcher.defaultRoute 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | --FILE-- 9 | array( 12 | "directory" => realpath(dirname(__FILE__)), 13 | "dispatcher" => array( 14 | "defaultRoute" => array( 15 | "type" => "map", 16 | "delimiter" => '##', 17 | "controllerPrefer" => 1, 18 | ), 19 | ), 20 | ), 21 | ); 22 | 23 | $app = new Yaf_Application($config); 24 | print_r($app->getDispatcher()->getRouter()->getRoutes()); 25 | var_export($app->getDispatcher()->getRouter()->getRoutes()); 26 | ?> 27 | --EXPECTF-- 28 | Array 29 | ( 30 | [_default] => Yaf_Route_Map Object 31 | ( 32 | [ctl_prefer:protected] => 1 33 | [delimiter:protected] => ## 34 | ) 35 | 36 | ) 37 | array ( 38 | '_default' => 39 | %saf_Route_Map::__set_state(array( 40 | 'ctl_prefer:protected' => true, 41 | 'delimiter:protected' => '##', 42 | )), 43 | ) 44 | -------------------------------------------------------------------------------- /tests/032.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Config_Ini with env 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | yaf.directory=/foo/bar 12 | yaf.use_namespace=0 13 | --FILE-- 14 | 20 | --EXPECTF-- 21 | Yaf_Config_Ini Object 22 | ( 23 | [readonly:protected] => 1 24 | [config:protected] => Array 25 | ( 26 | [env] => bar 27 | [ini] => /foo/bar 28 | [const] => Dummy 29 | ) 30 | 31 | [filename:protected] => %s 32 | ) 33 | -------------------------------------------------------------------------------- /tests/033.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_View_Simple with predefined template dir 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | array( 11 | "directory" => realpath(dirname(__FILE__)), 12 | "dispatcher" => array( 13 | "catchException" => 0, 14 | "throwException" => 1, 15 | ), 16 | "modules" => "module", 17 | ), 18 | ); 19 | 20 | class ControllerController extends Yaf_Controller_Abstract { 21 | public function actionAction() { 22 | } 23 | 24 | public function indexAction() { 25 | Yaf_Dispatcher::getInstance()->disableView(); 26 | $this->forward("dummy"); 27 | } 28 | 29 | public function dummyAction() { 30 | Yaf_Dispatcher::getInstance()->enableView(); 31 | } 32 | } 33 | 34 | 35 | $app = new Yaf_Application($config); 36 | $request = new Yaf_Request_Http("/module/controller/action"); 37 | 38 | try { 39 | $app->getDispatcher()->returnResponse(false)->dispatch($request); 40 | } catch (Yaf_Exception $e) { 41 | echo $e->getMessage(), "\n"; 42 | } 43 | 44 | $view = new Yaf_View_Simple(dirname(__FILE__) . 'no-exists'); 45 | $app->getDispatcher()->setView($view); 46 | try { 47 | $app->getDispatcher()->returnResponse(false)->dispatch($request); 48 | } catch (Yaf_Exception $e) { 49 | echo $e->getMessage(), "\n"; 50 | } 51 | 52 | $request = new Yaf_Request_Http("/module/controller/index"); 53 | try { 54 | $app->getDispatcher()->returnResponse(false)->dispatch($request); 55 | } catch (Yaf_Exception $e) { 56 | echo $e->getMessage(), "\n"; 57 | } 58 | ?> 59 | --EXPECTF-- 60 | Failed opening template %stests%cmodules%cModule%cviews%ccontroller%caction.phtml: No such file or directory 61 | Failed opening template %stestsno-exists%ccontroller%caction.phtml: No such file or directory 62 | Failed opening template %stestsno-exists%ccontroller%cdummy.phtml: No such file or directory 63 | -------------------------------------------------------------------------------- /tests/034.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_View_Simple::eval 3 | --SKIPIF-- 4 | 10 | --INI-- 11 | yaf.use_namespace=0 12 | --FILE-- 13 | 23 | 24 | PHP; 25 | 26 | $view->assign("entry", array('a', 'b', 'c')); 27 | echo $view->eval($tpl, array('name' => 'template')); 28 | 29 | ?> 30 | --EXPECTF-- 31 | template 32 | 1. a 33 | 1. b 34 | 1. c 35 | template 36 | -------------------------------------------------------------------------------- /tests/035.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_View_Simple with short_tag_open 3 | --SKIPIF-- 4 | = 0) { 7 | print "skip PHP 5.4 remove short_open_tag"; 8 | } 9 | ?> 10 | --INI-- 11 | short_open_tag = 0 12 | yaf.use_namespace=0 13 | --FILE-- 14 | "; 19 | 20 | file_put_contents($tpl, $content); 21 | 22 | echo $view->render($tpl, array('name' => 'template')); 23 | echo "\n"; 24 | $view->display($tpl, array('name' => 'template')); 25 | $view = new Yaf_View_Simple(dirname(__FILE__), array("short_tag" => 0)); 26 | echo "\n"; 27 | var_dump(ini_get("short_open_tag")); 28 | $view->display($tpl, array('name' => 'template')); 29 | echo "\n"; 30 | print_r($view); 31 | unlink($tpl); 32 | ?> 33 | --EXPECTF-- 34 | template 35 | template 36 | string(1) "0" 37 | 38 | Yaf_View_Simple Object 39 | ( 40 | [_tpl_vars:protected] => Array 41 | ( 42 | ) 43 | 44 | [_tpl_dir:protected] => %s 45 | [_options:protected] => Array 46 | ( 47 | [short_tag] => 0 48 | ) 49 | 50 | ) 51 | -------------------------------------------------------------------------------- /tests/037.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Loader and open_basedir 3 | --SKIPIF-- 4 | 12 | --INI-- 13 | yaf.lowcase_path=0 14 | yaf.use_spl_autoload=0 15 | yaf.use_namespace=0 16 | --FILE-- 17 | import("./Dummy.php")); 23 | var_dump($loader->autoload("Dummy")); 24 | 25 | file_put_contents($dir . "/Dummy.php", ""); 26 | ini_set("open_basedir", $odir); 27 | $loader = Yaf_Loader::getInstance($dir); 28 | $loader->import($dir . "/Dummy.php"); 29 | $loader->autoload("Dummy"); 30 | ?> 31 | --CLEAN-- 32 | 35 | --EXPECTF-- 36 | Warning: Yaf_Loader::import(): Yaf_Loader need to be initialize first in %s037.php on line %d 37 | bool(false) 38 | bool(false) 39 | 40 | Warning: Yaf_Loader::autoload(): Failed opening script %cDummy.php: No such file or directory in %s037.php on line %d 41 | bool(true) 42 | 43 | Warning: Yaf_Loader::import(): open_basedir restriction in effect. File(%sDummy.php) is not within the allowed path(s): (%sfoo) in %s037.php on line %d 44 | 45 | Warning: Yaf_Loader::import(%sDummy.php): %cailed to open stream: Operation not permitted in %s037.php on line %d 46 | 47 | Warning: Yaf_Loader::import(): Failed opening '%sDummy.php' for inclusion (include_path='%s') in %s037.php on line %d 48 | 49 | Warning: Yaf_Loader::autoload(): open_basedir restriction in effect. File(%sDummy.php) is not within the allowed path(s): (%sfoo) in %s037.php on line %d 50 | 51 | Warning: Yaf_Loader::autoload(%sDummy.php): %cailed to open stream: Operation not permitted in %s037.php on line %d 52 | 53 | Warning: Yaf_Loader::autoload(): Failed opening '%sDummy.php' for inclusion (include_path='%s') in %s037.php on line %d 54 | 55 | Warning: Yaf_Loader::autoload(): Failed opening script %sDummy.php: Operation not permitted in %s037.php on line %d 56 | -------------------------------------------------------------------------------- /tests/038.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_View_Simple error message outputing 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | log_errors=0 8 | display_errors=1 9 | yaf.use_namespace=0 10 | --FILE-- 11 | assign("name", "laruence"); 18 | $tpl = APPLICATION_PATH . '/tpls/foo.phtml'; 19 | 20 | file_put_contents($tpl, << 25 | HTML 26 | ); 27 | 28 | echo $view->render($tpl); 29 | ?> 30 | --CLEAN-- 31 | 36 | --EXPECTF-- 37 | Parse error: syntax error, unexpected %s in %sfoo.phtml on line %d 38 | -------------------------------------------------------------------------------- /tests/039.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_View_Simple recursive render error message outputing 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | log_errors=0 8 | display_errors=1 9 | yaf.use_namespace=0 10 | --FILE-- 11 | assign("name", "laruence"); 17 | $tpl = APPLICATION_PATH . '/tpls/foo.phtml'; 18 | $tpl2 = APPLICATION_PATH . '/tpls/foo2.phtml'; 19 | 20 | file_put_contents($tpl, <<render(\$tpl); 23 | ?> 24 | HTML 25 | ); 26 | 27 | file_put_contents($tpl2, << 32 | HTML 33 | ); 34 | 35 | try { 36 | echo $view->render($tpl, array('tpl' => $tpl2)); 37 | } catch (Error $e) { 38 | echo $e->getMessage(); 39 | } 40 | ?> 41 | --CLEAN-- 42 | 47 | --EXPECTF-- 48 | syntax error, unexpected %s 49 | -------------------------------------------------------------------------------- /tests/040.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Fixed bug that segv in Yaf_View_Simple::render if the tpl is not a string 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | --FILE-- 9 | render(NULL); 12 | $view->render(0); 13 | $view->render(true); 14 | echo "okey"; 15 | ?> 16 | --EXPECT-- 17 | okey 18 | -------------------------------------------------------------------------------- /tests/041.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for controller return false preventing auto-renderring 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | array( 11 | "directory" => realpath(dirname(__FILE__)), 12 | "dispatcher" => array( 13 | "catchException" => 0, 14 | "throwException" => 1, 15 | ), 16 | "modules" => "module", 17 | ), 18 | ); 19 | 20 | class ControllerController extends Yaf_Controller_Abstract { 21 | public function actionAction() { 22 | } 23 | 24 | public function indexAction() { 25 | $this->forward("controller", "dummy"); 26 | return FALSE; /* don't auto-render */ 27 | } 28 | 29 | public function dummyAction() { 30 | Yaf_Dispatcher::getInstance()->enableView(); 31 | } 32 | } 33 | 34 | 35 | $app = new Yaf_Application($config); 36 | $request = new Yaf_Request_Http("/module/controller/action"); 37 | 38 | try { 39 | $app->getDispatcher()->returnResponse(false)->dispatch($request); 40 | } catch (Yaf_Exception $e) { 41 | echo $e->getMessage(), "\n"; 42 | } 43 | 44 | $view = new Yaf_View_Simple(dirname(__FILE__) . 'no-exists'); 45 | $app->getDispatcher()->setView($view); 46 | try { 47 | $app->getDispatcher()->returnResponse(false)->dispatch($request); 48 | } catch (Yaf_Exception $e) { 49 | echo $e->getMessage(), "\n"; 50 | } 51 | 52 | $request = new Yaf_Request_Http("/module/controller/index"); 53 | try { 54 | $app->getDispatcher()->returnResponse(false)->dispatch($request); 55 | } catch (Yaf_Exception $e) { 56 | echo $e->getMessage(), "\n"; 57 | } 58 | ?> 59 | --EXPECTF-- 60 | Failed opening template %stests%cmodules%cModule%cviews%ccontroller%caction.phtml: No such file or directory 61 | Failed opening template %stestsno-exists%ccontroller%caction.phtml: No such file or directory 62 | Failed opening template %stestsno-exists%ccontroller%cdummy.phtml: No such file or directory 63 | -------------------------------------------------------------------------------- /tests/042.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for throw exception in Yaf_Controller::init 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | array( 11 | "directory" => realpath(dirname(__FILE__)), 12 | "dispatcher" => array( 13 | "catchException" => 0, 14 | "throwException" => 1, 15 | ), 16 | "modules" => "module", 17 | ), 18 | ); 19 | 20 | class ControllerController extends Yaf_Controller_Abstract { 21 | public function init() { 22 | throw new Yaf_Exception("exception"); 23 | } 24 | 25 | public function indexAction() { 26 | echo "okey"; 27 | return FALSE; 28 | } 29 | } 30 | 31 | 32 | $app = new Yaf_Application($config); 33 | $request = new Yaf_Request_Http("/module/controller/index"); 34 | 35 | try { 36 | $app->getDispatcher()->returnResponse(false)->dispatch($request); 37 | } catch (Yaf_Exception $e) { 38 | echo $e->getMessage(), "\n"; 39 | } 40 | ?> 41 | --EXPECTF-- 42 | exception 43 | -------------------------------------------------------------------------------- /tests/043.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for yaf.system settings 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/tmp" 7 | yaf.use_spl_autoload=1 8 | yaf.name_suffix=1 9 | yaf.name_separator="" 10 | yaf.lowcase_path=1 11 | yaf.environ="product" 12 | yaf.use_namespace=0 13 | --FILE-- 14 | 28 | --EXPECTF-- 29 | bool(true) 30 | bool(true) 31 | bool(true) 32 | bool(true) 33 | bool(false) 34 | bool(true) 35 | 36 | Warning: Yaf_Loader::autoload(): Failed opening script %sapplcation%cplugins%cABC%cEFG.php: No such file or directory in %s043.php on line %d 37 | 38 | Fatal error: Uncaught Error: Class %cPlugin__ABC_EFG%c not found in %s043.php:%d 39 | %a -------------------------------------------------------------------------------- /tests/044.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Memleaks in Yaf_Dispatcher::getInstance() 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | yaf.environ="product" 8 | yaf.use_namespace=0 9 | --FILE-- 10 | 20 | --EXPECTF-- 21 | string(14) "Yaf_Dispatcher" 22 | -------------------------------------------------------------------------------- /tests/045.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for segfault while use closure as error handler 3 | --SKIPIF-- 4 | 8 | --INI-- 9 | yaf.use_namespace=0 10 | --FILE-- 11 | array( 14 | "directory" => realpath(dirname(__FILE__)), 15 | "dispatcher" => array( 16 | "catchException" => 0, 17 | "throwException" => 0, 18 | ), 19 | ), 20 | ); 21 | 22 | class Bootstrap extends Yaf_Bootstrap_Abstract { 23 | public function _initErrorHandler(Yaf_Dispatcher $dispatcher) { 24 | var_dump($dispatcher->getDefaultModule()); 25 | var_dump($dispatcher->getDefaultController()); 26 | $dispatcher->setDefaultAction("dummy"); 27 | var_dump($dispatcher->getDefaultAction()); 28 | $dispatcher->setErrorHandler(function($errorCode, $errorMessage, $file, $line) { 29 | throw new ErrorException($errorMessage, 0, $errorCode, $file, $line); 30 | }); 31 | } 32 | } 33 | 34 | class IndexController extends Yaf_Controller_Abstract { 35 | public function dummyAction() { 36 | echo $undefined_var; 37 | return FALSE; 38 | } 39 | } 40 | 41 | $app = new Yaf_Application($config); 42 | try { 43 | $app->bootstrap()->run(); 44 | } catch (Exception $e) { 45 | var_dump($e->getMessage()); 46 | } 47 | ?> 48 | --EXPECTF-- 49 | string(5) "Index" 50 | string(5) "Index" 51 | string(5) "dummy" 52 | string(33) "Undefined variable%sundefined_var" -------------------------------------------------------------------------------- /tests/046.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Loader with single class 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 13 | "directory" => realpath(dirname(__FILE__)), 14 | "library" => array( 15 | "directory" => "/tmp", 16 | "namespace" => "Foo", 17 | ), 18 | ), 19 | ); 20 | $app = new Yaf_Application($config); 21 | $loader = Yaf_Loader::getInstance(); 22 | var_dump($loader->isLocalName("Foo_Bar")); 23 | var_dump($loader->isLocalName("Foo")); 24 | $loader->clearLocalNamespace(); 25 | $loader->registerLocalNamespace("Bar"); 26 | var_dump($loader->isLocalName("Foo_Bar")); 27 | var_dump($loader->isLocalName("Bar")); 28 | ?> 29 | --EXPECTF-- 30 | bool(true) 31 | bool(true) 32 | bool(false) 33 | bool(true) 34 | -------------------------------------------------------------------------------- /tests/047.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Loader with spl_autoload 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 13 | "directory" => realpath(dirname(__FILE__)), 14 | "library" => array( 15 | "directory" => "./Notexists", 16 | "namespace" => "Foo", 17 | ), 18 | ), 19 | ); 20 | 21 | function pre_load($name) { 22 | var_dump($name); 23 | } 24 | 25 | function load($name) { 26 | eval("class " . $name . " {} "); 27 | return TRUE; 28 | } 29 | 30 | spl_autoload_register("pre_load"); 31 | 32 | $app = new Yaf_Application($config); 33 | 34 | spl_autoload_register("load"); 35 | 36 | $a = new Foo(); 37 | 38 | print_r($a); 39 | ?> 40 | --EXPECTF-- 41 | string(3) "Foo" 42 | 43 | Warning: Yaf_Loader::autoload(): Failed opening script %sNotexists%cFoo.php: No such file or directory in %s047.php on line %d 44 | Foo Object 45 | ( 46 | ) 47 | -------------------------------------------------------------------------------- /tests/050.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Sample application with return response 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | 10 | --FILE-- 11 | array( 17 | "directory" => APPLICATION_PATH, 18 | ), 19 | ); 20 | 21 | file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<returnResponse(true); 26 | } 27 | } 28 | PHP 29 | ); 30 | 31 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<bootstrap()->run(); 44 | var_dump("-------"); 45 | echo $response; 46 | ?> 47 | --CLEAN-- 48 | 53 | --EXPECTF-- 54 | string(7) "-------" 55 | view 56 | -------------------------------------------------------------------------------- /tests/051.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Fixed bug that segfault while a abnormal object set to Yaf_Route*::route 3 | --SKIPIF-- 4 | ='8.0.0') print "skip"; ?> 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | route($x); 14 | 15 | $x = new Yaf_Route_Static(); 16 | $x->route($x); 17 | 18 | $x = new Yaf_Route_Rewrite("#^/test#", array("controller" => "info"), array()); 19 | $x->route($x); 20 | 21 | $x = new Yaf_Route_Supervar("r"); 22 | $x->route($x); 23 | 24 | $x = new Yaf_Route_Regex("#^/test#", array("controller" => "info"), array()); 25 | $x->route($x); 26 | 27 | echo "okey"; 28 | ?> 29 | --EXPECTF-- 30 | okey -------------------------------------------------------------------------------- /tests/052.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Request APis 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.use_namespace=0 8 | --FILE-- 9 | getMessage()); 15 | } 16 | $request = new Yaf_Request_Http("xxxxxxxxxxxxxxxxxxxxxxxxxxx"); 17 | var_dump($request->get("xxx")); 18 | var_dump($request->getQuery("xxx")); 19 | var_dump($request->getServer("xxx")); 20 | var_dump($request->getPost("xxx")); 21 | var_dump($request->getCookie("xxx")); 22 | var_dump($request->getEnv("xxx")); 23 | echo "------default value-------\n"; 24 | var_dump($request->get("xxx", "123")); 25 | print_r($request->getQuery("xxx", new stdClass())); 26 | print_r($request->getServer("xxx", array())); 27 | var_dump($request->getPost("xxx", NULL)); 28 | var_dump($request->getCookie("xxx"), false); 29 | var_dump($request->getEnv("xxx"), "2.13232"); 30 | echo "-----others-----\n"; 31 | var_dump($request->isXmlHttpRequest()); 32 | var_dump($request->isCli()); 33 | var_dump($request->isPost()); 34 | echo "------params-------\n"; 35 | var_dump($request->getParam("xxxx")); 36 | var_dump($request->getParams()); 37 | var_dump($request->setParam("xxxx")); 38 | ?> 39 | --EXPECTF-- 40 | string(%d) "Yaf_Request_Http::__construct() expects at most 2 %s, 3 given" 41 | NULL 42 | NULL 43 | NULL 44 | NULL 45 | NULL 46 | NULL 47 | ------default value------- 48 | string(3) "123" 49 | stdClass Object 50 | ( 51 | ) 52 | Array 53 | ( 54 | ) 55 | NULL 56 | NULL 57 | bool(false) 58 | NULL 59 | string(7) "2.13232" 60 | -----others----- 61 | bool(false) 62 | bool(true) 63 | bool(false) 64 | ------params------- 65 | NULL 66 | array(0) { 67 | } 68 | 69 | Fatal error: Uncaught TypeError: Yaf_Request_Abstract::setParam()%sarray, string given in %s052.php:%d 70 | %a -------------------------------------------------------------------------------- /tests/054.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | check for Various segfault 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | getMessage()); 15 | } 16 | 17 | $request = new Yaf_Request_Simple(NULL); 18 | var_dump($request->isOptions()); 19 | 20 | 21 | $config = new Yaf_Config_Simple(array()); 22 | $config->key(); 23 | echo "okey"; 24 | ?> 25 | --EXPECTF-- 26 | string(%d) "Argument is not a valid ini file '%s'" 27 | bool(false) 28 | okey 29 | -------------------------------------------------------------------------------- /tests/055.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | check for Yaf_Dispatcher::autoRender 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.environ="product" 9 | yaf.use_namespace=0 10 | --FILE-- 11 | autoRender(true); 15 | var_dump(Yaf_Dispatcher::getInstance()->autoRender()); 16 | Yaf_Dispatcher::getInstance()->autoRender(false); 17 | var_dump(Yaf_Dispatcher::getInstance()->autoRender()); 18 | ?> 19 | --EXPECTF-- 20 | bool(true) 21 | bool(false) 22 | -------------------------------------------------------------------------------- /tests/056.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | check for Yaf_Dispatcher::throwException 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.environ="product" 9 | yaf.use_namespace=0 10 | --FILE-- 11 | throwException(true); 15 | var_dump(Yaf_Dispatcher::getInstance()->throwException()); 16 | Yaf_Dispatcher::getInstance()->throwException(false); 17 | var_dump(Yaf_Dispatcher::getInstance()->throwException()); 18 | ?> 19 | --EXPECTF-- 20 | bool(true) 21 | bool(false) 22 | -------------------------------------------------------------------------------- /tests/057.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | check for Yaf_Dispatcher::catchException 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.environ="product" 9 | yaf.use_namespace=0 10 | --FILE-- 11 | catchException(true); 15 | var_dump(Yaf_Dispatcher::getInstance()->catchException()); 16 | Yaf_Dispatcher::getInstance()->catchException(false); 17 | var_dump(Yaf_Dispatcher::getInstance()->catchException()); 18 | ?> 19 | --EXPECTF-- 20 | bool(true) 21 | bool(false) 22 | -------------------------------------------------------------------------------- /tests/058.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | check for Yaf_Dispatcher::flushInstantly 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.environ="product" 9 | yaf.use_namespace=0 10 | --FILE-- 11 | flushInstantly(true); 15 | var_dump(Yaf_Dispatcher::getInstance()->flushInstantly()); 16 | Yaf_Dispatcher::getInstance()->flushInstantly(false); 17 | var_dump(Yaf_Dispatcher::getInstance()->flushInstantly()); 18 | ?> 19 | --EXPECTF-- 20 | bool(true) 21 | bool(false) 22 | -------------------------------------------------------------------------------- /tests/059.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check nesting view render 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<returnResponse(true); 25 | } 26 | } 27 | PHP 28 | ); 29 | 30 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<flushInstantly(true); 35 | } 36 | public function indexAction() { 37 | var_dump(\$this->_view->getScriptPath()); 38 | } 39 | } 40 | PHP 41 | ); 42 | 43 | file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "display('index/sub.phtml', array('content' => 'dummy'));?>"); 44 | file_put_contents(APPLICATION_PATH . "/views/index/sub.phtml", "eval('foobar'); ?>"); 45 | 46 | $app = new Yaf_Application($config); 47 | $response = $app->bootstrap()->run(); 48 | ?> 49 | --CLEAN-- 50 | 54 | --EXPECTF-- 55 | string(%d) "%sapplication%cviews" 56 | Yaf_View_Simple Object 57 | ( 58 | [tpl_dir:protected] => %s 59 | [tpl_vars:protected] => Array 60 | ( 61 | ) 62 | 63 | ) 64 | dummyfoobar 65 | -------------------------------------------------------------------------------- /tests/060.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for working with other autoloaders 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 21 | "directory" => APPLICATION_PATH, 22 | ), 23 | ); 24 | 25 | file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<setErrorHandler(array("Bootstrap", "errorHandler")); 38 | } 39 | } 40 | PHP 41 | ); 42 | 43 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<_view->obj = \$obj; 49 | } 50 | } 51 | PHP 52 | ); 53 | 54 | file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", ""); 55 | 56 | $app = new Yaf_Application($config); 57 | $response = $app->bootstrap()->run(); 58 | ?> 59 | --CLEAN-- 60 | 64 | --EXPECTF-- 65 | Dummy 66 | -------------------------------------------------------------------------------- /tests/061.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug empty template file interrupts forward chain 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<forward("dummy"); 25 | } 26 | public function dummyAction() { 27 | } 28 | } 29 | PHP 30 | ); 31 | 32 | file_put_contents(APPLICATION_PATH . "/controllers/Dummy.php", <<run(); 46 | ?> 47 | --CLEAN-- 48 | 52 | --EXPECTF-- 53 | Dummy 54 | -------------------------------------------------------------------------------- /tests/062.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_View_Simple and application's template directory 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | yaf.use_namespace=0 8 | --FILE-- 9 | getMessage()); 15 | } 16 | 17 | $config = array( 18 | "application" => array( 19 | "directory" => dirname(__FILE__), 20 | ), 21 | ); 22 | $app = new Yaf_Application($config); 23 | 24 | $view = Yaf_Dispatcher::getInstance()->initView(""); 25 | var_dump($view->getScriptPath()); 26 | ?> 27 | --EXPECTF-- 28 | string(%d) "Expects an absolute path for templates directory" 29 | NULL 30 | -------------------------------------------------------------------------------- /tests/063.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Rewrite with dynamic mvc 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | "m", 17 | "controller" => ":1", 18 | "action" => ":a", 19 | ) 20 | ); 21 | 22 | $router->addRoute("subdir", $route)->addRoute("yaf", new Yaf_Route_Rewrite( 23 | "/yaf/:action/*", 24 | array( 25 | "action" => ':action', 26 | "controller" => "index", 27 | ) 28 | ))->route($request); 29 | 30 | var_dump($router->getCurrentRoute()); 31 | print_r($request->getParams()); 32 | var_dump($request->getActionName()); 33 | var_dump($request->getControllerName()); 34 | var_dump($request->getModuleName()); 35 | 36 | $request = new Yaf_Request_Http("/yaf/act/name/value"); 37 | $router->route($request); 38 | 39 | var_dump($router->getCurrentRoute()); 40 | print_r($request->getParams()); 41 | var_dump($request->getActionName()); 42 | var_dump($request->getControllerName()); 43 | var_dump($request->getModuleName()); 44 | 45 | ?> 46 | --EXPECTF-- 47 | string(6) "subdir" 48 | Array 49 | ( 50 | [con] => ctl 51 | [a] => act 52 | [name] => value 53 | ) 54 | string(3) "act" 55 | NULL 56 | string(1) "M" 57 | string(3) "yaf" 58 | Array 59 | ( 60 | [action] => act 61 | [name] => value 62 | ) 63 | string(3) "act" 64 | string(5) "Index" 65 | NULL 66 | -------------------------------------------------------------------------------- /tests/064.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Regex with dynamic mvc 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | .*?)/(.*?)/.*#", 15 | array( 16 | "module" => "m", 17 | "controller" => ":c", 18 | "action" => ":a", 19 | ), 20 | array( 21 | 2 => "a", 22 | ) 23 | ); 24 | 25 | $router->addRoute("subdir", $route)->addRoute("yaf", new Yaf_Route_Regex( 26 | "#yaf/(.*?)/.*#", 27 | array( 28 | "action" => ':action', 29 | "controller" => "index", 30 | ), 31 | array( 32 | 1 => "action", 33 | ) 34 | ))->route($request); 35 | 36 | var_dump($router->getCurrentRoute()); 37 | print_r($request->getParams()); 38 | var_dump($request->getActionName()); 39 | var_dump($request->getControllerName()); 40 | var_dump($request->getModuleName()); 41 | 42 | $request = new Yaf_Request_Http("/yaf/act/name/value"); 43 | $router->route($request); 44 | 45 | var_dump($router->getCurrentRoute()); 46 | print_r($request->getParams()); 47 | var_dump($request->getActionName()); 48 | var_dump($request->getControllerName()); 49 | var_dump($request->getModuleName()); 50 | 51 | ?> 52 | --EXPECTF-- 53 | string(6) "subdir" 54 | Array 55 | ( 56 | [c] => ctl 57 | [a] => act 58 | ) 59 | string(3) "act" 60 | string(3) "Ctl" 61 | string(1) "M" 62 | string(3) "yaf" 63 | Array 64 | ( 65 | [action] => act 66 | ) 67 | string(3) "act" 68 | string(5) "Index" 69 | NULL 70 | -------------------------------------------------------------------------------- /tests/065.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Yaf_Route_Regex map is optional 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | addConfig( 15 | array( 16 | array( 17 | "type" => "regex", 18 | "match" => "#^/ap/([^/]*)/*#i", 19 | "route" => array( 20 | array( 21 | "action" => 'ap', 22 | ), 23 | ), 24 | ) 25 | ) 26 | )->route($request); 27 | 28 | var_dump($router->getCurrentRoute()); 29 | var_dump($request->getActionName()); 30 | 31 | 32 | $router->addRoute("regex", new Yaf_Route_Regex("#^/ap/([^/]*)/*#i", array("action" => "ap")))->route($request); 33 | 34 | var_dump($router->getCurrentRoute()); 35 | var_dump($request->getActionName()); 36 | 37 | ?> 38 | --EXPECT-- 39 | int(0) 40 | NULL 41 | string(5) "regex" 42 | string(2) "ap" 43 | -------------------------------------------------------------------------------- /tests/066.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Regex with abnormal map 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | addRoute("ap", new Yaf_Route_Regex( 14 | "#^/ap/([^/]*)/([^/]*)/*#i", 15 | array( 16 | "action" => 'ap', 17 | ), 18 | array( 19 | 1 => 23432, 20 | 2 => NULL, 21 | ) 22 | ))->route($request); 23 | 24 | var_dump($router->getCurrentRoute()); 25 | var_dump($request->getParam(1)); 26 | var_dump($request->getActionName()); 27 | var_dump($request->getControllerName()); 28 | var_dump($request->getParam('name')); 29 | 30 | ?> 31 | --EXPECTF-- 32 | string(2) "ap" 33 | NULL 34 | string(2) "ap" 35 | NULL 36 | NULL 37 | -------------------------------------------------------------------------------- /tests/067.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check actions map with defined action class 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", << "actions/sub.php", 25 | ); 26 | public function indexAction() { 27 | var_dump(\$this->forward('sub')); 28 | } 29 | } 30 | PHP 31 | ); 32 | 33 | file_put_contents(APPLICATION_PATH . "/actions/sub.php", <<getModuleName()); 38 | var_dump(\$this->getControllerName()); 39 | } 40 | } 41 | PHP 42 | ); 43 | 44 | file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", "indexAction" . PHP_EOL); 45 | file_put_contents(APPLICATION_PATH . "/views/index/sub.phtml", "subAction" . PHP_EOL); 46 | 47 | $app = new Yaf_Application($config); 48 | $request = new Yaf_Request_Simple(); 49 | $app->getDispatcher()->dispatch($request); 50 | $new_request = new Yaf_Request_Simple(); 51 | $new_request->setActionName('sub'); 52 | $app->getDispatcher()->dispatch($new_request); 53 | ?> 54 | --CLEAN-- 55 | 59 | --EXPECTF-- 60 | bool(true) 61 | string(5) "Index" 62 | string(5) "Index" 63 | indexAction 64 | subAction 65 | string(5) "Index" 66 | string(5) "Index" 67 | subAction 68 | -------------------------------------------------------------------------------- /tests/068.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for multi inheritance of section 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | toArray()); 11 | 12 | ?> 13 | --EXPECTF-- 14 | Array 15 | ( 16 | [base] => Array 17 | ( 18 | [base] => Array 19 | ( 20 | [a] => 1 21 | [b] => 2 22 | ) 23 | 24 | ) 25 | 26 | [extra] => Array 27 | ( 28 | [base] => Array 29 | ( 30 | [c] => 3 31 | ) 32 | 33 | ) 34 | 35 | [foo] => Array 36 | ( 37 | [base] => Array 38 | ( 39 | [d] => 4 40 | ) 41 | 42 | ) 43 | 44 | [multi] => Array 45 | ( 46 | [base] => Array 47 | ( 48 | [d] => 4 49 | [a] => 1 50 | [b] => 2 51 | [c] => 3 52 | ) 53 | 54 | ) 55 | 56 | [] => Array 57 | ( 58 | [base] => Array 59 | ( 60 | [d] => 4 61 | ) 62 | 63 | ) 64 | 65 | ) 66 | -------------------------------------------------------------------------------- /tests/069.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Fixed bug that alter_response is not binary safe 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", << tail" . PHP_EOL); 31 | 32 | $app = new Yaf_Application($config); 33 | $app->run(); 34 | ?> 35 | --CLEAN-- 36 | 40 | --EXPECTF-- 41 | head tail 42 | -------------------------------------------------------------------------------- /tests/070.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Fixed misleading error message when providing a string in Yaf_Application construction 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | run(); 19 | } 20 | catch (Exception $e){ 21 | print $e->getPrevious()->getMessage(); 22 | } 23 | 24 | ?> 25 | --CLEAN-- 26 | --EXPECTF-- 27 | Expects a path to *.ini configuration file as parameter 28 | -------------------------------------------------------------------------------- /tests/071.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | return type in Yaf_Simple_Config::valid() should be boolean 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | valid()); 12 | ?> 13 | --CLEAN-- 14 | --EXPECTF-- 15 | bool(false) 16 | -------------------------------------------------------------------------------- /tests/073.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Rewrite::assemble 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | "product", 16 | ), 17 | array() 18 | ); 19 | 20 | $router->addRoute("rewrite", $route); 21 | 22 | var_dump($router->getRoute('rewrite')->assemble( 23 | array( 24 | ':name' => 'foo', 25 | ':id' => 'bar', 26 | ':tmpkey1' => 'tmpval1' 27 | ), 28 | array( 29 | 'tkey1' => 'tval1', 30 | 'tkey2' => 'tval2' 31 | ) 32 | ) 33 | ); 34 | 35 | var_dump($router->getRoute('rewrite')->assemble( 36 | array( 37 | ':name' => 'foo', 38 | ':id' => 1, 39 | ':tmpkey1' => 'tmpval1' 40 | ), 41 | array( 42 | 'tkey1' => 'tval1', 43 | 'tkey2' => 22222 44 | ) 45 | ) 46 | ); 47 | 48 | --EXPECTF-- 49 | string(57) "/product/foo/bar/tmpkey1/tmpval1/?tkey1=tval1&tkey2=tval2" 50 | string(55) "/product/foo/1/tmpkey1/tmpval1/?tkey1=tval1&tkey2=22222" 51 | -------------------------------------------------------------------------------- /tests/074.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Simple::assemble 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | addRoute("simple", $route); 15 | 16 | var_dump($router->getRoute('simple')->assemble( 17 | array( 18 | ':a' => 'yafaction', 19 | 'tkey' => 'tval', 20 | ':c' => 'yafcontroller', 21 | ':m' => 'yafmodule' 22 | ), 23 | array( 24 | 'tkey1' => 'tval1', 25 | 'tkey2' => 'tval2' 26 | ) 27 | )); 28 | --EXPECTF-- 29 | string(64) "?m=yafmodule&c=yafcontroller&a=yafaction&tkey1=tval1&tkey2=tval2" 30 | -------------------------------------------------------------------------------- /tests/075.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Regex::assemble 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | "product", //route to product controller, 16 | ), 17 | array(), 18 | array(), 19 | '/:m/:c/:a' 20 | ); 21 | 22 | $router->addRoute("regex", $route); 23 | 24 | var_dump($router->getRoute('regex')->assemble( 25 | array( 26 | ':m' => 'module', 27 | ':c' => 'controller', 28 | ':a' => 'action' 29 | ), 30 | array( 31 | 'tkey1' => 'tval1', 32 | 'tkey2' => 33 | 'tval2' 34 | ) 35 | ) 36 | ); 37 | --EXPECTF-- 38 | string(49) "/module/controller/action?tkey1=tval1&tkey2=tval2" 39 | -------------------------------------------------------------------------------- /tests/076.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Supervar::assemble 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.throw_exception=1 7 | yaf.use_namespace=0 8 | --FILE-- 9 | addRoute("supervar", $route); 16 | 17 | var_dump($router->getRoute('supervar')->assemble( 18 | array( 19 | ':a' => 'yafaction', 20 | 'tkey' => 'tval', 21 | ':c' => 'yafcontroller', 22 | ':m' => 'yafmodule' 23 | ), 24 | array( 25 | 'tkey1' => 'tval1', 26 | 'tkey2' => 'tval2' 27 | ) 28 | )); 29 | 30 | try { 31 | var_dump($router->getRoute('supervar')->assemble( 32 | array( 33 | ':a' => 'yafaction', 34 | 'tkey' => 'tval', 35 | ':m' => 'yafmodule' 36 | ), 37 | array( 38 | 'tkey1' => 'tval1', 39 | 'tkey2' => 'tval2', 40 | 1 => array(), 41 | ) 42 | )); 43 | } catch (Exception $e) { 44 | var_dump($e->getMessage()); 45 | } 46 | --EXPECTF-- 47 | string(%d) "?r=/yafmodule/yafcontroller/yafaction&tkey1=tval1&tkey2=tval2" 48 | string(%d) "You need to specify the controller by ':c'" 49 | -------------------------------------------------------------------------------- /tests/077.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Static::assemble 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | addRoute("static", $route); 15 | 16 | var_dump($router->getRoute('static')->assemble( 17 | array( 18 | ':a' => 'yafaction', 19 | 'tkey' => 'tval', 20 | ':c' => 'yafcontroller', 21 | ':m' => 'yafmodule' 22 | ), 23 | array( 24 | 'tkey1' => 'tval1', 25 | 'tkey2' => 'tval2' 26 | ) 27 | ) 28 | ); 29 | 30 | var_dump($router->getRoute('static')->assemble( 31 | array( 32 | ':a' => 'yafaction', 33 | 'tkey' => 'tval', 34 | ':c' => 'yafcontroller', 35 | ':m' => 'yafmodule' 36 | ), 37 | array( 38 | 1 => 2, 39 | array(), 40 | ) 41 | ) 42 | ); 43 | --EXPECTF-- 44 | string(%d) "/yafmodule/yafcontroller/yafaction?tkey1=tval1&tkey2=tval2" 45 | string(%d) "/yafmodule/yafcontroller/yafaction" 46 | -------------------------------------------------------------------------------- /tests/078.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Map::assemble 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | addRoute("map", $route); 15 | 16 | var_dump($router->getRoute('map')->assemble( 17 | array( 18 | ':c' => 'foo_bar' 19 | ), 20 | array( 21 | 'tkey1' => 'tval1', 22 | 'tkey2' => 'tval2' 23 | ) 24 | ) 25 | ); 26 | 27 | $route = new Yaf_Route_Map(true, '_'); 28 | $router->addRoute("map", $route); 29 | 30 | var_dump($router->getRoute('map')->assemble( 31 | array( 32 | ':a' => 'foo_bar' 33 | ), 34 | array( 35 | 'tkey1' => 'tval1', 36 | 'tkey2' => 'tval2' 37 | ) 38 | ) 39 | ); 40 | 41 | --EXPECTF-- 42 | string(%d) "/foo/bar?tkey1=tval1&tkey2=tval2" 43 | string(%d) "/foo/bar/_/tkey1/tval1/tkey2/tval2" 44 | -------------------------------------------------------------------------------- /tests/079.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Autoloading the classes under library 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<registerLocalNamespace("Test"); 25 | Yaf_Registry::set("test", new Test()); 26 | } 27 | } 28 | PHP 29 | ); 30 | 31 | file_put_contents(APPLICATION_PATH . "/library/Test.php", <<bootstrap(); 43 | ?> 44 | --CLEAN-- 45 | 49 | --EXPECTF-- 50 | string(4) "okey" 51 | -------------------------------------------------------------------------------- /tests/080.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | PHP7 didn't display Error. 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | array( 14 | "directory" => APPLICATION_PATH, 15 | "bootstrap" => APPLICATION_PATH . "/mybootstrap.php", 16 | ), 17 | ); 18 | 19 | file_put_contents(APPLICATION_PATH . "/mybootstrap.php", <<bootstrap()->run(); 39 | ?> 40 | --CLEAN-- 41 | 45 | --EXPECTF-- 46 | Fatal error: Uncaught Error: Call to undefined function geoge() in %s:5 47 | Stack trace: 48 | #0 [internal function]: IndexController->indexAction() 49 | #1 %s080.php(%d): Yaf_Application->run() 50 | #2 {main} 51 | thrown in %s on line %d 52 | -------------------------------------------------------------------------------- /tests/081.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | PHP7 Yaf_Response leak memory 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | setBody($string); 12 | $response->setBody($string); 13 | var_dump($response->getBody()); 14 | ?> 15 | --EXPECTF-- 16 | string(19) "Jason is a good boy" 17 | -------------------------------------------------------------------------------- /tests/082.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for variables out of scope 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.library="/php/global/dir" 7 | log_errors=0 8 | display_errors=1 9 | yaf.use_namespace=0 10 | --FILE-- 11 | assign("name", "laruence"); 17 | $tpl = APPLICATION_PATH . '/tpls/foo.phtml'; 18 | 19 | file_put_contents($tpl, <<render($tpl); 26 | ?> 27 | --CLEAN-- 28 | 33 | --EXPECTF-- 34 | laruence 35 | %s: Undefined variable%stpl in %sfoo.phtml on line %d -------------------------------------------------------------------------------- /tests/083.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for ReturnResponse in cli 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | "view" => array( 18 | "ext" => "html", 19 | ), 20 | ), 21 | ); 22 | 23 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<getDispatcher()->returnResponse(true)->dispatch(new Yaf_Request_Simple("CLI", "Index","Index","index")); 35 | var_dump($response->getBody()); 36 | ?> 37 | --CLEAN-- 38 | 43 | --EXPECTF-- 44 | string(4) "okey" 45 | -------------------------------------------------------------------------------- /tests/084.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check request methods 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | isGet()); 14 | var_dump($request->isPost()); 15 | var_dump($request->isHead()); 16 | var_dump($request->isDelete()); 17 | var_dump($request->isPut()); 18 | var_dump($request->isOptions()); 19 | var_dump($request->isPatch()); 20 | return; 21 | } 22 | 23 | checkMethod("GET"); 24 | checkMethod("POST"); 25 | checkMethod("HEAD"); 26 | checkMethod("DELETE"); 27 | checkMethod("PUT"); 28 | checkMethod("OPTIONS"); 29 | checkMethod("PATCH"); 30 | ?> 31 | --EXPECTF-- 32 | checking GET... 33 | bool(true) 34 | bool(false) 35 | bool(false) 36 | bool(false) 37 | bool(false) 38 | bool(false) 39 | bool(false) 40 | checking POST... 41 | bool(false) 42 | bool(true) 43 | bool(false) 44 | bool(false) 45 | bool(false) 46 | bool(false) 47 | bool(false) 48 | checking HEAD... 49 | bool(false) 50 | bool(false) 51 | bool(true) 52 | bool(false) 53 | bool(false) 54 | bool(false) 55 | bool(false) 56 | checking DELETE... 57 | bool(false) 58 | bool(false) 59 | bool(false) 60 | bool(true) 61 | bool(false) 62 | bool(false) 63 | bool(false) 64 | checking PUT... 65 | bool(false) 66 | bool(false) 67 | bool(false) 68 | bool(false) 69 | bool(true) 70 | bool(false) 71 | bool(false) 72 | checking OPTIONS... 73 | bool(false) 74 | bool(false) 75 | bool(false) 76 | bool(false) 77 | bool(false) 78 | bool(true) 79 | bool(false) 80 | checking PATCH... 81 | bool(false) 82 | bool(false) 83 | bool(false) 84 | bool(false) 85 | bool(false) 86 | bool(false) 87 | bool(true) 88 | -------------------------------------------------------------------------------- /tests/085.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check Yaf_Request_Http::getRaw 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --POST-- 8 | a=b&c=d 9 | --FILE-- 10 | getRaw()); 13 | ?> 14 | --EXPECT-- 15 | string(7) "a=b&c=d" 16 | -------------------------------------------------------------------------------- /tests/086.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Response_HTTP::setRedirect in CLI 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | setRedirect('https://yourdomain.com')); 11 | ?> 12 | --EXPECT-- 13 | bool(false) 14 | -------------------------------------------------------------------------------- /tests/087.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Map with arbitrary urls 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | route($req); 20 | echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName(); 21 | if (($args = $req->getParams())) { 22 | echo " args=>"; 23 | foreach ($args as $k => $v) { 24 | echo $k , "->", $v , ","; 25 | } 26 | } 27 | echo "\n"; 28 | } 29 | 30 | $route = new Yaf_Route_Map(false, ":"); 31 | 32 | foreach ($url as $u) { 33 | $req = new Yaf_Request_Http($u); 34 | $route->route($req); 35 | echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName(); 36 | if (($args = $req->getParams())) { 37 | echo " args=>"; 38 | foreach ($args as $k => $v) { 39 | echo $k , "->", $v , ","; 40 | } 41 | } 42 | echo "\n"; 43 | } 44 | --EXPECT-- 45 | / : m=> c=> a=> 46 | /foo : m=> c=>Foo a=> 47 | /foo/ : m=> c=>Foo a=> 48 | /foo///bar : m=> c=>Foo_Bar a=> 49 | //foo//bar : m=> c=>Foo_Bar a=> 50 | /foo/bar/// : m=> c=>Foo_Bar a=> 51 | /foo/bar/: : m=> c=>Foo_Bar_: a=> 52 | /foo/bar/:/ : m=> c=>Foo_Bar_: a=> 53 | /foo///bar/:/name/laruence/age/32 : m=> c=>Foo_Bar_:_Name_Laruence_Age_32 a=> 54 | foo/bar/:dummy/value:/age/37 : m=> c=>Foo_Bar_:dummy_Value:_Age_37 a=> 55 | / : m=> c=> a=> 56 | /foo : m=> c=> a=>foo 57 | /foo/ : m=> c=> a=>foo 58 | /foo///bar : m=> c=> a=>foo_bar 59 | //foo//bar : m=> c=> a=>foo_bar 60 | /foo/bar/// : m=> c=> a=>foo_bar 61 | /foo/bar/: : m=> c=> a=>foo_bar 62 | /foo/bar/:/ : m=> c=> a=>foo_bar 63 | /foo///bar/:/name/laruence/age/32 : m=> c=> a=>foo_bar args=>name->laruence,age->32, 64 | foo/bar/:dummy/value:/age/37 : m=> c=> a=>foo_bar args=>dummy->value:,age->37, 65 | -------------------------------------------------------------------------------- /tests/088.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Route_Rwrite with arbitrary urls 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | ":name", 21 | "action" => ":subname" 22 | ) 23 | ); 24 | 25 | foreach ($url as $u) { 26 | $req = new Yaf_Request_Http($u); 27 | $route->route($req); 28 | echo $u, " : ", "m=>", $req->getModuleName(), " c=>", $req->getControllerName(), " a=>", $req->getActionName(); 29 | if (($args = $req->getParams())) { 30 | echo " args=>"; 31 | foreach ($args as $k => $v) { 32 | echo $k , "->", $v , ","; 33 | } 34 | } 35 | echo "\n"; 36 | } 37 | ?> 38 | --EXPECT-- 39 | / : m=> c=> a=> 40 | /foo : m=> c=> a=> 41 | //foo/ : m=> c=> a=> 42 | /foo/bar : m=> c=> a=> 43 | /foo/// : m=> c=> a=> 44 | /foo/cont/act : m=> c=> a=> 45 | /foo/cont/act/ : m=> c=>Cont a=>act args=>name->cont,subname->act, 46 | /foocont/act : m=> c=> a=> 47 | /foo/cont//act : m=> c=> a=> 48 | /foo//cont///act// : m=> c=>Cont a=>act args=>name->cont,subname->act, 49 | /foo/cont/act//var/value/ : m=> c=>Cont a=>act args=>name->cont,subname->act,var->value, 50 | /foo/cont/act//var/value/age : m=> c=>Cont a=>act args=>name->cont,subname->act,var->value,age->, 51 | /foo/cont/act//var/value/age/12// : m=> c=>Cont a=>act args=>name->cont,subname->act,var->value,age->12, 52 | -------------------------------------------------------------------------------- /tests/089.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Config_Ini gets 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | base)); 14 | var_dump(gettype($config->base->application->directory)); 15 | 16 | var_dump($config->base->routes->rewrite->route->controller); 17 | var_dump($config->base["routes"]["rewrite"]["route"]["controller"]); 18 | var_dump($config->get("base.routes.rewrite.route.controller")); 19 | 20 | var_dump($config->base->get("routes.rewrite.match")); 21 | var_dump($config["base.routes.rewrite.route.controllers"]); 22 | 23 | $config = new Yaf_Config_Ini($file, "nocatch"); 24 | var_dump(count($config)); 25 | var_dump($config->get("routes.rewrite.match")); 26 | var_dump($config->application->dispatcher->throwException); 27 | var_dump($config->application["dispatcher"]["catchException"]); 28 | ?> 29 | --EXPECTF-- 30 | int(5) 31 | string(6) "string" 32 | string(5) "Index" 33 | string(5) "Index" 34 | string(5) "Index" 35 | string(17) "/yaf/:name/:value" 36 | NULL 37 | int(6) 38 | string(15) "/yaf/:name/:age" 39 | string(0) "" 40 | string(1) "1" 41 | -------------------------------------------------------------------------------- /tests/091.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Request_getXXX 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --GET-- 10 | name=get 11 | --POST-- 12 | name=raw 13 | --FILE-- 14 | getServer("name")); 24 | var_dump($request->getQuery("name")); 25 | var_dump($request->getCookie("name")); 26 | var_dump($request->getPost("name")); 27 | var_dump($request->getEnv("name")); 28 | var_dump($request->getRequest("name")); 29 | var_dump($request->getRaw()); 30 | 31 | var_dump(count($request->getServer())); 32 | var_dump(count($request->getQuery())); 33 | var_dump(count($request->getCookie())); 34 | var_dump(count($request->getPost())); 35 | var_dump(count($request->getEnv())); 36 | var_dump(count($request->getRequest())); 37 | ?> 38 | --EXPECTF-- 39 | string(6) "server" 40 | string(3) "get" 41 | string(6) "cookie" 42 | string(4) "post" 43 | string(3) "env" 44 | string(7) "request" 45 | string(8) "name=raw" 46 | int(%d) 47 | int(%d) 48 | int(%d) 49 | int(%d) 50 | int(%d) 51 | int(%d) 52 | -------------------------------------------------------------------------------- /tests/092.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for base uri detecting 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | getBaseuri()); 17 | var_dump($req->getRequestUri()); 18 | 19 | unset($_SERVER["SCRIPT_NAME"]); 20 | $_SERVER["PHP_SELF"] = "/yaf/index.php"; 21 | $req = new Yaf_Request_Http(); 22 | var_dump($req->getBaseuri()); 23 | var_dump($req->getRequestUri()); 24 | 25 | 26 | unset($_SERVER["REQUEST_URI"]); 27 | unset($_SERVER["PHP_SELF"]); 28 | $_SERVER["PATH_INFO"] = "/c/a"; 29 | $req = new Yaf_Request_Http(); 30 | var_dump($req->getBaseuri()); 31 | var_dump($req->getRequestUri()); 32 | ?> 33 | --EXPECT-- 34 | string(4) "/yaf" 35 | string(8) "/yaf/c/a" 36 | string(4) "/yaf" 37 | string(8) "/yaf/c/a" 38 | string(0) "" 39 | string(4) "/c/a" 40 | -------------------------------------------------------------------------------- /tests/093.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for numeric keys in view assign 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.use_namespace=0 8 | 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<getView()->assign("var", "str key"); 27 | \$this->getView()->assign(1, "number key"); 28 | \$this->getView()->assign(2.3, "float key"); 29 | \$this->getView()->display("index/index.phtml", [-1 => "number key", "0x2342" => "hex key"]); 30 | return false; 31 | } 32 | } 33 | PHP 34 | ); 35 | 36 | file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", ""); 39 | 40 | $app = new Yaf_Application($config); 41 | $app->run(); 42 | 43 | ?> 44 | --CLEAN-- 45 | 49 | --EXPECTF-- 50 | array(1) { 51 | ["var"]=> 52 | string(7) "str key" 53 | } 54 | -------------------------------------------------------------------------------- /tests/096.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Custom route 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | setModuleName("moDule"); 17 | $request->setControllerName("index"); 18 | $request->action = "ActioN"; 19 | } 20 | return $switch; 21 | } 22 | 23 | public function assemble($info, $verify = NULL) { 24 | } 25 | } 26 | 27 | $router->addRoute("custom", new myRoute); 28 | 29 | $request = new Yaf_Request_Http("/foo/dummy"); 30 | $router->route($request); 31 | print_r($request); 32 | var_dump($router->getCurrentRoute()); 33 | 34 | $switch = false; 35 | $request = new Yaf_Request_Http("/foo/dummy"); 36 | $router->route($request); 37 | print_r($request); 38 | var_dump($router->getCurrentRoute()); 39 | ?> 40 | --EXPECT-- 41 | Yaf_Request_Http Object 42 | ( 43 | [method] => CLI 44 | [module] => Module 45 | [controller] => Index 46 | [action] => action 47 | [uri:protected] => /foo/dummy 48 | [base_uri:protected] => 49 | [dispatched:protected] => 50 | [routed:protected] => 1 51 | [language:protected] => 52 | [params:protected] => Array 53 | ( 54 | ) 55 | 56 | ) 57 | string(6) "custom" 58 | Yaf_Request_Http Object 59 | ( 60 | [method] => CLI 61 | [module] => 62 | [controller] => Foo 63 | [action] => dummy 64 | [uri:protected] => /foo/dummy 65 | [base_uri:protected] => 66 | [dispatched:protected] => 67 | [routed:protected] => 1 68 | [language:protected] => 69 | [params:protected] => Array 70 | ( 71 | ) 72 | 73 | ) 74 | string(8) "_default" 75 | -------------------------------------------------------------------------------- /tests/098.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Bootstrap protected method 3 | --SKIPIF-- 4 | 8 | --INI-- 9 | yaf.use_namespace=0 10 | --FILE-- 11 | array( 14 | "directory" => realpath(dirname(__FILE__)), 15 | "dispatcher" => array( 16 | "catchException" => 0, 17 | "throwException" => 0, 18 | ), 19 | ), 20 | ); 21 | 22 | class Bootstrap extends Yaf_Bootstrap_Abstract { 23 | protected function _initErrorHandler(Yaf_Dispatcher $dispatcher) { 24 | echo "Bad"; 25 | } 26 | } 27 | 28 | class IndexController extends Yaf_Controller_Abstract { 29 | public function indexAction() { 30 | echo "Okey"; 31 | return FALSE; 32 | } 33 | } 34 | 35 | $app = new Yaf_Application($config); 36 | try { 37 | $app->bootstrap()->run(); 38 | } catch (Exception $e) { 39 | var_dump($e->getMessage()); 40 | } 41 | ?> 42 | --EXPECTF-- 43 | Warning: %scannot call protected method Bootstrap::_initErrorHandler() in %s098.php on line %d 44 | Okey 45 | -------------------------------------------------------------------------------- /tests/101.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for various cycle references 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | request = new Yaf_Request_Simple(); 13 | $foo->request->setParam("foo", $foo); 14 | unset($foo); 15 | 16 | $foo = new Stdclass(); 17 | $foo->config = new Yaf_Config_Simple(array(), 0); 18 | $foo->config->foo = $foo; 19 | unset($foo); 20 | 21 | $foo = new Stdclass(); 22 | $foo->request = new Yaf_Request_Simple(); 23 | $app = new Yaf_Application(["yaf" => ["directory" => __DIR__]]); 24 | $app->getDispatcher()->setRequest($foo->request); 25 | unset($foo); 26 | ?> 27 | okey 28 | --EXPECT-- 29 | okey 30 | -------------------------------------------------------------------------------- /tests/102.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for yaf.forward_limit 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | yaf.forward_limit = 10; 8 | --FILE-- 9 | array( 12 | "directory" => realpath(dirname(__FILE__)), 13 | "modules" => "module", 14 | ), 15 | ); 16 | 17 | class ControllerController extends Yaf_Controller_Abstract { 18 | public function actionAction($from = NULL) { 19 | if (!$from) { 20 | print "starting\n"; 21 | } else { 22 | var_dump($from); 23 | } 24 | $this->forward("module", "controller", "index", array("from" => __METHOD__)); 25 | return false; 26 | } 27 | 28 | public function indexAction($from) { 29 | var_dump($from); 30 | $this->forward("dummy", array("from" => __METHOD__)); 31 | return false; 32 | } 33 | 34 | public function dummyAction($from) { 35 | var_dump($from); 36 | $this->forward("controller", "action", array("from" => __METHOD__)); 37 | return false; 38 | } 39 | } 40 | 41 | 42 | $app = new Yaf_Application($config); 43 | $request = new Yaf_Request_Http("/module/controller/action"); 44 | 45 | try { 46 | $app->getDispatcher()->returnResponse(false)->dispatch($request); 47 | } catch (Yaf_Exception $e) { 48 | echo $e->getMessage(), "\n"; 49 | } 50 | ?> 51 | --EXPECTF-- 52 | starting 53 | string(34) "ControllerController::actionAction" 54 | string(33) "ControllerController::indexAction" 55 | string(33) "ControllerController::dummyAction" 56 | string(34) "ControllerController::actionAction" 57 | string(33) "ControllerController::indexAction" 58 | string(33) "ControllerController::dummyAction" 59 | string(34) "ControllerController::actionAction" 60 | string(33) "ControllerController::indexAction" 61 | string(33) "ControllerController::dummyAction" 62 | The maximum dispatching count 10 is reached 63 | -------------------------------------------------------------------------------- /tests/103.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Request::set*Name 's second argument 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | yaf.forward_limit = 10; 8 | --FILE-- 9 | setModuleName("foo", true); 13 | var_dump($request->getModuleName()); 14 | $request->setModuleName("foo", false); 15 | var_dump($request->getModuleName()); 16 | $request->setModuleName("foo_bAR", true); 17 | var_dump($request->getModuleName()); 18 | $request->setModuleName("foo_bAR", false); 19 | var_dump($request->getModuleName()); 20 | 21 | 22 | $request->setControllerName("foo", true); 23 | var_dump($request->getControllerName()); 24 | $request->setControllerName("foo", false); 25 | var_dump($request->getControllerName()); 26 | $request->setControllerName("foo_bAR", true); 27 | var_dump($request->getControllerName()); 28 | $request->setControllerName("foo_bAR", false); 29 | var_dump($request->getControllerName()); 30 | 31 | $request->setActionName("Foo", true); 32 | var_dump($request->getActionName()); 33 | $request->setActionName("Foo", false); 34 | var_dump($request->getActionName()); 35 | $request->setActionName("foo_bAR", true); 36 | var_dump($request->getActionName()); 37 | $request->setActionName("foo_bAR", false); 38 | var_dump($request->getActionName()); 39 | ?> 40 | --EXPECT-- 41 | string(3) "Foo" 42 | string(3) "foo" 43 | string(7) "Foo_Bar" 44 | string(7) "foo_bAR" 45 | string(3) "Foo" 46 | string(3) "foo" 47 | string(7) "Foo_Bar" 48 | string(7) "foo_bAR" 49 | string(3) "foo" 50 | string(3) "Foo" 51 | string(7) "foo_bar" 52 | string(7) "foo_bAR" 53 | -------------------------------------------------------------------------------- /tests/105.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Application::bootstrap errors 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | $app = new Yaf_Application($config); 21 | 22 | $app->bootstrap(); 23 | file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<bootstrap(); 27 | file_put_contents(APPLICATION_PATH . "/Bootstrap.php", <<bootstrap(); 34 | } catch (Exception $e) { 35 | var_dump($e->getMessage()); 36 | } 37 | ?> 38 | --CLEAN-- 39 | 43 | --EXPECTF-- 44 | Warning: Yaf_Application::bootstrap(): Couldn't find bootstrap file %sBootstrap.php in %s105.php on line %d 45 | 46 | Warning: Yaf_Application::bootstrap(): Couldn't find class Bootstrap in %sBootstrap.php in %s105.php on line %d 47 | string(%d) "'Bootstrap' is not a subclass of Yaf_Bootstrap_Abstract" 48 | -------------------------------------------------------------------------------- /tests/106.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for PSR-4 autoloading 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 15 | "directory" => APPLICATION_PATH, 16 | "library" => array( 17 | "namespace" => array( 18 | "\Zend" => "/lib/Zend/foo", 19 | "\Microsoft\PHP" => "/var/lib/microsoft", 20 | "\Microsoft\ASP" => "/var/lib/asp", 21 | ) 22 | ), 23 | ), 24 | ); 25 | $app = new Yaf_Application($config); 26 | $loader = Yaf_Loader::getInstance(); 27 | var_dump($loader->getNamespaces()); 28 | var_dump($loader->getNamespacePath("\Zend\Foo\Dummy")); 29 | var_dump($loader->getNamespacePath("\Microsoft\Java")); 30 | var_dump($loader->getNamespacePath("\Microsoft\PHP\Framework")); 31 | 32 | $loader->registerNamespace("\Google\Robot", "/library/vendor/lib/robot"); 33 | var_dump($loader->getNamespacePath("Google\Robot")); 34 | 35 | var_dump(class_exists("\Microsoft\PHP\Framework\Dummy")); 36 | var_dump(class_exists("\Microsoft\ASP\Framework\Dummy")); 37 | var_dump(class_exists("\Zend\Foo\Dummy\Bar")); 38 | ?> 39 | --CLEAN-- 40 | 44 | --EXPECTF-- 45 | array(2) { 46 | ["Zend"]=> 47 | string(13) "/lib/Zend/foo" 48 | ["Microsoft"]=> 49 | array(2) { 50 | ["PHP"]=> 51 | string(18) "/var/lib/microsoft" 52 | ["ASP"]=> 53 | string(12) "/var/lib/asp" 54 | } 55 | } 56 | string(13) "/lib/Zend/foo" 57 | string(%d) "%sapplication%clibrary" 58 | string(18) "/var/lib/microsoft" 59 | string(%d) "%sapplication%clibrary" 60 | 61 | Warning: Yaf_Loader::autoload(): Failed opening script /var/lib/microsoft%cFramework%cDummy.php: No such file or directory in %s106.php on line %d 62 | bool(false) 63 | 64 | Warning: Yaf_Loader::autoload(): Failed opening script /var/lib/asp%cFramework%cDummy.php: No such file or directory in %s106.php on line %d 65 | bool(false) 66 | 67 | Warning: Yaf_Loader::autoload(): Failed opening script /lib/Zend/foo%cFoo%cDummy%cBar.php: No such file or directory in %s106.php on line %d 68 | bool(false) 69 | -------------------------------------------------------------------------------- /tests/107.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Dispatcher::setRespone 3 | --SKIPIF-- 4 | 8 | --EXTENSIONS-- 9 | json 10 | --INI-- 11 | yaf.use_spl_autoload=0 12 | yaf.lowcase_path=0 13 | yaf.use_namespace=0 14 | --FILE-- 15 | array( 21 | "directory" => APPLICATION_PATH, 22 | ), 23 | ); 24 | 25 | class my_response extends Yaf_Response_Abstract { 26 | public $bodys; 27 | 28 | public function appendBody($body, $name = NULL) { 29 | $this->bodys[] = $body; 30 | } 31 | public function response() { 32 | var_dump(json_encode($this->bodys)); 33 | } 34 | } 35 | 36 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<getDispatcher()->setResponse(new my_response()); 49 | $app->run(); 50 | ?> 51 | --CLEAN-- 52 | 56 | --EXPECT-- 57 | string(19) "["custom response"]" 58 | -------------------------------------------------------------------------------- /tests/108.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for auto response with ErrorController 3 | --SKIPIF-- 4 | 8 | --EXTENSIONS-- 9 | json 10 | --INI-- 11 | yaf.use_spl_autoload=0 12 | yaf.lowcase_path=0 13 | yaf.use_namespace=0 14 | --FILE-- 15 | array( 21 | "directory" => APPLICATION_PATH, 22 | "dispatcher" => array ( 23 | "catchException" => true, 24 | ), 25 | ), 26 | ); 27 | 28 | file_put_contents(APPLICATION_PATH . "/controllers/Error.php", <<getResponse(); 33 | \$response->setBody(json_encode(array( 34 | "code" => \$exception->getCode(), 35 | "msg" => \$exception->getMessage(), 36 | ) 37 | )); 38 | \$response->response(); 39 | return false; 40 | } 41 | } 42 | PHP 43 | ); 44 | 45 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<returnResponse(true); 50 | } 51 | } 52 | PHP 53 | ); 54 | 55 | $app = new Yaf_Application($config); 56 | $response = $app->run(); 57 | ?> 58 | --CLEAN-- 59 | 64 | --EXPECTF-- 65 | {"code":%d,"msg":"There is no method indexAction in IndexController"} 66 | -------------------------------------------------------------------------------- /tests/109.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for SIMD build_camel_name 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | setControllerName($u); 45 | if ($request->getControllerName() != build_camel_name($u)) { 46 | echo $u, ": expected: " , build_camel_name($u), "; got: ", $request->getControllerName(), "\n"; 47 | } 48 | } 49 | 50 | /* random test */ 51 | $i = 0; 52 | while ($i++ < 1024) { 53 | $len = rand(1, 64); 54 | $u = str_repeat(' ', $len); 55 | for ($c = 0; $c < $len; $c++) { 56 | @$u[$c] = rand(1, 255); 57 | } 58 | $request->setControllerName($u); 59 | if ($request->getControllerName() != build_camel_name($u)) { 60 | echo $u, ": expected: " , build_camel_name($u), "; got: ", $request->getControllerName(), "\n"; 61 | } 62 | } 63 | ?> 64 | okey 65 | --EXPECT-- 66 | okey 67 | -------------------------------------------------------------------------------- /tests/110.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug (open file not destroy or crash in Yaf_Config_Ini, PHP 8.1 or later) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | 22 | --EXPECTF-- 23 | string(4) "Done" -------------------------------------------------------------------------------- /tests/bug61493.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #61493 (Can't remove item when using unset() with a Yaf_Config_Simple instance) 3 | --CREDITS-- 4 | littlemiaor at gmail dot com 5 | --SKIPIF-- 6 | 7 | --INI-- 8 | yaf.use_namespace=0 9 | --FILE-- 10 | 'bar', 14 | ), false); 15 | 16 | unset($config['foo']); 17 | print_r($config); 18 | ?> 19 | --EXPECTF-- 20 | Yaf_Config_Simple Object 21 | ( 22 | [readonly:protected] => 23 | [config:protected] => Array 24 | ( 25 | ) 26 | 27 | ) 28 | -------------------------------------------------------------------------------- /tests/bug62702.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | FR #62702 (Make baseuri case-insensitive) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | route($request); 13 | var_dump($request->getControllerName()); 14 | 15 | $request = new Yaf_Request_Http("/Sample/ABC", "/sample"); 16 | $router->route($request); 17 | var_dump($request->getControllerName()); 18 | 19 | 20 | $router = new Yaf_Route_Map(true); 21 | $request = new Yaf_Request_Http("/sample/A/B/C", "/sample"); 22 | $router->route($request); 23 | var_dump($request->getControllerName()); 24 | 25 | $request = new Yaf_Request_Http("/sample", "/sAmplE/"); 26 | $router->route($request); 27 | var_dump($request->getControllerName()); 28 | 29 | $router = new Yaf_Route_Regex("#^/test#", array("controller" => "info"), array()); 30 | $request = new Yaf_Request_Http("/test/", "/Test"); 31 | $router->route($request); 32 | var_dump($request->getControllerName()); 33 | 34 | $request = new Yaf_Request_Http("/sample/test", "/sAmplE"); 35 | $router->route($request); 36 | var_dump($request->getControllerName()); 37 | 38 | $router = new Yaf_Route_Rewrite("/test", array("controller" => "info"), array()); 39 | $request = new Yaf_Request_Http("/test/", "/Test"); 40 | $router->route($request); 41 | var_dump($request->getControllerName()); 42 | 43 | $request = new Yaf_Request_Http("/sample/test", "/sAmplE"); 44 | $router->route($request); 45 | var_dump($request->getControllerName()); 46 | 47 | $router = new Yaf_Route_Rewrite("/sample/", array("controller" => "info"), array()); 48 | $request = new Yaf_Request_Http("/sample/test", "/sam"); 49 | $router->route($request); 50 | var_dump($request->getControllerName()); 51 | ?> 52 | --EXPECTF-- 53 | NULL 54 | string(3) "Abc" 55 | string(5) "A_B_C" 56 | NULL 57 | NULL 58 | string(4) "Info" 59 | NULL 60 | string(4) "Info" 61 | string(4) "Info" 62 | -------------------------------------------------------------------------------- /tests/bug63381.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #63381 ($_SERVER['SCRIPT_NAME'] changed by yaf) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 21 | "directory" => APPLICATION_PATH, 22 | ), 23 | ); 24 | 25 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<run(); 47 | 48 | var_dump($server === $_SERVER); 49 | var_dump($cookie === $_COOKIE); 50 | var_dump($get === $_GET); 51 | var_dump($post === $_POST); 52 | 53 | ?> 54 | --CLEAN-- 55 | 59 | --EXPECTF-- 60 | bool(true) 61 | bool(true) 62 | bool(true) 63 | bool(true) 64 | -------------------------------------------------------------------------------- /tests/bug63438.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #63438 (Strange behavior with nested rendering) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | render($file); 23 | } 24 | 25 | file_put_contents(dirname(__FILE__) . '/outer.phtml', "1 3\n"); 26 | file_put_contents(dirname(__FILE__) . '/inner.phtml', "2"); 27 | print (view('outer.phtml')); 28 | 29 | file_put_contents(dirname(__FILE__) . '/outer.phtml', "1 display('inner.phtml');?> 3\n"); 30 | print (view('outer.phtml')); 31 | 32 | file_put_contents(dirname(__FILE__) . '/outer.phtml', "1 eval('2');?> 3\n"); 33 | print (view('outer.phtml')); 34 | 35 | file_put_contents(dirname(__FILE__) . '/outer.phtml', "1 display('inner.phtml');?> 3\n"); 36 | file_put_contents(dirname(__FILE__) . '/inner.phtml', ""); 37 | print (view('outer.phtml')); 38 | ?> 39 | --CLEAN-- 40 | 44 | --EXPECTF-- 45 | 1 2 3 46 | 1 2 3 47 | 1 2 3 48 | 49 | Fatal error: Uncaught Error: Call to undefined function undefined_function() in %sinner.phtml:%d 50 | %a 51 | done 52 | -------------------------------------------------------------------------------- /tests/bug63900.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #63900 (Segfault if separated action executes failed) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.throw_exception=0 9 | yaf.catch_exception=1 10 | yaf.use_namespace=0 11 | --FILE-- 12 | array( 18 | "directory" => APPLICATION_PATH, 19 | ), 20 | ); 21 | 22 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", << "controllers/IndexAction.php", 27 | ); 28 | } 29 | PHP 30 | ); 31 | 32 | file_put_contents(APPLICATION_PATH . "/controllers/IndexAction.php", <<run(); 46 | echo "Okey"; 47 | ?> 48 | --CLEAN-- 49 | 53 | --EXPECTF-- 54 | Okey 55 | -------------------------------------------------------------------------------- /tests/bug70913.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #70913 (Segfault while new Yaf_Controller) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.throw_exception=0 9 | yaf.catch_exception=1 10 | yaf.use_namespace=0 11 | --FILE-- 12 | array( 18 | "directory" => APPLICATION_PATH, 19 | ), 20 | ); 21 | 22 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<getRequest(), \$this->getResponse(), \$this->getView()); 27 | } 28 | } 29 | PHP 30 | ); 31 | 32 | file_put_contents(APPLICATION_PATH . "/controllers/Second.php", <<run(); 44 | print_r($response); 45 | ?> 46 | --CLEAN-- 47 | 51 | --EXPECT-- 52 | Okey 53 | Yaf_Response_Cli Object 54 | ( 55 | [response_code:protected] => 0 56 | [header_sent:protected] => 57 | ) 58 | -------------------------------------------------------------------------------- /tests/bug76213.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #76213 (Memory leaks with yaf_dispatcher_exception_handler) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | array( 11 | "directory" => realpath(dirname(__FILE__)), 12 | "dispatcher" => array( 13 | "catchException" => 1 14 | ) 15 | ), 16 | ); 17 | 18 | $app = new Yaf_Application($config); 19 | 20 | try { 21 | $request = new Yaf_Request_Http("/index/admin/login1"); 22 | $app->getDispatcher()->dispatch($request); 23 | } catch(Yaf_Exception $e) { 24 | var_dump($e->getMessage()); 25 | } 26 | ?> 27 | --EXPECTF-- 28 | string(%d) "%s" 29 | -------------------------------------------------------------------------------- /tests/bug76217.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #76217 (Memory leaks with Yaf_Dispatcher::setDefault*) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | setDefaultModule("index") 19 | ->setDefaultController("admin") 20 | ->setDefaultAction("login"); 21 | } 22 | } 23 | PHP 24 | ); 25 | 26 | file_put_contents(APPLICATION_PATH . "/controllers/Admin.php", << array( 41 | "directory" => APPLICATION_PATH, 42 | "modules" => "Index,User,Admin", 43 | ), 44 | ); 45 | 46 | $app = new Yaf_Application($config); 47 | $app->bootstrap()->run(); 48 | ?> 49 | --CLEAN-- 50 | 54 | --EXPECTF-- 55 | string(%d) "%s" 56 | -------------------------------------------------------------------------------- /tests/build.inc: -------------------------------------------------------------------------------- 1 | 44 | -------------------------------------------------------------------------------- /tests/issue134.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ISSUE #134 (Segfault while calling assemble) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --FILE-- 8 | 'index', 14 | 'action' => 'detail', 15 | 'module' => 'kfc' 16 | ) 17 | ); 18 | $router->addRoute("kfc/index/detail", $route); 19 | 20 | print_r($router->getRoute('kfc/index/detail')->assemble( 21 | array( 22 | ':id' => '1', 23 | ) 24 | )); 25 | --EXPECTF-- 26 | /detail/1 27 | -------------------------------------------------------------------------------- /tests/issue163.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Issue #163 (forward from init controller) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.throw_exception=0 9 | yaf.catch_exception=1 10 | yaf.use_namespace=0 11 | --FILE-- 12 | array( 18 | "directory" => APPLICATION_PATH, 19 | ), 20 | ); 21 | 22 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<forward("Index", "Second", "okey"); 27 | } 28 | public function indexAction() { 29 | echo "bad"; 30 | } 31 | } 32 | PHP 33 | ); 34 | 35 | file_put_contents(APPLICATION_PATH . "/controllers/Second.php", <<run(); 50 | ?> 51 | --CLEAN-- 52 | 56 | --EXPECT-- 57 | Okey 58 | -------------------------------------------------------------------------------- /tests/issue231.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ISSUE #231 (php-fpm worker core dump BUG) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | variables_order=EPS 7 | yaf.lowcase_path=0 8 | yaf.throw_exception=0 9 | yaf.catch_exception=1 10 | yaf.use_namespace=0 11 | --POST-- 12 | SCRIPT_FILENAME=issue231.php 13 | --FILE-- 14 | 20 | --EXPECTF-- 21 | Yaf_Request_Http Object 22 | ( 23 | [method] => POST 24 | [module] => 25 | [controller] => 26 | [action] => 27 | [uri:protected] => %stests 28 | [base_uri:protected] => 29 | [dispatched:protected] => 30 | [routed:protected] => 31 | [language:protected] => 32 | [params:protected] => Array 33 | ( 34 | ) 35 | 36 | ) 37 | %saf_Request_Http::__set_state(array( 38 | 'method' => 'POST', 39 | 'module' => NULL, 40 | 'controller' => NULL, 41 | 'action' => NULL, 42 | 'uri:protected' => '%stests', 43 | 'base_uri:protected' => '%s', 44 | 'dispatched:protected' => false, 45 | 'routed:protected' => false, 46 | 'language:protected' => '', 47 | 'params:protected' => 48 | array ( 49 | ), 50 | )) 51 | -------------------------------------------------------------------------------- /tests/issue232.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ISSUE #232 (Segfault with Yaf_Route_Simple) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.lowcase_path=0 7 | yaf.throw_exception=0 8 | yaf.catch_exception=1 9 | yaf.use_namespace=0 10 | --GET-- 11 | c=index 12 | --FILE-- 13 | route($request); 17 | var_dump($request->getModuleName()); 18 | var_dump($request->getControllerName()); 19 | var_dump($request->getActionName()); 20 | ?> 21 | --EXPECTF-- 22 | NULL 23 | string(5) "Index" 24 | NULL 25 | -------------------------------------------------------------------------------- /tests/issue297.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ISSUE #297 (Yaf_Loader fail to load namespace class name) 3 | --SKIPIF-- 4 | 8 | --INI-- 9 | yaf.lowcase_path=0 10 | yaf.throw_exception=0 11 | yaf.catch_exception=1 12 | yaf.use_namespace=1 13 | yaf.use_spl_autoload=0 14 | --FILE-- 15 | autoload("Test\Test")); 18 | var_dump(new \Test\Test\Test\Test\Test\Test\T\Test\Test); //for __SSE2__ 19 | ?> 20 | --EXPECTF-- 21 | Warning: Yaf\Loader::autoload(): Failed opening script %s%cTest/Test.php: No such file or directory in %sissue297.php on line %d 22 | bool(true) 23 | 24 | Warning: Yaf\Loader::autoload(): Failed opening script %s/Test/Test/Test/Test/Test/Test/T/Test/Test.php: No such file or directory in %sissue297.php on line %d 25 | 26 | Fatal error: Uncaught Error: Class %cTest\Test\Test\Test\Test\Test\T\Test\Test%c not found in %sissue297.php:%d 27 | Stack trace: 28 | #0 {main} 29 | thrown in %sissue297.php on line %d -------------------------------------------------------------------------------- /tests/issue303.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ISSUE #303 (local variable is overrided by view renderring) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<display("index", array());; 26 | var_dump(\$local); 27 | return false; 28 | } 29 | } 30 | PHP 31 | ); 32 | 33 | file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", ""); 34 | 35 | $app = new Yaf_Application($config); 36 | $app->run(); 37 | 38 | ?> 39 | --CLEAN-- 40 | 45 | --EXPECTF-- 46 | bool(true) 47 | -------------------------------------------------------------------------------- /tests/issue311.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ISSUE #311 (Yaf_application::environ should respect $environ) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | yaf.environ=product 10 | --FILE-- 11 | array( 14 | "directory" => dirname(__DIR__), 15 | ), 16 | ); 17 | $app = new Yaf_Application($config,'dev');//使用dev环境 18 | echo ini_get('yaf.environ'),' ',$app->environ();//显示系统配置的yaf环境和当前应用的yaf环境 19 | ?> 20 | --EXPECT-- 21 | product dev 22 | -------------------------------------------------------------------------------- /tests/issue415.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Issue #415 ($actions changed to be reference) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.throw_exception=0 9 | yaf.catch_exception=1 10 | yaf.use_namespace=0 11 | --FILE-- 12 | array( 18 | "directory" => APPLICATION_PATH, 19 | ), 20 | ); 21 | 22 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", << 'need init', 27 | ]; 28 | 29 | public function init() { 30 | // foreach (\$this->actions as \$action => \$path) { 31 | // \$this->actions[\$action] = 'actions/IndexAction.php'; 32 | // } 33 | array_walk(\$this->actions, function(\$path, \$action) { 34 | \$this->actions[\$action] = 'actions/IndexAction.php'; 35 | }); 36 | } 37 | } 38 | PHP 39 | ); 40 | 41 | @mkdir(APPLICATION_PATH . "/actions/"); 42 | file_put_contents(APPLICATION_PATH . "/actions/IndexAction.php", <<run(); 55 | ?> 56 | --CLEAN-- 57 | 61 | --EXPECT-- 62 | Okey 63 | -------------------------------------------------------------------------------- /tests/issue420.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Issue #420 (bug in yaf_dispatcher_get_call_parameters) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.throw_exception=0 9 | yaf.catch_exception=1 10 | yaf.use_namespace=0 11 | --FILE-- 12 | array( 18 | "directory" => APPLICATION_PATH, 19 | ), 20 | ); 21 | 22 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<setControllerName('Foo_Bar', false); 36 | var_dump($req->getControllerName()); 37 | $req->setControllerName('index'); 38 | $req->setActionName('func'); 39 | $req->setParam(array('b' => 'the second param')); 40 | $app->getDispatcher()->dispatch($req); 41 | $req->clearParams(); 42 | $req->setParam(array('a' => 'the first param')); 43 | $app->getDispatcher()->dispatch($req); 44 | ?> 45 | --CLEAN-- 46 | 50 | --EXPECT-- 51 | string(7) "Foo_Bar" 52 | int(0) 53 | string(16) "the second param" 54 | string(15) "the first param" 55 | int(1) 56 | -------------------------------------------------------------------------------- /tests/issue468.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ISSUE #468 Check for same name variables assignment 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=0 7 | yaf.use_namespace=0 8 | 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | "dispatcher" => array ( 18 | "catchException" => true, 19 | ), 20 | ), 21 | ); 22 | 23 | 24 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<getView()->assign("ref", "first-source"); 29 | } 30 | 31 | public function indexAction() { 32 | \$this->getView()->assign("ref", "second-source"); 33 | \$this->getView()->display("index/index.phtml", ["ref" => "thrid-source"]); 34 | var_dump(\$this->getViewpath()); 35 | return false; 36 | } 37 | } 38 | PHP 39 | ); 40 | 41 | file_put_contents(APPLICATION_PATH . "/views/index/index.phtml", ""); 44 | 45 | $app = new Yaf_Application($config); 46 | $app->run(); 47 | 48 | ?> 49 | --CLEAN-- 50 | 54 | --EXPECTF-- 55 | string(12) "thrid-source" 56 | string(%d) "%sapplication%cviews" 57 | -------------------------------------------------------------------------------- /tests/issue518.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for Yaf_Response_HTTP::setRedirect in CGI 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_namespace=0 7 | --GET-- 8 | foo=bar 9 | --FILE-- 10 | setHeader("custom", "foobar"); 13 | $response->response(); 14 | var_dump($response->setRedirect('https://yourdomain.com')); 15 | ?> 16 | --EXPECTHEADERS-- 17 | Status: 302 Found 18 | Location: https://yourdomain.com 19 | custom: foobar 20 | --EXPECT-- 21 | bool(true) 22 | -------------------------------------------------------------------------------- /tests/issue530.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Segfault while exiting in action 3 | --SKIPIF-- 4 | 8 | --INI-- 9 | yaf.use_namespace=0 10 | yaf.use_spl_autoload=0 11 | --FILE-- 12 | array( 18 | "directory" => APPLICATION_PATH, 19 | ), 20 | ); 21 | $app = new Yaf_Application($config); 22 | 23 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", <<run(); 34 | ?> 35 | --CLEAN-- 36 | 40 | --EXPECT-- 41 | okey 42 | -------------------------------------------------------------------------------- /tests/issue535.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | ISSUE #535 (Segsev while throw exception in action) 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | yaf.use_spl_autoload=1 7 | yaf.lowcase_path=0 8 | yaf.use_namespace=0 9 | --FILE-- 10 | array( 16 | "directory" => APPLICATION_PATH, 17 | ), 18 | ); 19 | 20 | file_put_contents(APPLICATION_PATH . "/controllers/Index.php", << "actions/test/seprate.php", 25 | ); 26 | } 27 | PHP 28 | ); 29 | 30 | @mkdir(APPLICATION_PATH . "/actions/test/"); 31 | file_put_contents(APPLICATION_PATH . "/actions/test/seprate.php", <<getDispatcher()->dispatch($request); 71 | ?> 72 | --CLEAN-- 73 | 77 | --EXPECT-- 78 | okey 79 | -------------------------------------------------------------------------------- /tests/multi-section.ini: -------------------------------------------------------------------------------- 1 | [base ] 2 | base.a=1 3 | base.b=2 4 | [ extra] 5 | base.c=3 6 | [ foo] 7 | base.d=4 8 | 9 | [ multi:: extra: base : foo ] 10 | [ ::multi2::::: base:] 11 | [: : :: : foo] 12 | -------------------------------------------------------------------------------- /tests/simple.ini: -------------------------------------------------------------------------------- 1 | [base] 2 | application.directory=APPLICATION_PATH "/applcation" 3 | name = "base" 4 | array.1 = 1 5 | 5=5 6 | array.name="name" 7 | routes.regex.type="regex" 8 | routes.regex.match="^/ap/(.*)" 9 | routes.regex.route.controller="Index" 10 | routes.regex.route.action="action" 11 | routes.regex.map.0="name" 12 | routes.regex.map.1="name" 13 | routes.regex.map.2="value" 14 | routes.simple.type="simple" 15 | routes.simple.controller="c" 16 | routes.simple.module="m" 17 | routes.simple.action="a" 18 | routes.supervar.type="supervar" 19 | routes.supervar.varname="c" 20 | routes.rewrite.type="rewrite" 21 | routes.rewrite.match="/yaf/:name/:value" 22 | routes.rewrite.route.controller="Index" 23 | routes.rewrite.route.action="action" 24 | 25 | [extra : base ] 26 | value = "2" 27 | name = "extra" 28 | array.name = "new_name" 29 | array.2 = "test" 30 | 31 | [product : extra] 32 | 33 | [nocatch : extra] 34 | application.dispatcher.throwException=Off 35 | application.dispatcher.catchException=yes 36 | routes.rewrite.match="/yaf/:name/:age" 37 | 38 | [envtest] 39 | env=${FOO} 40 | ini=${yaf.directory} 41 | const=FOO 42 | 43 | -------------------------------------------------------------------------------- /tests/system.ini: -------------------------------------------------------------------------------- 1 | [base] 2 | application.directory=APPLICATION_PATH "/applcation" 3 | application.system.lowcase_path=0 4 | application.system.name_suffix=0 5 | application.system.name_separator="__" 6 | [product : base] 7 | ;only yaf runtime configure can be set 8 | application.system.open_basedir=APPLICATION_PATH 9 | application.system.use_spl_autoload=0 10 | application.system.open_basedir=APPLICATION_PATH 11 | application.system.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=0 12 | application.system.library=APPLICATION_PATH 13 | application.system.cache_config=Off 14 | -------------------------------------------------------------------------------- /tools/cg/README.md: -------------------------------------------------------------------------------- 1 | ##Yaf Codes Generator 2 | 3 | ###Usage 4 | ``` 5 | php yaf_cg -d Sample 6 | ``` 7 | 8 | will generator folder "Sample" under output: 9 | ``` 10 | $ ls ./Sample/ 11 | application/ conf/ index.php readme.txt 12 | ``` 13 | ``` 14 | php yaf_cg -d Sample -n 15 | will generate a namespace example 16 | ``` 17 | -------------------------------------------------------------------------------- /tools/cg/templates/.htaccess.tpl: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | RewriteCond %{REQUEST_FILENAME} !-f 3 | RewriteRule .* index.php 4 | -------------------------------------------------------------------------------- /tools/cg/templates/application/Bootstrap.php.tpl: -------------------------------------------------------------------------------- 1 | getConfig(); 15 | Yaf_Registry::set('config', $arrConfig); 16 | } 17 | 18 | public function _initPlugin(Yaf_Dispatcher $dispatcher) { 19 | //注册一个插件 20 | $objSamplePlugin = new SamplePlugin(); 21 | $dispatcher->registerPlugin($objSamplePlugin); 22 | } 23 | 24 | public function _initRoute(Yaf_Dispatcher $dispatcher) { 25 | //在这里注册自己的路由协议,默认使用简单路由 26 | } 27 | 28 | public function _initView(Yaf_Dispatcher $dispatcher) { 29 | //在这里注册自己的view控制器,例如smarty,firekylin 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tools/cg/templates/application/controllers/Error.php.tpl: -------------------------------------------------------------------------------- 1 | getView()->assign("exception", $exception); 14 | //5. render by Yaf 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tools/cg/templates/application/controllers/Index.php.tpl: -------------------------------------------------------------------------------- 1 | getView()->assign("header", "Yaf Example"); 15 | } 16 | 17 | /** 18 | * 默认动作 19 | * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参 20 | * 对于如下的例子, 当访问http://yourhost/{&$APP_NAME&}/index/index/index/name/{&$AUTHOR&} 的时候, 你就会发现不同 21 | */ 22 | public function indexAction($name = "Stranger") { 23 | //1. fetch query 24 | $get = $this->getRequest()->getQuery("get", "default value"); 25 | 26 | //2. fetch model 27 | $model = new SampleModel(); 28 | 29 | //3. assign 30 | $this->getView()->assign("content", $model->selectSample()); 31 | $this->getView()->assign("name", $name); 32 | 33 | //4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板 34 | return TRUE; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tools/cg/templates/application/library/readme.txt.tpl: -------------------------------------------------------------------------------- 1 | 项目库文件放在这里 -------------------------------------------------------------------------------- /tools/cg/templates/application/models/Sample.php.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 500 Error 4 | 5 |
6 | 9 |
10 |
11 | getMessage(); 13 | ?> 14 | 15 | 16 | -------------------------------------------------------------------------------- /tools/cg/templates/application/views/index/index.phtml.tpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | <?=$header?> 4 | 5 | 6 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tools/cg/templates/conf/application.ini.tpl: -------------------------------------------------------------------------------- 1 | [common] 2 | application.directory = APPLICATION_PATH "/application" 3 | application.dispatcher.catchException = TRUE 4 | 5 | [product : common] 6 | -------------------------------------------------------------------------------- /tools/cg/templates/index.php.tpl: -------------------------------------------------------------------------------- 1 | bootstrap()->run(); 9 | ?> 10 | -------------------------------------------------------------------------------- /tools/cg/templates/readme.txt.tpl: -------------------------------------------------------------------------------- 1 | 可以按照以下步骤来部署和运行程序: 2 | 1.请确保机器{&$DEV_PC&}已经安装了Yaf框架, 并且已经加载入PHP; 3 | 2.把{&$APP_NAME&}目录Copy到Webserver的DocumentRoot目录下; 4 | 3.需要在php.ini里面启用如下配置,生产的代码才能正确运行: 5 | yaf.environ="product" 6 | 4.重启Webserver; 7 | 5.访问http://yourhost/{&$APP_NAME&}/,出现Hellow Word!, 表示运行成功,否则请查看php错误日志; 8 | -------------------------------------------------------------------------------- /travis/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | phpize && ./configure && make clean && make 3 | -------------------------------------------------------------------------------- /travis/run-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TEST_DIR="`pwd`/tests/" 3 | 4 | make test 5 | 6 | for file in `find $TEST_DIR -name "*.diff" 2>/dev/null` 7 | do 8 | grep "\-\-XFAIL--" ${file/%diff/phpt} >/dev/null 2>&1 9 | if [ $? -gt 0 ] 10 | then 11 | FAILS[${#FAILS[@]}]="$file" 12 | fi 13 | done 14 | 15 | if [ ${#FAILS[@]} -gt 0 ] 16 | then 17 | for fail in "${FAILS[@]}" 18 | do 19 | sh -xc "cat $fail" 20 | done 21 | exit 1 22 | else 23 | exit 0 24 | fi 25 | -------------------------------------------------------------------------------- /views/yaf_view_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_VIEW_INTERFACE_H 18 | #define YAF_VIEW_INTERFACE_H 19 | 20 | extern zend_class_entry *yaf_view_interface_ce; 21 | 22 | YAF_STARTUP_FUNCTION(view_interface); 23 | 24 | #endif 25 | /* 26 | * Local variables: 27 | * tab-width: 4 28 | * c-basic-offset: 4 29 | * End: 30 | * vim600: noet sw=4 ts=4 fdm=marker 31 | * vim<600: noet sw=4 ts=4 32 | */ 33 | -------------------------------------------------------------------------------- /views/yaf_view_simple.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_VIEW_SIMPLE_H 18 | #define YAF_VIEW_SIMPLE_H 19 | 20 | #define VIEW_BUFFER_BLOCK_SIZE 4096 21 | #define VIEW_BUFFER_SIZE_MASK 4095 22 | 23 | extern zend_class_entry *yaf_view_simple_ce; 24 | 25 | void yaf_view_simple_instance(yaf_view_t *view, zend_string *tpl_dir); 26 | int yaf_view_simple_render(yaf_view_t *view, zend_string *tpl, zval *vars, zval *ret); 27 | 28 | YAF_STARTUP_FUNCTION(view_simple); 29 | 30 | #endif 31 | /* 32 | * Local variables: 33 | * tab-width: 4 34 | * c-basic-offset: 4 35 | * End: 36 | * vim600: noet sw=4 ts=4 fdm=marker 37 | * vim<600: noet sw=4 ts=4 38 | */ 39 | -------------------------------------------------------------------------------- /yaf.php: -------------------------------------------------------------------------------- 1 | "; 3 | 4 | if(!extension_loaded('ap')) { 5 | dl('ap.' . PHP_SHLIB_SUFFIX); 6 | } 7 | $module = 'ap'; 8 | $functions = get_extension_funcs($module); 9 | echo "Functions available in the test extension:$br\n"; 10 | foreach($functions as $func) { 11 | echo $func."$br\n"; 12 | } 13 | echo "$br\n"; 14 | $function = 'confirm_' . $module . '_compiled'; 15 | if (extension_loaded($module)) { 16 | $str = $function($module); 17 | } else { 18 | $str = "Module $module is not compiled into PHP"; 19 | } 20 | echo "$str\n"; 21 | ?> 22 | -------------------------------------------------------------------------------- /yaf_action.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ACTION_H 18 | #define YAF_ACTION_H 19 | 20 | #define YAF_ACTION_PROPERTY_NAME_CTRL "_controller" 21 | 22 | #define yaf_action_object yaf_controller_object 23 | 24 | extern zend_class_entry * yaf_action_ce; 25 | 26 | void yaf_action_init(yaf_action_object *action, yaf_controller_t *ctl, zend_string *name); 27 | 28 | YAF_STARTUP_FUNCTION(action); 29 | #endif 30 | /* 31 | * Local variables: 32 | * tab-width: 4 33 | * c-basic-offset: 4 34 | * End: 35 | * vim600: noet sw=4 ts=4 fdm=marker 36 | * vim<600: noet sw=4 ts=4 37 | */ 38 | 39 | -------------------------------------------------------------------------------- /yaf_application.stub.php: -------------------------------------------------------------------------------- 1 | | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifdef HAVE_CONFIG_H 18 | #include "config.h" 19 | #endif 20 | 21 | #include "php.h" 22 | 23 | #include "php_yaf.h" 24 | #include "yaf_namespace.h" 25 | #include "yaf_bootstrap.h" 26 | 27 | zend_class_entry *yaf_bootstrap_ce; 28 | 29 | /** {{{ yaf_bootstrap_methods 30 | */ 31 | zend_function_entry yaf_bootstrap_methods[] = { 32 | {NULL, NULL, NULL} 33 | }; 34 | /* }}} */ 35 | 36 | /** {{{ YAF_STARTUP_FUNCTION 37 | */ 38 | YAF_STARTUP_FUNCTION(bootstrap) { 39 | zend_class_entry ce; 40 | 41 | YAF_INIT_CLASS_ENTRY(ce, "Yaf_Bootstrap_Abstract", "Yaf\\Bootstrap_Abstract", yaf_bootstrap_methods); 42 | yaf_bootstrap_ce = zend_register_internal_class_ex(&ce, NULL); 43 | yaf_bootstrap_ce->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; 44 | 45 | return SUCCESS; 46 | } 47 | /* }}} */ 48 | 49 | /* 50 | * Local variables: 51 | * tab-width: 4 52 | * c-basic-offset: 4 53 | * End: 54 | * vim600: noet sw=4 ts=4 fdm=marker 55 | * vim<600: noet sw=4 ts=4 56 | */ 57 | -------------------------------------------------------------------------------- /yaf_bootstrap.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_BOOTSTRAP_H 18 | #define YAF_BOOTSTRAP_H 19 | 20 | #define YAF_DEFAULT_BOOTSTRAP "Bootstrap" 21 | #define YAF_BOOTSTRAP_INITFUNC_PREFIX "_init" 22 | 23 | extern zend_class_entry *yaf_bootstrap_ce; 24 | 25 | YAF_STARTUP_FUNCTION(bootstrap); 26 | #endif 27 | /* 28 | * Local variables: 29 | * tab-width: 4 30 | * c-basic-offset: 4 31 | * End: 32 | * vim600: noet sw=4 ts=4 fdm=marker 33 | * vim<600: noet sw=4 ts=4 34 | */ 35 | -------------------------------------------------------------------------------- /yaf_loader.stub.php: -------------------------------------------------------------------------------- 1 | | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_NAMESPACE_H 18 | #define YAF_NAMESPACE_H 19 | 20 | #define namespace_switch(n) \ 21 | ((yaf_is_use_namespace())? n##_ns : n) 22 | 23 | #define YAF_INIT_CLASS_ENTRY(ce, name, name_ns, methods) \ 24 | if (yaf_is_use_namespace()) { \ 25 | INIT_CLASS_ENTRY(ce, name_ns, methods); \ 26 | } else { \ 27 | INIT_CLASS_ENTRY(ce, name, methods); \ 28 | } 29 | 30 | #endif /* PHP_YAF_H */ 31 | 32 | /* 33 | * Local variables: 34 | * tab-width: 4 35 | * c-basic-offset: 4 36 | * End: 37 | * vim600: noet sw=4 ts=4 fdm=marker 38 | * vim<600: noet sw=4 ts=4 39 | */ 40 | -------------------------------------------------------------------------------- /yaf_plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_PLUGIN_H 18 | #define YAF_PLUGIN_H 19 | 20 | extern zend_class_entry *yaf_plugin_ce; 21 | 22 | YAF_STARTUP_FUNCTION(plugin); 23 | #endif 24 | 25 | /* 26 | * Local variables: 27 | * tab-width: 4 28 | * c-basic-offset: 4 29 | * End: 30 | * vim600: noet sw=4 ts=4 fdm=marker 31 | * vim<600: noet sw=4 ts=4 32 | */ 33 | -------------------------------------------------------------------------------- /yaf_plugin_arginfo.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, edit the .stub.php file instead. 2 | * Stub hash: f66e1addbc0bacfe1709bf3bde6b79445e0b4ace */ 3 | 4 | ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Yaf_Plugin_Abstract_routerStartup, 0, 0, 2) 5 | ZEND_ARG_OBJ_INFO(0, request, Yaf_Request_Abstract, 0) 6 | ZEND_ARG_OBJ_INFO(0, response, Yaf_Response_Abstract, 0) 7 | ZEND_END_ARG_INFO() 8 | 9 | #define arginfo_class_Yaf_Plugin_Abstract_routerShutdown arginfo_class_Yaf_Plugin_Abstract_routerStartup 10 | 11 | #define arginfo_class_Yaf_Plugin_Abstract_dispatchLoopStartup arginfo_class_Yaf_Plugin_Abstract_routerStartup 12 | 13 | #define arginfo_class_Yaf_Plugin_Abstract_dispatchLoopShutdown arginfo_class_Yaf_Plugin_Abstract_routerStartup 14 | 15 | #define arginfo_class_Yaf_Plugin_Abstract_preDispatch arginfo_class_Yaf_Plugin_Abstract_routerStartup 16 | 17 | #define arginfo_class_Yaf_Plugin_Abstract_postDispatch arginfo_class_Yaf_Plugin_Abstract_routerStartup 18 | 19 | #define arginfo_class_Yaf_Plugin_Abstract_preResponse arginfo_class_Yaf_Plugin_Abstract_routerStartup 20 | 21 | ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NS_Yaf_Plugin_Abstract_routerStartup, 0, 0, 2) 22 | ZEND_ARG_OBJ_INFO(0, request, Yaf\\Request_Abstract, 0) 23 | ZEND_ARG_OBJ_INFO(0, response, Yaf\\Response_Abstract, 0) 24 | ZEND_END_ARG_INFO() 25 | 26 | #define arginfo_class_NS_Yaf_Plugin_Abstract_routerShutdown arginfo_class_NS_Yaf_Plugin_Abstract_routerStartup 27 | 28 | #define arginfo_class_NS_Yaf_Plugin_Abstract_dispatchLoopStartup arginfo_class_NS_Yaf_Plugin_Abstract_routerStartup 29 | 30 | #define arginfo_class_NS_Yaf_Plugin_Abstract_dispatchLoopShutdown arginfo_class_NS_Yaf_Plugin_Abstract_routerStartup 31 | 32 | #define arginfo_class_NS_Yaf_Plugin_Abstract_preDispatch arginfo_class_NS_Yaf_Plugin_Abstract_routerStartup 33 | 34 | #define arginfo_class_NS_Yaf_Plugin_Abstract_postDispatch arginfo_class_NS_Yaf_Plugin_Abstract_routerStartup 35 | 36 | #define arginfo_class_NS_Yaf_Plugin_Abstract_preResponse arginfo_class_NS_Yaf_Plugin_Abstract_routerStartup 37 | -------------------------------------------------------------------------------- /yaf_registry.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Yet Another Framework | 4 | +----------------------------------------------------------------------+ 5 | | This source file is subject to version 3.01 of the PHP license, | 6 | | that is bundled with this package in the file LICENSE, and is | 7 | | available through the world-wide-web at the following url: | 8 | | http://www.php.net/license/3_01.txt | 9 | | If you did not receive a copy of the PHP license and are unable to | 10 | | obtain it through the world-wide-web, please send a note to | 11 | | license@php.net so we can mail you a copy immediately. | 12 | +----------------------------------------------------------------------+ 13 | | Author: Xinchen Hui | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_REGISTRY_H 18 | #define YAF_REGISTRY_H 19 | 20 | typedef struct { 21 | zend_array entries; 22 | zend_array *properties; 23 | zend_object std; 24 | } yaf_registry_object; 25 | 26 | #define Z_YAFREGISTRYOBJ(zv) (php_yaf_registry_fetch_object(Z_OBJ(zv))) 27 | #define Z_YAFREGISTRYOBJ_P(zv) Z_YAFREGISTRYOBJ(*zv) 28 | static zend_always_inline yaf_registry_object *php_yaf_registry_fetch_object(zend_object *obj) { 29 | return (yaf_registry_object *)((char*)(obj) - XtOffsetOf(yaf_registry_object, std)); 30 | } 31 | 32 | extern zend_class_entry *yaf_registry_ce; 33 | 34 | YAF_STARTUP_FUNCTION(registry); 35 | #endif 36 | 37 | /* 38 | * Local variables: 39 | * tab-width: 4 40 | * c-basic-offset: 4 41 | * End: 42 | * vim600: noet sw=4 ts=4 fdm=marker 43 | * vim<600: noet sw=4 ts=4 44 | */ 45 | -------------------------------------------------------------------------------- /yaf_registry.stub.php: -------------------------------------------------------------------------------- 1 | | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_ROUTER_H 18 | #define YAF_ROUTER_H 19 | 20 | #define YAF_ROUTER_URL_DELIMIETER '/' 21 | #define YAF_ROUTE_REGEX_DILIMITER '#' 22 | 23 | typedef struct { 24 | zend_array routes; 25 | zval current; 26 | zend_array *properties; 27 | zend_object std; 28 | } yaf_router_object; 29 | 30 | #define Z_YAFROUTEROBJ(zv) (php_yaf_router_fetch_object(Z_OBJ(zv))) 31 | #define Z_YAFROUTEROBJ_P(zv) Z_YAFROUTEROBJ(*zv) 32 | 33 | static zend_always_inline yaf_router_object *php_yaf_router_fetch_object(zend_object *obj) { 34 | return (yaf_router_object *)((char*)(obj) - XtOffsetOf(yaf_router_object, std)); 35 | } 36 | 37 | extern zend_class_entry *yaf_router_ce; 38 | 39 | void yaf_router_instance(yaf_router_t *this_ptr); 40 | void yaf_router_parse_parameters(const char *str, size_t len, zval *params); 41 | int yaf_router_route(yaf_router_object *router, yaf_request_t *request); 42 | 43 | YAF_STARTUP_FUNCTION(router); 44 | 45 | #endif 46 | 47 | /* 48 | * Local variables: 49 | * tab-width: 4 50 | * c-basic-offset: 4 51 | * End: 52 | * vim600: noet sw=4 ts=4 fdm=marker 53 | * vim<600: noet sw=4 ts=4 54 | */ 55 | -------------------------------------------------------------------------------- /yaf_router.stub.php: -------------------------------------------------------------------------------- 1 | | 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef YAF_SESSION_H 18 | #define YAF_SESSION_H 19 | 20 | #define YAF_SESSION_STARTED (1<<0) 21 | 22 | typedef struct { 23 | zend_uchar flags; 24 | zend_array *session; 25 | zend_array *properties; 26 | zend_object std; 27 | } yaf_session_object; 28 | 29 | #define Z_YAFSESSIONOBJ(zv) (php_yaf_session_fetch_object(Z_OBJ(zv))) 30 | #define Z_YAFSESSIONOBJ_P(zv) Z_YAFSESSIONOBJ(*zv) 31 | 32 | static zend_always_inline yaf_session_object *php_yaf_session_fetch_object(zend_object *obj) { 33 | return (yaf_session_object *)((char*)(obj) - XtOffsetOf(yaf_session_object, std)); 34 | } 35 | 36 | extern zend_class_entry *yaf_session_ce; 37 | 38 | #if PHP_VERSION_ID < 70200 39 | PHPAPI void php_session_start(); 40 | #else 41 | PHPAPI int php_session_start(); 42 | #endif 43 | YAF_STARTUP_FUNCTION(session); 44 | #endif 45 | 46 | /* 47 | * Local variables: 48 | * tab-width: 4 49 | * c-basic-offset: 4 50 | * End: 51 | * vim600: noet sw=4 ts=4 fdm=marker 52 | * vim<600: noet sw=4 ts=4 53 | */ 54 | -------------------------------------------------------------------------------- /yaf_session_legacy_arginfo.h: -------------------------------------------------------------------------------- 1 | /* This is a generated file, edit the .stub.php file instead. 2 | * Stub hash: f10baf628eb99eafbf7d0d0baef833070aa0d3ba */ 3 | 4 | ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Yaf_Session___construct, 0, 0, 0) 5 | ZEND_END_ARG_INFO() 6 | 7 | #define arginfo_class_Yaf_Session_getInstance arginfo_class_Yaf_Session___construct 8 | 9 | #define arginfo_class_Yaf_Session_start arginfo_class_Yaf_Session___construct 10 | 11 | ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Yaf_Session_get, 0, 0, 0) 12 | ZEND_ARG_INFO(0, name) 13 | ZEND_END_ARG_INFO() 14 | 15 | ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Yaf_Session_has, 0, 0, 1) 16 | ZEND_ARG_INFO(0, name) 17 | ZEND_END_ARG_INFO() 18 | 19 | ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Yaf_Session_set, 0, 0, 2) 20 | ZEND_ARG_INFO(0, name) 21 | ZEND_ARG_INFO(0, value) 22 | ZEND_END_ARG_INFO() 23 | 24 | #define arginfo_class_Yaf_Session_del arginfo_class_Yaf_Session_has 25 | 26 | #define arginfo_class_Yaf_Session_clear arginfo_class_Yaf_Session___construct 27 | 28 | #define arginfo_class_Yaf_Session_count arginfo_class_Yaf_Session___construct 29 | 30 | #define arginfo_class_Yaf_Session_rewind arginfo_class_Yaf_Session___construct 31 | 32 | #define arginfo_class_Yaf_Session_current arginfo_class_Yaf_Session___construct 33 | 34 | #define arginfo_class_Yaf_Session_next arginfo_class_Yaf_Session___construct 35 | 36 | #define arginfo_class_Yaf_Session_valid arginfo_class_Yaf_Session___construct 37 | 38 | #define arginfo_class_Yaf_Session_key arginfo_class_Yaf_Session___construct 39 | 40 | #define arginfo_class_Yaf_Session_offsetGet arginfo_class_Yaf_Session_has 41 | 42 | #define arginfo_class_Yaf_Session_offsetSet arginfo_class_Yaf_Session_set 43 | 44 | #define arginfo_class_Yaf_Session_offsetUnSet arginfo_class_Yaf_Session_has 45 | 46 | #define arginfo_class_Yaf_Session_offsetExists arginfo_class_Yaf_Session_has 47 | 48 | #define arginfo_class_Yaf_Session___get arginfo_class_Yaf_Session_has 49 | 50 | #define arginfo_class_Yaf_Session___isset arginfo_class_Yaf_Session_has 51 | 52 | #define arginfo_class_Yaf_Session___set arginfo_class_Yaf_Session_set 53 | 54 | #define arginfo_class_Yaf_Session___unset arginfo_class_Yaf_Session_has 55 | 56 | --------------------------------------------------------------------------------