This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 173297 - Incorrect use of Hint - Variable might not have been initialized
Summary: Incorrect use of Hint - Variable might not have been initialized
Status: RESOLVED DUPLICATE of bug 170541
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P4 blocker (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks: 170541
  Show dependency tree
 
Reported: 2009-09-29 16:23 UTC by laurin1
Modified: 2011-09-13 08:06 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description laurin1 2009-09-29 16:23:12 UTC
Here's a different scenario where the Hint is incorrect. NB is issuing a warning for $sUpper and $sLastFirst (at the 
return statement), but those two variables MUST be assigned in the if-then-else statement.

function GetProvider($sID, $iID = '', $sField = 'name', $sAliasName = ''){

	if(!$iID) return '';

	if($sID == 'id'){

		$sSQL = "SELECT prov5_skey FROM users WHERE id=".$iID;
		$rSQL = MYSQLQuery($sSQL, __FILE__.' - '.__FUNCTION__.' - Get Prov5 Skey by User ID');

		if($rSQL) $aSQL = mysql_fetch_array($rSQL);

		$sProv = GetProvider('skey', $aSQL['prov5_skey'], $sField, $sAliasName);

		return $sProv;

	}

	//If upper case NAME, then return upper case RESULT
	if($sField == 'NAME'){

		$sField = 'name';
		$sUpper = true;

	}
	elseif($sField == 'LFNAME'){

		$sField 		= 'name';
		$sUpper 		= true;
		$sLastFirst 	= true;

	}
	else{

		$sLastFirst 	= false;
		$sUpper 		= false;

	}

	if($sField == 'name') $sField = "TRIM(p.fname) fname, TRIM(p.lname) lname";

	$sSQL = "SELECT ".$sField." ".$sAliasName.", p.cred, p.nname default_name FROM prov5 p WHERE p.".$sID.
			"='".$iID."'";
	$rSQL = ODBCQuery($sSQL, __FILE__.' '.__FUNCTION__.' - Select Records');

	if($rSQL) $aSQL = odbc_fetch_array($rSQL);

	if($sField == 'TRIM(p.fname) fname, TRIM(p.lname) lname')
		return GetProviderName($aSQL, $sUpper, $sLastFirst, 'default_name');

	$sField = ($sAliasName != '') ? $sAliasName : $sField;

	return trim(FormatNameCaps($aSQL[$sField], true));

}
Comment 1 laurin1 2009-09-29 16:25:52 UTC
Here is another example when it does the same thing with switch ($aTypes is marked in the foreach statement).

function Create_Document_Links(){

	global $aDATA, $iSkey, $sID;

	$aFiles2	= array();
	$aDates	= array();

	if(!$aDATA['episode']){

		$sDATA = "SELECT DECODE(c.case_number, '"._MYSQLENCODE1."') ssn, c.episode FROM rm5_case5 c where ".
				"skey=".$iSkey;
		$rDATA = MYSQLQuery($sDATA, __FILE__.' - '.__FUNCTION__.' - Get Patient Info');

		if($rDATA) $aDATA = mysql_fetch_array($rDATA);
	}

	switch($sID){

		case('auth_docs'):

			$aTypes = array('Auth Grid Docs');
			break;

		default: $aTypes = array('Insurance ID Cards', 'Drivers Licenses', 'Doctors Orders');

	}

	foreach($aTypes as $sType){

		$aFiles = scandir('\\\\'._UNCSERVERNAME.'\\'.$sType);

		if($sType == 'Doctors Orders'){

			foreach($aFiles as $sFile){

				if($aDATA['ssn'] && stristr($sFile, $aDATA['ssn']) && stristr($sFile, $aDATA
['episode'])){

					$sFileName 					
	= '\\\\'._UNCSERVERNAME.'\\'.$sType.'\\'.$sFile;
					$aFiles2[substr($sFile, 0, -4)] 		= $sFileName;
					$aDates[substr($sFile, 0, -4)] 		= filemtime($sFileName);

				}

			}

			if(is_array($aDates)){

				arsort($aDates);

				foreach($aDates as $sLabel => $sDate){

					echo '<tr><td><a target="_blank" class="normal" href="'.$aFiles2[$sLabel].
						'">'.$sLabel.'</a> ';

					Input2::$sType		= BUTTON;
					Input2::$sName		= "cmdMove";
					Input2::$sValue	= "Move";
					Input2::$sStyle	= "width:70px";
					Input2::$sOnClick	= "PopUpDialog('/popups/choose_patient.php?sForm=".
										"DocAssign&id=".
										str_ireplace('\\', '\\\\', $aFiles2
[$sLabel]).
										"&cboActivePatient=".$aDATA
['skey']."&sType=".$sType.
										"', 'generic_dialog')";
					Input2::Display();

					echo '</td><td>'.$sType.'</td><td>'.$sType.
						'</td><td>&nbsp;</td><td>'.FormatDateTime($sDate, 
false).'&nbsp;</td></tr>';

				}

			}

		}
		else{

			foreach($aFiles as $sFile){

				if($aDATA['ssn'] && stristr($sFile, $aDATA['ssn']))
					$aFiles2[substr($sFile, 0, -4)] 
= '\\\\'._UNCSERVERNAME.'\\'.$sType.'\\'.$sFile;
				elseif(preg_match('('.$iSkey.'[_0-9]*.htm)', $sFile))
					$aFiles2[substr($sFile, 0, -4)] 
= '\\\\'._UNCSERVERNAME.'\\'.$sType.'\\'.$sFile;

			}

			if(is_array($aFiles2)){

				foreach($aFiles2 as $sLabel => $sFile){

					echo '<tr><td style="text-align:left"><a target="_blank" class="normal" '.
						'href="'.$sFile.'">'.$sLabel.'</a> ';

					Input2::$sType		= BUTTON;
					Input2::$sName		= "cmdMove";
					Input2::$sValue	= "Move";
					Input2::$sStyle	= "width:70px";
					Input2::$sOnClick	= "PopUpDialog('/popups/choose_patient.php?
sForm=DocAssign&id=".
										str_ireplace('\\', '\\\\', 
$sFile)."&cboActivePatient=".
										$aDATA
['skey']."&type=".$sType."', 'generic_dialog')";
					Input2::Display();

					if($sType == 'Auth Grid Docs'){

						if(preg_match('('.$iSkey.'[_0-9]*.htm)', $sFile)) $sType2 = 'Saved 
Grid';
						else $sType2 = 'Scanned Doc';

					}
					else $sType2 = $sType;

					echo '</td><td>'.$sType.'</td><td>'.$sType2.'</td>'.
						'<td>&nbsp;</td><td>'.FormatDateTime(filemtime($sFile)).'</td></tr>';

				}

			}

		}

		unset($aFiles, $aFiles2);

	}

}
Comment 2 rmatous 2009-09-29 16:28:04 UTC
experimental hints
Comment 3 rmatous 2009-10-06 12:31:46 UTC
Experimental Hint disabled as default - see #170541
Comment 4 Tomasz Slota 2010-02-10 08:46:57 UTC
reassigning to default owner
Comment 5 Filip Zamboj 2010-09-15 12:30:14 UTC
batch reassigning
Comment 6 Ondrej Brejla 2011-09-13 08:06:03 UTC

*** This bug has been marked as a duplicate of bug 170541 ***