Added WeakRef as default extension

This commit is contained in:
Shoghi Cervantes 2014-05-19 17:33:04 +02:00
parent 3729c5b603
commit c15f05622e
3 changed files with 139 additions and 7 deletions

View File

@ -11,7 +11,7 @@ PHPNCURSES_VERSION="1.0.2"
PTHREADS_VERSION="2.0.4" PTHREADS_VERSION="2.0.4"
PHP_POCKETMINE_VERSION="0.0.4" PHP_POCKETMINE_VERSION="0.0.4"
UOPZ_VERSION="2.0.3" UOPZ_VERSION="2.0.3"
WEAKREF_VERSION="0.2.2" WEAKREF_VERSION="0.2.4"
PHPYAML_VERSION="1.1.1" PHPYAML_VERSION="1.1.1"
YAML_VERSION="0.1.4" YAML_VERSION="0.1.4"
LIBXML_VERSION="2.9.1" LIBXML_VERSION="2.9.1"
@ -527,11 +527,11 @@ fi
#mv uopz-$UOPZ_VERSION "$DIR/install_data/php/ext/uopz" #mv uopz-$UOPZ_VERSION "$DIR/install_data/php/ext/uopz"
#echo " done!" #echo " done!"
#WeakRef WeakRef
#echo -n "[PHP WeakRef] downloading $WEAKREF_VERSION..." echo -n "[PHP Weakref] downloading $WEAKREF_VERSION..."
#download_file "http://pecl.php.net/get/Weakref-$WEAKREF_VERSION.tgz" | tar -zx >> "$DIR/install.log" 2>&1 download_file "http://pecl.php.net/get/Weakref-$WEAKREF_VERSION.tgz" | tar -zx >> "$DIR/install.log" 2>&1
#mv Weakref-$WEAKREF_VERSION "$DIR/install_data/php/ext/weakref" mv Weakref-$WEAKREF_VERSION "$DIR/install_data/php/ext/weakref"
#echo " done!" echo " done!"
#PHP YAML #PHP YAML
echo -n "[PHP YAML] downloading $PHPYAML_VERSION..." echo -n "[PHP YAML] downloading $PHPYAML_VERSION..."

View File

@ -333,11 +333,16 @@ namespace pocketmine {
console("[ERROR] You have the native PocketMine extension, but your version is lower than 0.0.1.", true, true, 0); console("[ERROR] You have the native PocketMine extension, but your version is lower than 0.0.1.", true, true, 0);
++$errors; ++$errors;
}elseif(version_compare(phpversion("pocketmine"), "0.0.4") > 0){ }elseif(version_compare(phpversion("pocketmine"), "0.0.4") > 0){
console("[ERROR] You have the native PocketMine extension, but your version is lower than 0.0.4.", true, true, 0); console("[ERROR] You have the native PocketMine extension, but your version is higher than 0.0.4.", true, true, 0);
++$errors; ++$errors;
} }
} }
if(!extension_loaded("Weakref") and !extension_loaded("weakref")){
console("[ERROR] Unable to find the Weakref extension.", true, true, 0);
++$errors;
}
if(!extension_loaded("curl")){ if(!extension_loaded("curl")){
console("[ERROR] Unable to find the cURL extension.", true, true, 0); console("[ERROR] Unable to find the cURL extension.", true, true, 0);
++$errors; ++$errors;

127
src/stubs/weakref.php Normal file
View File

@ -0,0 +1,127 @@
<?php
/**
* WeakRef extension stub file for code completion purposes
*
* WARNING: Do not include this file
*
*/
class WeakRef{
/**
* Constructs a new weak reference.
*
* @param object $object
*/
public function __construct($object = null){}
/**
* Acquires a strong reference on that object,
* virtually turning the weak reference into a strong one.
*
* @return bool
*/
public function acquire(){}
/**
* Returns the object pointed to by the weak reference
*
* @return object
*/
public function get(){}
/**
* Releases a previously acquired reference,
* potentially turning a strong reference back into a weak reference.
*
* @return bool
*/
public function release(){}
/**
* Checks whether the object referenced still exists
*
* @return bool
*/
public function valid(){}
}
class WeakMap implements Countable, ArrayAccess, Iterator{
/**
* Constructs a new map
*/
public function __construct(){}
/**
* Counts the number of live entries in the map
*
* @return int
*/
public function count(){}
/**
* Returns the current value being iterated on in the map.
*
* @return mixed
*/
public function current(){}
/**
* Returns the object serving as key in the map, at the current iterating position.
*
* @return mixed
*/
public function key(){}
/**
* Advances to the next map element.
*/
public function next(){}
/**
* Checks whether the passed object is referenced in the map.
*
* @param object $object
*
* @return bool
*/
public function offsetExists($object){}
/**
* Returns the value pointed to by a certain object.
*
* @param object $object
*
* @return mixed
*/
public function offsetGet($object){}
/**
* Updates the map with a new key-value pair.
* If the key already existed in the map, the old value is replaced with the new.
*
* @param object $object
* @param mixed $value
*/
public function offsetSet($object, $value){}
/**
* Removes an entry from the map.
*
* @param object $object
*/
public function offsetUnset($object){}
/**
* Rewinds the iterator to the beginning of the map.
*/
public function rewind(){}
/**
* Returns whether the iterator is still on a valid map element.
*
* @return bool
*/
public function valid(){}
}