Skip to content

Commit

Permalink
Merge pull request #10 from matsuo/resolve-incorrect-case
Browse files Browse the repository at this point in the history
Resolve "Class File_IMC referenced with incorrect case: FILE_IMC" detected by PHPStan
  • Loading branch information
CloCkWeRX authored Jul 17, 2024
2 parents 0303b03 + 0f88fd8 commit d3e8666
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
4 changes: 2 additions & 2 deletions File/IMC/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function escape(&$text)
if (is_object($text)) {
throw new File_IMC_Exception(
'The escape() method works only with string literals and arrays.',
FILE_IMC::ERROR_INVALID_PARAM_TYPE
File_IMC::ERROR_INVALID_PARAM_TYPE
);
}
if (is_array($text)) {
Expand Down Expand Up @@ -325,7 +325,7 @@ public function addParam($param_name, $param_value, $prop=null, $iter=null)
throw new File_IMC_Exception(
$iter.' is not a valid iteration number for '
.$prop.'; must be a positive integer.',
FILE_IMC::ERROR_INVALID_ITERATION
File_IMC::ERROR_INVALID_ITERATION
);
}

Expand Down
86 changes: 43 additions & 43 deletions File/IMC/Build/Vcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function validateParam($name, $text, $prop = null, $iter = null)
"vCard [$prop] [$iter] [$name]: "
.'The parameter value may only contain '
.'a-z, A-Z, 0-9, and dashes (-).',
FILE_IMC::ERROR_INVALID_PARAM
File_IMC::ERROR_INVALID_PARAM
);
}
if ($this->value['VERSION'][0][0][0] == '2.1') {
Expand All @@ -121,7 +121,7 @@ public function validateParam($name, $text, $prop = null, $iter = null)
}
throw new File_IMC_Exception(
"[$prop] [$iter] Unknown vCard version number or other error.",
FILE_IMC::ERROR
File_IMC::ERROR
);
}

Expand Down Expand Up @@ -182,7 +182,7 @@ protected function _validateParam21($name, $text, $prop, $iter)
throw new File_IMC_Exception(
'vCard 2.1 ['.$prop.']['.$iter.']: '
.'"'.$name.'" is an unknown or invalid parameter name.',
FILE_IMC::ERROR_INVALID_PARAM);
File_IMC::ERROR_INVALID_PARAM);
*/
break;
}
Expand All @@ -191,7 +191,7 @@ protected function _validateParam21($name, $text, $prop, $iter)
throw new File_IMC_Exception(
'vCard 2.1 ['.$prop.']['.$iter.']: '
.'"'.$text.'" is not a recognized '.$name.' value.',
FILE_IMC::ERROR_INVALID_PARAM);
File_IMC::ERROR_INVALID_PARAM);
*/
return $result;
}
Expand Down Expand Up @@ -233,7 +233,7 @@ protected function _validateParam30($name, $text, $prop, $iter)
throw new File_IMC_Exception(
'vCard 3.0 ['.$prop.']['.$iter.']: '
.'"'.$name.'" is an unknown or invalid parameter name.',
FILE_IMC::ERROR_INVALID_PARAM);
File_IMC::ERROR_INVALID_PARAM);
*/
break;
}
Expand All @@ -242,7 +242,7 @@ protected function _validateParam30($name, $text, $prop, $iter)
throw new File_IMC_Exception(
'vCard 3.0 ['.$prop.']['.$iter.']: '
.'"'.$text.'" is not a recognized '.$name.' value.',
FILE_IMC::ERROR_INVALID_PARAM);
File_IMC::ERROR_INVALID_PARAM);
*/
return $result;
}
Expand Down Expand Up @@ -285,13 +285,13 @@ protected function _setADR($value, $iter)
$value[$i] = '';
}
}
$this->setValue('ADR', $iter, FILE_IMC::VCARD_ADR_POB, $value[0]);
$this->setValue('ADR', $iter, FILE_IMC::VCARD_ADR_EXTEND, $value[1]);
$this->setValue('ADR', $iter, FILE_IMC::VCARD_ADR_STREET, $value[2]);
$this->setValue('ADR', $iter, FILE_IMC::VCARD_ADR_LOCALITY, $value[3]);
$this->setValue('ADR', $iter, FILE_IMC::VCARD_ADR_REGION, $value[4]);
$this->setValue('ADR', $iter, FILE_IMC::VCARD_ADR_POSTCODE, $value[5]);
$this->setValue('ADR', $iter, FILE_IMC::VCARD_ADR_COUNTRY, $value[6]);
$this->setValue('ADR', $iter, File_IMC::VCARD_ADR_POB, $value[0]);
$this->setValue('ADR', $iter, File_IMC::VCARD_ADR_EXTEND, $value[1]);
$this->setValue('ADR', $iter, File_IMC::VCARD_ADR_STREET, $value[2]);
$this->setValue('ADR', $iter, File_IMC::VCARD_ADR_LOCALITY, $value[3]);
$this->setValue('ADR', $iter, File_IMC::VCARD_ADR_REGION, $value[4]);
$this->setValue('ADR', $iter, File_IMC::VCARD_ADR_POSTCODE, $value[5]);
$this->setValue('ADR', $iter, File_IMC::VCARD_ADR_COUNTRY, $value[6]);
}

