- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
function test_file_for_smells( $filename )
{
global $MAX_FUNCTION_LINE_COUNT, $MAX_INDENTATION_LEVEL;
$function_line_count = 0;
$found_continued_line = 0;
$line_number = 0;
$fp = fopen( $filename, "r" );
if( ! $fp )
return;
while( ! feof( $fp ) )
{
$line = chop( fgets( $fp, 4096 ) );
$line_number++;
while( substr( $line, 0, 9 ) == "function " &&
substr( $line, strlen($line) - 1, 1 ) != ')' )
{
$line = $line . chop( fgets( $fp, 4096 ) )
$found_continued_line++;
}
if( substr( $line, 0, 9 ) == "function " )
{
$function_line_count = 1;
$function_name = substr( $line, 9, strpos($line, '(') - 9 );
}
if( $function_line_count > 0 )
{
if( $line == "\t}" )
{
$function_line_count = $function_line_count - 3;
if( $function_line_count > $MAX_FUNCTION_LINE_COUNT )
print_warning( $filename, $line, $line_number, "$function_name() too long ($function_line_count lines)" );
$function_line_count = 0;
}
else
$function_line_count++;
$result = test_line_for_indentation( $line, $MAX_INDENTATION_LEVEL );
if( ! $result )
print_warning( $filename, $line, $line_number, "Too much nesting." );
$result = test_line_for_function_definition( $line, $MAX_NUM_PARAMETERS );
if( ! $result )
print_warning( $filename, $line, $line_number, "Too many parameters." );
if( $found_continued_line > 0 )
{
$line_number += $found_continued_line;
$found_continued_line = 0;
}
}
}
}
inkanus-gray 11.12.2010 01:04 # 0
telnet 11.12.2010 11:22 # +2
http://ajaxian.com/archives/j4p5-javascript-interpreter-written-in-php-5
http://code.google.com/p/lisphp/
По компиляторам ничего не увидел.
KirAmp 11.12.2010 14:35 # +1
KirAmp 11.12.2010 14:42 # 0
telnet 11.12.2010 15:17 # 0
2) чтобы работало быстрее (HipHop for PHP)
Мартин 11.12.2010 16:15 # 0
Desktop 21.09.2018 14:23 # 0
guest8 21.09.2018 14:43 # −999
OBEH 21.09.2018 14:48 # −1
komprenda 14.12.2010 23:37 # −4