Skip to content

Commit

Permalink
+ Fix autoloader.
Browse files Browse the repository at this point in the history
+ Plug debug holes.
+ Refer to demos.
  • Loading branch information
AnrDaemon committed Jul 19, 2016
1 parent 55f653c commit 6cbf2f4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
11 changes: 9 additions & 2 deletions Minecraft/NBT/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
*
*
*
* @version $Id: Reader.php 177 2016-07-17 23:33:03Z anrdaemon $
* @version $Id: Reader.php 190 2016-07-19 21:45:04Z anrdaemon $
*/

namespace AnrDaemon\Minecraft\NBT;
namespace
{
// Plug the built-in debug logging.
if(!class_exists('\tool', false)) { final class tool { static function __callStatic($name, $args) {} } }
}
namespace AnrDaemon\Minecraft\NBT
{

if(version_compare(PHP_VERSION, '5.5.11', '<'))
die('Needs SplFileObject::fread(). Upgrade your PHP.');
Expand Down Expand Up @@ -63,3 +69,4 @@ public function fread($length)
return $data;
}
}
}
15 changes: 9 additions & 6 deletions Minecraft/NBT/Tag.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<?php
/** Minecraft NBT Tag base class.
*
* @version $Id: Tag.php 187 2016-07-19 19:25:51Z anrdaemon $
* @version $Id: Tag.php 189 2016-07-19 20:38:29Z anrdaemon $
*/

namespace AnrDaemon\Minecraft\NBT;

namespace
{
// Plug the built-in debug logging.
if(!class_exists('\tool', false)) { final class tool { static function __callStatic($name, $args) {} } }
}
namespace AnrDaemon\Minecraft\NBT
{
use
JsonSerializable, Serializable, SplFileObject;

// Plug the built-in debug logging.
if(!class_exists('\tool', false)) { final class tool { static function __callStatic($name, $args) {} } }

abstract class Tag
implements Serializable, JsonSerializable
{
Expand Down Expand Up @@ -39,3 +41,4 @@ abstract public function jsonSerialize();
abstract public function serialize();
abstract public function unserialize($blob);
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ To handle 64-bit tags (i.e. TAG_Long, TAG_Double), 64-bit Linux version of PHP 5

Just grab the archive, untar it and `include '.../classloader.php';`.
It's MAGIC!

## Demos.

Can be found in [separate repository](https://github.com/AnrDaemon/minecraft-nbt-demos).
4 changes: 3 additions & 1 deletion classloader.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php
/** Universal stackable classloader.
*
* @version SVN: $Id: classloader.php 184 2016-07-19 17:15:06Z anrdaemon $
* @version SVN: $Id: classloader.php 188 2016-07-19 20:03:31Z anrdaemon $
*/

spl_autoload_register(function($className){
if(strncasecmp($className, 'AnrDaemon\\', 10) !== 0)
return;
$file = new SplFileInfo(__DIR__ . strtr(substr("$className.php", 9), '\\', '/'));
$path = $file->getRealPath();
if(!empty($path))
Expand Down

0 comments on commit 6cbf2f4

Please sign in to comment.