From 0f88fd895ed3b3853cefed08e354a3a06e78d23c Mon Sep 17 00:00:00 2001 From: Atsushi Matsuo Date: Thu, 18 Jul 2024 05:56:54 +0900 Subject: [PATCH] Resolve "Class File_IMC referenced with incorrect case: FILE_IMC" detected by PHPStan --- File/IMC/Build.php | 4 +- File/IMC/Build/Vcard.php | 86 ++++++++++++++++++++-------------------- File/IMC/Parse/Vcard.php | 28 ++++++------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/File/IMC/Build.php b/File/IMC/Build.php index 29b4832..0026af1 100644 --- a/File/IMC/Build.php +++ b/File/IMC/Build.php @@ -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)) { @@ -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 ); } diff --git a/File/IMC/Build/Vcard.php b/File/IMC/Build/Vcard.php index 96479d4..5197af9 100644 --- a/File/IMC/Build/Vcard.php +++ b/File/IMC/Build/Vcard.php @@ -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') { @@ -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 ); } @@ -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; } @@ -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; } @@ -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; } @@ -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; } @@ -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]); } /** @@ -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 ); } } @@ -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]); } /** @@ -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]); } /** @@ -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); } /** @@ -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); } /** @@ -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); } /** @@ -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; @@ -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)) { @@ -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); @@ -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 ); } } diff --git a/File/IMC/Parse/Vcard.php b/File/IMC/Parse/Vcard.php index d5b7282..68ee76a 100644 --- a/File/IMC/Parse/Vcard.php +++ b/File/IMC/Parse/Vcard.php @@ -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]) ); } @@ -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]) ); } @@ -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 ); } }