Index: core/kernel/globals.php =================================================================== --- core/kernel/globals.php +++ core/kernel/globals.php @@ -928,6 +928,75 @@ throw new InvalidArgumentException(sprintf('Unknown escape strategy "%s"', $strategy)); } + + /** + * Mark a method as deprecated and inform when it has been used. + * + * The current behavior is to trigger a user deprecation notice in Debug Mode. + * This method is to be used in every method that is deprecated. + * + * @param string $method The method that was called. + * @param string $version The version that deprecated the method. + * @param string|null $replacement The method that should have been called. + * + * @return void + */ + public static function deprecatedMethod($method, $version, $replacement = null) + { + $application =& kApplication::Instance(); + + if ( !$application->isDebugMode() ) { + return; + } + + $msg = '%1$s is deprecated since version %2$s'; + + if ( !is_null($replacement) ) { + @trigger_error(sprintf($msg . '! Use %3$s instead.', $method, $version, $replacement), E_USER_DEPRECATED); + } + else { + @trigger_error(sprintf($msg . ' with no alternative available.', $method, $version), E_USER_DEPRECATED); + } + } + + /** + * Mark a method argument as deprecated and inform when it has been used. + * + * This method is to be used whenever a deprecated method argument is used. + * Before this method is called, the argument must be checked for whether it was + * used by comparing it to its default value or evaluating whether it is empty. + * For example: + * + * if ( !$deprecated ) { + * kUtil::deprecatedArgument(__METHOD__, '5.2.2'); + * } + * + * The current behavior is to trigger a user deprecation notice in Debug Mode. + * + * @param string $method The method that was called. + * @param string $version The version that deprecated the argument used. + * @param string|null $message A message regarding the change. + * + * @return void + */ + public static function deprecatedArgument($method, $version, $message = null) + { + $application =& kApplication::Instance(); + + if ( !$application->isDebugMode() ) { + return; + } + + $msg = '%1$s was called with an argument that is deprecated since version %2$s'; + + if ( !is_null($message) ) { + @trigger_error(sprintf($msg . '! %3$s', $method, $version, $message), E_USER_DEPRECATED); + } + else { + @trigger_error(sprintf($msg . ' with no alternative available.', $method, $version), E_USER_DEPRECATED); + } + } + } /** @@ -958,7 +1027,7 @@ if ( !function_exists('parse_ini_string') ) { /** - * Equivalent for "parse_ini_string" function available since PHP 5.3.0 + * Equivalent for "parse_ini_string" method available since PHP 5.3.0 * * @param string $ini * @param bool $process_sections @@ -985,7 +1054,7 @@ } if ( !function_exists('imagecreatefrombmp') ) { - // just in case if GD will add this function in future + // just in case if GD will add this method in future function imagecreatefrombmp($filename) { //Ouverture du fichier en mode binaire Index: modules/in-commerce/units/helpers/order_helper.php =================================================================== --- modules/in-commerce/units/helpers/order_helper.php +++ modules/in-commerce/units/helpers/order_helper.php @@ -174,14 +174,12 @@ * @param string $number Credit card number. * * @return integer - * @deprecated + * @deprecated 5.2.2-B1 + * @see OrderHelper::getCreditCardType() */ public function getCreditCartType($number) { - @trigger_error( - 'Usage of deprecated method OrderHelper::getCreditCartType. Use OrderHelper::getCreditCardType.', - E_USER_DEPRECATED - ); + kUtil::deprecatedMethod(__METHOD__, '5.2.2-B1', 'OrderHelper::getCreditCardType'); return $this->getCreditCardType($number); }