[limb-svn] r7088 - in 3.x/trunk/limb: core/src datetime/src i18n/src/locale log/src macro/src/compiler macro/src/tags/form macro/src/tags/list macro/src/tags/tree

svn at limb-project.com svn at limb-project.com
Thu Jul 3 14:03:56 MSD 2008


Author: korchasa
Date: 2008-07-03 14:03:56 +0400 (Thu, 03 Jul 2008)
New Revision: 7088
URL: http://fisheye.limb-project.com/changelog/limb/?cs=7088

Modified:
   3.x/trunk/limb/core/src/lmbSet.class.php
   3.x/trunk/limb/datetime/src/lmbDateTime.class.php
   3.x/trunk/limb/i18n/src/locale/lmbLocale.class.php
   3.x/trunk/limb/log/src/lmbLog.class.php
   3.x/trunk/limb/macro/src/compiler/lmbMacroNode.class.php
   3.x/trunk/limb/macro/src/tags/form/select.tag.php
   3.x/trunk/limb/macro/src/tags/list/list.tag.php
   3.x/trunk/limb/macro/src/tags/tree/tree.tag.php
Log:
-- replace is_a() by instanceof operator

Modified: 3.x/trunk/limb/core/src/lmbSet.class.php
===================================================================
--- 3.x/trunk/limb/core/src/lmbSet.class.php	2008-07-03 09:40:14 UTC (rev 7087)
+++ 3.x/trunk/limb/core/src/lmbSet.class.php	2008-07-03 10:03:56 UTC (rev 7088)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/core/src/lmbSetInterface.interface.php');
 
@@ -26,7 +26,7 @@
   {
     if(isset($this->$name) && !$this->_isGuarded($name))
       return $this->$name;
-    
+
     if(LIMB_UNDEFINED !== $default)
       return $default;
   }
@@ -83,7 +83,7 @@
 
   function merge($values)
   {
-    if(is_array($values) || is_a($values, 'ArrayAccess'))
+    if(is_array($values) || ($values instanceof ArrayAccess))
     {
       foreach($values as $name => $value)
         $this->set($name, $value);

Modified: 3.x/trunk/limb/datetime/src/lmbDateTime.class.php
===================================================================
--- 3.x/trunk/limb/datetime/src/lmbDateTime.class.php	2008-07-03 09:40:14 UTC (rev 7087)
+++ 3.x/trunk/limb/datetime/src/lmbDateTime.class.php	2008-07-03 10:03:56 UTC (rev 7088)
@@ -20,7 +20,7 @@
   const HOUR = 3600;
   const DAY = 86400;
   const WEEK = 604800;
-  
+
   //YYYY-MM-DD HH:MM:SS timezone
   const DATE_ISO_REGEX = '~^(([0-9]{4})-([0-9]{2})-([0-9]{2}))?((?(1)\s+)([0-9]{2}):([0-9]{2}):?([0-9]{2})?)?$~';
 
@@ -51,7 +51,7 @@
       $this->second = (int)$second;
       $this->tz     = $tz;
     }
-    elseif(is_a($year_or_date, 'lmbDateTime'))
+    elseif($year_or_date instanceof lmbDateTime)
     {
       $this->_copy($year_or_date);
     }
@@ -80,7 +80,7 @@
 
   /**
    * Wrapper around constructor
-   * 
+   *
    * It can be useful since the following is not allowed in PHP 'new lmbDateTime(..)->addDay(..)->'
    *
    * @param integer $year_or_date
@@ -149,13 +149,13 @@
     $date = new self((int)$stamp);
     return $date->getIsoDate();
   }
-  
+
   static function stampToShortIso($stamp)
   {
     $date = new $class((int)$stamp);
     return $date->getIsoShortDate();
   }
-  
+
   function _createTimeZoneObject($code=null)
   {
     lmb_require('limb/datetime/src/lmbDateTimeZone.class.php');

Modified: 3.x/trunk/limb/i18n/src/locale/lmbLocale.class.php
===================================================================
--- 3.x/trunk/limb/i18n/src/locale/lmbLocale.class.php	2008-07-03 09:40:14 UTC (rev 7087)
+++ 3.x/trunk/limb/i18n/src/locale/lmbLocale.class.php	2008-07-03 10:03:56 UTC (rev 7088)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/config/src/lmbIni.class.php');
 lmb_require('limb/i18n/src/locale/lmbLocaleSpec.class.php');
@@ -88,7 +88,7 @@
 
   function initLocaleSettings($config)
   {
-    if(!is_a($config, 'lmbIni'))
+    if(!$config instanceof lmbIni)
       throw new lmbException('Config object must be an lmbIni instance', array('config' => $config));
 
     $this->_initCountrySettings($config);

Modified: 3.x/trunk/limb/log/src/lmbLog.class.php
===================================================================
--- 3.x/trunk/limb/log/src/lmbLog.class.php	2008-07-03 09:40:14 UTC (rev 7087)
+++ 3.x/trunk/limb/log/src/lmbLog.class.php	2008-07-03 10:03:56 UTC (rev 7088)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/log/src/lmbLogEntry.class.php');
 lmb_require('limb/core/src/lmbBacktrace.class.php');
@@ -119,7 +119,7 @@
     if(!$this->isLogEnabled())
       return;
 
-    if(is_a($e, 'lmbException'))
+    if($e instanceof lmbException)
       $this->error($e->getMessage(), $e->getParams(), new lmbBacktrace($e->getTrace(), 5));
     else
       $this->error($e->getMessage(), array(), new lmbBacktrace($e->getTrace(), 5));

Modified: 3.x/trunk/limb/macro/src/compiler/lmbMacroNode.class.php
===================================================================
--- 3.x/trunk/limb/macro/src/compiler/lmbMacroNode.class.php	2008-07-03 09:40:14 UTC (rev 7087)
+++ 3.x/trunk/limb/macro/src/compiler/lmbMacroNode.class.php	2008-07-03 10:03:56 UTC (rev 7088)
@@ -18,9 +18,9 @@
   protected $node_id;
   protected $children = array();
   protected $parent;
-  
+
   static protected $counter = 1;
-  
+
   /**
   * @var lmbMacroSourceLocation
   */
@@ -138,7 +138,7 @@
       }
     }
   }
