Skip to content
Browse files

Make autoloader function anonymous.

  • Loading branch information...
1 parent dd11f1b commit 9de6137d4ede5460080809157c6721cd1dadc863 @sebastianbergmann committed
Showing with 196 additions and 213 deletions.
  1. +178 −184 PHP/Token/Stream/Autoload.php
  2. +17 −27 PHP/Token/Stream/Autoload.php.in
  3. +1 −2 build.xml
View
362 PHP/Token/Stream/Autoload.php
@@ -42,191 +42,185 @@
* @since File available since Release 1.1.0
*/
-function php_tokenstream_autoload($class = NULL)
-{
- static $classes = NULL;
- static $path = NULL;;
+spl_autoload_register(
+ function ($class)
+ {
+ static $classes = NULL;
+ static $path = NULL;;
- if ($classes === NULL) {
- $classes = array(
- 'php_token' => '/Token.php',
- 'php_token_abstract' => '/Token.php',
- 'php_token_ampersand' => '/Token.php',
- 'php_token_and_equal' => '/Token.php',
- 'php_token_array' => '/Token.php',
- 'php_token_array_cast' => '/Token.php',
- 'php_token_as' => '/Token.php',
- 'php_token_at' => '/Token.php',
- 'php_token_backtick' => '/Token.php',
- 'php_token_bad_character' => '/Token.php',
- 'php_token_bool_cast' => '/Token.php',
- 'php_token_boolean_and' => '/Token.php',
- 'php_token_boolean_or' => '/Token.php',
- 'php_token_break' => '/Token.php',
- 'php_token_caret' => '/Token.php',
- 'php_token_case' => '/Token.php',
- 'php_token_catch' => '/Token.php',
- 'php_token_character' => '/Token.php',
- 'php_token_class' => '/Token.php',
- 'php_token_class_c' => '/Token.php',
- 'php_token_clone' => '/Token.php',
- 'php_token_close_bracket' => '/Token.php',
- 'php_token_close_curly' => '/Token.php',
- 'php_token_close_square' => '/Token.php',
- 'php_token_close_tag' => '/Token.php',
- 'php_token_colon' => '/Token.php',
- 'php_token_comma' => '/Token.php',
- 'php_token_comment' => '/Token.php',
- 'php_token_concat_equal' => '/Token.php',
- 'php_token_const' => '/Token.php',
- 'php_token_constant_encapsed_string' => '/Token.php',
- 'php_token_continue' => '/Token.php',
- 'php_token_curly_open' => '/Token.php',
- 'php_token_dec' => '/Token.php',
- 'php_token_declare' => '/Token.php',
- 'php_token_default' => '/Token.php',
- 'php_token_dir' => '/Token.php',
- 'php_token_div' => '/Token.php',
- 'php_token_div_equal' => '/Token.php',
- 'php_token_dnumber' => '/Token.php',
- 'php_token_do' => '/Token.php',
- 'php_token_doc_comment' => '/Token.php',
- 'php_token_dollar' => '/Token.php',
- 'php_token_dollar_open_curly_braces' => '/Token.php',
- 'php_token_dot' => '/Token.php',
- 'php_token_double_arrow' => '/Token.php',
- 'php_token_double_cast' => '/Token.php',
- 'php_token_double_colon' => '/Token.php',
- 'php_token_double_quotes' => '/Token.php',
- 'php_token_echo' => '/Token.php',
- 'php_token_else' => '/Token.php',
- 'php_token_elseif' => '/Token.php',
- 'php_token_empty' => '/Token.php',
- 'php_token_encapsed_and_whitespace' => '/Token.php',
- 'php_token_end_heredoc' => '/Token.php',
- 'php_token_enddeclare' => '/Token.php',
- 'php_token_endfor' => '/Token.php',
- 'php_token_endforeach' => '/Token.php',
- 'php_token_endif' => '/Token.php',
- 'php_token_endswitch' => '/Token.php',
- 'php_token_endwhile' => '/Token.php',
- 'php_token_equal' => '/Token.php',
- 'php_token_eval' => '/Token.php',
- 'php_token_exclamation_mark' => '/Token.php',
- 'php_token_exit' => '/Token.php',
- 'php_token_extends' => '/Token.php',
- 'php_token_file' => '/Token.php',
- 'php_token_final' => '/Token.php',
- 'php_token_for' => '/Token.php',
- 'php_token_foreach' => '/Token.php',
- 'php_token_func_c' => '/Token.php',
- 'php_token_function' => '/Token.php',
- 'php_token_global' => '/Token.php',
- 'php_token_goto' => '/Token.php',
- 'php_token_gt' => '/Token.php',
- 'php_token_halt_compiler' => '/Token.php',
- 'php_token_if' => '/Token.php',
- 'php_token_implements' => '/Token.php',
- 'php_token_inc' => '/Token.php',
- 'php_token_include' => '/Token.php',
- 'php_token_include_once' => '/Token.php',
- 'php_token_includes' => '/Token.php',
- 'php_token_inline_html' => '/Token.php',
- 'php_token_instanceof' => '/Token.php',
- 'php_token_int_cast' => '/Token.php',
- 'php_token_interface' => '/Token.php',
- 'php_token_is_equal' => '/Token.php',
- 'php_token_is_greater_or_equal' => '/Token.php',
- 'php_token_is_identical' => '/Token.php',
- 'php_token_is_not_equal' => '/Token.php',
- 'php_token_is_not_identical' => '/Token.php',
- 'php_token_is_smaller_or_equal' => '/Token.php',
- 'php_token_isset' => '/Token.php',
- 'php_token_line' => '/Token.php',
- 'php_token_list' => '/Token.php',
- 'php_token_lnumber' => '/Token.php',
- 'php_token_logical_and' => '/Token.php',
- 'php_token_logical_or' => '/Token.php',
- 'php_token_logical_xor' => '/Token.php',
- 'php_token_lt' => '/Token.php',
- 'php_token_method_c' => '/Token.php',
- 'php_token_minus' => '/Token.php',
- 'php_token_minus_equal' => '/Token.php',
- 'php_token_mod_equal' => '/Token.php',
- 'php_token_mul_equal' => '/Token.php',
- 'php_token_mult' => '/Token.php',
- 'php_token_namespace' => '/Token.php',
- 'php_token_new' => '/Token.php',
- 'php_token_ns_c' => '/Token.php',
- 'php_token_ns_separator' => '/Token.php',
- 'php_token_num_string' => '/Token.php',
- 'php_token_object_cast' => '/Token.php',
- 'php_token_object_operator' => '/Token.php',
- 'php_token_open_bracket' => '/Token.php',
- 'php_token_open_curly' => '/Token.php',
- 'php_token_open_square' => '/Token.php',
- 'php_token_open_tag' => '/Token.php',
- 'php_token_open_tag_with_echo' => '/Token.php',
- 'php_token_or_equal' => '/Token.php',
- 'php_token_paamayim_nekudotayim' => '/Token.php',
- 'php_token_percent' => '/Token.php',
- 'php_token_pipe' => '/Token.php',
- 'php_token_plus' => '/Token.php',
- 'php_token_plus_equal' => '/Token.php',
- 'php_token_print' => '/Token.php',
- 'php_token_private' => '/Token.php',
- 'php_token_protected' => '/Token.php',
- 'php_token_public' => '/Token.php',
- 'php_token_question_mark' => '/Token.php',
- 'php_token_require' => '/Token.php',
- 'php_token_require_once' => '/Token.php',
- 'php_token_return' => '/Token.php',
- 'php_token_semicolon' => '/Token.php',
- 'php_token_sl' => '/Token.php',
- 'php_token_sl_equal' => '/Token.php',
- 'php_token_sr' => '/Token.php',
- 'php_token_sr_equal' => '/Token.php',
- 'php_token_start_heredoc' => '/Token.php',
- 'php_token_static' => '/Token.php',
- 'php_token_stream' => '/Token/Stream.php',
- 'php_token_stream_cachingfactory' => '/Token/Stream/CachingFactory.php',
- 'php_token_string' => '/Token.php',
- 'php_token_string_cast' => '/Token.php',
- 'php_token_string_varname' => '/Token.php',
- 'php_token_switch' => '/Token.php',
- 'php_token_throw' => '/Token.php',
- 'php_token_tilde' => '/Token.php',
- 'php_token_trait' => '/Token.php',
- 'php_token_try' => '/Token.php',
- 'php_token_unset' => '/Token.php',
- 'php_token_unset_cast' => '/Token.php',
- 'php_token_use' => '/Token.php',
- 'php_token_var' => '/Token.php',
- 'php_token_variable' => '/Token.php',
- 'php_token_while' => '/Token.php',
- 'php_token_whitespace' => '/Token.php',
- 'php_token_xor_equal' => '/Token.php',
- 'php_tokenwithscope' => '/Token.php'
- );
+ if ($classes === NULL) {
+ $classes = array(
+ 'php_token' => '/Token.php',
+ 'php_token_abstract' => '/Token.php',
+ 'php_token_ampersand' => '/Token.php',
+ 'php_token_and_equal' => '/Token.php',
+ 'php_token_array' => '/Token.php',
+ 'php_token_array_cast' => '/Token.php',
+ 'php_token_as' => '/Token.php',
+ 'php_token_at' => '/Token.php',
+ 'php_token_backtick' => '/Token.php',
+ 'php_token_bad_character' => '/Token.php',
+ 'php_token_bool_cast' => '/Token.php',
+ 'php_token_boolean_and' => '/Token.php',
+ 'php_token_boolean_or' => '/Token.php',
+ 'php_token_break' => '/Token.php',
+ 'php_token_callable' => '/Token.php',
+ 'php_token_caret' => '/Token.php',
+ 'php_token_case' => '/Token.php',
+ 'php_token_catch' => '/Token.php',
+ 'php_token_character' => '/Token.php',
+ 'php_token_class' => '/Token.php',
+ 'php_token_class_c' => '/Token.php',
+ 'php_token_clone' => '/Token.php',
+ 'php_token_close_bracket' => '/Token.php',
+ 'php_token_close_curly' => '/Token.php',
+ 'php_token_close_square' => '/Token.php',
+ 'php_token_close_tag' => '/Token.php',
+ 'php_token_colon' => '/Token.php',
+ 'php_token_comma' => '/Token.php',
+ 'php_token_comment' => '/Token.php',
+ 'php_token_concat_equal' => '/Token.php',
+ 'php_token_const' => '/Token.php',
+ 'php_token_constant_encapsed_string' => '/Token.php',
+ 'php_token_continue' => '/Token.php',
+ 'php_token_curly_open' => '/Token.php',
+ 'php_token_dec' => '/Token.php',
+ 'php_token_declare' => '/Token.php',
+ 'php_token_default' => '/Token.php',
+ 'php_token_dir' => '/Token.php',
+ 'php_token_div' => '/Token.php',
+ 'php_token_div_equal' => '/Token.php',
+ 'php_token_dnumber' => '/Token.php',
+ 'php_token_do' => '/Token.php',
+ 'php_token_doc_comment' => '/Token.php',
+ 'php_token_dollar' => '/Token.php',
+ 'php_token_dollar_open_curly_braces' => '/Token.php',
+ 'php_token_dot' => '/Token.php',
+ 'php_token_double_arrow' => '/Token.php',
+ 'php_token_double_cast' => '/Token.php',
+ 'php_token_double_colon' => '/Token.php',
+ 'php_token_double_quotes' => '/Token.php',
+ 'php_token_echo' => '/Token.php',
+ 'php_token_else' => '/Token.php',
+ 'php_token_elseif' => '/Token.php',
+ 'php_token_empty' => '/Token.php',
+ 'php_token_encapsed_and_whitespace' => '/Token.php',
+ 'php_token_end_heredoc' => '/Token.php',
+ 'php_token_enddeclare' => '/Token.php',
+ 'php_token_endfor' => '/Token.php',
+ 'php_token_endforeach' => '/Token.php',
+ 'php_token_endif' => '/Token.php',
+ 'php_token_endswitch' => '/Token.php',
+ 'php_token_endwhile' => '/Token.php',
+ 'php_token_equal' => '/Token.php',
+ 'php_token_eval' => '/Token.php',
+ 'php_token_exclamation_mark' => '/Token.php',
+ 'php_token_exit' => '/Token.php',
+ 'php_token_extends' => '/Token.php',
+ 'php_token_file' => '/Token.php',
+ 'php_token_final' => '/Token.php',
+ 'php_token_for' => '/Token.php',
+ 'php_token_foreach' => '/Token.php',
+ 'php_token_func_c' => '/Token.php',
+ 'php_token_function' => '/Token.php',
+ 'php_token_global' => '/Token.php',
+ 'php_token_goto' => '/Token.php',
+ 'php_token_gt' => '/Token.php',
+ 'php_token_halt_compiler' => '/Token.php',
+ 'php_token_if' => '/Token.php',
+ 'php_token_implements' => '/Token.php',
+ 'php_token_inc' => '/Token.php',
+ 'php_token_include' => '/Token.php',
+ 'php_token_include_once' => '/Token.php',
+ 'php_token_includes' => '/Token.php',
+ 'php_token_inline_html' => '/Token.php',
+ 'php_token_instanceof' => '/Token.php',
+ 'php_token_insteadof' => '/Token.php',
+ 'php_token_int_cast' => '/Token.php',
+ 'php_token_interface' => '/Token.php',
+ 'php_token_is_equal' => '/Token.php',
+ 'php_token_is_greater_or_equal' => '/Token.php',
+ 'php_token_is_identical' => '/Token.php',
+ 'php_token_is_not_equal' => '/Token.php',
+ 'php_token_is_not_identical' => '/Token.php',
+ 'php_token_is_smaller_or_equal' => '/Token.php',
+ 'php_token_isset' => '/Token.php',
+ 'php_token_line' => '/Token.php',
+ 'php_token_list' => '/Token.php',
+ 'php_token_lnumber' => '/Token.php',
+ 'php_token_logical_and' => '/Token.php',
+ 'php_token_logical_or' => '/Token.php',
+ 'php_token_logical_xor' => '/Token.php',
+ 'php_token_lt' => '/Token.php',
+ 'php_token_method_c' => '/Token.php',
+ 'php_token_minus' => '/Token.php',
+ 'php_token_minus_equal' => '/Token.php',
+ 'php_token_mod_equal' => '/Token.php',
+ 'php_token_mul_equal' => '/Token.php',
+ 'php_token_mult' => '/Token.php',
+ 'php_token_namespace' => '/Token.php',
+ 'php_token_new' => '/Token.php',
+ 'php_token_ns_c' => '/Token.php',
+ 'php_token_ns_separator' => '/Token.php',
+ 'php_token_num_string' => '/Token.php',
+ 'php_token_object_cast' => '/Token.php',
+ 'php_token_object_operator' => '/Token.php',
+ 'php_token_open_bracket' => '/Token.php',
+ 'php_token_open_curly' => '/Token.php',
+ 'php_token_open_square' => '/Token.php',
+ 'php_token_open_tag' => '/Token.php',
+ 'php_token_open_tag_with_echo' => '/Token.php',
+ 'php_token_or_equal' => '/Token.php',
+ 'php_token_paamayim_nekudotayim' => '/Token.php',
+ 'php_token_percent' => '/Token.php',
+ 'php_token_pipe' => '/Token.php',
+ 'php_token_plus' => '/Token.php',
+ 'php_token_plus_equal' => '/Token.php',
+ 'php_token_print' => '/Token.php',
+ 'php_token_private' => '/Token.php',
+ 'php_token_protected' => '/Token.php',
+ 'php_token_public' => '/Token.php',
+ 'php_token_question_mark' => '/Token.php',
+ 'php_token_require' => '/Token.php',
+ 'php_token_require_once' => '/Token.php',
+ 'php_token_return' => '/Token.php',
+ 'php_token_semicolon' => '/Token.php',
+ 'php_token_sl' => '/Token.php',
+ 'php_token_sl_equal' => '/Token.php',
+ 'php_token_sr' => '/Token.php',
+ 'php_token_sr_equal' => '/Token.php',
+ 'php_token_start_heredoc' => '/Token.php',
+ 'php_token_static' => '/Token.php',
+ 'php_token_stream' => '/Token/Stream.php',
+ 'php_token_stream_cachingfactory' => '/Token/Stream/CachingFactory.php',
+ 'php_token_string' => '/Token.php',
+ 'php_token_string_cast' => '/Token.php',
+ 'php_token_string_varname' => '/Token.php',
+ 'php_token_switch' => '/Token.php',
+ 'php_token_throw' => '/Token.php',
+ 'php_token_tilde' => '/Token.php',
+ 'php_token_trait' => '/Token.php',
+ 'php_token_trait_c' => '/Token.php',
+ 'php_token_try' => '/Token.php',
+ 'php_token_unset' => '/Token.php',
+ 'php_token_unset_cast' => '/Token.php',
+ 'php_token_use' => '/Token.php',
+ 'php_token_var' => '/Token.php',
+ 'php_token_variable' => '/Token.php',
+ 'php_token_while' => '/Token.php',
+ 'php_token_whitespace' => '/Token.php',
+ 'php_token_xor_equal' => '/Token.php',
+ 'php_tokenwithscope' => '/Token.php',
+ 'php_tokenwithscopeandvisibility' => '/Token.php'
+ );
- $path = dirname(dirname(dirname(__FILE__)));
- }
+ $path = dirname(dirname(dirname(__FILE__)));
+ }
- if ($class === NULL) {
- $result = array(__FILE__);
+ $cn = strtolower($class);
- foreach ($classes as $file) {
- $result[] = $path . $file;
- }
-
- return $result;
- }
-
- $cn = strtolower($class);
-
- if (isset($classes[$cn])) {
- require $path . $classes[$cn];
- }
-}
-
-spl_autoload_register('php_tokenstream_autoload');
+ if (isset($classes[$cn])) {
+ require $path . $classes[$cn];
+ }
+ }
+);
View
44 PHP/Token/Stream/Autoload.php.in
@@ -42,34 +42,24 @@
* @since File available since Release 1.1.0
*/
-function php_tokenstream_autoload($class = NULL)
-{
- static $classes = NULL;
- static $path = NULL;;
+spl_autoload_register(
+ function ($class)
+ {
+ static $classes = NULL;
+ static $path = NULL;;
- if ($classes === NULL) {
- $classes = array(
- ___CLASSLIST___
- );
+ if ($classes === NULL) {
+ $classes = array(
+ ___CLASSLIST___
+ );
- $path = dirname(dirname(dirname(__FILE__)));
- }
+ $path = dirname(dirname(dirname(__FILE__)));
+ }
- if ($class === NULL) {
- $result = array(__FILE__);
+ $cn = strtolower($class);
- foreach ($classes as $file) {
- $result[] = $path . $file;
- }
-
- return $result;
- }
-
- $cn = strtolower($class);
-
- if (isset($classes[$cn])) {
- require $path . $classes[$cn];
- }
-}
-
-spl_autoload_register('php_tokenstream_autoload');
+ if (isset($classes[$cn])) {
+ require $path . $classes[$cn];
+ }
+ }
+);
View
3 build.xml
@@ -44,11 +44,10 @@
<exec executable="phpab">
<arg value="--output" />
<arg path="PHP/Token/Stream/Autoload.php" />
- <arg value="--compat" />
<arg value="--template" />
<arg path="PHP/Token/Stream/Autoload.php.in" />
<arg value="--indent" />
- <arg value=" " />
+ <arg value=" " />
<arg path="PHP" />
</exec>
</target>

0 comments on commit 9de6137

Please sign in to comment.
Something went wrong with that request. Please try again.