/**
Expand All @@ -314,24 +314,24 @@ protected function _setFN($text = null, $iter = 0)
if (is_array($this->value['N'])) {
// build from N.
// first (given) name, first iteration, first repetition
$text .= $this->getValue('N', 0, FILE_IMC::VCARD_N_GIVEN, 0);
$text .= $this->getValue('N', 0, File_IMC::VCARD_N_GIVEN, 0);
// add a space after, if there was text
if ($text != '') {
$text .= ' ';
}
// last (family) name, first iteration, first repetition
$text .= $this->getValue('N', 0, FILE_IMC::VCARD_N_FAMILY, 0);
$text .= $this->getValue('N', 0, File_IMC::VCARD_N_FAMILY, 0);
// add a space after, if there was text
if ($text != '') {
$text .= ' ';
}
// last-name suffix, first iteration, first repetition
$text .= $this->getValue('N', 0, FILE_IMC::VCARD_N_SUFFIX, 0);
$text .= $this->getValue('N', 0, File_IMC::VCARD_N_SUFFIX, 0);
} else {
// no N exists, and no FN was set, so return.
throw new File_IMC_Exception(
'FN not specified and N not set; cannot set FN.',
FILE_IMC::ERROR_PARAM_NOT_SET
File_IMC::ERROR_PARAM_NOT_SET
);
}
}
Expand Down Expand Up @@ -363,8 +363,8 @@ protected function _setGEO($value, $iter)
$value[$i] = '';
}
}
$this->setValue('GEO', $iter, FILE_IMC::VCARD_GEO_LAT, $value[0]);
$this->setValue('GEO', $iter, FILE_IMC::VCARD_GEO_LON, $value[1]);
$this->setValue('GEO', $iter, File_IMC::VCARD_GEO_LAT, $value[0]);
$this->setValue('GEO', $iter, File_IMC::VCARD_GEO_LON, $value[1]);
}

/**
Expand Down Expand Up @@ -401,11 +401,11 @@ protected function _setN($value, $iter)
$value[$i] = '';
}
}
$this->setValue('N', $iter, FILE_IMC::VCARD_N_FAMILY, $value[0]);
$this->setValue('N', $iter, FILE_IMC::VCARD_N_GIVEN, $value[1]);
$this->setValue('N', $iter, FILE_IMC::VCARD_N_ADDL, $value[2]);
$this->setValue('N', $iter, FILE_IMC::VCARD_N_PREFIX, $value[3]);
$this->setValue('N', $iter, FILE_IMC::VCARD_N_SUFFIX, $value[4]);
$this->setValue('N', $iter, File_IMC::VCARD_N_FAMILY, $value[0]);
$this->setValue('N', $iter, File_IMC::VCARD_N_GIVEN, $value[1]);
$this->setValue('N', $iter, File_IMC::VCARD_N_ADDL, $value[2]);
$this->setValue('N', $iter, File_IMC::VCARD_N_PREFIX, $value[3]);
$this->setValue('N', $iter, File_IMC::VCARD_N_SUFFIX, $value[4]);
}

/**
Expand Down Expand Up @@ -475,17 +475,17 @@ protected function _getADR($iter)
if (! is_integer($iter) || $iter < 0) {
throw new File_IMC_Exception(
'ADR iteration number not valid.',
FILE_IMC::ERROR_INVALID_ITERATION
File_IMC::ERROR_INVALID_ITERATION
);
}
return $this->getMeta('ADR', $iter)
.$this->getValue('ADR', $iter, FILE_IMC::VCARD_ADR_POB) . ';'
.$this->getValue('ADR', $iter, FILE_IMC::VCARD_ADR_EXTEND) . ';'
.$this->getValue('ADR', $iter, FILE_IMC::VCARD_ADR_STREET) . ';'
.$this->getValue('ADR', $iter, FILE_IMC::VCARD_ADR_LOCALITY) . ';'
.$this->getValue('ADR', $iter, FILE_IMC::VCARD_ADR_REGION) . ';'
.$this->getValue('ADR', $iter, FILE_IMC::VCARD_ADR_POSTCODE) . ';'
.$this->getValue('ADR', $iter, FILE_IMC::VCARD_ADR_COUNTRY);
.$this->getValue('ADR', $iter, File_IMC::VCARD_ADR_POB) . ';'
.$this->getValue('ADR', $iter, File_IMC::VCARD_ADR_EXTEND) . ';'
.$this->getValue('ADR', $iter, File_IMC::VCARD_ADR_STREET) . ';'
.$this->getValue('ADR', $iter, File_IMC::VCARD_ADR_LOCALITY) . ';'
.$this->getValue('ADR', $iter, File_IMC::VCARD_ADR_REGION) . ';'
.$this->getValue('ADR', $iter, File_IMC::VCARD_ADR_POSTCODE) . ';'
.$this->getValue('ADR', $iter, File_IMC::VCARD_ADR_COUNTRY);
}

/**
Expand All @@ -499,8 +499,8 @@ protected function _getADR($iter)
protected function _getGEO($iter)
{
return $this->getMeta('GEO', $iter)
.$this->getValue('GEO', $iter, FILE_IMC::VCARD_GEO_LAT, 0) . ';'
.$this->getValue('GEO', $iter, FILE_IMC::VCARD_GEO_LON, 0);
.$this->getValue('GEO', $iter, File_IMC::VCARD_GEO_LAT, 0) . ';'
.$this->getValue('GEO', $iter, File_IMC::VCARD_GEO_LON, 0);
}

/**
Expand All @@ -514,11 +514,11 @@ protected function _getGEO($iter)
protected function _getN($iter)
{
return $this->getMeta('N', $iter)
.$this->getValue('N', $iter, FILE_IMC::VCARD_N_FAMILY) . ';'
.$this->getValue('N', $iter, FILE_IMC::VCARD_N_GIVEN) . ';'
.$this->getValue('N', $iter, FILE_IMC::VCARD_N_ADDL) . ';'
.$this->getValue('N', $iter, FILE_IMC::VCARD_N_PREFIX) . ';'
.$this->getValue('N', $iter, FILE_IMC::VCARD_N_SUFFIX);
.$this->getValue('N', $iter, File_IMC::VCARD_N_FAMILY) . ';'
.$this->getValue('N', $iter, File_IMC::VCARD_N_GIVEN) . ';'
.$this->getValue('N', $iter, File_IMC::VCARD_N_ADDL) . ';'
.$this->getValue('N', $iter, File_IMC::VCARD_N_PREFIX) . ';'
.$this->getValue('N', $iter, File_IMC::VCARD_N_SUFFIX);
}

/**
Expand Down Expand Up @@ -579,7 +579,7 @@ public function set($prop, $value, $iter = 0)
} elseif (!is_integer($iter) || $iter < 0) {
throw new File_IMC_Exception(
$prop.' iteration number not valid.',
FILE_IMC::ERROR_INVALID_ITERATION
File_IMC::ERROR_INVALID_ITERATION
);
}
$method = '_set'.$prop;
Expand All @@ -589,7 +589,7 @@ public function set($prop, $value, $iter = 0)
if ($prop == 'VERSION' && !in_array($value, array('2.1','3.0'))) {
throw new File_IMC_Exception(
'Version must be 3.0 or 2.1 to be valid.',
FILE_IMC::ERROR_INVALID_VCARD_VERSION
File_IMC::ERROR_INVALID_VCARD_VERSION
);
} elseif (in_array($prop, array('PHOTO','LOGO','SOUND','KEY'))) {
if (file_exists($value)) {
Expand Down Expand Up @@ -630,7 +630,7 @@ public function get($prop, $iter = 0)
if (!is_integer($iter) || $iter < 0) {
throw new File_IMC_Exception(
$prop.' iteration number not valid.',
FILE_IMC::ERROR_INVALID_ITERATION
File_IMC::ERROR_INVALID_ITERATION
);
}
$this->encode($prop, $iter);
Expand Down Expand Up @@ -731,7 +731,7 @@ public function fetch()
} elseif (in_array($ver, $prop_dfn['req'])) {
throw new File_IMC_Exception(
$prop.' not set (required).',
FILE_IMC::ERROR_PARAM_NOT_SET
File_IMC::ERROR_PARAM_NOT_SET
);
}
}
Expand Down
28 changes: 14 additions & 14 deletions File/IMC/Parse/Vcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ protected function _parseN($text)
// array_pad makes sure there are the right number of elements
$tmp = array_pad($this->_splitBySemi($text), 5, '');
return array(
$this->_splitByComma($tmp[FILE_IMC::VCARD_N_FAMILY]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_N_GIVEN]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_N_ADDL]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_N_PREFIX]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_N_SUFFIX])
$this->_splitByComma($tmp[File_IMC::VCARD_N_FAMILY]),
$this->_splitByComma($tmp[File_IMC::VCARD_N_GIVEN]),
$this->_splitByComma($tmp[File_IMC::VCARD_N_ADDL]),
$this->_splitByComma($tmp[File_IMC::VCARD_N_PREFIX]),
$this->_splitByComma($tmp[File_IMC::VCARD_N_SUFFIX])
);
}

Expand All @@ -173,13 +173,13 @@ protected function _parseADR($text)
// array_pad makes sure there are the right number of elements
$tmp = array_pad($this->_splitBySemi($text), 7, '');
return array(
$this->_splitByComma($tmp[FILE_IMC::VCARD_ADR_POB]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_ADR_EXTEND]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_ADR_STREET]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_ADR_LOCALITY]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_ADR_REGION]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_ADR_POSTCODE]),
$this->_splitByComma($tmp[FILE_IMC::VCARD_ADR_COUNTRY])
$this->_splitByComma($tmp[File_IMC::VCARD_ADR_POB]),
$this->_splitByComma($tmp[File_IMC::VCARD_ADR_EXTEND]),
$this->_splitByComma($tmp[File_IMC::VCARD_ADR_STREET]),
$this->_splitByComma($tmp[File_IMC::VCARD_ADR_LOCALITY]),
$this->_splitByComma($tmp[File_IMC::VCARD_ADR_REGION]),
$this->_splitByComma($tmp[File_IMC::VCARD_ADR_POSTCODE]),
$this->_splitByComma($tmp[File_IMC::VCARD_ADR_COUNTRY])
);
}

Expand Down Expand Up @@ -249,8 +249,8 @@ protected function _parseGEO($text)
// array_pad makes sure there are the right number of elements
$tmp = array_pad($this->_splitBySemi($text), 2, '');
return array(
array($tmp[FILE_IMC::VCARD_GEO_LAT]), // lat
array($tmp[FILE_IMC::VCARD_GEO_LON]) // lon
array($tmp[File_IMC::VCARD_GEO_LAT]), // lat
array($tmp[File_IMC::VCARD_GEO_LON]) // lon
);
}
}

0 comments on commit d3e8666

Please sign in to comment.