-  
+
   /**
    * Sometimes it is useful to find node located in another tree branch, eg:
    *  <code>
@@ -156,12 +156,12 @@
       return $this->parent->findUpChild($id);
   }
 
-  
+
   function findChildByClass($class)
   {
     foreach($this->children as $child)
     {
-      if(is_a($child, $class))
+      if($child instanceof $class)
         return $child;
       else
       {
@@ -176,9 +176,9 @@
     $ret = array();
     foreach($this->children as $child)
     {
-      if(is_a($child, $class))
+      if($child instanceof  $class)
         $ret[] = $child;
-      
+
       $more_children = $child->findChildrenByClass($class);
       if(count($more_children))
         $ret = array_merge($ret, $more_children);
@@ -190,7 +190,7 @@
   {
     foreach($this->children as $child)
     {
-      if(is_a($child, $class))
+      if($child instanceof $class)
         return $child;
     }
   }
@@ -200,7 +200,7 @@
     $result = array();
     foreach($this->children as $child)
     {
-      if(is_a($child, $class))
+      if($child instanceof $class)
         $result[] = $child;
     }
     return $result;
@@ -210,19 +210,19 @@
   {
     $parent = $this->parent;
 
-    while($parent && !is_a($parent, $class))
+    while($parent && (!$parent instanceof $class))
       $parent = $parent->parent;
 
     return $parent;
   }
-  
+
   function findRoot()
   {
     $root = $this;
     while ($root->parent != NULL)
       $root = $root->parent;
     return $root;
-  }   
+  }
 
   function preParse(){}
 

Modified: 3.x/trunk/limb/macro/src/tags/form/select.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/form/select.tag.php	2008-07-03 09:40:14 UTC (rev 7087)
+++ 3.x/trunk/limb/macro/src/tags/form/select.tag.php	2008-07-03 10:03:56 UTC (rev 7088)
@@ -18,7 +18,7 @@
 class lmbMacroSelectTag extends lmbMacroFormElementTag
 {
   protected $html_tag = 'select';
-  
+
   function preParse($compiler)
   {
     if ($this->getBool('multiple'))
@@ -45,44 +45,44 @@
       $this->widget_include_file = 'limb/macro/src/tags/form/lmbMacroSingleSelectWidget.class.php';
       $this->widget_class_name = 'lmbMacroSingleSelectWidget';
     }
-    
+
     // always has closing tag
     $this->has_closing_tag = true;
 
     parent :: preParse($compiler);
   }
-  
+
   protected function _generateBeforeOpeningTag($code)
   {
     $select = $this->getRuntimeVar();
     // passing specified variable as a datasource to form widget
     if($this->has('options'))
     {
-      $options = $this->get('options');       
+      $options = $this->get('options');
       $code->writePHP("{$select}->setOptions({$options});\n");
       $this->remove('options');
     }
   }
-  
+
   function _generateContent($code_writer)
   {
     $select = $this->getRuntimeVar();
-    
+
     foreach($this->getChildren() as $option_tag)
     {
-      if(!is_a($option_tag, 'lmbMacroOptionTag'))
+      if(!$option_tag instanceof lmbMacroOptionTag)
         continue;
 
       $value = $option_tag->get('value');
       $prepend = $option_tag->getBool('prepend');
-      
+
       $text = $code_writer->generateVar();
-      
+
       $code_writer->writePHP("ob_start();\n");
       $option_tag->generateNow($code_writer);
       $code_writer->writePHP("{$text} = ob_get_contents();\n");
       $code_writer->writePHP("ob_end_clean();\n");
-      
+
       if($prepend)
         $code_writer->writePHP("{$select}->prependToOptions('{$value}', {$text});\n");
       else
@@ -93,5 +93,5 @@
     }
 
     $code_writer->writePHP("{$select}->renderOptions();\n");
-  }   
+  }
 }

Modified: 3.x/trunk/limb/macro/src/tags/list/list.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/list/list.tag.php	2008-07-03 09:40:14 UTC (rev 7087)
+++ 3.x/trunk/limb/macro/src/tags/list/list.tag.php	2008-07-03 10:03:56 UTC (rev 7088)
@@ -10,7 +10,7 @@
 /**
  * The parent compile time component for lists
  * @tag list
- * @aliases list:list 
+ * @aliases list:list
  * @req_attributes using
  * @package macro
  * @version $Id$
@@ -19,12 +19,12 @@
 {
   protected $counter_var_var;
   protected $count_source = false;
-  
+
   function preParse($compiler)
   {
     if(!$this->has('using') && $this->has('for'))
       $this->set('using', $this->get('for'));
-    
+
     return parent :: preParse($compiler);
   }
 
@@ -45,13 +45,13 @@
     $this->_prepareSourceVar($code);
 
     $this->_initializeGlueTags($code);
-    
+
     $key = '';
-    
+
     if ($key_var = $this->get('key')) {
     	$key = $key_var . ' => ';
     }
-    
+
     $code->writePHP('foreach(' . $this->source_var . ' as ' . $key . $as . ') {');
 
     if($user_counter = $this->get('counter'))
@@ -78,7 +78,7 @@
         else
           $postponed_nodes[] = $child;
       }
-      elseif(is_a($child, 'lmbMacroListItemTag'))
+      elseif($child instanceof lmbMacroListItemTag)
       {
         $found_item_tag = true;
         $code->writePHP('}');
@@ -97,12 +97,12 @@
 
     $this->_renderEmptyTag($code);
   }
-  
+
   protected function _initializeGlueTags($code)
   {
     if(!$list_item_tag = $this->findChildByClass('lmbMacroListItemTag'))
       $this->raise('{{list:item}} tag is not found for {{list}} tag but required');
-    
+
     $glue_tags = $list_item_tag->findImmediateChildrenByClass('lmbMacroListGlueTag');
     foreach($glue_tags as $glue_tag)
       $glue_tag->generateInitCode($code);
@@ -125,7 +125,7 @@
 
     foreach($classes as $class)
     {
-      if(is_a($node, $class))
+      if($node instanceof $class)
         return true;
     }
     return false;
@@ -142,7 +142,7 @@
     $code->writePHP("{$temp_using} = {$using};\n");
     $code->writePHP("\nif(!is_array({$temp_using}) && !({$temp_using} instanceof Iterator)) {\n");
       $code->writePHP("{$temp_using} = array();}\n");
-    
+
     if($this->count_source)
     {
       $code->writePHP($this->source_var . " = array();\n");

Modified: 3.x/trunk/limb/macro/src/tags/tree/tree.tag.php
===================================================================
--- 3.x/trunk/limb/macro/src/tags/tree/tree.tag.php	2008-07-03 09:40:14 UTC (rev 7087)
+++ 3.x/trunk/limb/macro/src/tags/tree/tree.tag.php	2008-07-03 10:03:56 UTC (rev 7088)
@@ -82,7 +82,7 @@
     $tags = array();
     foreach($this->children as $child)
     {
-      if(is_a($child, 'lmbMacroTreeNodeTag'))
+      if($child instanceof lmbMacroTreeNodeTag)
         break;
       $tags[] = $child;
     }
@@ -97,7 +97,7 @@
     {
       if($collect)
         $tags[] = $child;
-      if(is_a($child, 'lmbMacroTreeNodeTag'))
+      if($child instanceof lmbMacroTreeNodeTag)
         $collect = true;
     }
     return $tags;



More information about the limb-svn mailing list