src/Alg/UnusedVariableFinder.php
private function inspectParsedMethods( $countCalls = FALSE )
	{
		foreach( $this->methods as $method => $data )												//  iterate before parsed methods
		{
			foreach( $data['lines'] as $nr => $line )												//  iterate method/function lines
			{
				$pattern	= "@^ *\t*[$]([a-z0-9_]+)(\t| )+=[^>].*@i";								//  prepare regular expression for variable assignment
				if( preg_match( $pattern, $line ) )													//  line contains variable assignment
					if( $var = trim( preg_replace( $pattern, "\\1", $line ) ) )						//  extract variable name from line
						if( !array_key_exists( $var, $this->methods[$method]['variables'] ) )		//  variable is not noted, yet
							$this->methods[$method]['variables'][$var]	= 0;						//  note newly found variable
				foreach( $this->methods[$method]['variables'] as $name => $count )					//  iterate known method/function variables
				{
					if( !$countCalls && $count )													//  variable is used and count mode is off
						continue;																	//  skip to next line
					if( preg_match( "/\(/", $name ) || preg_match( "/\)/", $name ) )
						xmp( $method."::".$name.' ('.join( ",", array_keys( $this->methods ) ).')' );
					$line		= preg_replace( "/\$".addslashes( $name )."\s*=/", "", $line );					//  remove variable assignment if found
					if( preg_match( '@\$'.addslashes( $name ).'[^a-z0-9_]@i', $line ) ){							//  if variable is used in this line
						$this->methods[$method]['variables'][$name]++;								//  increate variable's use counter
					}
				}
			}
		}
	}
private function inspectParsedMethods( $countCalls = FALSE )
	{
		foreach( $this->methods as $method => $data )												//  iterate before parsed methods
		{
			foreach( $data['lines'] as $nr => $line )												//  iterate method/function lines
			{
				$pattern	= "@^ *\t*[$]([a-z0-9_]+)(\t| )+=[^>].*@i";								//  prepare regular expression for variable assignment
				if( preg_match( $pattern, $line ) )													//  line contains variable assignment
					if( $var = trim( preg_replace( $pattern, "\\1", $line ) ) )						//  extract variable name from line
						if( !array_key_exists( $var, $this->methods[$method]['variables'] ) )		//  variable is not noted, yet
							$this->methods[$method]['variables'][$var]	= 0;						//  note newly found variable
				foreach( $this->methods[$method]['variables'] as $name => $count )					//  iterate known method/function variables
				{
					if( !$countCalls && $count )													//  variable is used and count mode is off
						continue;																	//  skip to next line
					if( preg_match( "/\(/", $name ) || preg_match( "/\)/", $name ) )
						xmp( $method."::".$name.' ('.join( ",", array_keys( $this->methods ) ).')' );
					$line		= preg_replace( "/\$".addslashes( $name )."\s*=/", "", $line );					//  remove variable assignment if found
					if( preg_match( '@\$'.addslashes( $name ).'[^a-z0-9_]@i', $line ) ){							//  if variable is used in this line
						$this->methods[$method]['variables'][$name]++;								//  increate variable's use counter
					}
				}
			}
		}
	}
private function inspectParsedMethods ( $ countCalls = FALSE ) { foreach ( $ this -> methods as $ method => $ data ) //  iterate before parsed methods
 { foreach ( $ data [ 'lines' ] as $ nr => $ line ) //  iterate method/function lines
 { $ pattern = "@^ *\t*[$]([a-z0-9_]+)(\t| )+=[^>].*@i" ; //  prepare regular expression for variable assignment
 if ( preg_match ( $ pattern , $ line ) ) //  line contains variable assignment
 if ( $ var = trim ( preg_replace ( $ pattern , "\\1" , $ line ) ) ) //  extract variable name from line
 if ( ! array_key_exists ( $ var , $ this -> methods [ $ method ] [ 'variables' ] ) ) //  variable is not noted, yet
 $ this -> methods [ $ method ] [ 'variables' ] [ $ var ] = 0 ; //  note newly found variable
 foreach ( $ this -> methods [ $ method ] [ 'variables' ] as $ name => $ count ) //  iterate known method/function variables
 { if ( ! $ countCalls && $ count ) //  variable is used and count mode is off
 continue ; //  skip to next line
 if ( preg_match ( "/\(/" , $ name ) || preg_match ( "/\)/" , $ name ) ) xmp ( $ method . "::" . $ name . ' (' . join ( "," , array_keys ( $ this -> methods ) ) . ')' ) ; $ line = preg_replace ( "/\$" . addslashes ( $ name ) . "\s*=/" , "" , $ line ) ; //  remove variable assignment if found
 if ( preg_match ( '@\$' . addslashes ( $ name ) . '[^a-z0-9_]@i' , $ line ) ) { //  if variable is used in this line
 $ this -> methods [ $ method ] [ 'variables' ] [ $ name ] ++ ; //  increate variable's use counter
 } } } } }
Inspects all before parsed methods for variables.
@access		public
@param		bool		$countCalls		Flag: count Number Variable uses
@return		void
Inspects all before parsed methods for variables .