[SUCS Devel] site r664 - trunk/lib/Validate

rjames93 at sucs.org rjames93 at sucs.org
Mon Apr 13 11:32:02 BST 2015


Author: rjames93
Date: 2015-04-13 11:31:51 +0100 (Mon, 13 Apr 2015)
New Revision: 664

Modified:
   trunk/lib/Validate/ISPN.php
   trunk/lib/Validate/Validate.php
Log:

Library ISPN validation was throwing errors like:  Non-static method Validate_ISPN::isbn() should not be called statically
Went through and added the prefix public static function() to stop unexpected output from component appearing when adding books
Not sure I got all use cases but for Shipping containers I don't think we need to worry too much

M    Validate/ISPN.php
M    Validate/Validate.php


Modified: trunk/lib/Validate/ISPN.php
===================================================================
--- trunk/lib/Validate/ISPN.php	2015-04-05 17:50:22 UTC (rev 663)
+++ trunk/lib/Validate/ISPN.php	2015-04-13 10:31:51 UTC (rev 664)
@@ -58,7 +58,7 @@
  */
 class Validate_ISPN
 {
-    function isbn($isbn)
+    public static function isbn($isbn)
     {
         if (preg_match("/[^0-9 IXSBN-]/", $isbn)) {
             return false;
@@ -91,7 +91,7 @@
      * @author Helgi Þormar <dufuz at php.net>
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    function isbn13($isbn)
+    public static function isbn13($isbn)
     {
         if (preg_match("/[^0-9 ISBN-]/", $isbn)) {
             return false;
@@ -121,7 +121,7 @@
      * @author Damien Seguy <dams at nexen.net>
      * @author Helgi Þormar <dufuz at php.net>
      */
-    function isbn10($isbn)
+    public static function isbn10($isbn)
     {
         static  $weights_isbn = array(10,9,8,7,6,5,4,3,2);
 
@@ -157,7 +157,7 @@
      * @access public
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    function issn($issn)
+    public static function issn($issn)
     {
         static $weights_issn = array(8,7,6,5,4,3,2);
 
@@ -191,7 +191,7 @@
      * @access public
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    function ismn($ismn)
+    public static function ismn($ismn)
     {
         static $weights_ismn = array(3,1,3,1,3,1,3,1,3);
 
@@ -228,7 +228,7 @@
      * @access public
      * @author David Grant <david at grant.org.uk>
      */
-    function isrc($isrc)
+    public static function isrc($isrc)
     {
         $isrc = str_replace(array('ISRC', '-', ' '), '', strtoupper($isrc));
         if (!preg_match("/[A-Z]{2}[A-Z0-9]{3}[0-9]{7}/", $isrc)) {
@@ -252,7 +252,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    function ean8($ean)
+    public static function ean8($ean)
     {
         static $weights_ean8 = array(3,1,3,1,3,1,3);
         return Validate_ISPN::process($ean, 8, $weights_ean8, 10, 10);
@@ -272,7 +272,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    function ean13($ean)
+    public static function ean13($ean)
     {
         static $weights_ean13 = array(1,3,1,3,1,3,1,3,1,3,1,3);
         return Validate_ISPN::process($ean, 13, $weights_ean13, 10, 10);
@@ -292,7 +292,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    function ean14($ean)
+    public static function ean14($ean)
     {
         static $weights_ean14 = array(3,1,3,1,3,1,3,1,3,1,3,1,3);
         return Validate_ISPN::process($ean, 14, $weights_ean14, 10, 10);
@@ -312,7 +312,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    function ucc12($ucc)
+    public static function ucc12($ucc)
     {
         static $weights_ucc12 = array(3,1,3,1,3,1,3,1,3,1,3);
         return Validate_ISPN::process($ucc, 12, $weights_ucc12, 10, 10);
@@ -332,7 +332,7 @@
      * @see Validate_ISPN::process()
      * @author Piotr Klaban <makler at man.torun.pl>
      */
-    function sscc($sscc)
+    public static function sscc($sscc)
     {
         static $weights_sscc = array(3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3);
         return Validate_ISPN::process($sscc, 18, $weights_sscc, 10, 10);
@@ -351,7 +351,7 @@
      * @access public
      * @see Validate::_checkControlNumber()
      */
-    function process($data, $length, &$weights, $modulo = 10, $subtract = 0)
+    public static function process($data, $length, &$weights, $modulo = 10, $subtract = 0)
     {
         //$weights = array(3,1,3,1,3,1,3,1,3,1,3,1,3,1,3,1,3);
         //$weights = array_slice($weights, 0, $length);

Modified: trunk/lib/Validate/Validate.php
===================================================================
--- trunk/lib/Validate/Validate.php	2015-04-05 17:50:22 UTC (rev 663)
+++ trunk/lib/Validate/Validate.php	2015-04-13 10:31:51 UTC (rev 664)
@@ -583,7 +583,7 @@
         return $ret;
     }
 
-    function _modf($val, $div) {
+    public static function _modf($val, $div) {
         if (function_exists('bcmod')) {
             return bcmod($val, $div);
         } elseif (function_exists('fmod')) {
@@ -604,7 +604,7 @@
      *
      * @access protected
      */
-    function _multWeights($number, &$weights) {
+    public static function _multWeights($number, &$weights) {
         if (!is_array($weights)) {
             return -1;
         }
@@ -634,7 +634,7 @@
      *
      * @access protected
      */
-    function _getControlNumber($number, &$weights, $modulo = 10, $subtract = 0, $allow_high = false) {
+    public static function _getControlNumber($number, &$weights, $modulo = 10, $subtract = 0, $allow_high = false) {
         // calc sum
         $sum = Validate::_multWeights($number, $weights);
         if ($sum == -1) {
@@ -663,7 +663,7 @@
      *
      * @access protected
      */
-    function _checkControlNumber($number, &$weights, $modulo = 10, $subtract = 0) {
+    public static function _checkControlNumber($number, &$weights, $modulo = 10, $subtract = 0) {
         if (strlen($number) < count($weights)) {
             return false;
         }




More information about the Devel mailing list