commit 177419e1059f8195b2eaac2a300e6f900d0cb563
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2014-07-22T06:39:43Z |
| subject | Minor bug fixes |
commit 177419e1059f8195b2eaac2a300e6f900d0cb563
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2014-07-22T06:39:43Z
Minor bug fixes
---
php/astropenguin/botanical/RegRename.php | 10 +++++-----
php/astropenguin/package.php | 31 +++++++++++++++++++++++++++++++
php/regRename.php | 11 ++++-------
3 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/php/astropenguin/botanical/RegRename.php b/php/astropenguin/botanical/RegRename.php
index d375bdd..fbac369 100644
--- a/php/astropenguin/botanical/RegRename.php
+++ b/php/astropenguin/botanical/RegRename.php
@@ -203,18 +203,18 @@ class RegRename
try
{
if(count($this->searchDirs) == 0)
- throw new Exception("Search directory is missing");
+ throw new \Exception("Search directory is missing");
else if(count($this->patterns) == 0)
- throw new Exception("Search pattern is missing");
+ throw new \Exception("Search pattern is missing");
else if(count($this->replaceStrs) == 0)
- throw new Exception("Replacement string is missing");
+ throw new \Exception("Replacement string is missing");
else if(count($this->replaceStrs) != count($this->patterns))
- throw new Exception("Replacement string and pattern count not match");
+ throw new \Exception("Replacement string and pattern count not match");
}
- catch(Exception $e)
+ catch( \Exception $e )
{
var_dump( $GLOBALS );
die("Error: $e.\n");
diff --git a/php/astropenguin/package.php b/php/astropenguin/package.php
new file mode 100644
index 0000000..ba4578c
--- /dev/null
+++ b/php/astropenguin/package.php
@@ -0,0 +1,31 @@
+<?php
+# ########################################
+# File: package.php
+# Description:
+# Namespace Package Loader
+#
+# Created on: 22 July 2014
+# Last Modified: Tue 22 Jul 2014 02:37:14 PM HKT
+# by: penguin
+# ##################
+
+IF( !function_exists( '___astropenguin_autoload' ) ):
+
+define( "_APPATH_", dirname( __FILE__ ) . '/' );
+
+function ___astropenguin_autoload( $classname )
+{
+ if( strncmp( $classname, 'astropenguin\\', 12 ) === 0 )
+ {
+ $classfile = str_replace( '\\', '/', substr( $classname, 12 ) );
+ $result = @include_once _APPATH_ . $classfile . '.php';
+ if( !$result )
+ {
+ trigger_error( "Failed to include $classfile" );
+ }
+ }
+}
+
+spl_autoload_register( '___astropenguin_autoload' );
+
+ENDIF;
diff --git a/php/regRename.php b/php/regRename.php
index 7e65725..748dd10 100644
--- a/php/regRename.php
+++ b/php/regRename.php
@@ -1,13 +1,10 @@
<?php
-
-namespace astropenguin\botanical;
-
error_reporting ( E_ALL^E_NOTICE ) ;
+require_once dirname( __FILE__ ) . '/astropenguin/package.php';
+
+use astropenguin\botanical\RegRename;
+use astropenguin\botanical\Args;
-spl_autoload_register(function ( $name )
-{
- require_once str_replace( '\\', '/', "$name.php" );
-});
//----------- Usage -----------