From fcda4004a2f68cce5ff80f8953bec2f1159e7ed8 Mon Sep 17 00:00:00 2001
From: Manuel 'Kea' Baldassarri <kea@keasoft.it>
Date: Tue, 16 Jun 2020 18:19:40 +0200
Subject: [PATCH 01/53] Fix parameters passed by reference in rect module and
 fix related tests (#41)

---
 src/rect.c             |  8 ++++----
 tests/006-rect.phpt    | 26 ++++++++++++++++++--------
 tests/007-rect-oo.phpt | 22 +++++++++++++++-------
 3 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/src/rect.c b/src/rect.c
index 4e303e8..186ffe8 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -270,7 +270,7 @@ PHP_FUNCTION(SDL_IntersectRect)
 	zval *obj1, *obj2, *result;
 	SDL_Rect rect1, rect2, rect3;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) {
 		return;
 	}
 	zval_to_sdl_rect(obj1, &rect1);
@@ -296,7 +296,7 @@ PHP_FUNCTION(SDL_UnionRect)
 	zval *obj1, *obj2, *result;
 	SDL_Rect rect1, rect2, rect3;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) {
 		return;
 	}
 	zval_to_sdl_rect(obj1, &rect1);
@@ -328,7 +328,7 @@ PHP_FUNCTION(SDL_EnclosePoints)
 	SDL_Rect clip, result;
 	SDL_Point *points;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz/", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE) {
 		return;
 	}
 	RETVAL_FALSE;
@@ -381,7 +381,7 @@ PHP_FUNCTION(SDL_IntersectRectAndLine)
 	SDL_Rect rect;
 	int x1, y1, x2, y2;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozzzz", &object, php_sdl_rect_ce, &z_x1, &z_y1, &z_x2, &z_y2) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/z/", &object, php_sdl_rect_ce, &z_x1, &z_y1, &z_x2, &z_y2) == FAILURE) {
 		return;
 	}
 	zval_to_sdl_rect(object, &rect);
diff --git a/tests/006-rect.phpt b/tests/006-rect.phpt
index 151113a..424bde8 100644
--- a/tests/006-rect.phpt
+++ b/tests/006-rect.phpt
@@ -3,8 +3,6 @@ rect group test, procedural mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --FILE--
 <?php
 echo "+++ Empty (true)\n";
@@ -67,7 +65,7 @@ var_dump(SDL_EnclosePoints($pts, 6, $r4, $res2), $res2);
 Done
 --EXPECTF--
 +++ Empty (true)
-object(SDL_Rect)#1 (4) {
+object(SDL_Rect)#1 (5) {
   ["x"]=>
   int(0)
   ["y"]=>
@@ -76,10 +74,12 @@ object(SDL_Rect)#1 (4) {
   int(0)
   ["h"]=>
   int(0)
+  ["clip_rect"]=>
+  NULL
 }
 bool(true)
 +++ Empty (false)
-object(SDL_Rect)#2 (4) {
+object(SDL_Rect)#2 (5) {
   ["x"]=>
   int(1)
   ["y"]=>
@@ -88,6 +88,8 @@ object(SDL_Rect)#2 (4) {
   int(3)
   ["h"]=>
   int(4)
+  ["clip_rect"]=>
+  NULL
 }
 bool(false)
 +++ Equal (true)
@@ -99,7 +101,7 @@ bool(false)
 +++ Inter (true)
 bool(true)
 bool(true)
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#6 (5) {
   ["x"]=>
   int(16)
   ["y"]=>
@@ -108,6 +110,8 @@ object(SDL_Rect)#6 (4) {
   int(14)
   ["h"]=>
   int(13)
+  ["clip_rect"]=>
+  NULL
 }
 +++ Inter (false)
 bool(false)
@@ -115,7 +119,7 @@ bool(false)
 NULL
 +++ Union
 NULL
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#6 (5) {
   ["x"]=>
   int(10)
   ["y"]=>
@@ -124,9 +128,11 @@ object(SDL_Rect)#6 (4) {
   int(28)
   ["h"]=>
   int(31)
+  ["clip_rect"]=>
+  NULL
 }
 NULL
-object(SDL_Rect)#%d (4) {
+object(SDL_Rect)#%d (5) {
   ["x"]=>
   int(10)
   ["y"]=>
@@ -135,6 +141,8 @@ object(SDL_Rect)#%d (4) {
   int(110)
   ["h"]=>
   int(20)
+  ["clip_rect"]=>
+  NULL
 }
 +++ InterLine
 bool(true)
@@ -146,7 +154,7 @@ bool(false)
 +++ EnclosePoints
 string(67) "SDL_Point(20,14) SDL_Point(13,20) SDL_Point(24,20) SDL_Point(20,28)"
 bool(true)
-object(SDL_Rect)#%d (4) {
+object(SDL_Rect)#%d (5) {
   ["x"]=>
   int(13)
   ["y"]=>
@@ -155,6 +163,8 @@ object(SDL_Rect)#%d (4) {
   int(12)
   ["h"]=>
   int(15)
+  ["clip_rect"]=>
+  NULL
 }
 
 Warning: SDL_EnclosePoints(): point #4 is not a SDL_Point object in %s/006-rect.php on line %d
diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt
index 61e60b8..ad1d6cc 100644
--- a/tests/007-rect-oo.phpt
+++ b/tests/007-rect-oo.phpt
@@ -3,8 +3,6 @@ rect group test, object mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --FILE--
 <?php
 echo "+++ Empty (true)\n";
@@ -55,7 +53,7 @@ var_dump($r1->IntersectLine($x1, $y1, $x2, $y2));
 Done
 --EXPECTF--
 +++ Empty (true)
-object(SDL_Rect)#1 (4) {
+object(SDL_Rect)#1 (5) {
   ["x"]=>
   int(0)
   ["y"]=>
@@ -64,11 +62,13 @@ object(SDL_Rect)#1 (4) {
   int(0)
   ["h"]=>
   int(0)
+  ["clip_rect"]=>
+  NULL
 }
 string(17) "SDL_Rect(0,0,0,0)"
 bool(true)
 +++ Empty (false)
-object(SDL_Rect)#2 (4) {
+object(SDL_Rect)#2 (5) {
   ["x"]=>
   int(1)
   ["y"]=>
@@ -77,6 +77,8 @@ object(SDL_Rect)#2 (4) {
   int(3)
   ["h"]=>
   int(4)
+  ["clip_rect"]=>
+  NULL
 }
 string(17) "SDL_Rect(1,2,3,4)"
 bool(false)
@@ -89,7 +91,7 @@ bool(false)
 +++ Inter (true)
 bool(true)
 bool(true)
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#6 (5) {
   ["x"]=>
   int(16)
   ["y"]=>
@@ -98,6 +100,8 @@ object(SDL_Rect)#6 (4) {
   int(14)
   ["h"]=>
   int(13)
+  ["clip_rect"]=>
+  NULL
 }
 +++ Inter (false)
 bool(false)
@@ -105,7 +109,7 @@ bool(false)
 NULL
 +++ Uninon
 NULL
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#6 (5) {
   ["x"]=>
   int(10)
   ["y"]=>
@@ -114,9 +118,11 @@ object(SDL_Rect)#6 (4) {
   int(28)
   ["h"]=>
   int(31)
+  ["clip_rect"]=>
+  NULL
 }
 NULL
-object(SDL_Rect)#6 (4) {
+object(SDL_Rect)#6 (5) {
   ["x"]=>
   int(10)
   ["y"]=>
@@ -125,6 +131,8 @@ object(SDL_Rect)#6 (4) {
   int(110)
   ["h"]=>
   int(20)
+  ["clip_rect"]=>
+  NULL
 }
 +++ InterLine
 bool(true)

From 413550b080521080ababceaba8ea727bd728f410 Mon Sep 17 00:00:00 2001
From: Manuel 'Kea' Baldassarri <kea@keasoft.it>
Date: Tue, 16 Jun 2020 21:52:12 +0200
Subject: [PATCH 02/53] Finish to port SDL_Palette and SDL_PixelFormat to Php7
 (#42)

* Fix pixel module params by ref

* Re-enable and port to PHP7 read/get/write property of SDL_Palette

* Re-enable and port to PHP7 read/get/write property of SDL_PixelFormat

* Fix SDL_VERSION param pass by reference

* Re-enable and port to PHP7 read/get/write property of SDL_Pixels

* Add missing return value

* Replace some spaces with tab
---
 src/pixels.c                  | 474 ++++++++++++++++++++++++++++------
 src/version.c                 |   2 +-
 tests/009-color.phpt          |   2 -
 tests/010-palette.phpt        |   2 -
 tests/011-palette-oo.phpt     |   2 -
 tests/012-pixelformat.phpt    |   6 +-
 tests/013-pixelformat-oo.phpt |   6 +-
 tests/014-version.phpt        |   4 +-
 tests/022-pixels.phpt         |   2 -
 9 files changed, 407 insertions(+), 93 deletions(-)

diff --git a/src/pixels.c b/src/pixels.c
index e6e0797..f954abe 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -30,9 +30,9 @@ struct php_sdl_color {
 static zend_class_entry *php_sdl_palette_ce;
 static zend_object_handlers php_sdl_palette_handlers;
 struct php_sdl_palette {
-	zend_object   zo;
 	SDL_Palette   *palette;
 	Uint32        flags;
+	zend_object   zo;
 };
 
 static zend_class_entry *php_sdl_pixelformat_ce;
@@ -46,9 +46,9 @@ struct php_sdl_pixelformat {
 static zend_class_entry *php_sdl_pixels_ce;
 static zend_object_handlers php_sdl_pixels_handlers;
 struct php_sdl_pixels {
-	zend_object      zo;
 	SDL_Pixels       pixels;
 	Uint32           flags;
+	zend_object      zo;
 };
 
 zend_class_entry *get_php_sdl_color_ce(void)
@@ -71,27 +71,45 @@ zend_class_entry *get_php_sdl_pixels_ce(void)
 	return php_sdl_pixels_ce;
 }
 
+static inline struct php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) {
+	return (struct php_sdl_palette*)((char*)(obj) - XtOffsetOf(struct php_sdl_palette, zo));
+}
+
 #define FETCH_PALETTE(__ptr, __id, __check) \
 { \
-        intern = (struct php_sdl_palette *)Z_OBJ_P(__id);\
-        __ptr = intern->palette; \
-        if (__check && !__ptr) {\
-                php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-                RETURN_FALSE;\
-        }\
+		intern = PHP_SDL_PALETTE_P(__id);\
+		__ptr = intern->palette; \
+		if (__check && !__ptr) {\
+				php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
+				RETURN_FALSE;\
+		}\
+}
+
+#define PHP_SDL_PALETTE_P(zv)  php_sdl_palette_from_obj(Z_OBJ_P((zv)))
+
+static inline struct php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_object *obj) {
+	return (struct php_sdl_pixelformat*)((char*)(obj) - XtOffsetOf(struct php_sdl_pixelformat, zo));
 }
 
 #define FETCH_PIXELFORMAT(__ptr, __id, __check) \
 { \
-		zend_object* zox = Z_OBJ_P(__id);\
-        intern = (struct php_sdl_pixelformat *)((char*)zox - zox->handlers->offset);\
-        __ptr = intern->format; \
-        if (__check && !__ptr) {\
-                php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-                RETURN_FALSE;\
-        }\
+		intern = PHP_SDL_PIXELFORMAT_P(__id);\
+		__ptr = intern->format; \
+		if (__check && !__ptr) {\
+				php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
+				RETURN_FALSE;\
+		}\
 }
 
+#define PHP_SDL_PIXELFORMAT_P(zv)  php_sdl_pixelformat_from_obj(Z_OBJ_P((zv)))
+
+static inline struct php_sdl_pixels* php_sdl_pixels_from_obj(zend_object *obj) {
+	return (struct php_sdl_pixels*)((char*)(obj) - XtOffsetOf(struct php_sdl_pixels, zo));
+}
+
+#define PHP_SDL_PIXELS_P(zv)  php_sdl_pixels_from_obj(Z_OBJ_P((zv)))
+
+
 zend_bool sdl_color_to_zval(SDL_Color *color, zval *value)
 {
 	if (color) {
@@ -143,7 +161,7 @@ zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags)
 		struct php_sdl_palette *intern;
 
 		object_init_ex(z_val, php_sdl_palette_ce);
-		intern = (struct php_sdl_palette *)Z_OBJ_P(z_val);
+		intern = PHP_SDL_PALETTE_P(z_val);
 		intern->palette = palette;
 		intern->flags = flags;
 
@@ -162,8 +180,7 @@ zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 f
 		struct php_sdl_pixelformat *intern;
 
 		object_init_ex(z_val, php_sdl_pixelformat_ce);
-		zend_object *zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_pixelformat *)((char*)zo - zo->handlers->offset);
+		intern = PHP_SDL_PIXELFORMAT_P(z_val);
 		intern->format = format;
 		intern->flags = flags;
 
@@ -182,7 +199,7 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags)
 		struct php_sdl_pixels *intern;
 
 		object_init_ex(z_val, php_sdl_pixels_ce);
-		intern = (struct php_sdl_pixels *)Z_OBJ_P(z_val);
+		intern = PHP_SDL_PIXELS_P(z_val);
 		intern->pixels = *pixels;
 		intern->flags  = flags;
 
@@ -199,8 +216,7 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val)
 	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce) {
 		struct php_sdl_pixelformat *intern;
 
-		zend_object *zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_pixelformat*)((char*)zo - zo->handlers->offset);
+		intern = PHP_SDL_PIXELFORMAT_P(z_val);
 		return intern->format;
 		}
 	return NULL;
@@ -213,7 +229,7 @@ SDL_Pixels *zval_to_sdl_pixels(zval *z_val)
 	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) {
 		struct php_sdl_pixels *intern;
 
-		intern = (struct php_sdl_pixels *)Z_OBJ_P(z_val);
+		intern = PHP_SDL_PIXELS_P(z_val);
 		return &intern->pixels;
 		}
 	return NULL;
@@ -226,7 +242,7 @@ SDL_Palette *zval_to_sdl_palette(zval *z_val)
 	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce) {
 		struct php_sdl_palette *intern;
 
-		intern = (struct php_sdl_palette *)Z_OBJ_P(z_val);
+		intern = PHP_SDL_PALETTE_P(z_val);
 		return intern->palette;
 		}
 	return NULL;
@@ -234,10 +250,10 @@ SDL_Palette *zval_to_sdl_palette(zval *z_val)
 /* }}} */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Color__construct, 0, 0, 4)
-       ZEND_ARG_INFO(0, r)
-       ZEND_ARG_INFO(0, g)
-       ZEND_ARG_INFO(0, b)
-       ZEND_ARG_INFO(0, a)
+	   ZEND_ARG_INFO(0, r)
+	   ZEND_ARG_INFO(0, g)
+	   ZEND_ARG_INFO(0, b)
+	   ZEND_ARG_INFO(0, a)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Color::__construct(int r, int g, int b, int a) */
@@ -319,7 +335,7 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
 	int bpp;
 	Uint32 rmask, gmask, bmask, amask;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lzzzzz", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/z/z/z/z/", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE) {
 		RETURN_FALSE;
 	}
 	if (SDL_PixelFormatEnumToMasks((Uint32)format, &bpp, &rmask, &gmask, &bmask, &amask)) {
@@ -391,7 +407,7 @@ static PHP_METHOD(SDL_PixelFormat, __construct)
 	zend_long format;
 	zend_error_handling error_handling;
 
-	intern = (struct php_sdl_pixelformat *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELFORMAT_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
 	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format)) {
@@ -420,7 +436,7 @@ static PHP_METHOD(SDL_PixelFormat, __toString)
 		return;
 	}
 
-	intern = (struct php_sdl_pixelformat *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELFORMAT_P(getThis());
 	spprintf(&buf, 100, "SDL_PixelFormat(%s)", SDL_GetPixelFormatName(intern->format->format));
 	RETVAL_STRING(buf);
 }
@@ -481,7 +497,7 @@ static PHP_METHOD(SDL_Palette, __construct)
 	zend_long ncolors;
 	zend_error_handling error_handling;
 
-	intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PALETTE_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
 	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) {
@@ -510,7 +526,7 @@ static PHP_METHOD(SDL_Palette, __toString)
 		return;
 	}
 
-	intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PALETTE_P(getThis());
 	spprintf(&buf, 100, "SDL_Palette(%d)", intern->palette ? intern->palette->ncolors : 0);
 	RETVAL_STRING(buf);
 }
@@ -522,7 +538,7 @@ static PHP_METHOD(SDL_Palette, count)
 {
 	struct php_sdl_palette *intern;
 
-	intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PALETTE_P(getThis());
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
@@ -532,7 +548,7 @@ static PHP_METHOD(SDL_Palette, count)
 /* }}} */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offset, 0, 0, 1)
-       ZEND_ARG_INFO(0, offset)
+	   ZEND_ARG_INFO(0, offset)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Palette, offsetExists(int offset) */
@@ -541,7 +557,7 @@ PHP_METHOD(SDL_Palette, offsetExists)
 	struct php_sdl_palette *intern;
 	zend_long offset;
 
-	intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PALETTE_P(getThis());
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
 		return;
 	}
@@ -558,7 +574,7 @@ PHP_METHOD(SDL_Palette, offsetGet)
 	struct php_sdl_palette *intern;
 	zend_long offset;
 
-	intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PALETTE_P(getThis());
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
 		return;
 	}
@@ -577,7 +593,7 @@ PHP_METHOD(SDL_Palette, offsetUnset)
 	zend_long offset;
 	SDL_Color color;
 
-	intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PALETTE_P(getThis());
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
 		return;
 	}
@@ -591,8 +607,8 @@ PHP_METHOD(SDL_Palette, offsetUnset)
 /* }}} */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 0, 2)
-       ZEND_ARG_INFO(0, offset)
-       ZEND_ARG_INFO(0, color)
+	   ZEND_ARG_INFO(0, offset)
+	   ZEND_ARG_INFO(0, color)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Palette, offsetSet(int offset, int value) */
@@ -603,7 +619,7 @@ PHP_METHOD(SDL_Palette, offsetSet)
 	zval *z_color;
 	SDL_Color color;
 
-	intern = (struct php_sdl_palette *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PALETTE_P(getThis());
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO", &offset, &z_color, php_sdl_color_ce) == FAILURE) {
 		return;
 	}
@@ -800,7 +816,7 @@ PHP_FUNCTION(SDL_GetRGB)
 	Uint8 r, g, b;
 	zend_long pix;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOzzz", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOz/z/z/", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b) == FAILURE) {
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -816,10 +832,10 @@ PHP_FUNCTION(SDL_GetRGB)
 
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_PixelFormat_GetRGB, 0, 0, 4)
-       ZEND_ARG_INFO(0, pixel)
-       ZEND_ARG_INFO(1, r)
-       ZEND_ARG_INFO(1, g)
-       ZEND_ARG_INFO(1, b)
+	   ZEND_ARG_INFO(0, pixel)
+	   ZEND_ARG_INFO(1, r)
+	   ZEND_ARG_INFO(1, g)
+	   ZEND_ARG_INFO(1, b)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto int SDL_PixelFormat::GetRGB(int pixel, int &r, int &g, int &b)
@@ -834,7 +850,7 @@ PHP_METHOD(SDL_PixelFormat, GetRGB)
 	Uint8 r, g, b;
 	zend_long pix;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olzzz", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz/z/z/", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b) == FAILURE) {
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -866,7 +882,7 @@ PHP_FUNCTION(SDL_GetRGBA)
 	Uint8 r, g, b, a;
 	zend_long pix;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOzzzz", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b, &z_a) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOz/z/z/z/", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b, &z_a) == FAILURE) {
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -895,7 +911,7 @@ PHP_METHOD(SDL_PixelFormat, GetRGBA)
 	Uint8 r, g, b, a;
 	zend_long pix;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olzzzz", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b, &z_a) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz/z/z/z/", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b, &z_a) == FAILURE) {
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -924,7 +940,7 @@ PHP_FUNCTION(SDL_CalculateGammaRamp)
 	Uint16 ramp[256];
 	int i;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "dz", &gamma, &z_ramp) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "dz/", &gamma, &z_ramp) == FAILURE) {
 		RETURN_FALSE;
 	}
 	SDL_CalculateGammaRamp((float)gamma, ramp);
@@ -938,8 +954,8 @@ PHP_FUNCTION(SDL_CalculateGammaRamp)
 
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels__construct, 0, 0, 2)
-       ZEND_ARG_INFO(0, pitch)
-       ZEND_ARG_INFO(0, h)
+	   ZEND_ARG_INFO(0, pitch)
+	   ZEND_ARG_INFO(0, h)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Pixels::__construct(int pitch, int h) */
@@ -949,7 +965,7 @@ static PHP_METHOD(SDL_Pixels, __construct)
 	zend_long pitch, h;
 	zend_error_handling error_handling;
 
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELS_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
 	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &pitch, &h)) {
@@ -983,7 +999,7 @@ static PHP_METHOD(SDL_Pixels, __toString)
 		return;
 	}
 
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELS_P(getThis());
 	spprintf(&buf, 100, "SDL_Pixels(%d,%d)", intern->pixels.pitch, intern->pixels.h);
 	RETVAL_STRING(buf);
 }
@@ -995,7 +1011,7 @@ static PHP_METHOD(SDL_Pixels, count)
 {
 	struct php_sdl_pixels *intern;
 
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELS_P(getThis());
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
 	}
@@ -1005,7 +1021,7 @@ static PHP_METHOD(SDL_Pixels, count)
 /* }}} */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offset, 0, 0, 1)
-       ZEND_ARG_INFO(0, offset)
+	   ZEND_ARG_INFO(0, offset)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Pixels, offsetExists(int offset) */
@@ -1014,7 +1030,7 @@ PHP_METHOD(SDL_Pixels, offsetExists)
 	struct php_sdl_pixels *intern;
 	zend_long offset;
 
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELS_P(getThis());
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
 		return;
 	}
@@ -1031,7 +1047,7 @@ PHP_METHOD(SDL_Pixels, offsetGet)
 	struct php_sdl_pixels *intern;
 	zend_long offset;
 
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELS_P(getThis());
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
 		return;
 	}
@@ -1049,7 +1065,7 @@ PHP_METHOD(SDL_Pixels, offsetUnset)
 	struct php_sdl_pixels *intern;
 	zend_long offset;
 
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELS_P(getThis());
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
 		return;
 	}
@@ -1062,8 +1078,8 @@ PHP_METHOD(SDL_Pixels, offsetUnset)
 /* }}} */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 0, 2)
-       ZEND_ARG_INFO(0, offset)
-       ZEND_ARG_INFO(0, value)
+	   ZEND_ARG_INFO(0, offset)
+	   ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */
@@ -1072,7 +1088,7 @@ PHP_METHOD(SDL_Pixels, offsetSet)
 	struct php_sdl_pixels *intern;
 	zend_long offset, value;
 
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis());
+	intern = PHP_SDL_PIXELS_P(getThis());
 	if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE) {
 		return;
 	}
@@ -1086,8 +1102,8 @@ PHP_METHOD(SDL_Pixels, offsetSet)
 
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_GetByte, 0, 0, 2)
-       ZEND_ARG_INFO(0, x)
-       ZEND_ARG_INFO(0, y)
+	   ZEND_ARG_INFO(0, x)
+	   ZEND_ARG_INFO(0, y)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto int SDL_Pixels::GetByte(int x, int y) */
@@ -1100,7 +1116,7 @@ PHP_METHOD(SDL_Pixels, GetByte)
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE) {
 		return;
 	}
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(z_pixels);\
+	intern = PHP_SDL_PIXELS_P(z_pixels);
 
 	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
 		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
@@ -1112,9 +1128,9 @@ PHP_METHOD(SDL_Pixels, GetByte)
 
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_SetByte, 0, 0, 3)
-       ZEND_ARG_INFO(0, x)
-       ZEND_ARG_INFO(0, y)
-       ZEND_ARG_INFO(0, byte)
+	   ZEND_ARG_INFO(0, x)
+	   ZEND_ARG_INFO(0, y)
+	   ZEND_ARG_INFO(0, byte)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */
@@ -1127,7 +1143,7 @@ PHP_METHOD(SDL_Pixels, SetByte)
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE) {
 		return;
 	}
-	intern = (struct php_sdl_pixels *)Z_OBJ_P(z_pixels);\
+	intern = PHP_SDL_PIXELS_P(z_pixels);
 
 	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
 		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
@@ -1144,7 +1160,7 @@ PHP_METHOD(SDL_Pixels, SetByte)
 	 */
 static void php_sdl_palette_free(zend_object *object)
 {
-	struct php_sdl_palette *intern = (struct php_sdl_palette *) object;
+	struct php_sdl_palette *intern = php_sdl_palette_from_obj(object);
 
 	if (intern->palette) {
 		if (!(intern->flags & SDL_DONTFREE)) {
@@ -1162,7 +1178,7 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type)
 {
 	struct php_sdl_palette *intern;
 
-	intern = ecalloc(1, sizeof(*intern));
+	intern = ecalloc(1, sizeof(struct php_sdl_palette) + zend_object_properties_size(class_type));
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
@@ -1174,11 +1190,104 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type)
 }
 /* }}} */
 
+/* {{{ sdl_palette_read_property*/
+zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
+{
+	struct php_sdl_palette *intern = PHP_SDL_PALETTE_P(object);
+	zval *retval, tmp_member;
+
+	if (Z_TYPE_P(member) != IS_STRING) {
+		zend_string *_str = zval_try_get_string_func(member);
+		if (UNEXPECTED(!_str)) {
+			return &EG(uninitialized_zval);
+		}
+		ZVAL_STR(&tmp_member, _str);
+		member = &tmp_member;
+		cache_slot = NULL;
+	}
+
+	if (!intern->palette) {
+		return zend_std_read_property(object, member, type, cache_slot, rv);
+	}
+
+	retval = rv;
+
+	if (!strcmp(Z_STRVAL_P(member), "ncolors")) {
+		ZVAL_LONG(retval, intern->palette->ncolors);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "version")) {
+		ZVAL_LONG(retval, intern->palette->version);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "refcount")) {
+		ZVAL_LONG(retval, intern->palette->refcount);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "colors")) {
+		int i;
+		zval z_color;
+		array_init(retval);
+		for (i=0 ; i<intern->palette->ncolors ; i++) {
+			sdl_color_to_zval(&intern->palette->colors[i], &z_color );
+			add_next_index_zval(retval, &z_color);
+		}
+
+	} else {
+		retval = zend_std_read_property(object, member, type, cache_slot, rv);
+		if (member == &tmp_member) {
+			zval_ptr_dtor_str(&tmp_member);
+		}
+		return retval;
+	}
+
+	if (member == &tmp_member) {
+		zval_dtor(member);
+	}
+	return retval;
+}
+/* }}} */
+
+#define SDL_PALETTE_ADD_PROPERTY(n,f) \
+	ZVAL_LONG(&zv, f); \
+	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
+
+/* {{{ sdl_palette_get_properties*/
+static HashTable *sdl_palette_get_properties(zval *object)
+{
+	HashTable *props;
+	zval zv, z_color;
+	int i;
+	struct php_sdl_palette *intern = PHP_SDL_PALETTE_P(object);
+
+	props = zend_std_get_properties(object);
+
+	if (intern->palette) {
+		SDL_PALETTE_ADD_PROPERTY("ncolors",  intern->palette->ncolors);
+		SDL_PALETTE_ADD_PROPERTY("version",  intern->palette->version);
+		SDL_PALETTE_ADD_PROPERTY("refcount", intern->palette->refcount);
+
+		array_init(&zv);
+		for (i=0 ; i<intern->palette->ncolors ; i++) {
+			sdl_color_to_zval(&intern->palette->colors[i], &z_color );
+			add_next_index_zval(&zv, &z_color);
+		}
+		zend_hash_str_update(props, "colors", sizeof("colors")-1, &zv);
+	}
+	return props;
+}
+/* }}} */
+
+/* {{{ sdl_palette_write_property */
+static zval *sdl_palette_write_property(zval *object, zval *member, zval *value, void **cache_slot)
+{
+	php_error_docref(NULL, E_ERROR, "Not supported, use SDL_SetPaletteColors() or SDL_Palette::SetColors()");
+	return value;
+}
+/* }}} */
+
 /* {{{ php_sdl_pixelformat_free
 	 */
 static void php_sdl_pixelformat_free(zend_object *object)
 {
-	struct php_sdl_pixelformat *intern = (struct php_sdl_pixelformat*)((char*)object - object->handlers->offset);
+	struct php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object);
 
 	if (intern->format) {
 		if (!(intern->flags & SDL_DONTFREE)) {
@@ -1208,11 +1317,145 @@ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type)
 }
 /* }}} */
 
+/* {{{ sdl_pixelformat_read_property*/
+zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
+{
+	struct php_sdl_pixelformat *intern;
+	zval *retval, tmp_member;
+
+	intern = PHP_SDL_PIXELFORMAT_P(object);
+
+	if (Z_TYPE_P(member) != IS_STRING) {
+		zend_string *_str = zval_try_get_string_func(member);
+		if (UNEXPECTED(!_str)) {
+			return &EG(uninitialized_zval);
+		}
+		ZVAL_STR(&tmp_member, _str);
+		member = &tmp_member;
+		cache_slot = NULL;
+	}
+
+	if (!intern->format) {
+		return zend_std_read_property(object, member, type, cache_slot, rv);
+	}
+
+	retval = rv;
+
+	if (!strcmp(Z_STRVAL_P(member), "format")) {
+		ZVAL_LONG(retval, intern->format->format);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "BitsPerPixel")) {
+		ZVAL_LONG(retval, intern->format->BitsPerPixel);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "BytesPerPixel")) {
+		ZVAL_LONG(retval, intern->format->BytesPerPixel);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Rmask")) {
+		ZVAL_LONG(retval, intern->format->Rmask);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Gmask")) {
+		ZVAL_LONG(retval, intern->format->Gmask);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Bmask")) {
+		ZVAL_LONG(retval, intern->format->Bmask);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Amask")) {
+		ZVAL_LONG(retval, intern->format->Amask);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Rloss")) {
+		ZVAL_LONG(retval, intern->format->Rloss);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Gloss")) {
+		ZVAL_LONG(retval, intern->format->Gloss);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Bloss")) {
+		ZVAL_LONG(retval, intern->format->Bloss);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Aloss")) {
+		ZVAL_LONG(retval, intern->format->Aloss);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Rshift")) {
+		ZVAL_LONG(retval, intern->format->Rshift);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Gshift")) {
+		ZVAL_LONG(retval, intern->format->Gshift);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Bshift")) {
+		ZVAL_LONG(retval, intern->format->Bshift);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "Ashift")) {
+		ZVAL_LONG(retval, intern->format->Ashift);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "palette")) {
+		sdl_palette_to_zval(intern->format->palette, retval, SDL_DONTFREE);
+
+	} else {
+		retval = zend_std_read_property(object, member, type, cache_slot, rv);
+		if (member == &tmp_member) {
+			zval_ptr_dtor_str(&tmp_member);
+		}
+		return retval;
+	}
+
+	if (member == &tmp_member) {
+		zval_dtor(member);
+	}
+	return retval;
+}
+/* }}} */
+
+#define SDL_PIXELFORMAT_ADD_PROPERTY(n,f) \
+	ZVAL_LONG(&zv, f); \
+	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
+
+/* {{{ sdl_pixelformat_read_property*/
+static HashTable *sdl_pixelformat_get_properties(zval *object)
+{
+	HashTable *props;
+	zval zv;
+	struct php_sdl_pixelformat *intern;
+
+	intern = PHP_SDL_PIXELFORMAT_P(object);
+
+	props = zend_std_get_properties(object);
+
+	if (intern->format) {
+		SDL_PIXELFORMAT_ADD_PROPERTY("format",        intern->format->format);
+		SDL_PIXELFORMAT_ADD_PROPERTY("BitsPerPixel",  intern->format->BitsPerPixel);
+		SDL_PIXELFORMAT_ADD_PROPERTY("BytesPerPixel", intern->format->BytesPerPixel);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Rmask",         intern->format->Rmask);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Gmask",         intern->format->Gmask);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Bmask",         intern->format->Bmask);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Amask",         intern->format->Amask);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Rloss",         intern->format->Rloss);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Gloss",         intern->format->Gloss);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Bloss",         intern->format->Bloss);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Aloss",         intern->format->Aloss);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Rshift",        intern->format->Rshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Gshift",        intern->format->Rshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Bshift",        intern->format->Rshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Ashift",        intern->format->Rshift);
+
+		sdl_palette_to_zval(intern->format->palette, &zv, SDL_DONTFREE);
+		zend_hash_str_update(props, "palette", sizeof("palette")-1, &zv);
+	}
+	return props;
+}
+/* }}} */
+
+/* {{{ sdl_pixelformat_write_property */
+static zval *sdl_pixelformat_write_property(zval *object, zval *member, zval *value, void **cache_slot)
+{
+	php_error_docref(NULL, E_ERROR, "Not supported, SDL_PixelFormat is read-only");
+	return value;
+}
+/* }}} */
+
 /* {{{ php_sdl_pixels_free
 	 */
 static void php_sdl_pixels_free(zend_object *object)
 {
-	struct php_sdl_pixels *intern = (struct php_sdl_pixels *) object;
+	struct php_sdl_pixels *intern = php_sdl_pixels_from_obj(object);
 
 	if (intern->pixels.pixels) {
 		if (!(intern->flags & SDL_DONTFREE)) {
@@ -1230,7 +1473,7 @@ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type)
 {
 	struct php_sdl_pixels *intern;
 
-	intern = ecalloc(1, sizeof(*intern));
+	intern = (struct php_sdl_pixels*)ecalloc(1, sizeof(struct php_sdl_pixels) + zend_object_properties_size(class_type));
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
@@ -1241,6 +1484,82 @@ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type)
 }
 /* }}} */
 
+/* {{{ sdl_pixels_read_property*/
+zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
+{
+	struct php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object);
+	zval *retval, tmp_member;
+
+	if (Z_TYPE_P(member) != IS_STRING) {
+		zend_string *_str = zval_try_get_string_func(member);
+		if (UNEXPECTED(!_str)) {
+			return &EG(uninitialized_zval);
+		}
+		ZVAL_STR(&tmp_member, _str);
+		member = &tmp_member;
+		cache_slot = NULL;
+	}
+
+	if (!intern->pixels.pixels) {
+		return zend_std_read_property(object, member, type, cache_slot, rv);
+	}
+
+	retval = rv;
+
+	if (!strcmp(Z_STRVAL_P(member), "h")) {
+		ZVAL_LONG(retval, intern->pixels.h);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "pitch")) {
+		ZVAL_LONG(retval, intern->pixels.pitch);
+
+	} else if (!strcmp(Z_STRVAL_P(member), "count")) {
+		ZVAL_LONG(retval, intern->pixels.pitch * intern->pixels.h);
+
+	} else {
+		retval = zend_std_read_property(object, member, type, cache_slot, rv);
+		if (member == &tmp_member) {
+			zval_dtor(member);
+		}
+		return retval;
+	}
+
+	if (member == &tmp_member) {
+		zval_dtor(member);
+	}
+	return retval;
+}
+/* }}} */
+
+#define SDL_PIXELS_ADD_PROPERTY(n,f) \
+	ZVAL_LONG(&zv, f); \
+	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
+
+/* {{{ sdl_pixels_read_properties */
+static HashTable *sdl_pixels_get_properties(zval *object)
+{
+	HashTable *props;
+	zval zv;
+	struct php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object);
+
+	props = zend_std_get_properties(object);
+
+	if (intern->pixels.pixels) {
+		SDL_PIXELS_ADD_PROPERTY("pitch",  intern->pixels.pitch);
+		SDL_PIXELS_ADD_PROPERTY("h",      intern->pixels.h);
+		SDL_PIXELS_ADD_PROPERTY("count",  intern->pixels.h * intern->pixels.pitch);
+	}
+	return props;
+}
+/* }}} */
+
+/* {{{ sdl_pixels_write_property */
+static zval *sdl_pixels_write_property(zval *object, zval *member, zval *value, void **cache_slot)
+{
+	php_error_docref(NULL, E_ERROR, "Not supported, SDL_Pixels is read-only");
+	return value;
+}
+/* }}} */
+
 /* {{{ php_sdl_color_methods[] */
 static const zend_function_entry php_sdl_color_methods[] = {
 	PHP_ME(SDL_Color, __construct,     arginfo_SDL_Color__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
@@ -1331,6 +1650,9 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_palette_ce->create_object = php_sdl_palette_new;
 	zend_class_implements(php_sdl_palette_ce, 1, zend_ce_arrayaccess);
 	memcpy(&php_sdl_palette_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+	php_sdl_palette_handlers.read_property  = sdl_palette_read_property;
+	php_sdl_palette_handlers.get_properties = sdl_palette_get_properties;
+	php_sdl_palette_handlers.write_property = sdl_palette_write_property;
 	php_sdl_palette_handlers.free_obj = php_sdl_palette_free;
 
 	REGISTER_PALETTE_PROP("ncolors");
@@ -1342,6 +1664,9 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_pixelformat_ce = zend_register_internal_class(&ce_pixelformat);
 	php_sdl_pixelformat_ce->create_object = php_sdl_pixelformat_new;
 	memcpy(&php_sdl_pixelformat_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+	php_sdl_pixelformat_handlers.read_property  = sdl_pixelformat_read_property;
+	php_sdl_pixelformat_handlers.get_properties = sdl_pixelformat_get_properties;
+	php_sdl_pixelformat_handlers.write_property = sdl_pixelformat_write_property;
 	php_sdl_pixelformat_handlers.free_obj = php_sdl_pixelformat_free;
 	php_sdl_pixelformat_handlers.offset = XtOffsetOf(struct php_sdl_pixelformat, zo);
 
@@ -1367,6 +1692,9 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_pixels_ce->create_object = php_sdl_pixels_new;
 	zend_class_implements(php_sdl_pixels_ce, 1, zend_ce_arrayaccess);
 	memcpy(&php_sdl_pixels_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+	php_sdl_pixels_handlers.read_property  = sdl_pixels_read_property;
+	php_sdl_pixels_handlers.get_properties = sdl_pixels_get_properties;
+	php_sdl_pixels_handlers.write_property = sdl_pixels_write_property;
 	php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free;
 
 	REGISTER_PIXELS_PROP("pitch");
diff --git a/src/version.c b/src/version.c
index 55e8d07..69cea57 100644
--- a/src/version.c
+++ b/src/version.c
@@ -144,7 +144,7 @@ PHP_FUNCTION(SDL_VERSION)
 	SDL_version version;
 	zval *version_array;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &version_array) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "z/", &version_array) == FAILURE) {
 		RETURN_FALSE;
 	}
 	SDL_VERSION(&version);
diff --git a/tests/009-color.phpt b/tests/009-color.phpt
index 12f99cf..3759648 100644
--- a/tests/009-color.phpt
+++ b/tests/009-color.phpt
@@ -3,8 +3,6 @@ SDL_Color test
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --FILE--
 <?php
 echo "Color\n";
diff --git a/tests/010-palette.phpt b/tests/010-palette.phpt
index 28307ff..02688ff 100644
--- a/tests/010-palette.phpt
+++ b/tests/010-palette.phpt
@@ -3,8 +3,6 @@ SDL_Palette test, procedural mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --FILE--
 <?php
 echo "= Alloc\n";
diff --git a/tests/011-palette-oo.phpt b/tests/011-palette-oo.phpt
index 81ea5aa..b50e522 100644
--- a/tests/011-palette-oo.phpt
+++ b/tests/011-palette-oo.phpt
@@ -3,8 +3,6 @@ SDL_Palette test, object mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --FILE--
 <?php
 echo "= Alloc\n";
diff --git a/tests/012-pixelformat.phpt b/tests/012-pixelformat.phpt
index 66b6e7c..60ee70e 100644
--- a/tests/012-pixelformat.phpt
+++ b/tests/012-pixelformat.phpt
@@ -3,8 +3,6 @@ SDL_PixelFormat test, procedural mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --FILE--
 <?php
 echo "= Palette\n";
@@ -48,8 +46,6 @@ int(0)
 int(0)
 = Result
 object(SDL_PixelFormat)#%d (16) {
-  ["format"]=>
-  int(303039488)
   ["BitsPerPixel"]=>
   int(4)
   ["BytesPerPixel"]=>
@@ -266,6 +262,8 @@ object(SDL_PixelFormat)#%d (16) {
       }
     }
   }
+  ["format"]=>
+  int(303039488)
 }
 = RGB
 int(8)
diff --git a/tests/013-pixelformat-oo.phpt b/tests/013-pixelformat-oo.phpt
index b9c6c08..200a057 100644
--- a/tests/013-pixelformat-oo.phpt
+++ b/tests/013-pixelformat-oo.phpt
@@ -3,8 +3,6 @@ SDL_PixelFormat test, object mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --FILE--
 <?php
 echo "= Palette\n";
@@ -51,8 +49,6 @@ string(42) "SDL_PixelFormat(SDL_PIXELFORMAT_INDEX4LSB)"
 int(0)
 = Result
 object(SDL_PixelFormat)#%d (16) {
-  ["format"]=>
-  int(303039488)
   ["BitsPerPixel"]=>
   int(4)
   ["BytesPerPixel"]=>
@@ -269,6 +265,8 @@ object(SDL_PixelFormat)#%d (16) {
       }
     }
   }
+  ["format"]=>
+  int(303039488)
 }
 = RGB
 int(8)
diff --git a/tests/014-version.phpt b/tests/014-version.phpt
index f671bc2..49981f6 100644
--- a/tests/014-version.phpt
+++ b/tests/014-version.phpt
@@ -3,8 +3,6 @@ SDL_version test suite
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --INI--
 error_reporting = 32767;
 --FILE--
@@ -26,7 +24,7 @@ SDL_VERSION($version);
 var_dump(array_key_exists('major', $version) && array_key_exists('minor', $version) && array_key_exists('patch', $version));
 var_dump(12030 === SDL_VERSIONNUM(10,20,30));
 var_dump(SDL_VERSION_ATLEAST(2,0,0));
-var_dump(SDL_VERSION_ATLEAST(2,0,5));
+var_dump(SDL_VERSION_ATLEAST(2,0,25));
 var_dump(is_string(SDL_GetRevision()));
 var_dump(is_integer(SDL_GetRevisionNumber()));
 
diff --git a/tests/022-pixels.phpt b/tests/022-pixels.phpt
index da36f1b..25f0a88 100644
--- a/tests/022-pixels.phpt
+++ b/tests/022-pixels.phpt
@@ -3,8 +3,6 @@ SDL_Pixels test
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
 --INI--
 error_reporting = 32767;
 --FILE--

From b4ded1ed7b5f1348c8fc52c49d1add1ede9d94b8 Mon Sep 17 00:00:00 2001
From: Manuel 'Kea' Baldassarri <kea@keasoft.it>
Date: Fri, 19 Jun 2020 20:12:50 +0200
Subject: [PATCH 03/53] Fix surface props initialization and rect extra field
 (#43)

* Fix SDL_surface wrong properties initialization, fix SDL_Palette and SDL_Pixel offset

* Fix SDL_Point conversion from and to zval

* Fix SDL_GetDisplayBounds return value and fix tests

* Skip 005-video.phpt if run on travis because lack of Video
---
 src/pixels.c                  | 127 +++++++++++++++++-----------------
 src/rect.c                    |  14 ++--
 src/surface.c                 |   6 +-
 src/video.c                   |   2 +-
 tests/005-video.phpt          |   9 ++-
 tests/006-rect.phpt           |  24 ++-----
 tests/007-rect-oo.phpt        |  20 ++----
 tests/012-pixelformat.phpt    |   4 +-
 tests/013-pixelformat-oo.phpt |   4 +-
 tests/test-functions.php      |   5 ++
 10 files changed, 97 insertions(+), 118 deletions(-)

diff --git a/src/pixels.c b/src/pixels.c
index f954abe..58f2b11 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -20,6 +20,7 @@
 
 #include "pixels.h"
 #include "zend_interfaces.h"
+#include "zend_operators.h"
 
 static zend_class_entry *php_sdl_color_ce;
 static zend_object_handlers php_sdl_color_handlers;
@@ -29,27 +30,27 @@ struct php_sdl_color {
 
 static zend_class_entry *php_sdl_palette_ce;
 static zend_object_handlers php_sdl_palette_handlers;
-struct php_sdl_palette {
+typedef struct _php_sdl_palette {
 	SDL_Palette   *palette;
 	Uint32        flags;
 	zend_object   zo;
-};
+} php_sdl_palette;
 
 static zend_class_entry *php_sdl_pixelformat_ce;
 static zend_object_handlers php_sdl_pixelformat_handlers;
-struct php_sdl_pixelformat {
+typedef struct _php_sdl_pixelformat {
 	SDL_PixelFormat *format;
 	Uint32           flags;
 	zend_object      zo;
-};
+} php_sdl_pixelformat;
 
 static zend_class_entry *php_sdl_pixels_ce;
 static zend_object_handlers php_sdl_pixels_handlers;
-struct php_sdl_pixels {
+typedef struct _php_sdl_pixels {
 	SDL_Pixels       pixels;
 	Uint32           flags;
 	zend_object      zo;
-};
+} php_sdl_pixels;
 
 zend_class_entry *get_php_sdl_color_ce(void)
 {
@@ -71,8 +72,8 @@ zend_class_entry *get_php_sdl_pixels_ce(void)
 	return php_sdl_pixels_ce;
 }
 
-static inline struct php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) {
-	return (struct php_sdl_palette*)((char*)(obj) - XtOffsetOf(struct php_sdl_palette, zo));
+static inline php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) {
+	return (php_sdl_palette*)((char*)(obj) - XtOffsetOf(php_sdl_palette, zo));
 }
 
 #define FETCH_PALETTE(__ptr, __id, __check) \
@@ -87,8 +88,8 @@ static inline struct php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj)
 
 #define PHP_SDL_PALETTE_P(zv)  php_sdl_palette_from_obj(Z_OBJ_P((zv)))
 
-static inline struct php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_object *obj) {
-	return (struct php_sdl_pixelformat*)((char*)(obj) - XtOffsetOf(struct php_sdl_pixelformat, zo));
+static inline php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_object *obj) {
+	return (php_sdl_pixelformat*)((char*)(obj) - XtOffsetOf(php_sdl_pixelformat, zo));
 }
 
 #define FETCH_PIXELFORMAT(__ptr, __id, __check) \
@@ -103,8 +104,8 @@ static inline struct php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_obje
 
 #define PHP_SDL_PIXELFORMAT_P(zv)  php_sdl_pixelformat_from_obj(Z_OBJ_P((zv)))
 
-static inline struct php_sdl_pixels* php_sdl_pixels_from_obj(zend_object *obj) {
-	return (struct php_sdl_pixels*)((char*)(obj) - XtOffsetOf(struct php_sdl_pixels, zo));
+static inline php_sdl_pixels* php_sdl_pixels_from_obj(zend_object *obj) {
+	return (php_sdl_pixels*)((char*)(obj) - XtOffsetOf(php_sdl_pixels, zo));
 }
 
 #define PHP_SDL_PIXELS_P(zv)  php_sdl_pixels_from_obj(Z_OBJ_P((zv)))
@@ -158,7 +159,7 @@ zend_bool zval_to_sdl_color(zval *value, SDL_Color *color)
 zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags)
 {
 	if (palette) {
-		struct php_sdl_palette *intern;
+		php_sdl_palette *intern;
 
 		object_init_ex(z_val, php_sdl_palette_ce);
 		intern = PHP_SDL_PALETTE_P(z_val);
@@ -177,7 +178,7 @@ zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags)
 zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 flags)
 {
 	if (format) {
-		struct php_sdl_pixelformat *intern;
+		php_sdl_pixelformat *intern;
 
 		object_init_ex(z_val, php_sdl_pixelformat_ce);
 		intern = PHP_SDL_PIXELFORMAT_P(z_val);
@@ -196,7 +197,7 @@ zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 f
 zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags)
 {
 	if (pixels) {
-		struct php_sdl_pixels *intern;
+		php_sdl_pixels *intern;
 
 		object_init_ex(z_val, php_sdl_pixels_ce);
 		intern = PHP_SDL_PIXELS_P(z_val);
@@ -214,7 +215,7 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags)
 SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val)
 {
 	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce) {
-		struct php_sdl_pixelformat *intern;
+		php_sdl_pixelformat *intern;
 
 		intern = PHP_SDL_PIXELFORMAT_P(z_val);
 		return intern->format;
@@ -227,7 +228,7 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val)
 SDL_Pixels *zval_to_sdl_pixels(zval *z_val)
 {
 	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) {
-		struct php_sdl_pixels *intern;
+		php_sdl_pixels *intern;
 
 		intern = PHP_SDL_PIXELS_P(z_val);
 		return &intern->pixels;
@@ -240,7 +241,7 @@ SDL_Pixels *zval_to_sdl_pixels(zval *z_val)
 SDL_Palette *zval_to_sdl_palette(zval *z_val)
 {
 	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce) {
-		struct php_sdl_palette *intern;
+		php_sdl_palette *intern;
 
 		intern = PHP_SDL_PALETTE_P(z_val);
 		return intern->palette;
@@ -403,7 +404,7 @@ PHP_FUNCTION(SDL_AllocFormat)
 /* {{{ proto SDL_PixelFormat::__construct(format) */
 static PHP_METHOD(SDL_PixelFormat, __construct)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zend_long format;
 	zend_error_handling error_handling;
 
@@ -429,7 +430,7 @@ static PHP_METHOD(SDL_PixelFormat, __construct)
 /* {{{ proto SDL_PixelFormat::__toString() */
 static PHP_METHOD(SDL_PixelFormat, __toString)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	char *buf;
 
 	if (zend_parse_parameters_none() == FAILURE) {
@@ -450,7 +451,7 @@ static PHP_METHOD(SDL_PixelFormat, __toString)
  */
 PHP_FUNCTION(SDL_FreeFormat)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zval *object;
 	SDL_PixelFormat *format;
 
@@ -493,7 +494,7 @@ PHP_FUNCTION(SDL_AllocPalette)
 /* {{{ proto SDL_Palette::__construct(ncolors) */
 static PHP_METHOD(SDL_Palette, __construct)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	zend_long ncolors;
 	zend_error_handling error_handling;
 
@@ -519,7 +520,7 @@ static PHP_METHOD(SDL_Palette, __construct)
 /* {{{ proto SDL_Palette::__toString() */
 static PHP_METHOD(SDL_Palette, __toString)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	char *buf;
 
 	if (zend_parse_parameters_none() == FAILURE) {
@@ -536,7 +537,7 @@ static PHP_METHOD(SDL_Palette, __toString)
 /* {{{ proto SDL_Palette, count(void)  */
 static PHP_METHOD(SDL_Palette, count)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 
 	intern = PHP_SDL_PALETTE_P(getThis());
 	if (zend_parse_parameters_none() == FAILURE) {
@@ -554,7 +555,7 @@ ZEND_END_ARG_INFO()
 /* {{{ proto SDL_Palette, offsetExists(int offset) */
 PHP_METHOD(SDL_Palette, offsetExists)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	zend_long offset;
 
 	intern = PHP_SDL_PALETTE_P(getThis());
@@ -571,7 +572,7 @@ PHP_METHOD(SDL_Palette, offsetExists)
 /* {{{ proto SDL_Palette, offsetGet(int offset) */
 PHP_METHOD(SDL_Palette, offsetGet)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	zend_long offset;
 
 	intern = PHP_SDL_PALETTE_P(getThis());
@@ -589,7 +590,7 @@ PHP_METHOD(SDL_Palette, offsetGet)
 /* {{{ proto SDL_Palette, offsetUnset(int offset) */
 PHP_METHOD(SDL_Palette, offsetUnset)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	zend_long offset;
 	SDL_Color color;
 
@@ -614,7 +615,7 @@ ZEND_END_ARG_INFO()
 /* {{{ proto SDL_Palette, offsetSet(int offset, int value) */
 PHP_METHOD(SDL_Palette, offsetSet)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	zend_long offset;
 	zval *z_color;
 	SDL_Color color;
@@ -640,7 +641,7 @@ PHP_METHOD(SDL_Palette, offsetSet)
  */
 PHP_FUNCTION(SDL_SetPixelFormatPalette)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	zval *z_format, *z_palette;
 	SDL_Palette *palette;
 	SDL_PixelFormat *format;
@@ -672,7 +673,7 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette)
  */
 PHP_FUNCTION(SDL_SetPaletteColors)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	zval *object, *z_colors, *z_color;
 	SDL_Palette *palette;
 	SDL_Color *colors;
@@ -732,7 +733,7 @@ PHP_FUNCTION(SDL_SetPaletteColors)
  */
 PHP_FUNCTION(SDL_FreePalette)
 {
-	struct php_sdl_palette *intern;
+	php_sdl_palette *intern;
 	zval *object;
 	SDL_Palette *palette;
 
@@ -758,7 +759,7 @@ PHP_FUNCTION(SDL_FreePalette)
  */
 PHP_FUNCTION(SDL_MapRGB)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zval *z_format;
 	SDL_PixelFormat *format;
 	zend_long r, g, b;
@@ -785,7 +786,7 @@ PHP_FUNCTION(SDL_MapRGB)
  */
 PHP_FUNCTION(SDL_MapRGBA)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zval *z_format;
 	SDL_PixelFormat *format;
 	zend_long r, g, b, a;
@@ -810,7 +811,7 @@ PHP_FUNCTION(SDL_MapRGBA)
  */
 PHP_FUNCTION(SDL_GetRGB)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zval *z_format, *z_r, *z_g, *z_b;
 	SDL_PixelFormat *format;
 	Uint8 r, g, b;
@@ -844,7 +845,7 @@ ZEND_END_ARG_INFO()
 */
 PHP_METHOD(SDL_PixelFormat, GetRGB)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zval *z_format, *z_r, *z_g, *z_b;
 	SDL_PixelFormat *format;
 	Uint8 r, g, b;
@@ -876,7 +877,7 @@ PHP_METHOD(SDL_PixelFormat, GetRGB)
  */
 PHP_FUNCTION(SDL_GetRGBA)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zval *z_format, *z_r, *z_g, *z_b, *z_a;
 	SDL_PixelFormat *format;
 	Uint8 r, g, b, a;
@@ -905,7 +906,7 @@ PHP_FUNCTION(SDL_GetRGBA)
 */
 PHP_METHOD(SDL_PixelFormat, GetRGBA)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zval *z_format, *z_r, *z_g, *z_b, *z_a;
 	SDL_PixelFormat *format;
 	Uint8 r, g, b, a;
@@ -961,7 +962,7 @@ ZEND_END_ARG_INFO()
 /* {{{ proto SDL_Pixels::__construct(int pitch, int h) */
 static PHP_METHOD(SDL_Pixels, __construct)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 	zend_long pitch, h;
 	zend_error_handling error_handling;
 
@@ -992,7 +993,7 @@ static PHP_METHOD(SDL_Pixels, __construct)
 /* {{{ proto SDL_Pixels::__toString() */
 static PHP_METHOD(SDL_Pixels, __toString)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 	char *buf;
 
 	if (zend_parse_parameters_none() == FAILURE) {
@@ -1009,7 +1010,7 @@ static PHP_METHOD(SDL_Pixels, __toString)
 /* {{{ proto SDL_Pixels, count(void) */
 static PHP_METHOD(SDL_Pixels, count)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
 	if (zend_parse_parameters_none() == FAILURE) {
@@ -1027,7 +1028,7 @@ ZEND_END_ARG_INFO()
 /* {{{ proto SDL_Pixels, offsetExists(int offset) */
 PHP_METHOD(SDL_Pixels, offsetExists)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 	zend_long offset;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
@@ -1044,7 +1045,7 @@ PHP_METHOD(SDL_Pixels, offsetExists)
 /* {{{ proto SDL_Pixels, offsetGet(int offset) */
 PHP_METHOD(SDL_Pixels, offsetGet)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 	zend_long offset;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
@@ -1062,7 +1063,7 @@ PHP_METHOD(SDL_Pixels, offsetGet)
 /* {{{ proto SDL_Pixels, offsetUnset(int offset) */
 PHP_METHOD(SDL_Pixels, offsetUnset)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 	zend_long offset;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
@@ -1085,7 +1086,7 @@ ZEND_END_ARG_INFO()
 /* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */
 PHP_METHOD(SDL_Pixels, offsetSet)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 	zend_long offset, value;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
@@ -1109,7 +1110,7 @@ ZEND_END_ARG_INFO()
 /* {{{ proto int SDL_Pixels::GetByte(int x, int y) */
 PHP_METHOD(SDL_Pixels, GetByte)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 	zval *z_pixels;
 	zend_long x, y;
 
@@ -1136,7 +1137,7 @@ ZEND_END_ARG_INFO()
 /* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */
 PHP_METHOD(SDL_Pixels, SetByte)
 {
-	struct php_sdl_pixels *intern;
+	php_sdl_pixels *intern;
 	zval *z_pixels;
 	zend_long x, y, v;
 
@@ -1160,7 +1161,7 @@ PHP_METHOD(SDL_Pixels, SetByte)
 	 */
 static void php_sdl_palette_free(zend_object *object)
 {
-	struct php_sdl_palette *intern = php_sdl_palette_from_obj(object);
+	php_sdl_palette *intern = php_sdl_palette_from_obj(object);
 
 	if (intern->palette) {
 		if (!(intern->flags & SDL_DONTFREE)) {
@@ -1176,9 +1177,7 @@ static void php_sdl_palette_free(zend_object *object)
  */
 static zend_object* php_sdl_palette_new(zend_class_entry *class_type)
 {
-	struct php_sdl_palette *intern;
-
-	intern = ecalloc(1, sizeof(struct php_sdl_palette) + zend_object_properties_size(class_type));
+	php_sdl_palette *intern = zend_object_alloc(sizeof(php_sdl_palette), class_type);
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
@@ -1193,7 +1192,7 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type)
 /* {{{ sdl_palette_read_property*/
 zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
 {
-	struct php_sdl_palette *intern = PHP_SDL_PALETTE_P(object);
+	php_sdl_palette *intern = PHP_SDL_PALETTE_P(object);
 	zval *retval, tmp_member;
 
 	if (Z_TYPE_P(member) != IS_STRING) {
@@ -1255,7 +1254,7 @@ static HashTable *sdl_palette_get_properties(zval *object)
 	HashTable *props;
 	zval zv, z_color;
 	int i;
-	struct php_sdl_palette *intern = PHP_SDL_PALETTE_P(object);
+	php_sdl_palette *intern = PHP_SDL_PALETTE_P(object);
 
 	props = zend_std_get_properties(object);
 
@@ -1287,7 +1286,7 @@ static zval *sdl_palette_write_property(zval *object, zval *member, zval *value,
 	 */
 static void php_sdl_pixelformat_free(zend_object *object)
 {
-	struct php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object);
+	php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object);
 
 	if (intern->format) {
 		if (!(intern->flags & SDL_DONTFREE)) {
@@ -1303,9 +1302,7 @@ static void php_sdl_pixelformat_free(zend_object *object)
  */
 static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type)
 {
-	struct php_sdl_pixelformat *intern;
-
-	intern = (struct php_sdl_pixelformat*)ecalloc(1, sizeof(struct php_sdl_pixelformat) + zend_object_properties_size(class_type));
+	php_sdl_pixelformat *intern = zend_object_alloc(sizeof(php_sdl_pixelformat), class_type);
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
@@ -1320,7 +1317,7 @@ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type)
 /* {{{ sdl_pixelformat_read_property*/
 zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
 {
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 	zval *retval, tmp_member;
 
 	intern = PHP_SDL_PIXELFORMAT_P(object);
@@ -1413,7 +1410,7 @@ static HashTable *sdl_pixelformat_get_properties(zval *object)
 {
 	HashTable *props;
 	zval zv;
-	struct php_sdl_pixelformat *intern;
+	php_sdl_pixelformat *intern;
 
 	intern = PHP_SDL_PIXELFORMAT_P(object);
 
@@ -1455,7 +1452,7 @@ static zval *sdl_pixelformat_write_property(zval *object, zval *member, zval *va
 	 */
 static void php_sdl_pixels_free(zend_object *object)
 {
-	struct php_sdl_pixels *intern = php_sdl_pixels_from_obj(object);
+	php_sdl_pixels *intern = php_sdl_pixels_from_obj(object);
 
 	if (intern->pixels.pixels) {
 		if (!(intern->flags & SDL_DONTFREE)) {
@@ -1471,9 +1468,7 @@ static void php_sdl_pixels_free(zend_object *object)
  */
 static zend_object* php_sdl_pixels_new(zend_class_entry *class_type)
 {
-	struct php_sdl_pixels *intern;
-
-	intern = (struct php_sdl_pixels*)ecalloc(1, sizeof(struct php_sdl_pixels) + zend_object_properties_size(class_type));
+	php_sdl_pixels *intern = zend_object_alloc(sizeof(php_sdl_pixels), class_type);
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
@@ -1487,7 +1482,7 @@ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type)
 /* {{{ sdl_pixels_read_property*/
 zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
 {
-	struct php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object);
+	php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object);
 	zval *retval, tmp_member;
 
 	if (Z_TYPE_P(member) != IS_STRING) {
@@ -1539,7 +1534,7 @@ static HashTable *sdl_pixels_get_properties(zval *object)
 {
 	HashTable *props;
 	zval zv;
-	struct php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object);
+	php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object);
 
 	props = zend_std_get_properties(object);
 
@@ -1654,6 +1649,7 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_palette_handlers.get_properties = sdl_palette_get_properties;
 	php_sdl_palette_handlers.write_property = sdl_palette_write_property;
 	php_sdl_palette_handlers.free_obj = php_sdl_palette_free;
+	php_sdl_palette_handlers.offset = XtOffsetOf(php_sdl_palette, zo);
 
 	REGISTER_PALETTE_PROP("ncolors");
 	REGISTER_PALETTE_PROP("version");
@@ -1668,7 +1664,7 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_pixelformat_handlers.get_properties = sdl_pixelformat_get_properties;
 	php_sdl_pixelformat_handlers.write_property = sdl_pixelformat_write_property;
 	php_sdl_pixelformat_handlers.free_obj = php_sdl_pixelformat_free;
-	php_sdl_pixelformat_handlers.offset = XtOffsetOf(struct php_sdl_pixelformat, zo);
+	php_sdl_pixelformat_handlers.offset = XtOffsetOf(php_sdl_pixelformat, zo);
 
 	REGISTER_FORMAT_PROP("format");
 	REGISTER_FORMAT_PROP("BitsPerPixel");
@@ -1696,6 +1692,7 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_pixels_handlers.get_properties = sdl_pixels_get_properties;
 	php_sdl_pixels_handlers.write_property = sdl_pixels_write_property;
 	php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free;
+	php_sdl_pixels_handlers.offset = XtOffsetOf(php_sdl_pixels, zo);
 
 	REGISTER_PIXELS_PROP("pitch");
 	REGISTER_PIXELS_PROP("h");
diff --git a/src/rect.c b/src/rect.c
index 186ffe8..d3afa41 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -59,9 +59,9 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value)
 zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
 {
 	if (pt) {
-		object_init_ex(value, php_sdl_rect_ce);
-		zend_update_property_long(php_sdl_rect_ce, value, "x", 1, pt->x);
-		zend_update_property_long(php_sdl_rect_ce, value, "y", 1, pt->y);
+		object_init_ex(value, php_sdl_point_ce);
+		zend_update_property_long(php_sdl_point_ce, value, "x", 1, pt->x);
+		zend_update_property_long(php_sdl_point_ce, value, "y", 1, pt->y);
 
 		return 1;
 	}
@@ -102,11 +102,11 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
 	if (Z_TYPE(*value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_point_ce) {
 		zval *val, rv;
 
-		val = zend_read_property(php_sdl_rect_ce, value, "x", 1, 0, &rv);
+		val = zend_read_property(php_sdl_point_ce, value, "x", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = pt->x = (int)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_rect_ce, value, "y", 1, 0, &rv);
+		val = zend_read_property(php_sdl_point_ce, value, "y", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = pt->y = (int)Z_LVAL_P(val);
 
@@ -169,8 +169,8 @@ static PHP_METHOD(SDL_Point, __construct)
 	}
 	zend_restore_error_handling(&error_handling);
 
-	zend_update_property_long(php_sdl_rect_ce, getThis(), "x", 1, x);
-	zend_update_property_long(php_sdl_rect_ce, getThis(), "y", 1, y);
+	zend_update_property_long(php_sdl_point_ce, getThis(), "x", 1, x);
+	zend_update_property_long(php_sdl_point_ce, getThis(), "y", 1, y);
 }
 /* }}} */
 
diff --git a/src/surface.c b/src/surface.c
index 486ce7b..5357242 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -1356,9 +1356,9 @@ PHP_MINIT_FUNCTION(sdl_surface)
 	REGISTER_SURFACE_PROP("w");
 	REGISTER_SURFACE_PROP("h");
 	REGISTER_SURFACE_PROP("pitch");
-	zend_declare_property_null(get_php_sdl_pixelformat_ce(), ZEND_STRL("format"), ZEND_ACC_PUBLIC);
-	zend_declare_property_null(get_php_sdl_rect_ce(), ZEND_STRL("clip_rect"), ZEND_ACC_PUBLIC);
-	zend_declare_property_null(get_php_sdl_pixels_ce(), ZEND_STRL("pixels"), ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("format"), ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("clip_rect"), ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("pixels"), ZEND_ACC_PUBLIC);
 
 	REGISTER_SURFACE_CLASS_CONST_LONG("SWSURFACE",         SDL_SWSURFACE);
 	REGISTER_SURFACE_CLASS_CONST_LONG("PREALLOC",          SDL_PREALLOC);
diff --git a/src/video.c b/src/video.c
index 9b059e5..bafef53 100644
--- a/src/video.c
+++ b/src/video.c
@@ -316,7 +316,7 @@ PHP_FUNCTION(SDL_GetDisplayBounds)
 	SDL_Rect rect;
 	zval *result;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &display, &result) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/", &display, &result) == FAILURE) {
 		RETURN_FALSE;
 	}
 	err = SDL_GetDisplayBounds((int)display, &rect);
diff --git a/tests/005-video.phpt b/tests/005-video.phpt
index 59e378e..3d5973f 100644
--- a/tests/005-video.phpt
+++ b/tests/005-video.phpt
@@ -3,8 +3,7 @@ video group test
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
-?>
+skipIfTravis();
 --FILE--
 <?php
 echo "== VideoDriver ==\n";
@@ -44,7 +43,7 @@ int(0)
 SDL_VideoInit():int(0)
 SDL_GetCurrentVideoDriver():string(%d) "%s"
 SDL_GetNumVideoDisplays():int(%d)
-SDL_GetDisplayName(0):string(9) "Color LCD"
+SDL_GetDisplayName(0):string(%d) "%s"
 SDL_GetDisplayBounds(0):int(0)
 object(SDL_Rect)#1 (4) {
   ["x"]=>
@@ -52,9 +51,9 @@ object(SDL_Rect)#1 (4) {
   ["y"]=>
   int(0)
   ["w"]=>
-  int(1680)
+  int(%d)
   ["h"]=>
-  int(1050)
+  int(%d)
 }
 SDL_GetNumDisplayModes(0):int(%d)
 SDL_GetDisplayMode(0,0):object(SDL_DisplayMode)#2 (4) {
diff --git a/tests/006-rect.phpt b/tests/006-rect.phpt
index 424bde8..1dd5ff1 100644
--- a/tests/006-rect.phpt
+++ b/tests/006-rect.phpt
@@ -65,7 +65,7 @@ var_dump(SDL_EnclosePoints($pts, 6, $r4, $res2), $res2);
 Done
 --EXPECTF--
 +++ Empty (true)
-object(SDL_Rect)#1 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(0)
   ["y"]=>
@@ -74,12 +74,10 @@ object(SDL_Rect)#1 (5) {
   int(0)
   ["h"]=>
   int(0)
-  ["clip_rect"]=>
-  NULL
 }
 bool(true)
 +++ Empty (false)
-object(SDL_Rect)#2 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(1)
   ["y"]=>
@@ -88,8 +86,6 @@ object(SDL_Rect)#2 (5) {
   int(3)
   ["h"]=>
   int(4)
-  ["clip_rect"]=>
-  NULL
 }
 bool(false)
 +++ Equal (true)
@@ -101,7 +97,7 @@ bool(false)
 +++ Inter (true)
 bool(true)
 bool(true)
-object(SDL_Rect)#6 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(16)
   ["y"]=>
@@ -110,8 +106,6 @@ object(SDL_Rect)#6 (5) {
   int(14)
   ["h"]=>
   int(13)
-  ["clip_rect"]=>
-  NULL
 }
 +++ Inter (false)
 bool(false)
@@ -119,7 +113,7 @@ bool(false)
 NULL
 +++ Union
 NULL
-object(SDL_Rect)#6 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(10)
   ["y"]=>
@@ -128,11 +122,9 @@ object(SDL_Rect)#6 (5) {
   int(28)
   ["h"]=>
   int(31)
-  ["clip_rect"]=>
-  NULL
 }
 NULL
-object(SDL_Rect)#%d (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(10)
   ["y"]=>
@@ -141,8 +133,6 @@ object(SDL_Rect)#%d (5) {
   int(110)
   ["h"]=>
   int(20)
-  ["clip_rect"]=>
-  NULL
 }
 +++ InterLine
 bool(true)
@@ -154,7 +144,7 @@ bool(false)
 +++ EnclosePoints
 string(67) "SDL_Point(20,14) SDL_Point(13,20) SDL_Point(24,20) SDL_Point(20,28)"
 bool(true)
-object(SDL_Rect)#%d (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(13)
   ["y"]=>
@@ -163,8 +153,6 @@ object(SDL_Rect)#%d (5) {
   int(12)
   ["h"]=>
   int(15)
-  ["clip_rect"]=>
-  NULL
 }
 
 Warning: SDL_EnclosePoints(): point #4 is not a SDL_Point object in %s/006-rect.php on line %d
diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt
index ad1d6cc..176e44e 100644
--- a/tests/007-rect-oo.phpt
+++ b/tests/007-rect-oo.phpt
@@ -53,7 +53,7 @@ var_dump($r1->IntersectLine($x1, $y1, $x2, $y2));
 Done
 --EXPECTF--
 +++ Empty (true)
-object(SDL_Rect)#1 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(0)
   ["y"]=>
@@ -62,13 +62,11 @@ object(SDL_Rect)#1 (5) {
   int(0)
   ["h"]=>
   int(0)
-  ["clip_rect"]=>
-  NULL
 }
 string(17) "SDL_Rect(0,0,0,0)"
 bool(true)
 +++ Empty (false)
-object(SDL_Rect)#2 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(1)
   ["y"]=>
@@ -77,8 +75,6 @@ object(SDL_Rect)#2 (5) {
   int(3)
   ["h"]=>
   int(4)
-  ["clip_rect"]=>
-  NULL
 }
 string(17) "SDL_Rect(1,2,3,4)"
 bool(false)
@@ -91,7 +87,7 @@ bool(false)
 +++ Inter (true)
 bool(true)
 bool(true)
-object(SDL_Rect)#6 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(16)
   ["y"]=>
@@ -100,8 +96,6 @@ object(SDL_Rect)#6 (5) {
   int(14)
   ["h"]=>
   int(13)
-  ["clip_rect"]=>
-  NULL
 }
 +++ Inter (false)
 bool(false)
@@ -109,7 +103,7 @@ bool(false)
 NULL
 +++ Uninon
 NULL
-object(SDL_Rect)#6 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(10)
   ["y"]=>
@@ -118,11 +112,9 @@ object(SDL_Rect)#6 (5) {
   int(28)
   ["h"]=>
   int(31)
-  ["clip_rect"]=>
-  NULL
 }
 NULL
-object(SDL_Rect)#6 (5) {
+object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(10)
   ["y"]=>
@@ -131,8 +123,6 @@ object(SDL_Rect)#6 (5) {
   int(110)
   ["h"]=>
   int(20)
-  ["clip_rect"]=>
-  NULL
 }
 +++ InterLine
 bool(true)
diff --git a/tests/012-pixelformat.phpt b/tests/012-pixelformat.phpt
index 60ee70e..7ab0907 100644
--- a/tests/012-pixelformat.phpt
+++ b/tests/012-pixelformat.phpt
@@ -46,6 +46,8 @@ int(0)
 int(0)
 = Result
 object(SDL_PixelFormat)#%d (16) {
+  ["format"]=>
+  int(303039488)
   ["BitsPerPixel"]=>
   int(4)
   ["BytesPerPixel"]=>
@@ -262,8 +264,6 @@ object(SDL_PixelFormat)#%d (16) {
       }
     }
   }
-  ["format"]=>
-  int(303039488)
 }
 = RGB
 int(8)
diff --git a/tests/013-pixelformat-oo.phpt b/tests/013-pixelformat-oo.phpt
index 200a057..baaa06d 100644
--- a/tests/013-pixelformat-oo.phpt
+++ b/tests/013-pixelformat-oo.phpt
@@ -49,6 +49,8 @@ string(42) "SDL_PixelFormat(SDL_PIXELFORMAT_INDEX4LSB)"
 int(0)
 = Result
 object(SDL_PixelFormat)#%d (16) {
+  ["format"]=>
+  int(303039488)
   ["BitsPerPixel"]=>
   int(4)
   ["BytesPerPixel"]=>
@@ -265,8 +267,6 @@ object(SDL_PixelFormat)#%d (16) {
       }
     }
   }
-  ["format"]=>
-  int(303039488)
 }
 = RGB
 int(8)
diff --git a/tests/test-functions.php b/tests/test-functions.php
index bd93d90..6046469 100644
--- a/tests/test-functions.php
+++ b/tests/test-functions.php
@@ -3,6 +3,11 @@
 function skipIncompleteTest() {
 	exit('skip test is not complete');
 }
+function skipIfTravis() {
+    if ((bool)getenv('TRAVIS')) {
+        exit('skip test if run on Travis');
+    }
+}
 function assertEquals($current, $expected, $assertionMessage) {
 	if($current === $expected) {
 		printf('PASS: %s.' . PHP_EOL, $assertionMessage);

From 3f31add0ce69b7446048b9608a1567dae98782b6 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sat, 20 Jun 2020 20:32:32 +0100
Subject: [PATCH 04/53] Do not assume there is joystick present in example file

---
 examples/007-input-handling.php | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php
index 95cb860..d070111 100644
--- a/examples/007-input-handling.php
+++ b/examples/007-input-handling.php
@@ -5,6 +5,12 @@
 $quit = false;
 
 SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
+$joystick = SDL_JoystickOpen(0);
+$joystickFound = !is_null($joystick);
+if(!$joystickFound) {
+	trigger_error('A joystick could not be found.', E_USER_NOTICE);
+}
+
 $window = SDL_CreateWindow("Input handling example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
 $renderer = SDL_CreateRenderer($window, -1, 0);
 
@@ -19,7 +25,6 @@
 SDL_SetRenderDrawColor($renderer, 255, 0, 255, 255);
 SDL_RenderClear($renderer);
 SDL_RenderPresent($renderer);
-$joystick = SDL_JoystickOpen(0);
 $rotCenter = new SDL_Point(10, 10);
 $event = new SDL_Event;
 $destRect = new SDL_Rect;
@@ -29,15 +34,17 @@
 $destRect->h = 64;
 $update = true;
 while (!$quit) {
-	$xJoystickMotion = SDL_JoystickGetAxis($joystick, 0);
-	if($xJoystickMotion !== 0) {
-		$x += ceil($xJoystickMotion / 32767) * 5;
-		$update = true;
-	}
-	$yJoystickMotion = SDL_JoystickGetAxis($joystick, 1);
-	if($yJoystickMotion !== 0) {
-		$y += ceil($yJoystickMotion / 32767) * 5;
-		$update = true;
+	if($joystickFound) {
+		$xJoystickMotion = SDL_JoystickGetAxis($joystick, 0);
+		if($xJoystickMotion !== 0) {
+			$x += ceil($xJoystickMotion / 32767) * 5;
+			$update = true;
+		}
+		$yJoystickMotion = SDL_JoystickGetAxis($joystick, 1);
+		if($yJoystickMotion !== 0) {
+			$y += ceil($yJoystickMotion / 32767) * 5;
+			$update = true;
+		}
 	}
 
 	while(SDL_PollEvent($event)) {
@@ -70,7 +77,9 @@
     SDL_Delay(25);
 }
 
-SDL_JoystickClose($joystick);
+if($joystickFound) {
+	SDL_JoystickClose($joystick);
+}
 
 SDL_DestroyTexture($texture);
 SDL_DestroyRenderer($renderer);

From 88532a57435a72e0e824c6aa78ff515d8c7555aa Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sat, 20 Jun 2020 21:35:02 +0100
Subject: [PATCH 05/53] Create docker file to use with travis

---
 .dockerignore        |  1 +
 .travis.yml          | 29 ++++-------------------------
 Dockerfile           | 21 +++++++++++++++++++++
 docker-entrypoint.sh | 10 ++++++++++
 4 files changed, 36 insertions(+), 25 deletions(-)
 create mode 100644 .dockerignore
 create mode 100644 Dockerfile
 create mode 100755 docker-entrypoint.sh

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..6b8710a
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+.git
diff --git a/.travis.yml b/.travis.yml
index 15e08d5..ad9cae6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,32 +1,11 @@
 language: php
 
-php:
-  - 7.3
-
-env:
-  - REPORT_EXIT_STATUS=1
+services:
+  - docker
 
 before_install:
-  - sudo add-apt-repository -y ppa:team-xbmc/ppa
-  - sudo apt-get update -qq
-  - |
-    travis_retry curl -L https://www.libsdl.org/release/SDL2-2.0.8.tar.gz | tar xz
-    pushd SDL2-2.0.8
-    ./configure
-    make
-    sudo make install
-    popd
-
-install:
-  - sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev
-
-before_script:
-  - phpize
-  - ./configure --quiet
-  - make all install
-  - echo "extension=sdl.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
-  - chmod +x run-tests.php
+  - docker build -t ponup/php-sdl .
 
 script:
-  - ./run-tests.php -q -p $(which php) --show-diff
+  - docker run --rm ponup/php-sdl 
 
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..5d363a3
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,21 @@
+FROM debian:10
+
+RUN apt-get update
+RUN apt-get install -y make build-essential wget
+RUN apt-get install -y lsb-release apt-transport-https ca-certificates 
+RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
+RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
+RUN apt-get update
+RUN apt-get install -y php7.4-dev
+RUN apt-get install -y libsdl2-dev
+RUN apt-get install -y xvfb
+COPY . /opt/php-sdl
+WORKDIR /opt/php-sdl
+RUN phpize
+RUN ./configure
+RUN make
+RUN make install
+RUN echo "extension=sdl.so" >> /etc/php/7.4/cli/php.ini
+
+ENTRYPOINT ["/opt/php-sdl/docker-entrypoint.sh"]
+
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
new file mode 100755
index 0000000..5c338f8
--- /dev/null
+++ b/docker-entrypoint.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+Xvfb :99 -screen 0 800x600x24 -ac &
+
+chmod +x ./run-tests.php
+
+export DISPLAY=:99
+./run-tests.php -q --show-diff
+
+killall -9 Xvfb

From 8a67461e39bd337006bb13ec9f2f631981adffc0 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sun, 21 Jun 2020 12:10:24 +0100
Subject: [PATCH 06/53] Re-format example files

---
 examples/001-sdl-version.php       |  7 ++---
 examples/002-error-messagebox.php  |  3 ++-
 examples/003-messagebox-inputs.php |  5 ++--
 examples/004-draw-points.php       | 17 +++++++------
 examples/005-draw-rectangle.php    |  2 ++
 examples/006-animated-boxes.php    | 17 +++++++------
 examples/007-input-handling.php    | 41 +++++++++++++++---------------
 examples/008-shaped-window.php     | 18 ++++++-------
 examples/009-window-events.php     | 26 +++++++++++--------
 examples/010-draw-lines.php        |  9 ++++---
 examples/bootstrap.php             |  6 +++--
 11 files changed, 83 insertions(+), 68 deletions(-)

diff --git a/examples/001-sdl-version.php b/examples/001-sdl-version.php
index 873de6f..f544161 100644
--- a/examples/001-sdl-version.php
+++ b/examples/001-sdl-version.php
@@ -1,12 +1,13 @@
 <?php
 
+declare(strict_types=1);
+
 require 'bootstrap.php';
 
-if(SDL_GetVersion($version)) {
-	printf('Powered by PHP %s, SDL extension %s and SDL2 library %s.' . PHP_EOL, phpversion(), phpversion('sdl'), implode('.', $version));
+if (SDL_GetVersion($version)) {
+    printf('Powered by PHP %s, SDL extension %s and SDL2 library %s.' . PHP_EOL, phpversion(), phpversion('sdl'), implode('.', $version));
 } else {
     trigger_error('SDL version could not be retrieved', E_USER_NOTICE);
 }
 
 printf('SDL version components are %d (SDL_MAJOR_VERSION), %d (SDL_MINOR_VERSION) and %d (SDL_PATCHLEVEL).' . PHP_EOL, SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
-
diff --git a/examples/002-error-messagebox.php b/examples/002-error-messagebox.php
index 5deedd6..c4012b5 100644
--- a/examples/002-error-messagebox.php
+++ b/examples/002-error-messagebox.php
@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 require 'bootstrap.php';
 
 SDL_Init(SDL_INIT_EVERYTHING);
@@ -7,4 +9,3 @@
 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, 'Error example', 'An error has occurred (just kidding)', null);
 
 SDL_Quit();
-
diff --git a/examples/003-messagebox-inputs.php b/examples/003-messagebox-inputs.php
index 17a6bd1..f3a985e 100644
--- a/examples/003-messagebox-inputs.php
+++ b/examples/003-messagebox-inputs.php
@@ -1,8 +1,10 @@
 <?php
 
+declare(strict_types=1);
+
 require 'bootstrap.php';
 
-if(false === SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, 'Message box title', 'This is an example message box')) {
+if (false === SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, 'Message box title', 'This is an example message box')) {
 	fprintf(STDERR, 'Unable to show simple message box');
 	return;
 }
@@ -22,4 +24,3 @@
 $dialog->Show($buttonId);
 
 echo 'Button selection: ', var_export($buttonId), PHP_EOL;
-
diff --git a/examples/004-draw-points.php b/examples/004-draw-points.php
index c2ea513..e0eabd5 100644
--- a/examples/004-draw-points.php
+++ b/examples/004-draw-points.php
@@ -1,10 +1,12 @@
 <?php
 
-const WINDOW_WIDTH = 800;
-const WINDOW_HEIGHT = 800;
+declare(strict_types=1);
 
 require 'bootstrap.php';
 
+const WINDOW_WIDTH = 800;
+const WINDOW_HEIGHT = 800;
+
 SDL_Init(SDL_INIT_VIDEO);
 $window = SDL_CreateWindow("Drawing points on screen", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
 $renderer = SDL_CreateRenderer($window, 0, SDL_RENDERER_ACCELERATED);
@@ -15,20 +17,19 @@
 
 // Draw line
 SDL_SetRenderDrawColor($renderer, 255, 0, 0, 255);
-for($i = 0; $i < WINDOW_WIDTH; ++$i) {
-	SDL_RenderDrawPoint($renderer, $i, $i);
+for ($i = 0; $i < WINDOW_WIDTH; ++$i) {
+    SDL_RenderDrawPoint($renderer, $i, $i);
 }
 SDL_RenderPresent($renderer);
 
 // Wait for quit event
 $event = new SDL_Event;
-while(true) {
-    if(SDL_PollEvent($event) && $event->type == SDL_QUIT) {
+while (true) {
+    if (SDL_PollEvent($event) && $event->type == SDL_QUIT) {
         break;
-	}
+    }
 }
 
 SDL_DestroyRenderer($renderer);
 SDL_DestroyWindow($window);
 SDL_Quit();
-
diff --git a/examples/005-draw-rectangle.php b/examples/005-draw-rectangle.php
index dd0ef26..a42b230 100644
--- a/examples/005-draw-rectangle.php
+++ b/examples/005-draw-rectangle.php
@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 require 'bootstrap.php';
 
 $window = SDL_CreateWindow('Primitive drawing example', SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
diff --git a/examples/006-animated-boxes.php b/examples/006-animated-boxes.php
index 1cb32ab..1912d62 100644
--- a/examples/006-animated-boxes.php
+++ b/examples/006-animated-boxes.php
@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 require 'bootstrap.php';
 
 SDL_Init(SDL_INIT_EVERYTHING);
@@ -27,23 +29,22 @@
 $event = new SDL_Event;
 
 $color = SDL_MapRGB($surf->format, 0xef, 0xff, 0x87);
-for($t = $time * $step; $t; $t--) {
+for ($t = $time * $step; $t; $t--) {
 
     if (!($t % $step)) {
-		$secondsLeft = $t / $step;
-		SDL_SetWindowTitle($window, "Will be closed in $secondsLeft seconds");
+        $secondsLeft = $t / $step;
+        SDL_SetWindowTitle($window, "Will be closed in $secondsLeft seconds");
     }
 
     // Display 1 rect in ~red
     $surf->FillRect($rects[$time * $step - $t], $color);
-	SDL_UpdateWindowSurfaceRects($window, array($rects[$time * $step - $t]));
+    SDL_UpdateWindowSurfaceRects($window, array($rects[$time * $step - $t]));
 
     usleep(1000000 / $step);
 
-	while(SDL_PollEvent($event)) {
-		if($event->type == SDL_QUIT) break;
-	}
+    while (SDL_PollEvent($event)) {
+        if ($event->type == SDL_QUIT) break;
+    }
 }
 
 SDL_DestroyWindow($window);
-
diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php
index d070111..c53884e 100644
--- a/examples/007-input-handling.php
+++ b/examples/007-input-handling.php
@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 require 'bootstrap.php';
 
 $quit = false;
@@ -7,7 +9,7 @@
 SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
 $joystick = SDL_JoystickOpen(0);
 $joystickFound = !is_null($joystick);
-if(!$joystickFound) {
+if (!$joystickFound) {
 	trigger_error('A joystick could not be found.', E_USER_NOTICE);
 }
 
@@ -16,7 +18,7 @@
 
 $image = SDL_LoadBMP("spaceship.bmp");
 if ($image === null) {
-    exit('Unable to load image');
+	exit('Unable to load image');
 }
 $texture = SDL_CreateTextureFromSurface($renderer, $image);
 $drect = $image->clip_rect;
@@ -34,50 +36,50 @@
 $destRect->h = 64;
 $update = true;
 while (!$quit) {
-	if($joystickFound) {
+	if ($joystickFound) {
 		$xJoystickMotion = SDL_JoystickGetAxis($joystick, 0);
-		if($xJoystickMotion !== 0) {
+		if ($xJoystickMotion !== 0) {
 			$x += ceil($xJoystickMotion / 32767) * 5;
 			$update = true;
 		}
 		$yJoystickMotion = SDL_JoystickGetAxis($joystick, 1);
-		if($yJoystickMotion !== 0) {
+		if ($yJoystickMotion !== 0) {
 			$y += ceil($yJoystickMotion / 32767) * 5;
 			$update = true;
 		}
 	}
 
-	while(SDL_PollEvent($event)) {
-    	switch ($event->type) {
-        	case SDL_QUIT:
-            	$quit = true;
-            	break;
-        	case SDL_MOUSEMOTION:
-            	$x = $event->motion->x;
-            	$y = $event->motion->y;
+	while (SDL_PollEvent($event)) {
+		switch ($event->type) {
+			case SDL_QUIT:
+				$quit = true;
+				break;
+			case SDL_MOUSEMOTION:
+				$x = $event->motion->x;
+				$y = $event->motion->y;
 				$update = true;
 				break;
 			case SDL_JOYAXISMOTION:
 				break;
-    	}
+		}
 	}
 
-	if($update) {
+	if ($update) {
 		SDL_RenderClear($renderer);
 		$destRect->x = $x;
 		$destRect->y = $y;
-	
+
 		if (SDL_RenderCopyEx($renderer, $texture, NULL, $destRect, 90, $rotCenter, SDL_FLIP_NONE) != 0) {
 			echo SDL_GetError(), PHP_EOL;
 		}
-		SDL_RenderPresent($renderer);	
+		SDL_RenderPresent($renderer);
 		$update = false;
 	}
 
-    SDL_Delay(25);
+	SDL_Delay(25);
 }
 
-if($joystickFound) {
+if ($joystickFound) {
 	SDL_JoystickClose($joystick);
 }
 
@@ -85,4 +87,3 @@
 SDL_DestroyRenderer($renderer);
 SDL_DestroyWindow($window);
 SDL_Quit();
-
diff --git a/examples/008-shaped-window.php b/examples/008-shaped-window.php
index 7819d6c..4538c3f 100644
--- a/examples/008-shaped-window.php
+++ b/examples/008-shaped-window.php
@@ -1,17 +1,19 @@
 <?php
 
-const WINDOW_WIDTH = 640;
-const WINDOW_HEIGHT = 640;
+declare(strict_types=1);
 
 require 'bootstrap.php';
 
+const WINDOW_WIDTH = 640;
+const WINDOW_HEIGHT = 640;
+
 SDL_Init(SDL_INIT_VIDEO);
 $window = SDL_CreateShapedWindow("Drawing points on screen", 10, 10, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
 $renderer = SDL_CreateRenderer($window, 0, 0);
 
 $surface = SDL_LoadBMP("p01_shape32alpha.bmp");
 if ($surface === null) {
-    exit('Unable to load image');
+	exit('Unable to load image');
 }
 $texture = SDL_CreateTextureFromSurface($renderer, $surface);
 
@@ -26,16 +28,14 @@
 // Wait for quit event
 $event = new SDL_Event;
 $quit = false;
-while(!$quit) {
-	while(SDL_PollEvent($event)) {
-		if($event->type == SDL_QUIT) $quit = true;
-		if($event->type == SDL_MOUSEBUTTONDOWN) $quit = true;
+while (!$quit) {
+	while (SDL_PollEvent($event)) {
+		$quit = in_array($event->type, [SDL_QUIT, SDL_MOUSEBUTTONDOWN]);
 	}
 
-    SDL_Delay(20);
+	SDL_Delay(20);
 }
 
 SDL_DestroyRenderer($renderer);
 SDL_DestroyWindow($window);
 SDL_Quit();
-
diff --git a/examples/009-window-events.php b/examples/009-window-events.php
index 75e2d9f..38222bd 100644
--- a/examples/009-window-events.php
+++ b/examples/009-window-events.php
@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 require 'bootstrap.php';
 
 $quit = false;
@@ -8,16 +10,18 @@
 $window = SDL_CreateWindow('Window Events', SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
 $renderer = SDL_CreateRenderer($window, -1, 0);
 
-SDL_SetRenderDrawColor($renderer, 255, 0, 255, 255);
+SDL_SetRenderDrawColor($renderer, 100, 0, 0, 0);
+SDL_RenderClear($renderer);
+SDL_RenderPresent($renderer);
 
 $event = new SDL_Event;
 while (!$quit) {
-	while(SDL_PollEvent($event)) {
-    	switch ($event->type) {
-        	case SDL_QUIT:
-            	$quit = true;
-            	break;
-        	case SDL_WINDOWEVENT:
+    while (SDL_PollEvent($event)) {
+        switch ($event->type) {
+            case SDL_QUIT:
+                $quit = true;
+                break;
+            case SDL_WINDOWEVENT:
                 $eventText = 'unknown';
                 switch ($event->window->event) {
                     case SDL_WINDOWEVENT_SHOWN:
@@ -70,10 +74,10 @@
                         break;
                 }
                 $window->setTitle($eventText);
-				printf('Event{windowID=%d, timestamp=%s, description=%s}' . PHP_EOL, $event->window->windowID, $event->window->timestamp, $eventText);
-            	break;
-    	}
-	}
+                printf('Event{windowID=%d, timestamp=%s, description=%s}' . PHP_EOL, $event->window->windowID, $event->window->timestamp, $eventText);
+                break;
+        }
+    }
 
     SDL_Delay(5);
 }
diff --git a/examples/010-draw-lines.php b/examples/010-draw-lines.php
index 9cc48f2..e59d201 100644
--- a/examples/010-draw-lines.php
+++ b/examples/010-draw-lines.php
@@ -1,10 +1,12 @@
 <?php
 
-const WINDOW_WIDTH = 800;
-const WINDOW_HEIGHT = 800;
+declare(strict_types=1);
 
 require 'bootstrap.php';
 
+const WINDOW_WIDTH = 800;
+const WINDOW_HEIGHT = 800;
+
 SDL_Init(SDL_INIT_VIDEO);
 $window = SDL_CreateWindow("Drawing lines on screen", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
 $renderer = SDL_CreateRenderer($window, 0, SDL_RENDERER_ACCELERATED);
@@ -21,7 +23,7 @@
 for ($iteration = 0; $offset > 0; ++$iteration) {
     $side = $iteration % 4;
     $sign = $side < 2 ? 1 : -1;
-    
+
     $x2 = $side % 2 ? $x1 + $sign * $offset : $x1;
     $y2 = $side % 2 ? $y1 : $y1 + $sign * $offset;
 
@@ -44,4 +46,3 @@
 SDL_DestroyRenderer($renderer);
 SDL_DestroyWindow($window);
 SDL_Quit();
-
diff --git a/examples/bootstrap.php b/examples/bootstrap.php
index 4518a46..417728c 100644
--- a/examples/bootstrap.php
+++ b/examples/bootstrap.php
@@ -1,6 +1,8 @@
 <?php
 
-extension_loaded('sdl') || dl('sdl.' . PHP_SHLIB_SUFFIX);
+if (!extension_loaded('sdl')) {
+    fprintf(STDERR, "The sdl extension is not loaded. Make sure it is in the system and there is a line for it on the php.ini file (eg \"extension=sdl.so\")");
+    exit(1);
+}
 
 error_reporting(E_ALL);
-

From 5cfa83bf6bccbf52f19048c22633fb89b1e4d97e Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sun, 21 Jun 2020 12:39:21 +0100
Subject: [PATCH 07/53] Set color key to spaceship example

---
 examples/007-input-handling.php | 4 ++++
 src/surface.c                   | 7 ++++---
 tests/020-surface.phpt          | 4 ++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php
index c53884e..cc8a01f 100644
--- a/examples/007-input-handling.php
+++ b/examples/007-input-handling.php
@@ -20,6 +20,10 @@
 if ($image === null) {
 	exit('Unable to load image');
 }
+$windowSurface = SDL_GetWindowSurface($window);
+$color = SDL_MapRGB($windowSurface->format, 0xff, 0xff, 0xff);
+SDL_SetColorKey($image, true, $color);
+
 $texture = SDL_CreateTextureFromSurface($renderer, $image);
 $drect = $image->clip_rect;
 SDL_FreeSurface($image);
diff --git a/src/surface.c b/src/surface.c
index 5357242..2a5f0ad 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -806,14 +806,15 @@ PHP_FUNCTION(SDL_SetColorKey)
 {
 	struct php_sdl_surface *intern;
 	zval *z_surface;
-	zend_long flag, key = 0;
+	zend_bool flag;
+	zend_long key = 0;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_surface, php_sdl_surface_ce, &flag, &key)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob|l", &z_surface, php_sdl_surface_ce, &flag, &key)) {
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
-	RETURN_LONG(SDL_SetColorKey(surface, (int)flag, (Uint32)key));
+	RETURN_LONG(SDL_SetColorKey(surface, flag ? SDL_TRUE : SDL_FALSE, (Uint32)key));
 }
 /* }}} */
 
diff --git a/tests/020-surface.phpt b/tests/020-surface.phpt
index 75f8504..53eaf90 100644
--- a/tests/020-surface.phpt
+++ b/tests/020-surface.phpt
@@ -21,9 +21,9 @@ var_dump(SDL_LockSurface($spal), $spal->locked);
 var_dump(SDL_UnlockSurface($spal), $spal->locked);
 
 echo "= ColorKey\n";
-var_dump(SDL_SetColorKey($spal, 1, 127));
+var_dump(SDL_SetColorKey($spal, true, 127));
 var_dump(SDL_GetColorKey($spal, $key), $key);
-var_dump(SDL_SetColorKey($spal, 0));
+var_dump(SDL_SetColorKey($spal, false));
 var_dump(SDL_GetColorKey($spal, $key));
 
 echo "= ColorMod\n";

From c79dcdffa47374e8fb0b1ea2c0fc1e9b7747f96d Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sun, 21 Jun 2020 13:02:13 +0100
Subject: [PATCH 08/53] Add gif example and link to readme

---
 README.md                       |  28 ++++++++++++++++------------
 examples/007-input-handling.php |   5 +++--
 input-handling-example.gif      | Bin 0 -> 56494 bytes
 3 files changed, 19 insertions(+), 14 deletions(-)
 create mode 100644 input-handling-example.gif

diff --git a/README.md b/README.md
index c8352ab..3938853 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,9 @@
 PHP-SDL
 =======
 
-SDL (Simple DirectMedia Layer) bindings for the PHP language.
+SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allows you to create multimedia desktop applications with windows, input handling, events, and more.
+
+[<img src="input-handling-example.gif" width="250" />](input-handling-example.gif)
 
 ## Installation
 
@@ -33,7 +35,7 @@ to your _php.ini_ file.
 
 The SDL extension mimics in almost every single aspect to the official C library, so until we write our own documentation, refer to the [C counterpart](https://wiki.libsdl.org/APIByCategory).
 
-### Example
+## Examples
 
 Standard SDL2 API is available in procedural style:
 
@@ -51,8 +53,17 @@ And is also available in object oriented style:
     unset($window); // will destroy the window
 ```
 
-Building
-========
+Complete examples can be found in the [examples](examples) folder.
+
+## Projects using the extension
+
+* [CubeCraft](https://github.com/Ponup/cubecraft)
+* [Conway's game of life](https://github.com/Ponup/conways-game-of-life)
+* [PhpOkoban](https://github.com/b-viguier/PhpOkoban)
+* [Inphpinity](https://github.com/b-viguier/Inphpinity)
+* [PhPresent](https://github.com/b-viguier/PhPresent)
+
+## Building
 
 To compile your new extension, you will have to execute the following steps:
 
@@ -66,13 +77,6 @@ $ [sudo] make install
 
 ## Support and feature requests
 
-Please submit anything that needs our attention to [issues section](https://github.com/php-sdl/extension/issues) on Github. We are commited to attend any request in a short timespan if it's a sensible matter.
-
+Please submit anything that needs our attention to the [issues section](https://github.com/php-sdl/extension/issues) on Github. We are commited to attend any request in a short timespan if it's a sensible matter.
 
-## Projects using this extension
 
-* [CubeCraft](https://github.com/Ponup/cubecraft)
-* [Conway's game of life](https://github.com/Ponup/conways-game-of-life)
-* [PhpOkoban](https://github.com/b-viguier/PhpOkoban)
-* [Inphpinity](https://github.com/b-viguier/Inphpinity)
-* [PhPresent](https://github.com/b-viguier/PhPresent)
diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php
index cc8a01f..45341d9 100644
--- a/examples/007-input-handling.php
+++ b/examples/007-input-handling.php
@@ -28,9 +28,10 @@
 $drect = $image->clip_rect;
 SDL_FreeSurface($image);
 
-SDL_SetRenderDrawColor($renderer, 255, 0, 255, 255);
+SDL_SetRenderDrawColor($renderer, 0xbb, 0xcc, 0xdd, 0xff);
 SDL_RenderClear($renderer);
 SDL_RenderPresent($renderer);
+
 $rotCenter = new SDL_Point(10, 10);
 $event = new SDL_Event;
 $destRect = new SDL_Rect;
@@ -80,7 +81,7 @@
 		$update = false;
 	}
 
-	SDL_Delay(25);
+	SDL_Delay(5);
 }
 
 if ($joystickFound) {
diff --git a/input-handling-example.gif b/input-handling-example.gif
new file mode 100644
index 0000000000000000000000000000000000000000..59bcb77a30edb8de46ebecba52753d121323d9d5
GIT binary patch

From 49ecbbe9bb911832bb178534fb1d8f8bf4844be9 Mon Sep 17 00:00:00 2001
From: Manuel 'Kea' Baldassarri <kea@keasoft.it>
Date: Mon, 22 Jun 2020 20:52:08 +0200
Subject: [PATCH 09/53] Fix surface and powerinfo params by ref (#44)

* Fix some surface functions params by ref and fix misplaced pointers to internal struct

* Fix SDL_GetPowerInfo params by ref

* 017-rwops-stream test was already working
---
 src/power.c                 |  2 +-
 src/surface.c               | 19 +++++++++++--------
 tests/017-rwops-stream.phpt |  1 -
 tests/018-power.phpt        |  1 -
 tests/020-surface.phpt      |  5 +++--
 tests/021-surface-oo.phpt   |  6 +++---
 6 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/src/power.c b/src/power.c
index c9a7c44..d59b4be 100644
--- a/src/power.c
+++ b/src/power.c
@@ -40,7 +40,7 @@ PHP_FUNCTION(SDL_GetPowerInfo)
 	zval *z_secs = NULL, *z_pct = NULL;
 	zend_bool has_secs, has_pct;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_secs, &z_pct) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z/z/", &z_secs, &z_pct) == FAILURE) {
 		RETURN_FALSE;
 	}
 
diff --git a/src/surface.c b/src/surface.c
index 2a5f0ad..2acb03c 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -186,7 +186,8 @@ static PHP_METHOD(SDL_Surface, __construct)
 	zend_long flags, width, height, depth, rmask, gmask, bmask, amask;
 	zend_error_handling error_handling;
 
-	intern = (struct php_sdl_surface *)Z_OBJ_P(getThis());
+	zend_object* zo = Z_OBJ_P(getThis());
+	intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset);
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
 	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) {
@@ -217,7 +218,9 @@ static PHP_METHOD(SDL_Surface, __toString)
 		return;
 	}
 
-	intern = (struct php_sdl_surface *)Z_OBJ_P(getThis());
+	zend_object* zo = Z_OBJ_P(getThis());
+	intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset);
+
 	if (intern->surface) {
 		buf_len = spprintf(&buf, 100, "SDL_Surface(%u,%d,%d,%u,0x%x,0x%x,0x%x,0x%x)",
 			intern->surface->flags, intern->surface->w, intern->surface->h,
@@ -839,7 +842,7 @@ PHP_FUNCTION(SDL_GetColorKey)
 	SDL_Surface *surface;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_key)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_key)) {
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -906,7 +909,7 @@ PHP_FUNCTION(SDL_GetSurfaceColorMod)
 	SDL_Surface *surface;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozzz", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b)) {
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -972,7 +975,7 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
 	SDL_Surface *surface;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_a)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_a)) {
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -1034,7 +1037,7 @@ PHP_FUNCTION(SDL_GetSurfaceBlendMode)
 	SDL_Surface *surface;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_mode)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_mode)) {
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -1098,7 +1101,7 @@ PHP_FUNCTION(SDL_GetClipRect)
 	SDL_Rect rect;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_rect)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_rect)) {
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -1272,7 +1275,7 @@ static zend_object* php_sdl_surface_new(zend_class_entry *class_type)
 {
 	struct php_sdl_surface *intern;
 
-	intern = (struct php_sdl_surface*)ecalloc(1, sizeof(struct php_sdl_surface) + zend_object_properties_size(class_type));
+	intern = (struct php_sdl_surface*)zend_object_alloc(sizeof(struct php_sdl_surface), class_type);
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
diff --git a/tests/017-rwops-stream.phpt b/tests/017-rwops-stream.phpt
index 0d64901..acee259 100644
--- a/tests/017-rwops-stream.phpt
+++ b/tests/017-rwops-stream.phpt
@@ -3,7 +3,6 @@ SDL_RWops test, stream mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
 getenv("SKIP_ONLINE_TESTS") or exit("skip test requiring internet connection");
 ?>
 --FILE--
diff --git a/tests/018-power.phpt b/tests/018-power.phpt
index 97e9c25..571e426 100644
--- a/tests/018-power.phpt
+++ b/tests/018-power.phpt
@@ -3,7 +3,6 @@ SDL_power test suite
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
 ?>
 --FILE--
 <?php
diff --git a/tests/020-surface.phpt b/tests/020-surface.phpt
index 53eaf90..9fa361b 100644
--- a/tests/020-surface.phpt
+++ b/tests/020-surface.phpt
@@ -3,7 +3,6 @@ SDL_Surface test, procedural mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
 ?>
 --FILE--
 <?php
@@ -25,7 +24,8 @@ var_dump(SDL_SetColorKey($spal, true, 127));
 var_dump(SDL_GetColorKey($spal, $key), $key);
 var_dump(SDL_SetColorKey($spal, false));
 var_dump(SDL_GetColorKey($spal, $key));
-
+var_dump(SDL_GetError());
+SDL_ClearError();
 echo "= ColorMod\n";
 var_dump(SDL_SetSurfaceColorMod($scol, 1, 2, 3));
 var_dump(SDL_GetSurfaceColorMod($scol, $r, $g, $b), $r, $g, $b);
@@ -81,6 +81,7 @@ int(0)
 int(127)
 int(0)
 int(-1)
+string(31) "Surface doesn't have a colorkey"
 = ColorMod
 int(0)
 int(0)
diff --git a/tests/021-surface-oo.phpt b/tests/021-surface-oo.phpt
index fbe91ec..f107820 100644
--- a/tests/021-surface-oo.phpt
+++ b/tests/021-surface-oo.phpt
@@ -3,11 +3,11 @@ SDL_Surface test, procedural mode
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIncompleteTest();
 ?>
 --FILE--
 <?php
 echo "= Create Palette\n";
+/* The flags (first parameter) are no longer used in SDL2 */
 $spal = new SDL_Surface(0, 150, 100, 8, 0, 0, 0, 0);
 var_dump("$spal");
 var_dump($spal->w, $spal->h, $spal->format->palette->ncolors, $spal->pixels);
@@ -57,7 +57,7 @@ $scol->Free()
 = Done
 --EXPECTF--
 = Create Palette
-string(40) "SDL_Surface(0,150,100,8,0x0,0x0,0x0,0x0)"
+string(40) "SDL_Surface(%d,150,100,8,0x0,0x0,0x0,0x0)"
 int(150)
 int(100)
 int(256)
@@ -70,7 +70,7 @@ object(SDL_Pixels)#%d (3) {
   int(15200)
 }
 = Create True colors
-string(57) "SDL_Surface(0,150,100,32,0xff000000,0xff0000,0xff00,0xff)"
+string(57) "SDL_Surface(%d,150,100,32,0xff000000,0xff0000,0xff00,0xff)"
 int(150)
 int(100)
 NULL

From cc2ac56ea305b4e344e7400fcb43450f7f73ce32 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Mon, 22 Jun 2020 22:53:45 +0100
Subject: [PATCH 10/53] Fix issue #31 (extending SDL_Rect)

---
 src/rect.c             |  4 ++--
 tests/007-rect-oo.phpt | 10 ++++++++--
 tests/028-point.phpt   | 19 +++++++++++++++++++
 3 files changed, 29 insertions(+), 4 deletions(-)
 create mode 100644 tests/028-point.phpt

diff --git a/src/rect.c b/src/rect.c
index d3afa41..9d6bd15 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -71,7 +71,7 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
 
 zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
 {
-	if (Z_TYPE(*value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_rect_ce) {
+	if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) {
 		zval *val, rv;
 
 		val = zend_read_property(php_sdl_rect_ce, value, "x", 1, 0, &rv);
@@ -99,7 +99,7 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
 
 zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
 {
-	if (Z_TYPE(*value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_point_ce) {
+	if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) {
 		zval *val, rv;
 
 		val = zend_read_property(php_sdl_point_ce, value, "x", 1, 0, &rv);
diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt
index 176e44e..951f744 100644
--- a/tests/007-rect-oo.phpt
+++ b/tests/007-rect-oo.phpt
@@ -49,6 +49,11 @@ var_dump($r1->IntersectLine($x1, $y1, $x2, $y2));
 var_dump($x1, $y1, $x2, $y2);
 $x1=0; $y1=2; $x2=40; $y2=6;
 var_dump($r1->IntersectLine($x1, $y1, $x2, $y2));
+
+echo '+++ Test subclasses of SDL_Rect can be passed to SDL functions', PHP_EOL;
+class CustomRect extends \SDL_Rect {}
+$customRect = new CustomRect(10, 20, 30, 40);
+var_dump(SDL_RectEmpty($customRect));
 ?>
 Done
 --EXPECTF--
@@ -131,5 +136,6 @@ int(15)
 int(29)
 int(24)
 bool(false)
-Done
-
++++ Test subclasses of SDL_Rect can be passed to SDL functions
+bool(false)
+Done
\ No newline at end of file
diff --git a/tests/028-point.phpt b/tests/028-point.phpt
new file mode 100644
index 0000000..dd3d3cb
--- /dev/null
+++ b/tests/028-point.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SDL_Point test suite
+--SKIPIF--
+<?php
+require 'test-functions.php';
+--FILE--
+SUITE: Start
+<?php
+echo 'TEST: Subclasses of SDL_Point can be converted properly', PHP_EOL;
+class CustomPoint extends \SDL_Point {}
+$customPoint = new CustomPoint(10, 20);
+echo strval($customPoint), PHP_EOL;
+?>
+SUITE: End
+--EXPECTF--
+SUITE: Start
+TEST: Subclasses of SDL_Point can be converted properly
+SDL_Point(10,20)
+SUITE: End

From bc1456d253dcce0416c6a189cb1848f7676faa6a Mon Sep 17 00:00:00 2001
From: Manuel 'Kea' Baldassarri <kea@keasoft.it>
Date: Sun, 23 Aug 2020 21:54:29 +0200
Subject: [PATCH 11/53] Add SDL_QueryTexture wrapper (#46)

---
 src/php_sdl.c |  1 +
 src/render.c  | 27 +++++++++++++++++++++++++++
 src/render.h  |  9 +++++++++
 3 files changed, 37 insertions(+)

diff --git a/src/php_sdl.c b/src/php_sdl.c
index cb881f1..0bd104c 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -216,6 +216,7 @@ static zend_function_entry sdl_functions[] = {
 	ZEND_FE(SDL_RenderPresent, arginfo_SDL_RenderPresent)
 	ZEND_FE(SDL_CreateTextureFromSurface, arginfo_SDL_CreateTextureFromSurface)
 	ZEND_FE(SDL_CreateTexture, arginfo_SDL_CreateTexture)
+	ZEND_FE(SDL_QueryTexture, arginfo_SDL_QueryTexture)
 	ZEND_FE(SDL_SetRenderTarget, arginfo_SDL_SetRenderTarget)
 	ZEND_FE(SDL_GetRendererOutputSize, arginfo_SDL_GetRendererOutputSize)
 
diff --git a/src/render.c b/src/render.c
index 789f664..1e874c9 100644
--- a/src/render.c
+++ b/src/render.c
@@ -334,6 +334,33 @@ PHP_FUNCTION(SDL_GetRendererOutputSize)
 	ZVAL_LONG(z_height, h);
 }
 
+PHP_FUNCTION(SDL_QueryTexture)
+{
+	zval *z_texture, *z_format, *z_access, *z_width, *z_height;
+	SDL_Texture *texture;
+	int w, h, access, result;
+	Uint32 format;
+
+	if( zend_parse_parameters(ZEND_NUM_ARGS(), "zz/z/z/z/", &z_texture, &z_format, &z_access, &z_width, &z_height) == FAILURE ) {
+		return;
+	}
+
+	texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+
+	result = SDL_QueryTexture(texture, &format, &access, &w, &h);
+
+	zval_dtor(z_format);
+	ZVAL_LONG(z_format, format);
+	zval_dtor(z_access);
+	ZVAL_LONG(z_access, access);
+	zval_dtor(z_width);
+	ZVAL_LONG(z_width, (long)w);
+	zval_dtor(z_height);
+	ZVAL_LONG(z_height, (long)h);
+
+	RETURN_LONG(result);
+}
+
 /* {{{ MINIT */
 PHP_MINIT_FUNCTION(sdl_render)
 {
diff --git a/src/render.h b/src/render.h
index 85bf2c3..34b5687 100644
--- a/src/render.h
+++ b/src/render.h
@@ -93,6 +93,14 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTexture, 0, 0, 5)
 	ZEND_ARG_INFO(0, h)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 5)
+	ZEND_ARG_INFO(0, texture)
+	ZEND_ARG_INFO(1, format)
+	ZEND_ARG_INFO(1, access)
+	ZEND_ARG_INFO(1, w)
+	ZEND_ARG_INFO(1, h)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderTarget, 0, 0, 2)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_INFO(0, texture)
@@ -138,6 +146,7 @@ PHP_FUNCTION(SDL_RenderPresent);
 PHP_FUNCTION(SDL_RenderDrawPoint);
 PHP_FUNCTION(SDL_CreateTextureFromSurface);
 PHP_FUNCTION(SDL_CreateTexture);
+PHP_FUNCTION(SDL_QueryTexture);
 PHP_FUNCTION(SDL_SetRenderTarget);
 PHP_FUNCTION(SDL_CreateRenderer);
 PHP_FUNCTION(SDL_RenderCopy);

From 8d0be8d32aa230af769bf559c46595fccfdc94b8 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sun, 23 Aug 2020 21:15:52 +0100
Subject: [PATCH 12/53] Prepare 2.4.0 release

---
 package.xml   | 41 ++++++++++++++++++++++++++++++++++-------
 src/php_sdl.h |  2 +-
 2 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/package.xml b/package.xml
index 02fb6a9..dd393bd 100644
--- a/package.xml
+++ b/package.xml
@@ -16,11 +16,12 @@
     <email>remi@php.net</email>
     <active>yes</active>
   </lead>
-  <date>2019-09-08</date>
+  <!-- Current version -->
+  <date>2020-08-23</date>
   <time>12:00:00</time>
   <version>
-    <release>2.3.0</release>
-    <api>2.3.0</api>
+    <release>2.4.0</release>
+    <api>2.4.0</api>
   </version>
   <stability>
     <release>devel</release>
@@ -28,9 +29,15 @@
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
   <notes>
-  	  - Fix out of bounds error (remicollet)
-  	  - Add basic joystick/gamepad support (santiagolizardo)
+  	  - Fix duplicate symbols (remicollet)
+  	  - Fix parameters passed by reference in rect module (kea)
+  	  - Port SDL_Palette and SDL_PixelFormat to PHP7 (kea)
+  	  - Fix surface props initialisation (kea)
+  	  - Fix surface and powerinfo params by ref (kea)
+  	  - Fix SDL_Rect inheritance issue (santiagolizardo)
+  	  - Add SQL_QueryTexture binding (kea)
   </notes>
+  <!--/Current version -->
   <contents>
     <dir name="/">
       <file role="doc" name="CREDITS"/>
@@ -98,6 +105,8 @@
         <file role="doc" name="006-animated-boxes.php"/>
         <file role="doc" name="007-input-handling.php"/>
         <file role="doc" name="008-shaped-window.php"/>
+        <file role="doc" name="009-window-events.php"/>
+        <file role="doc" name="010-draw-lines.php"/>
         <file role="doc" name="bootstrap.php"/>
         <file role="doc" name="p01_shape24.bmp"/>
         <file role="doc" name="p01_shape32alpha.bmp"/>
@@ -131,6 +140,7 @@
         <file role="test" name="025-mutex-oo.phpt"/>
         <file role="test" name="026-filesystem.phpt"/>
         <file role="test" name="027-joystick.phpt"/>
+        <file role="test" name="028-point.phpt"/>
         <file role="test" name="test-functions.php"/>
       </dir>
     </dir>
@@ -138,16 +148,33 @@
   <dependencies>
     <required>
       <php>
-        <min>7.3.0</min>
+        <min>7.4.0</min>
       </php>
       <pearinstaller>
-        <min>1.9.0</min>
+        <min>1.10.0</min>
       </pearinstaller>
     </required>
   </dependencies>
   <providesextension>sdl</providesextension>
   <extsrcrelease/>
   <changelog>
+  	  <release>
+  <date>2019-09-08</date>
+  <time>12:00:00</time>
+  <version>
+    <release>2.3.0</release>
+    <api>2.3.0</api>
+  </version>
+  <stability>
+    <release>devel</release>
+    <api>devel</api>
+  </stability>
+  <license uri="http://www.php.net/license">PHP</license>
+  <notes>
+  	  - Fix out of bounds error (remicollet)
+  	  - Add basic joystick/gamepad support (santiagolizardo)
+  </notes>
+  	  </release>
     <release>
       <date>2019-09-02</date>
       <time>12:00:00</time>
diff --git a/src/php_sdl.h b/src/php_sdl.h
index c0cb014..c3afd94 100644
--- a/src/php_sdl.h
+++ b/src/php_sdl.h
@@ -32,7 +32,7 @@ extern "C" {
 #include <php.h>
 #include <zend_exceptions.h>
 
-#define PHP_SDL_VERSION "2.3.0"
+#define PHP_SDL_VERSION "2.4.0"
 
 #if defined(__APPLE__) && defined(__MACH__)
 #include <SDL2/SDL.h>

From 3ddeb7dd02d5ee9db4347caad7c62d5399ddc13c Mon Sep 17 00:00:00 2001
From: Manuel Baldassarri <kea@keasoft.it>
Date: Fri, 18 Jun 2021 20:30:44 +0200
Subject: [PATCH 13/53] Add PHP 8 support (#50)

* Add PHP 8 support

* Remove PHP 7 support

* Update min PHP version to 8.0

Co-authored-by: Santiago <santiagolizardo@users.noreply.github.com>
---
 Dockerfile       |   4 +-
 config.m4        |   4 +-
 src/event.c      |  11 +--
 src/messagebox.c |  36 ++++-----
 src/php_sdl.h    |   4 -
 src/pixels.c     | 200 ++++++++++++++++++-----------------------------
 src/rect.c       |  36 ++++-----
 src/shape.c      |   2 +-
 src/surface.c    |  56 +++++++------
 src/video.c      |  12 +--
 src/window.c     |   4 +-
 11 files changed, 158 insertions(+), 211 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 5d363a3..a77b5b9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,7 +6,7 @@ RUN apt-get install -y lsb-release apt-transport-https ca-certificates
 RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
 RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
 RUN apt-get update
-RUN apt-get install -y php7.4-dev
+RUN apt-get install -y php8.0-dev
 RUN apt-get install -y libsdl2-dev
 RUN apt-get install -y xvfb
 COPY . /opt/php-sdl
@@ -15,7 +15,7 @@ RUN phpize
 RUN ./configure
 RUN make
 RUN make install
-RUN echo "extension=sdl.so" >> /etc/php/7.4/cli/php.ini
+RUN echo "extension=sdl.so" >> /etc/php/8.0/cli/php.ini
 
 ENTRYPOINT ["/opt/php-sdl/docker-entrypoint.sh"]
 
diff --git a/config.m4 b/config.m4
index 03d0d69..06963bd 100644
--- a/config.m4
+++ b/config.m4
@@ -10,8 +10,8 @@ if test "$PHP_SDL" != "no"; then
   export OLD_CPPFLAGS="$CPPFLAGS"
   export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_SDL2 -Wall -Wfatal-errors"
 
-  REQ_PHP_VERSION="7.3.0"
-  REQ_PHP_VERSION_ID=70300
+  REQ_PHP_VERSION="8.0.0"
+  REQ_PHP_VERSION_ID=80000
   if test -z "$PHP_VERSION_ID"; then
     AC_MSG_CHECKING(PHP version)
     AC_TRY_COMPILE([#include <php_version.h>], [
diff --git a/src/event.c b/src/event.c
index a0760bc..027dbf3 100644
--- a/src/event.c
+++ b/src/event.c
@@ -43,7 +43,7 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value)
 
 	object_init_ex(value, php_sdl_event_ce);
 
-	zend_update_property_long(php_sdl_event_ce, value, ZEND_STRL("type"), event->type);
+	zend_update_property_long(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), event->type);
 
 	switch(event->type) {
 		case SDL_MOUSEMOTION: {
@@ -122,7 +122,7 @@ zend_bool zval_to_sdl_event(zval *value, SDL_Event *event)
 	zval *val, rv;
 	
 	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_event_ce) {
-		val = zend_read_property(php_sdl_event_ce, value, ZEND_STRL("type"), 0, &rv);
+		val = zend_read_property(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = event->type = (int)Z_LVAL_P(val);
 
@@ -163,14 +163,11 @@ static PHP_METHOD(SDL_Event, __toString)
 }
 /* }}} */
 
-static HashTable *sdl_event_get_properties(zval *object)
+static HashTable *sdl_event_get_properties(zend_object *object)
 {
 	HashTable *props;    
 	props = zend_std_get_properties(object);
-        zval test;
-        zend_string *key = zend_string_init("type", 4, 0);
-        ZVAL_LONG(&test, SDL_QUIT);
-        zend_hash_update(props, key, &test);
+
 	return props;
 }
 
diff --git a/src/messagebox.c b/src/messagebox.c
index dcbb361..86be6c0 100644
--- a/src/messagebox.c
+++ b/src/messagebox.c
@@ -66,9 +66,9 @@ zend_bool sdl_messageboxcolor_to_zval(const SDL_MessageBoxColor *color, zval *va
 {
 	if (color) {
 		object_init_ex(value, php_sdl_messageboxcolor_ce);
-		zend_update_property_long(php_sdl_messageboxcolor_ce, value, "r", 1, color->r);
-		zend_update_property_long(php_sdl_messageboxcolor_ce, value, "g", 1, color->g);
-		zend_update_property_long(php_sdl_messageboxcolor_ce, value, "b", 1, color->b);
+		zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "r", 1, color->r);
+		zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "g", 1, color->g);
+		zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "b", 1, color->b);
 
 		return 1;
 	}
@@ -82,9 +82,9 @@ zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data,
 {
 	if (data) {
 		object_init_ex(value, php_sdl_messageboxbuttondata_ce);
-		zend_update_property_long(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("flags"), data->flags);
-		zend_update_property_long(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("buttonid"), data->buttonid);
-		zend_update_property_string(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("text"), data->text);
+		zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("flags"), data->flags);
+		zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("buttonid"), data->buttonid);
+		zend_update_property_string(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("text"), data->text);
 
 		return 1;
 	}
@@ -119,15 +119,15 @@ zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color)
 
 		/* we convert the properties, without copy: yes ! */
 
-		val = zend_read_property(php_sdl_messageboxcolor_ce, value, "r", 1, 0, &rv);
+		val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "r", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = color->r = (Uint8)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_messageboxcolor_ce, value, "g", 1, 0, &rv);
+		val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "g", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = color->g = (Uint8)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_messageboxcolor_ce, value, "b", 1, 0, &rv);
+		val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "b", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = color->b = (Uint8)Z_LVAL_P(val);
 
@@ -147,15 +147,15 @@ zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData
 
 		/* we convert the properties, without copy: yes ! */
 
-		val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("flags"), 0, &rv);
+		val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("flags"), 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = data->flags = (Uint32)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("buttonid"), 0, &rv);
+		val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("buttonid"), 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = data->buttonid = (int)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("text"), 0, &rv);
+		val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("text"), 0, &rv);
 		convert_to_string(val);
 		data->text = Z_STRVAL_P(val);
 
@@ -250,9 +250,9 @@ static PHP_METHOD(SDL_MessageBoxColor, __construct)
 	}
 	zend_restore_error_handling(&error_handling);
 
-	zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "r", 1, r&255);
-	zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "g", 1, g&255);
-	zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "b", 1, b&255);
+	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "r", 1, r&255);
+	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "g", 1, g&255);
+	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "b", 1, b&255);
 }
 /* }}} */
 
@@ -305,9 +305,9 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __construct)
 	}
 	zend_restore_error_handling(&error_handling);
 
-	zend_update_property_long(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("flags"), flags);
-	zend_update_property_long(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("buttonid"), (int)id);
-	zend_update_property_string(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("text"), text);
+	zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("flags"), flags);
+	zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("buttonid"), (int)id);
+	zend_update_property_string(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("text"), text);
 }
 /* }}} */
 
diff --git a/src/php_sdl.h b/src/php_sdl.h
index c3afd94..ac2d6ee 100644
--- a/src/php_sdl.h
+++ b/src/php_sdl.h
@@ -68,10 +68,6 @@ PHP_MINFO_FUNCTION(sdl);
 
 zend_bool php_sdl_check_overflow(int a, int b, int silent);
 
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
 #ifdef  __cplusplus
 } // extern "C" 
 #endif
diff --git a/src/pixels.c b/src/pixels.c
index 58f2b11..2e67fd0 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -115,10 +115,10 @@ zend_bool sdl_color_to_zval(SDL_Color *color, zval *value)
 {
 	if (color) {
 		object_init_ex(value, php_sdl_color_ce);
-		zend_update_property_long(php_sdl_color_ce, value, "r", 1, color->r);
-		zend_update_property_long(php_sdl_color_ce, value, "g", 1, color->g);
-		zend_update_property_long(php_sdl_color_ce, value, "b", 1, color->b);
-		zend_update_property_long(php_sdl_color_ce, value, "a", 1, color->a);
+		zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, color->r);
+		zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "g", 1, color->g);
+		zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "b", 1, color->b);
+		zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "a", 1, color->a);
 
 		return 1;
 	}
@@ -131,19 +131,19 @@ zend_bool zval_to_sdl_color(zval *value, SDL_Color *color)
 	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_color_ce) {
 		zval *val, rv;
 
-		val = zend_read_property(php_sdl_color_ce, value, "r", 1, 0, &rv);
+		val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = color->r = (Uint8)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_color_ce, value, "g", 1, 0, &rv);
+		val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "g", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = color->g = (Uint8)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_color_ce, value, "b", 1, 0, &rv);
+		val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "b", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = color->b = (Uint8)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_color_ce, value, "a", 1, 0, &rv);
+		val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "a", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = color->a = (Uint8)Z_LVAL_P(val);
 
@@ -270,10 +270,10 @@ static PHP_METHOD(SDL_Color, __construct)
 	}
 	zend_restore_error_handling(&error_handling);
 
-	zend_update_property_long(php_sdl_color_ce, getThis(), "r", 1, r&255);
-	zend_update_property_long(php_sdl_color_ce, getThis(), "g", 1, g&255);
-	zend_update_property_long(php_sdl_color_ce, getThis(), "b", 1, b&255);
-	zend_update_property_long(php_sdl_color_ce, getThis(), "a", 1, a&255);
+	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "r", 1, r&255);
+	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "g", 1, g&255);
+	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "b", 1, b&255);
+	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "a", 1, a&255);
 }
 /* }}} */
 
@@ -353,7 +353,7 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
 
 		RETURN_TRUE;
 	}
-	RETURN_FALSE;;
+	RETURN_FALSE;
 }
 /* }}} */
 
@@ -486,7 +486,7 @@ PHP_FUNCTION(SDL_AllocPalette)
 	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) {
 		return;
 	}
-	palette = SDL_AllocPalette(ncolors);
+	palette = SDL_AllocPalette((int)ncolors);
 	sdl_palette_to_zval(palette, return_value, 0);
 }
 /* }}} */
@@ -690,15 +690,15 @@ PHP_FUNCTION(SDL_SetPaletteColors)
 	if (ncolors <= 0) {
 		ncolors = count;
 	} else if (ncolors > count) {
-		php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, ncolors);
+		php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %lld", count, ncolors);
 		ncolors = count;
 	}
 	if (first >= intern->palette->ncolors) {
-		php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", first, intern->palette->ncolors);
+		php_error_docref(NULL, E_WARNING, "Invalid first color index, %lld >= %d", first, intern->palette->ncolors);
 		RETURN_LONG(-1);
 	}
 	if (first+ncolors > intern->palette->ncolors) {
-		php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", first+ncolors, intern->palette->ncolors);
+		php_error_docref(NULL, E_WARNING, "Invalid color number, %lld > %d", first+ncolors, intern->palette->ncolors);
 		RETURN_LONG(-1);
 	}
 	colors = emalloc(sizeof(SDL_Color) * ncolors);
@@ -975,16 +975,16 @@ static PHP_METHOD(SDL_Pixels, __construct)
 	}
 	zend_restore_error_handling(&error_handling);
 
-	if (php_sdl_check_overflow(pitch, h, 1)) {
+	if (php_sdl_check_overflow((int)pitch, (int)h, 1)) {
 		zend_throw_exception(zend_exception_get_default(), "Invalid size", 0);
 	} else {
 		if (pitch & 3) {
 			pitch = (pitch + 3) & ~3;
-			php_error_docref(NULL, E_NOTICE, "Pitch set to %ld", pitch);
+			php_error_docref(NULL, E_NOTICE, "Pitch set to %d", (int)pitch);
 		}
-		intern->pixels.pixels = ecalloc(pitch, h);
-		intern->pixels.pitch  = pitch;
-		intern->pixels.h      = h;
+		intern->pixels.pixels = ecalloc((int)pitch, (int)h);
+		intern->pixels.pitch  = (int)pitch;
+		intern->pixels.h      = (int)h;
 	}
 }
 /* }}} */
@@ -1120,7 +1120,7 @@ PHP_METHOD(SDL_Pixels, GetByte)
 	intern = PHP_SDL_PIXELS_P(z_pixels);
 
 	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
+		php_error_docref(NULL, E_NOTICE, "Invalid position (%lld,%lld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
 		RETURN_FALSE;
 	}
 	RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
@@ -1147,7 +1147,7 @@ PHP_METHOD(SDL_Pixels, SetByte)
 	intern = PHP_SDL_PIXELS_P(z_pixels);
 
 	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
+		php_error_docref(NULL, E_NOTICE, "Invalid position (%lld,%lld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
 		RETURN_FALSE;
 	}
 	RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
@@ -1190,20 +1190,11 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type)
 /* }}} */
 
 /* {{{ sdl_palette_read_property*/
-zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
+zval *sdl_palette_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
 {
-	php_sdl_palette *intern = PHP_SDL_PALETTE_P(object);
-	zval *retval, tmp_member;
-
-	if (Z_TYPE_P(member) != IS_STRING) {
-		zend_string *_str = zval_try_get_string_func(member);
-		if (UNEXPECTED(!_str)) {
-			return &EG(uninitialized_zval);
-		}
-		ZVAL_STR(&tmp_member, _str);
-		member = &tmp_member;
-		cache_slot = NULL;
-	}
+	php_sdl_palette *intern = php_sdl_palette_from_obj(object);
+	char *member_val = ZSTR_VAL(member);
+	zval *retval;
 
 	if (!intern->palette) {
 		return zend_std_read_property(object, member, type, cache_slot, rv);
@@ -1211,16 +1202,16 @@ zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cac
 
 	retval = rv;
 
-	if (!strcmp(Z_STRVAL_P(member), "ncolors")) {
+	if (!strcmp(member_val, "ncolors")) {
 		ZVAL_LONG(retval, intern->palette->ncolors);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "version")) {
+	} else if (!strcmp(member_val, "version")) {
 		ZVAL_LONG(retval, intern->palette->version);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "refcount")) {
+	} else if (!strcmp(member_val, "refcount")) {
 		ZVAL_LONG(retval, intern->palette->refcount);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "colors")) {
+	} else if (!strcmp(member_val, "colors")) {
 		int i;
 		zval z_color;
 		array_init(retval);
@@ -1231,15 +1222,10 @@ zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cac
 
 	} else {
 		retval = zend_std_read_property(object, member, type, cache_slot, rv);
-		if (member == &tmp_member) {
-			zval_ptr_dtor_str(&tmp_member);
-		}
+
 		return retval;
 	}
 
-	if (member == &tmp_member) {
-		zval_dtor(member);
-	}
 	return retval;
 }
 /* }}} */
@@ -1249,12 +1235,12 @@ zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cac
 	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
 
 /* {{{ sdl_palette_get_properties*/
-static HashTable *sdl_palette_get_properties(zval *object)
+static HashTable *sdl_palette_get_properties(zend_object *object)
 {
 	HashTable *props;
 	zval zv, z_color;
 	int i;
-	php_sdl_palette *intern = PHP_SDL_PALETTE_P(object);
+	php_sdl_palette *intern = php_sdl_palette_from_obj(object);
 
 	props = zend_std_get_properties(object);
 
@@ -1275,7 +1261,7 @@ static HashTable *sdl_palette_get_properties(zval *object)
 /* }}} */
 
 /* {{{ sdl_palette_write_property */
-static zval *sdl_palette_write_property(zval *object, zval *member, zval *value, void **cache_slot)
+static zval *sdl_palette_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot)
 {
 	php_error_docref(NULL, E_ERROR, "Not supported, use SDL_SetPaletteColors() or SDL_Palette::SetColors()");
 	return value;
@@ -1315,22 +1301,11 @@ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type)
 /* }}} */
 
 /* {{{ sdl_pixelformat_read_property*/
-zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
+zval *sdl_pixelformat_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
 {
-	php_sdl_pixelformat *intern;
-	zval *retval, tmp_member;
-
-	intern = PHP_SDL_PIXELFORMAT_P(object);
-
-	if (Z_TYPE_P(member) != IS_STRING) {
-		zend_string *_str = zval_try_get_string_func(member);
-		if (UNEXPECTED(!_str)) {
-			return &EG(uninitialized_zval);
-		}
-		ZVAL_STR(&tmp_member, _str);
-		member = &tmp_member;
-		cache_slot = NULL;
-	}
+	php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object);
+	char *member_val = ZSTR_VAL(member);
+	zval *retval;
 
 	if (!intern->format) {
 		return zend_std_read_property(object, member, type, cache_slot, rv);
@@ -1338,65 +1313,60 @@ zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void *
 
 	retval = rv;
 
-	if (!strcmp(Z_STRVAL_P(member), "format")) {
+	if (!strcmp(member_val, "format")) {
 		ZVAL_LONG(retval, intern->format->format);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "BitsPerPixel")) {
+	} else if (!strcmp(member_val, "BitsPerPixel")) {
 		ZVAL_LONG(retval, intern->format->BitsPerPixel);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "BytesPerPixel")) {
+	} else if (!strcmp(member_val, "BytesPerPixel")) {
 		ZVAL_LONG(retval, intern->format->BytesPerPixel);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Rmask")) {
+	} else if (!strcmp(member_val, "Rmask")) {
 		ZVAL_LONG(retval, intern->format->Rmask);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Gmask")) {
+	} else if (!strcmp(member_val, "Gmask")) {
 		ZVAL_LONG(retval, intern->format->Gmask);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Bmask")) {
+	} else if (!strcmp(member_val, "Bmask")) {
 		ZVAL_LONG(retval, intern->format->Bmask);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Amask")) {
+	} else if (!strcmp(member_val, "Amask")) {
 		ZVAL_LONG(retval, intern->format->Amask);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Rloss")) {
+	} else if (!strcmp(member_val, "Rloss")) {
 		ZVAL_LONG(retval, intern->format->Rloss);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Gloss")) {
+	} else if (!strcmp(member_val, "Gloss")) {
 		ZVAL_LONG(retval, intern->format->Gloss);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Bloss")) {
+	} else if (!strcmp(member_val, "Bloss")) {
 		ZVAL_LONG(retval, intern->format->Bloss);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Aloss")) {
+	} else if (!strcmp(member_val, "Aloss")) {
 		ZVAL_LONG(retval, intern->format->Aloss);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Rshift")) {
+	} else if (!strcmp(member_val, "Rshift")) {
 		ZVAL_LONG(retval, intern->format->Rshift);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Gshift")) {
+	} else if (!strcmp(member_val, "Gshift")) {
 		ZVAL_LONG(retval, intern->format->Gshift);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Bshift")) {
+	} else if (!strcmp(member_val, "Bshift")) {
 		ZVAL_LONG(retval, intern->format->Bshift);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "Ashift")) {
+	} else if (!strcmp(member_val, "Ashift")) {
 		ZVAL_LONG(retval, intern->format->Ashift);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "palette")) {
+	} else if (!strcmp(member_val, "palette")) {
 		sdl_palette_to_zval(intern->format->palette, retval, SDL_DONTFREE);
 
 	} else {
 		retval = zend_std_read_property(object, member, type, cache_slot, rv);
-		if (member == &tmp_member) {
-			zval_ptr_dtor_str(&tmp_member);
-		}
+
 		return retval;
 	}
 
-	if (member == &tmp_member) {
-		zval_dtor(member);
-	}
 	return retval;
 }
 /* }}} */
@@ -1406,14 +1376,12 @@ zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void *
 	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
 
 /* {{{ sdl_pixelformat_read_property*/
-static HashTable *sdl_pixelformat_get_properties(zval *object)
+static HashTable *sdl_pixelformat_get_properties(zend_object *object)
 {
 	HashTable *props;
 	zval zv;
 	php_sdl_pixelformat *intern;
-
-	intern = PHP_SDL_PIXELFORMAT_P(object);
-
+	intern = php_sdl_pixelformat_from_obj(object);
 	props = zend_std_get_properties(object);
 
 	if (intern->format) {
@@ -1429,9 +1397,9 @@ static HashTable *sdl_pixelformat_get_properties(zval *object)
 		SDL_PIXELFORMAT_ADD_PROPERTY("Bloss",         intern->format->Bloss);
 		SDL_PIXELFORMAT_ADD_PROPERTY("Aloss",         intern->format->Aloss);
 		SDL_PIXELFORMAT_ADD_PROPERTY("Rshift",        intern->format->Rshift);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Gshift",        intern->format->Rshift);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Bshift",        intern->format->Rshift);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Ashift",        intern->format->Rshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Gshift",        intern->format->Gshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Bshift",        intern->format->Bshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Ashift",        intern->format->Ashift);
 
 		sdl_palette_to_zval(intern->format->palette, &zv, SDL_DONTFREE);
 		zend_hash_str_update(props, "palette", sizeof("palette")-1, &zv);
@@ -1441,7 +1409,7 @@ static HashTable *sdl_pixelformat_get_properties(zval *object)
 /* }}} */
 
 /* {{{ sdl_pixelformat_write_property */
-static zval *sdl_pixelformat_write_property(zval *object, zval *member, zval *value, void **cache_slot)
+static zval *sdl_pixelformat_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot)
 {
 	php_error_docref(NULL, E_ERROR, "Not supported, SDL_PixelFormat is read-only");
 	return value;
@@ -1480,20 +1448,13 @@ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type)
 /* }}} */
 
 /* {{{ sdl_pixels_read_property*/
-zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
+zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv )
 {
-	php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object);
-	zval *retval, tmp_member;
+	php_sdl_pixels *intern;
+	intern = php_sdl_pixels_from_obj(object);
+	char *member_val = ZSTR_VAL(member);
 
-	if (Z_TYPE_P(member) != IS_STRING) {
-		zend_string *_str = zval_try_get_string_func(member);
-		if (UNEXPECTED(!_str)) {
-			return &EG(uninitialized_zval);
-		}
-		ZVAL_STR(&tmp_member, _str);
-		member = &tmp_member;
-		cache_slot = NULL;
-	}
+	zval *retval;
 
 	if (!intern->pixels.pixels) {
 		return zend_std_read_property(object, member, type, cache_slot, rv);
@@ -1501,26 +1462,21 @@ zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cach
 
 	retval = rv;
 
-	if (!strcmp(Z_STRVAL_P(member), "h")) {
+	if (!strcmp(member_val, "h")) {
 		ZVAL_LONG(retval, intern->pixels.h);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "pitch")) {
+	} else if (!strcmp(member_val, "pitch")) {
 		ZVAL_LONG(retval, intern->pixels.pitch);
 
-	} else if (!strcmp(Z_STRVAL_P(member), "count")) {
+	} else if (!strcmp(member_val, "count")) {
 		ZVAL_LONG(retval, intern->pixels.pitch * intern->pixels.h);
 
 	} else {
 		retval = zend_std_read_property(object, member, type, cache_slot, rv);
-		if (member == &tmp_member) {
-			zval_dtor(member);
-		}
+
 		return retval;
 	}
 
-	if (member == &tmp_member) {
-		zval_dtor(member);
-	}
 	return retval;
 }
 /* }}} */
@@ -1530,11 +1486,11 @@ zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cach
 	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
 
 /* {{{ sdl_pixels_read_properties */
-static HashTable *sdl_pixels_get_properties(zval *object)
+static HashTable *sdl_pixels_get_properties(zend_object *object)
 {
 	HashTable *props;
 	zval zv;
-	php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object);
+	php_sdl_pixels *intern = php_sdl_pixels_from_obj(object);
 
 	props = zend_std_get_properties(object);
 
@@ -1548,7 +1504,7 @@ static HashTable *sdl_pixels_get_properties(zval *object)
 /* }}} */
 
 /* {{{ sdl_pixels_write_property */
-static zval *sdl_pixels_write_property(zval *object, zval *member, zval *value, void **cache_slot)
+static zval *sdl_pixels_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot)
 {
 	php_error_docref(NULL, E_ERROR, "Not supported, SDL_Pixels is read-only");
 	return value;
@@ -1566,7 +1522,7 @@ static const zend_function_entry php_sdl_color_methods[] = {
 
 /* {{{ php_sdl_palette_methods[] */
 static const zend_function_entry php_sdl_palette_methods[] = {
-	PHP_ME(SDL_Palette, __construct,   arginfo_SDL_AllocPalette,        ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, __construct,   arginfo_SDL_AllocPalette,        ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Palette, __toString,    arginfo_palette_none,            ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Palette, count,         arginfo_palette_none,            ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Palette, offsetExists,  arginfo_SDL_Palette_offset,      ZEND_ACC_PUBLIC)
@@ -1584,7 +1540,7 @@ static const zend_function_entry php_sdl_palette_methods[] = {
 
 /* {{{ php_sdl_pixelformat_methods[] */
 static const zend_function_entry php_sdl_pixelformat_methods[] = {
-	PHP_ME(SDL_PixelFormat, __construct,  arginfo_SDL_AllocFormat,            ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_PixelFormat, __construct,  arginfo_SDL_AllocFormat,            ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_PixelFormat, __toString,   arginfo_palette_none,               ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_PixelFormat, GetRGB,       arginfo_SDL_PixelFormat_GetRGB,     ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_PixelFormat, GetRGBA,      arginfo_SDL_PixelFormat_GetRGBA,    ZEND_ACC_PUBLIC)
@@ -1601,7 +1557,7 @@ static const zend_function_entry php_sdl_pixelformat_methods[] = {
 
 /* {{{ php_sdl_pixels_methods[] */
 static const zend_function_entry php_sdl_pixels_methods[] = {
-	PHP_ME(SDL_Pixels,    __construct,   arginfo_SDL_Pixels__construct,     ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels,    __construct,   arginfo_SDL_Pixels__construct,     ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels,    __toString,    arginfo_format_none,               ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels,    count,         arginfo_format_none,               ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels,    offsetExists,  arginfo_SDL_Pixels_offset,         ZEND_ACC_PUBLIC)
diff --git a/src/rect.c b/src/rect.c
index 9d6bd15..38112ed 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -45,10 +45,10 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value)
 {
 	if (rect) {
 		object_init_ex(value, php_sdl_rect_ce);
-		zend_update_property_long(php_sdl_rect_ce, value, "x", 1, rect->x);
-		zend_update_property_long(php_sdl_rect_ce, value, "y", 1, rect->y);
-		zend_update_property_long(php_sdl_rect_ce, value, "w", 1, rect->w);
-		zend_update_property_long(php_sdl_rect_ce, value, "h", 1, rect->h);
+		zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, rect->x);
+		zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "y", 1, rect->y);
+		zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "w", 1, rect->w);
+		zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "h", 1, rect->h);
 
 		return 1;
 	}
@@ -60,8 +60,8 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
 {
 	if (pt) {
 		object_init_ex(value, php_sdl_point_ce);
-		zend_update_property_long(php_sdl_point_ce, value, "x", 1, pt->x);
-		zend_update_property_long(php_sdl_point_ce, value, "y", 1, pt->y);
+		zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, pt->x);
+		zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "y", 1, pt->y);
 
 		return 1;
 	}
@@ -74,19 +74,19 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
 	if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) {
 		zval *val, rv;
 
-		val = zend_read_property(php_sdl_rect_ce, value, "x", 1, 0, &rv);
+		val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = rect->x = (int)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_rect_ce, value, "y", 1, 0, &rv);
+		val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "y", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = rect->y = (int)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_rect_ce, value, "w", 1, 0, &rv);
+		val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "w", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = rect->w = (int)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_rect_ce, value, "h", 1, 0, &rv);
+		val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "h", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = rect->h = (int)Z_LVAL_P(val);
 
@@ -102,11 +102,11 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
 	if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) {
 		zval *val, rv;
 
-		val = zend_read_property(php_sdl_point_ce, value, "x", 1, 0, &rv);
+		val = zend_read_property(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = pt->x = (int)Z_LVAL_P(val);
 
-		val = zend_read_property(php_sdl_point_ce, value, "y", 1, 0, &rv);
+		val = zend_read_property(php_sdl_point_ce, Z_OBJ_P(value), "y", 1, 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = pt->y = (int)Z_LVAL_P(val);
 
@@ -129,10 +129,10 @@ static PHP_METHOD(SDL_Rect, __construct)
 		return;
 	}
 
-	zend_update_property_long(php_sdl_rect_ce, getThis(), "x", 1, x);
-	zend_update_property_long(php_sdl_rect_ce, getThis(), "y", 1, y);
-	zend_update_property_long(php_sdl_rect_ce, getThis(), "w", 1, w);
-	zend_update_property_long(php_sdl_rect_ce, getThis(), "h", 1, h);
+	zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "x", 1, x);
+	zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "y", 1, y);
+	zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "w", 1, w);
+	zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "h", 1, h);
 }
 /* }}} */
 
@@ -169,8 +169,8 @@ static PHP_METHOD(SDL_Point, __construct)
 	}
 	zend_restore_error_handling(&error_handling);
 
-	zend_update_property_long(php_sdl_point_ce, getThis(), "x", 1, x);
-	zend_update_property_long(php_sdl_point_ce, getThis(), "y", 1, y);
+	zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(getThis()), "x", 1, x);
+	zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(getThis()), "y", 1, y);
 }
 /* }}} */
 
diff --git a/src/shape.c b/src/shape.c
index 185e739..786b81f 100644
--- a/src/shape.c
+++ b/src/shape.c
@@ -189,7 +189,7 @@ static const zend_function_entry php_sdl_windowshapemode_methods[] = {
 
 #define REGISTER_CLASS_CONST_LONG(const_name, value) \
 	REGISTER_LONG_CONSTANT("ShapeMode" const_name, value, CONST_CS | CONST_PERSISTENT); \
-	zend_declare_class_constant_long(php_sdl_windowshapemode_ce, ZEND_STRL(const_name), value); \
+	zend_declare_class_constant_long(php_sdl_windowshapemode_ce, const_name, sizeof(const_name)-1, value); \
 
 /* {{{ MINIT */
 PHP_MINIT_FUNCTION(sdl_shape)
diff --git a/src/surface.c b/src/surface.c
index 2acb03c..b66391c 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -113,7 +113,7 @@ PHP_FUNCTION(SDL_CreateRGBSurface)
 	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) {
 		return;
 	}
-	surface = SDL_CreateRGBSurface(flags, width, height, depth, rmask, gmask, bmask, amask);
+	surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask);
 	sdl_surface_to_zval(surface, return_value);
 }
 /* }}} */
@@ -196,7 +196,7 @@ static PHP_METHOD(SDL_Surface, __construct)
 	}
 	zend_restore_error_handling(&error_handling);
 
-	intern->surface = SDL_CreateRGBSurface(flags, width, height, depth, rmask, gmask, bmask, amask);
+	intern->surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask);
 	if (intern->surface) {
 		/* copy flags to be able to check before access to surface */
 		intern->flags = intern->surface->flags;
@@ -1195,15 +1195,15 @@ PHP_FUNCTION(SDL_ConvertPixels)
 	}
 	if (h < 0 || h > src->h || h > dst->h) {
 		h = (src->h > dst->h ? dst->h : src->h);
-		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h);\
+		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %lld", h);
 	}
 	if (sp != src->pitch) {
 		sp = src->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp);\
+		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %lld", sp);
 	}
 	if (dp != dst->pitch) {
 		dp = dst->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp);\
+		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %lld", dp);
 	}
 	RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp));
 }
@@ -1287,51 +1287,49 @@ static zend_object* php_sdl_surface_new(zend_class_entry *class_type)
 }
 /* }}} */
 
+static inline struct php_sdl_surface* php_sdl_surface_from_obj(zend_object *obj) {
+	return (struct php_sdl_surface *) ((char *) (obj) - obj->handlers->offset);
+}
+
 /* {{{ sdl_surface_read_property*/
-zval *sdl_surface_read_property(zval *object, zval *member, int type, void** cache_slot, zval *retval)
+zval *sdl_surface_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *retval)
 {
-	zval tmp_member;
-	zend_object* zobject = Z_OBJ_P(object);
-	struct php_sdl_surface *intern = (struct php_sdl_surface *)((char*)zobject - zobject->handlers->offset);
+	struct php_sdl_surface *intern;
+	char *member_val;
 
- 	if (!intern->surface) {
- 		ZVAL_NULL(retval);
- 		return retval;
-	}
+	intern = php_sdl_surface_from_obj(object);
+	member_val = ZSTR_VAL(member);
 
- 	if (Z_TYPE_P(member) != IS_STRING) {
-		tmp_member = *member;
-		zval_copy_ctor(&tmp_member);
-		convert_to_string(&tmp_member);
-		member = &tmp_member;
+	if (!intern->surface) {
+		retval = zend_std_read_property(object, member, type, cache_slot, retval);
+		return retval;
 	}
 
- 	if (!strcmp(Z_STRVAL_P(member), "flags")) {
+	if (!strcmp(member_val, "flags")) {
 		ZVAL_LONG(retval, intern->surface->flags);
- 	} else if (!strcmp(Z_STRVAL_P(member), "w")) {
+ 	} else if (!strcmp(member_val, "w")) {
 		ZVAL_LONG(retval, intern->surface->w);
- 	} else if (!strcmp(Z_STRVAL_P(member), "h")) {
+ 	} else if (!strcmp(member_val, "h")) {
 		ZVAL_LONG(retval, intern->surface->h);
- 	} else if (!strcmp(Z_STRVAL_P(member), "pitch")) {
+ 	} else if (!strcmp(member_val, "pitch")) {
 		ZVAL_LONG(retval, intern->surface->pitch);
- 	} else if (!strcmp(Z_STRVAL_P(member), "locked")) {
+ 	} else if (!strcmp(member_val, "locked")) {
 		ZVAL_LONG(retval, intern->surface->locked);
- 	} else if (!strcmp(Z_STRVAL_P(member), "format")) {
+ 	} else if (!strcmp(member_val, "format")) {
 		sdl_pixelformat_to_zval(intern->surface->format, retval, SDL_DONTFREE);
- 	} else if (!strcmp(Z_STRVAL_P(member), "clip_rect")) {
+ 	} else if (!strcmp(member_val, "clip_rect")) {
 		sdl_rect_to_zval(&intern->surface->clip_rect, retval);
- 	} else if (!strcmp(Z_STRVAL_P(member), "pixels")) {
+ 	} else if (!strcmp(member_val, "pixels")) {
 		SDL_Pixels pix;
  		pix.pitch  = intern->surface->pitch;
 		pix.h      = intern->surface->h;
 		pix.pixels = (Uint8 *)intern->surface->pixels;
 		sdl_pixels_to_zval(&pix, retval, SDL_DONTFREE);
  	} else {
+		retval = zend_std_read_property(object, member, type, cache_slot, retval);
 		return retval;
 	}
- 	if (member == &tmp_member) {
-		zval_dtor(member);
-	}
+
 	return retval;
 }
 /* }}} */
diff --git a/src/video.c b/src/video.c
index bafef53..9d571c8 100644
--- a/src/video.c
+++ b/src/video.c
@@ -41,7 +41,7 @@ zend_class_entry *get_php_sdl_displaymode_ce(void)
 }
 
 #define update_displaymode_prop(z_value, name, value) \
-	zend_update_property_long(php_sdl_displaymode_ce, z_value, ZEND_STRL(name), value)
+	zend_update_property_long(php_sdl_displaymode_ce, Z_OBJ_P(z_value), ZEND_STRL(name), value)
 
 zend_bool sdl_displaymode_to_zval(SDL_DisplayMode *display, zval *value)
 {
@@ -61,9 +61,9 @@ zend_bool sdl_displaymode_to_zval(SDL_DisplayMode *display, zval *value)
 #define read_displaymode_prop(z_value, name, value) \
 { \
 	zval *val, rv; \
-	val = zend_read_property(php_sdl_displaymode_ce, z_value, ZEND_STRL(name), 0, &rv); \
+	val = zend_read_property(php_sdl_displaymode_ce, Z_OBJ_P(z_value), ZEND_STRL(name), 0, &rv); \
 	convert_to_long(val); \
-	Z_LVAL_P(val) = value = (int)Z_LVAL_P(val); \
+	Z_LVAL_P(val) = (value) = (int)Z_LVAL_P(val); \
 }
 
 zend_bool zval_to_sdl_displaymode(zval *value, SDL_DisplayMode *display)
@@ -526,7 +526,7 @@ PHP_FUNCTION(SDL_DisableScreenSaver)
 
 /* {{{ php_sdl_displaymode_methods[] */
 static const zend_function_entry php_sdl_displaymode_methods[] = {
-	PHP_ME(SDL_DisplayMode, __construct, arginfo_SDL_DisplayMode__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_DisplayMode, __construct, arginfo_SDL_DisplayMode__construct, ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_DisplayMode, __toString,  arginfo_video_none,                 ZEND_ACC_PUBLIC)
 
 	PHP_FE_END
@@ -543,8 +543,8 @@ PHP_MINIT_FUNCTION(sdl_video)
 	memcpy(&php_sdl_displaymode_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
 	zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("format"),       0, ZEND_ACC_PUBLIC);
-	zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("w"),                        0, ZEND_ACC_PUBLIC);
-	zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("h"),                        0, ZEND_ACC_PUBLIC);
+	zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("w"),            0, ZEND_ACC_PUBLIC);
+	zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("h"),            0, ZEND_ACC_PUBLIC);
 	zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("refresh_rate"), 0, ZEND_ACC_PUBLIC);
 
 	return SUCCESS;
diff --git a/src/window.c b/src/window.c
index 0cfdfc6..4522057 100644
--- a/src/window.c
+++ b/src/window.c
@@ -69,12 +69,12 @@ static inline void sdl_window_add_long_property(HashTable *props, const char *na
 }
 
 /* {{{ sdl_window_read_property*/
-static HashTable *sdl_window_get_properties(zval *object)
+static HashTable *sdl_window_get_properties(zend_object *object)
 {
 	HashTable *props;
     zend_string* z_string;
 	zval zv;
-	struct php_sdl_window* intern = php_sdl_window_fetch_object(Z_OBJ_P(object));
+	struct php_sdl_window* intern = php_sdl_window_fetch_object(object);
 
 	props = zend_std_get_properties(object);
 

From 9475a300e802e5e4163c973acd4d5c4b033554a8 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 18 Jun 2021 19:35:42 +0100
Subject: [PATCH 14/53] Remove EXPERIMENTAL file

---
 EXPERIMENTAL | 5 -----
 package.xml  | 1 -
 2 files changed, 6 deletions(-)
 delete mode 100644 EXPERIMENTAL

diff --git a/EXPERIMENTAL b/EXPERIMENTAL
deleted file mode 100644
index 6443e99..0000000
--- a/EXPERIMENTAL
+++ /dev/null
@@ -1,5 +0,0 @@
-this extension is experimental,
-its functions may change their names 
-or move to extension all together 
-so do not rely to much on them 
-you have been warned!
diff --git a/package.xml b/package.xml
index dd393bd..9d8528d 100644
--- a/package.xml
+++ b/package.xml
@@ -42,7 +42,6 @@
     <dir name="/">
       <file role="doc" name="CREDITS"/>
       <file role="doc" name="LICENSE"/>
-      <file role="doc" name="EXPERIMENTAL"/>
       <file role="src" name="config.m4"/>
       <dir name="src">
         <file role="src" name="php_sdl.c"/>

From 13f7f76be5726e098afa17c5d2285d0de994a9b1 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 18 Jun 2021 19:36:45 +0100
Subject: [PATCH 15/53] Add Manuel to CREDITS file

---
 CREDITS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CREDITS b/CREDITS
index 417db3b..19a36f5 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1,2 +1,2 @@
 SDL
-Santiago Lizardo, Remi Collet
+Santiago Lizardo, Remi Collet, Manuel Baldassarri

From 561fd47e02d8b25b5c905661911ce895706a8626 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 18 Jun 2021 19:41:00 +0100
Subject: [PATCH 16/53] Remove php_error warnings

---
 src/pixels.c  | 10 +++++-----
 src/surface.c |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/pixels.c b/src/pixels.c
index 2e67fd0..f9b913e 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -690,15 +690,15 @@ PHP_FUNCTION(SDL_SetPaletteColors)
 	if (ncolors <= 0) {
 		ncolors = count;
 	} else if (ncolors > count) {
-		php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %lld", count, ncolors);
+		php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, ncolors);
 		ncolors = count;
 	}
 	if (first >= intern->palette->ncolors) {
-		php_error_docref(NULL, E_WARNING, "Invalid first color index, %lld >= %d", first, intern->palette->ncolors);
+		php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", first, intern->palette->ncolors);
 		RETURN_LONG(-1);
 	}
 	if (first+ncolors > intern->palette->ncolors) {
-		php_error_docref(NULL, E_WARNING, "Invalid color number, %lld > %d", first+ncolors, intern->palette->ncolors);
+		php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", first+ncolors, intern->palette->ncolors);
 		RETURN_LONG(-1);
 	}
 	colors = emalloc(sizeof(SDL_Color) * ncolors);
@@ -1120,7 +1120,7 @@ PHP_METHOD(SDL_Pixels, GetByte)
 	intern = PHP_SDL_PIXELS_P(z_pixels);
 
 	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%lld,%lld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
+		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
 		RETURN_FALSE;
 	}
 	RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
@@ -1147,7 +1147,7 @@ PHP_METHOD(SDL_Pixels, SetByte)
 	intern = PHP_SDL_PIXELS_P(z_pixels);
 
 	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%lld,%lld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
+		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
 		RETURN_FALSE;
 	}
 	RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
diff --git a/src/surface.c b/src/surface.c
index b66391c..7716fe6 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -1195,15 +1195,15 @@ PHP_FUNCTION(SDL_ConvertPixels)
 	}
 	if (h < 0 || h > src->h || h > dst->h) {
 		h = (src->h > dst->h ? dst->h : src->h);
-		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %lld", h);
+		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h);
 	}
 	if (sp != src->pitch) {
 		sp = src->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %lld", sp);
+		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp);
 	}
 	if (dp != dst->pitch) {
 		dp = dst->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %lld", dp);
+		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp);
 	}
 	RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp));
 }

From ac8197fab469809e4dbec83027db124190e66295 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 18 Jun 2021 19:41:46 +0100
Subject: [PATCH 17/53] Make PHP8 requirement explicit

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 3938853..3eadd15 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allo
 
 * C compiler
 * Automake tools
-* PHP devel
+* PHP8 devel
 * libSDL2 devel libraries and headers
 * UN*X OS (eg Linux, Macos)
 

From 0076e48a150461edbbbf7eaf2448d15def7221a1 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 18 Jun 2021 19:53:19 +0100
Subject: [PATCH 18/53] Bump version to 2.5.0

---
 package.xml   | 85 +++++++++++++++++++++++++++++++--------------------
 src/php_sdl.h |  2 +-
 2 files changed, 53 insertions(+), 34 deletions(-)

diff --git a/package.xml b/package.xml
index 9d8528d..a282e0e 100644
--- a/package.xml
+++ b/package.xml
@@ -1,5 +1,7 @@
 <?xml version="1.0"?>
-<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+<package xmlns="http://pear.php.net/dtd/package-2.0"
+  xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
   <name>sdl</name>
   <channel>pecl.php.net</channel>
   <summary>SDL for PHP</summary>
@@ -17,11 +19,11 @@
     <active>yes</active>
   </lead>
   <!-- Current version -->
-  <date>2020-08-23</date>
+  <date>2021-06-18</date>
   <time>12:00:00</time>
   <version>
-    <release>2.4.0</release>
-    <api>2.4.0</api>
+    <release>2.5.0</release>
+    <api>2.5.0</api>
   </version>
   <stability>
     <release>devel</release>
@@ -29,13 +31,8 @@
   </stability>
   <license uri="http://www.php.net/license">PHP</license>
   <notes>
-  	  - Fix duplicate symbols (remicollet)
-  	  - Fix parameters passed by reference in rect module (kea)
-  	  - Port SDL_Palette and SDL_PixelFormat to PHP7 (kea)
-  	  - Fix surface props initialisation (kea)
-  	  - Fix surface and powerinfo params by ref (kea)
-  	  - Fix SDL_Rect inheritance issue (santiagolizardo)
-  	  - Add SQL_QueryTexture binding (kea)
+    - Add support for PHP8 (Manuel Baldassarri)
+    - Remove support for PHP7 (Manuel Baldassarri)
   </notes>
   <!--/Current version -->
   <contents>
@@ -147,7 +144,7 @@
   <dependencies>
     <required>
       <php>
-        <min>7.4.0</min>
+        <min>8.0.0</min>
       </php>
       <pearinstaller>
         <min>1.10.0</min>
@@ -157,23 +154,45 @@
   <providesextension>sdl</providesextension>
   <extsrcrelease/>
   <changelog>
-  	  <release>
-  <date>2019-09-08</date>
-  <time>12:00:00</time>
-  <version>
-    <release>2.3.0</release>
-    <api>2.3.0</api>
-  </version>
-  <stability>
-    <release>devel</release>
-    <api>devel</api>
-  </stability>
-  <license uri="http://www.php.net/license">PHP</license>
-  <notes>
+    <release>
+      <date>2020-08-23</date>
+      <time>12:00:00</time>
+      <version>
+        <release>2.4.0</release>
+        <api>2.4.0</api>
+      </version>
+      <stability>
+        <release>devel</release>
+        <api>devel</api>
+      </stability>
+      <license uri="http://www.php.net/license">PHP</license>
+      <notes>
+  	  - Fix duplicate symbols (remicollet)
+  	  - Fix parameters passed by reference in rect module (kea)
+  	  - Port SDL_Palette and SDL_PixelFormat to PHP7 (kea)
+  	  - Fix surface props initialisation (kea)
+  	  - Fix surface and powerinfo params by ref (kea)
+  	  - Fix SDL_Rect inheritance issue (santiagolizardo)
+  	  - Add SQL_QueryTexture binding (kea)
+      </notes>
+    </release>
+    <release>
+      <date>2019-09-08</date>
+      <time>12:00:00</time>
+      <version>
+        <release>2.3.0</release>
+        <api>2.3.0</api>
+      </version>
+      <stability>
+        <release>devel</release>
+        <api>devel</api>
+      </stability>
+      <license uri="http://www.php.net/license">PHP</license>
+      <notes>
   	  - Fix out of bounds error (remicollet)
   	  - Add basic joystick/gamepad support (santiagolizardo)
-  </notes>
-  	  </release>
+      </notes>
+    </release>
     <release>
       <date>2019-09-02</date>
       <time>12:00:00</time>
@@ -189,7 +208,7 @@
       <notes>
   	  - Fix undefined symbol (sdl_window_to_zval)
   	  - Tidy up GL context creation 
-  </notes>
+      </notes>
     </release>
     <release>
       <date>2019-08-28</date>
@@ -204,10 +223,10 @@
       </stability>
       <license uri="http://www.php.net/license">PHP</license>
       <notes>
-  	  	  	  - Add support for window events. (Benoit Viguier)
-  	  	  	  - Add support for the SDL_RenderCopyEx, SDL_RenderDrawLine and SDL_RenderDrawRect functions. (Benoit Viguier)
-  	  	  	  - Fix memory leak in the SDL_RenderCopy function. (Benoit Viguier)
-  	  	  </notes>
+        - Add support for window events. (Benoit Viguier)
+        - Add support for the SDL_RenderCopyEx, SDL_RenderDrawLine and SDL_RenderDrawRect functions. (Benoit Viguier)
+        - Fix memory leak in the SDL_RenderCopy function. (Benoit Viguier)
+      </notes>
     </release>
     <release>
       <stability>
@@ -224,7 +243,7 @@
 	  	  - Code updated to support PHP7.
 	  	  - Code that could be implemented in userland was removed from the extension.
 	  	  - Unit tests improvements/changes.
-  	  </notes>
+      </notes>
     </release>
   </changelog>
 </package>
diff --git a/src/php_sdl.h b/src/php_sdl.h
index ac2d6ee..bd8a498 100644
--- a/src/php_sdl.h
+++ b/src/php_sdl.h
@@ -32,7 +32,7 @@ extern "C" {
 #include <php.h>
 #include <zend_exceptions.h>
 
-#define PHP_SDL_VERSION "2.4.0"
+#define PHP_SDL_VERSION "2.5.0"
 
 #if defined(__APPLE__) && defined(__MACH__)
 #include <SDL2/SDL.h>

From bc9f203bfe16c93bfdf4735202df671fe79b5753 Mon Sep 17 00:00:00 2001
From: Zorobabel <zorobabel@users.noreply.github.com>
Date: Tue, 12 Oct 2021 14:14:31 -0500
Subject: [PATCH 19/53] Config file for Windows (#53)

* Config file for Windows

* Tabs removed
---
 config.w32 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 config.w32

diff --git a/config.w32 b/config.w32
new file mode 100644
index 0000000..5c35324
--- /dev/null
+++ b/config.w32
@@ -0,0 +1,18 @@
+// vim:ft=javascript
+
+ARG_ENABLE('sdl', 'Whether to enable SDL2 support', 'no');
+
+if(PHP_SDL != 'no') {
+    CHECK_LIB("SDL2.lib", "sdl", PHP_SDL);
+    CHECK_LIB("SDL2main.lib", "sdl", PHP_SDL);
+    CHECK_LIB("SDL2test.lib", "sdl", PHP_SDL);
+
+    var sdl_sources = 'php_sdl.c blendmode.c cpuinfo.c error.c event.c filesystem.c glcontext.c joystick.c keyboard.c messagebox.c mouse.c mutex.c pixels.c platform.c power.c rect.c render.c rwops.c sdl.c shape.c surface.c timer.c version.c video.c window.c';
+
+    EXTENSION('sdl', sdl_sources, PHP_SDL_SHARED);
+
+    var sdl_headers = 'php_sdl.h blendmode.h cpuinfo.h error.h event.h filesystem.h glcontext.h joystick.h keyboard.h messagebox.h mouse.h mutex.h pixels.h platform.h power.h rect.h render.h rwops.h sdl.h shape.h surface.h timer.h version.h video.h window.h';
+
+    PHP_INSTALL_HEADERS('ext/sdl', sdl_headers);
+    AC_DEFINE('HAVE_SDL', 1);
+}

From ca7eb21022d734a2287459612673e056803d8511 Mon Sep 17 00:00:00 2001
From: Manuel Baldassarri <kea@keasoft.it>
Date: Sun, 31 Oct 2021 22:31:02 +0100
Subject: [PATCH 20/53] Rename width parameter in SDL_Rect::__construct() (#54)

fix "Duplicate parameter name $y for function SDL_Rect::__construct()"
---
 src/rect.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/rect.h b/src/rect.h
index 91168d5..718c1d1 100644
--- a/src/rect.h
+++ b/src/rect.h
@@ -39,7 +39,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect__construct, /*unused*/0, /*ret ref*/0, /
        ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0)
        ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0)
        ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0)
-       ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0)
+       ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
 

From 36956f39c93448172f58cd9aff64fd8a4a895118 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sat, 11 Dec 2021 22:34:10 +0000
Subject: [PATCH 21/53] Add SDL_PointInRect function

---
 .gitignore                         |  1 +
 examples/001-sdl-version.php       |  4 +---
 examples/002-error-messagebox.php  | 10 +++++-----
 examples/003-messagebox-inputs.php | 23 +++++++++++++----------
 examples/bootstrap.php             | 16 ++++++++++++++--
 src/messagebox.c                   |  2 ++
 src/php_sdl.c                      |  1 +
 src/rect.c                         | 18 ++++++++++++++++++
 src/rect.h                         |  6 ++++++
 tests/029-point-in-rect.phpt       | 17 +++++++++++++++++
 10 files changed, 78 insertions(+), 20 deletions(-)
 create mode 100644 tests/029-point-in-rect.phpt

diff --git a/.gitignore b/.gitignore
index a3f5442..e49381f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,3 +58,4 @@ php_test_results*.txt
 configure.ac
 .vscode
 .DS_Store
+tags
diff --git a/examples/001-sdl-version.php b/examples/001-sdl-version.php
index f544161..8828e30 100644
--- a/examples/001-sdl-version.php
+++ b/examples/001-sdl-version.php
@@ -1,6 +1,4 @@
-<?php
-
-declare(strict_types=1);
+<?php declare(strict_types=1);
 
 require 'bootstrap.php';
 
diff --git a/examples/002-error-messagebox.php b/examples/002-error-messagebox.php
index c4012b5..1592c73 100644
--- a/examples/002-error-messagebox.php
+++ b/examples/002-error-messagebox.php
@@ -1,11 +1,11 @@
-<?php
-
-declare(strict_types=1);
+<?php declare(strict_types=1);
 
 require 'bootstrap.php';
 
-SDL_Init(SDL_INIT_EVERYTHING);
+initSDLOrExit();
 
-SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, 'Error example', 'An error has occurred (just kidding)', null);
+if(SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, 'Error example', 'An error has occurred (just kidding)', null) !== 0) {
+	printSdlErrorAndExit();
+}
 
 SDL_Quit();
diff --git a/examples/003-messagebox-inputs.php b/examples/003-messagebox-inputs.php
index f3a985e..fbd33e5 100644
--- a/examples/003-messagebox-inputs.php
+++ b/examples/003-messagebox-inputs.php
@@ -1,17 +1,18 @@
-<?php
-
-declare(strict_types=1);
+<?php declare(strict_types=1);
 
 require 'bootstrap.php';
 
-if (false === SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, 'Message box title', 'This is an example message box')) {
+if(SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, 'Message box title', 'This is an example message box') !== 0) {
 	fprintf(STDERR, 'Unable to show simple message box');
-	return;
+	exit(1);
 }
 
+const BUTTON_ID_YES = 1;
+const BUTTON_ID_NO = 0;
+
 $buttons = [
-	new SDL_MessageBoxButtonData(SDL_MessageBoxButtonData::RETURNKEY_DEFAULT, 1, 'Yes'),
-	new SDL_MessageBoxButtonData(SDL_MessageBoxButtonData::ESCAPEKEY_DEFAULT, 0, 'No'),
+	new SDL_MessageBoxButtonData(SDL_MessageBoxButtonData::RETURNKEY_DEFAULT, BUTTON_ID_YES, 'Yes'),
+	new SDL_MessageBoxButtonData(SDL_MessageBoxButtonData::ESCAPEKEY_DEFAULT, BUTTON_ID_NO, 'No'),
 ];
 $colors = [
 	SDL_MessageBoxColor::BACKGROUND => new SDL_MessageBoxColor(0, 0, 0),
@@ -21,6 +22,8 @@
 	SDL_MessageBoxColor::BUTTON_SELECTED => new SDL_MessageBoxColor(0, 0, 255),
 ];
 $dialog = new SDL_MessageBoxData(SDL_MessageBoxData::INFORMATION, "Message box data", 'Select Yes or No', $buttons, $colors);
-$dialog->Show($buttonId);
-
-echo 'Button selection: ', var_export($buttonId), PHP_EOL;
+if(0 === $dialog->Show($buttonId)) {
+	echo 'Button selection: ', $buttonId === BUTTON_ID_YES ? 'Yes' : 'No', PHP_EOL;
+} else {
+	printSdlErrorAndExit();
+}
diff --git a/examples/bootstrap.php b/examples/bootstrap.php
index 417728c..b635538 100644
--- a/examples/bootstrap.php
+++ b/examples/bootstrap.php
@@ -1,8 +1,20 @@
-<?php
+<?php declare(strict_types=1);
+
+error_reporting(E_ALL);
 
 if (!extension_loaded('sdl')) {
     fprintf(STDERR, "The sdl extension is not loaded. Make sure it is in the system and there is a line for it on the php.ini file (eg \"extension=sdl.so\")");
     exit(1);
 }
 
-error_reporting(E_ALL);
+function initSDLOrExit() {
+	if(SDL_Init(SDL_INIT_EVERYTHING) !== 0) {
+		printSdlErrorAndExit();
+	}
+}
+
+function printSdlErrorAndExit() {
+	fprintf(STDERR, "ERROR: %s\n", SDL_GetError());
+	exit(1);
+}
+
diff --git a/src/messagebox.c b/src/messagebox.c
index 86be6c0..3aadf53 100644
--- a/src/messagebox.c
+++ b/src/messagebox.c
@@ -508,6 +508,8 @@ PHP_FUNCTION(SDL_ShowMessageBox)
 		zval_dtor(z_id);
 		ZVAL_LONG(z_id, (long)id);
 	}
+
+	RETVAL_LONG(res);
 }
 /* }}} */
 
diff --git a/src/php_sdl.c b/src/php_sdl.c
index 0bd104c..38938f9 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -262,6 +262,7 @@ static zend_function_entry sdl_functions[] = {
 	ZEND_FE(SDL_UnionRect,					arginfo_SDL_Rect3)
 	ZEND_FE(SDL_IntersectRectAndLine,		arginfo_SDL_IntersectRectAndLine)
 	ZEND_FE(SDL_EnclosePoints,				arginfo_SDL_EnclosePoints)
+	ZEND_FE(SDL_PointInRect,				arginfo_SDL_PointInRect)
 
 	// Events
 	ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent)
diff --git a/src/rect.c b/src/rect.c
index 38112ed..aee9676 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -405,6 +405,24 @@ PHP_FUNCTION(SDL_IntersectRectAndLine)
 }
 /* }}} */
 
+PHP_FUNCTION(SDL_PointInRect)
+{
+	zval *z_point, *z_rect;
+	SDL_Point point;
+	SDL_Rect rect;
+
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_point, php_sdl_point_ce, &z_rect, php_sdl_rect_ce) == FAILURE) {
+		return;
+	}
+	zval_to_sdl_rect(z_rect, &rect);
+	zval_to_sdl_point(z_point, &point);
+
+	if (SDL_PointInRect(&point, &rect)) {
+		RETURN_TRUE;
+	}
+	RETURN_FALSE;
+}
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0)
 ZEND_END_ARG_INFO()
 
diff --git a/src/rect.h b/src/rect.h
index 718c1d1..916337d 100644
--- a/src/rect.h
+++ b/src/rect.h
@@ -100,6 +100,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect_IntersectLine, 0, 0, 4)
        ZEND_ARG_INFO(1, Y2)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_PointInRect, 0, 0, 2)
+       ZEND_ARG_OBJ_INFO(0, point, SDL_Point, 0)
+       ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
+ZEND_END_ARG_INFO()
+
 PHP_FUNCTION(SDL_RectEmpty);
 PHP_FUNCTION(SDL_RectEquals);
 PHP_FUNCTION(SDL_HasIntersection);
@@ -107,6 +112,7 @@ PHP_FUNCTION(SDL_IntersectRect);
 PHP_FUNCTION(SDL_UnionRect);
 PHP_FUNCTION(SDL_EnclosePoints);
 PHP_FUNCTION(SDL_IntersectRectAndLine);
+PHP_FUNCTION(SDL_PointInRect);
 
 PHP_MINIT_FUNCTION(sdl_rect);
 
diff --git a/tests/029-point-in-rect.phpt b/tests/029-point-in-rect.phpt
new file mode 100644
index 0000000..4fba04c
--- /dev/null
+++ b/tests/029-point-in-rect.phpt
@@ -0,0 +1,17 @@
+--TEST--
+SDL_PointInRect test suite
+--SKIPIF--
+<?php
+require 'test-functions.php';
+--FILE--
+SUITE: Start
+<?php
+var_dump(SDL_PointInRect(new SDL_Point(10, 20), new SDL_Rect(100, 200, 50, 50)));
+var_dump(SDL_PointInRect(new SDL_Point(10, 20), new SDL_Rect(0, 10, 50, 50)));
+?>
+SUITE: End
+--EXPECTF--
+SUITE: Start
+bool(false)
+bool(true)
+SUITE: End

From fcb80722e9f2060903c807d2c16cc690bc8bf122 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Tue, 18 Jan 2022 20:26:50 +0000
Subject: [PATCH 22/53] Update license

---
 LICENSE | 69 ++++-----------------------------------------------------
 1 file changed, 4 insertions(+), 65 deletions(-)

diff --git a/LICENSE b/LICENSE
index 42536af..e4e776b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,68 +1,7 @@
--------------------------------------------------------------------- 
-                  The PHP License, version 3.01
-Copyright (c) 1999 - 2012 The PHP Group. All rights reserved.
--------------------------------------------------------------------- 
+Copyright 2022 Santiago Lizardo
 
-Redistribution and use in source and binary forms, with or without
-modification, is permitted provided that the following conditions
-are met:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 
-  1. Redistributions of source code must retain the above copyright
-     notice, this list of conditions and the following disclaimer.
- 
-  2. Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-     the documentation and/or other materials provided with the
-     distribution.
- 
-  3. The name "PHP" must not be used to endorse or promote products
-     derived from this software without prior written permission. For
-     written permission, please contact group@php.net.
-  
-  4. Products derived from this software may not be called "PHP", nor
-     may "PHP" appear in their name, without prior written permission
-     from group@php.net.  You may indicate that your software works in
-     conjunction with PHP by saying "Foo for PHP" instead of calling
-     it "PHP Foo" or "phpfoo"
- 
-  5. The PHP Group may publish revised and/or new versions of the
-     license from time to time. Each version will be given a
-     distinguishing version number.
-     Once covered code has been published under a particular version
-     of the license, you may always continue to use it under the terms
-     of that version. You may also choose to use such covered code
-     under the terms of any subsequent version of the license
-     published by the PHP Group. No one other than the PHP Group has
-     the right to modify the terms applicable to covered code created
-     under this License.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 
-  6. Redistributions of any form whatsoever must retain the following
-     acknowledgment:
-     "This product includes PHP software, freely available from
-     <http://www.php.net/software/>".
-
-THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND 
-ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 
-PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PHP
-DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
-INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-OF THE POSSIBILITY OF SUCH DAMAGE.
-
--------------------------------------------------------------------- 
-
-This software consists of voluntary contributions made by many
-individuals on behalf of the PHP Group.
-
-The PHP Group can be contacted via Email at group@php.net.
-
-For more information on the PHP Group and the PHP project, 
-please see <http://www.php.net>.
-
-PHP includes the Zend Engine, freely available at
-<http://www.zend.com>.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

From db76b1264fb3e1e50e29803bf0584121f2f3dc10 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Tue, 18 Jan 2022 20:27:09 +0000
Subject: [PATCH 23/53] Use HTTPS in URL

---
 src/blendmode.c  | 2 +-
 src/cpuinfo.c    | 2 +-
 src/error.c      | 2 +-
 src/event.c      | 2 +-
 src/filesystem.c | 2 +-
 src/glcontext.c  | 2 +-
 src/keyboard.c   | 2 +-
 src/messagebox.c | 2 +-
 src/mouse.c      | 2 +-
 src/mutex.c      | 2 +-
 src/php_sdl.c    | 2 +-
 src/pixels.c     | 2 +-
 src/platform.c   | 2 +-
 src/power.c      | 2 +-
 src/rect.c       | 2 +-
 src/render.c     | 2 +-
 src/rwops.c      | 2 +-
 src/sdl.c        | 2 +-
 src/shape.c      | 2 +-
 src/surface.c    | 2 +-
 src/timer.c      | 2 +-
 src/version.c    | 2 +-
 src/video.c      | 2 +-
 src/window.c     | 2 +-
 24 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/blendmode.c b/src/blendmode.c
index c088e53..decb075 100644
--- a/src/blendmode.c
+++ b/src/blendmode.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/cpuinfo.c b/src/cpuinfo.c
index fc9d1af..eba2dae 100644
--- a/src/cpuinfo.c
+++ b/src/cpuinfo.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/error.c b/src/error.c
index 4b1d3ce..dc99886 100644
--- a/src/error.c
+++ b/src/error.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/event.c b/src/event.c
index 027dbf3..a015ed7 100644
--- a/src/event.c
+++ b/src/event.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/filesystem.c b/src/filesystem.c
index 3cdc93b..9bf9263 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/glcontext.c b/src/glcontext.c
index 889bdab..f285047 100644
--- a/src/glcontext.c
+++ b/src/glcontext.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/keyboard.c b/src/keyboard.c
index 6a76c6a..cec4b62 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/messagebox.c b/src/messagebox.c
index 3aadf53..8613231 100644
--- a/src/messagebox.c
+++ b/src/messagebox.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/mouse.c b/src/mouse.c
index aa59cd1..3f60e05 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/mutex.c b/src/mutex.c
index 5bd65c7..d2825a5 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/php_sdl.c b/src/php_sdl.c
index 38938f9..5356520 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/pixels.c b/src/pixels.c
index f9b913e..26a5388 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/platform.c b/src/platform.c
index 40d1268..81f0baf 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/power.c b/src/power.c
index d59b4be..8628c4e 100644
--- a/src/power.c
+++ b/src/power.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/rect.c b/src/rect.c
index aee9676..9e9cda1 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/render.c b/src/render.c
index 1e874c9..8f1d143 100644
--- a/src/render.c
+++ b/src/render.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/rwops.c b/src/rwops.c
index 290830d..5d0400e 100644
--- a/src/rwops.c
+++ b/src/rwops.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/sdl.c b/src/sdl.c
index 2f4eabf..2ab6bb3 100644
--- a/src/sdl.c
+++ b/src/sdl.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/shape.c b/src/shape.c
index 786b81f..99c086b 100644
--- a/src/shape.c
+++ b/src/shape.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/surface.c b/src/surface.c
index 7716fe6..ec39c4c 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/timer.c b/src/timer.c
index 67c0af9..d0cd321 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/version.c b/src/version.c
index 69cea57..184bdfd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/video.c b/src/video.c
index 9d571c8..5670e04 100644
--- a/src/video.c
+++ b/src/video.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
diff --git a/src/window.c b/src/window.c
index 4522057..71c6a16 100644
--- a/src/window.c
+++ b/src/window.c
@@ -7,7 +7,7 @@
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
+  | https://www.php.net/license/3_01.txt                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |

From e70f1f41af0f29ab7616110d3418ff435c9670c2 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Tue, 18 Jan 2022 20:27:17 +0000
Subject: [PATCH 24/53] Update git ignore

---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index e49381f..cf929d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,3 +59,4 @@ configure.ac
 .vscode
 .DS_Store
 tags
+*.dep

From 9a942c58b39b1e32e6ec737e1d8938b39cc44bbc Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Wed, 19 Jan 2022 21:42:02 +0000
Subject: [PATCH 25/53] Update README

---
 README.md | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/README.md b/README.md
index 3eadd15..f8d8de8 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allo
 
 * C compiler
 * Automake tools
-* PHP8 devel
+* PHP8.1 devel
 * libSDL2 devel libraries and headers
 * UN*X OS (eg Linux, Macos)
 
@@ -40,17 +40,17 @@ The SDL extension mimics in almost every single aspect to the official C library
 Standard SDL2 API is available in procedural style:
 
 ```php
-    $window = SDL_CreateWindow( "Foo window", 500, 50, 350, 300, SDL_WINDOW_SHOWN+SDL_WINDOW_RESIZABLE);
-    SDL_SetWindowTitle($window, "Some new title");
-    SDL_DestroyWindow($window);
+$window = SDL_CreateWindow( "Foo window", 500, 50, 350, 300, SDL_WINDOW_SHOWN+SDL_WINDOW_RESIZABLE);
+SDL_SetWindowTitle($window, "Some new title");
+SDL_DestroyWindow($window);
 ```
 
 And is also available in object oriented style:
 
 ```php
-    $window = new SDL_Window( "Foo window", 100, 50, 350, 300, SDL_Window::SHOWN|SDL_Window::RESIZABLE);
-    $window->SetTitle("Some new title");
-    unset($window); // will destroy the window
+$window = new SDL_Window( "Foo window", 100, 50, 350, 300, SDL_Window::SHOWN|SDL_Window::RESIZABLE);
+$window->SetTitle("Some new title");
+unset($window); // will destroy the window
 ```
 
 Complete examples can be found in the [examples](examples) folder.
@@ -68,15 +68,10 @@ Complete examples can be found in the [examples](examples) folder.
 To compile your new extension, you will have to execute the following steps:
 
 ```bash
-$ phpize
-$ ./configure [--enable--sdl] 
-$ make
-$ make test
-$ [sudo] make install
+phpize
+./configure [--enable--sdl] 
+make
+make test
+[sudo] make install
 ```
 
-## Support and feature requests
-
-Please submit anything that needs our attention to the [issues section](https://github.com/php-sdl/extension/issues) on Github. We are commited to attend any request in a short timespan if it's a sensible matter.
-
-

From f765d7797b04979bfeb3fd37d95445e20c45ab4f Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Wed, 19 Jan 2022 22:35:40 +0000
Subject: [PATCH 26/53] Fix broken UTs

---
 README.md    |  4 ++--
 src/pixels.c | 45 +++++++++++++++++++++++++++++++--------------
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md
index f8d8de8..67b0a6b 100644
--- a/README.md
+++ b/README.md
@@ -69,9 +69,9 @@ To compile your new extension, you will have to execute the following steps:
 
 ```bash
 phpize
-./configure [--enable--sdl] 
+./configure [--with--sdl] 
 make
 make test
-[sudo] make install
+sudo make install
 ```
 
diff --git a/src/pixels.c b/src/pixels.c
index 26a5388..04af620 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -548,9 +548,9 @@ static PHP_METHOD(SDL_Palette, count)
 }
 /* }}} */
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offset, 0, 0, 1)
-	   ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetExists, 0, 1, _IS_BOOL, 0)
+	ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO();
 
 /* {{{ proto SDL_Palette, offsetExists(int offset) */
 PHP_METHOD(SDL_Palette, offsetExists)
@@ -569,6 +569,10 @@ PHP_METHOD(SDL_Palette, offsetExists)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetGet, 0, 1, IS_MIXED, 1)
+	ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO();
+
 /* {{{ proto SDL_Palette, offsetGet(int offset) */
 PHP_METHOD(SDL_Palette, offsetGet)
 {
@@ -587,6 +591,10 @@ PHP_METHOD(SDL_Palette, offsetGet)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetUnset, 0, 1, IS_VOID, 0)
+	ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO();
+
 /* {{{ proto SDL_Palette, offsetUnset(int offset) */
 PHP_METHOD(SDL_Palette, offsetUnset)
 {
@@ -607,11 +615,12 @@ PHP_METHOD(SDL_Palette, offsetUnset)
 }
 /* }}} */
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 2, IS_VOID, 0)
 	   ZEND_ARG_INFO(0, offset)
 	   ZEND_ARG_INFO(0, color)
 ZEND_END_ARG_INFO()
 
+
 /* {{{ proto SDL_Palette, offsetSet(int offset, int value) */
 PHP_METHOD(SDL_Palette, offsetSet)
 {
@@ -1021,9 +1030,9 @@ static PHP_METHOD(SDL_Pixels, count)
 }
 /* }}} */
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offset, 0, 0, 1)
-	   ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetExists, 0, 1, _IS_BOOL, 0)
+	ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO();
 
 /* {{{ proto SDL_Pixels, offsetExists(int offset) */
 PHP_METHOD(SDL_Pixels, offsetExists)
@@ -1042,6 +1051,10 @@ PHP_METHOD(SDL_Pixels, offsetExists)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetGet, 0, 1, IS_MIXED, 1)
+	ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO();
+
 /* {{{ proto SDL_Pixels, offsetGet(int offset) */
 PHP_METHOD(SDL_Pixels, offsetGet)
 {
@@ -1060,6 +1073,10 @@ PHP_METHOD(SDL_Pixels, offsetGet)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetUnset, 0, 1, IS_VOID, 0)
+	ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO();
+
 /* {{{ proto SDL_Pixels, offsetUnset(int offset) */
 PHP_METHOD(SDL_Pixels, offsetUnset)
 {
@@ -1078,7 +1095,7 @@ PHP_METHOD(SDL_Pixels, offsetUnset)
 }
 /* }}} */
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 2, IS_VOID, 0)
 	   ZEND_ARG_INFO(0, offset)
 	   ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO()
@@ -1525,10 +1542,10 @@ static const zend_function_entry php_sdl_palette_methods[] = {
 	PHP_ME(SDL_Palette, __construct,   arginfo_SDL_AllocPalette,        ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Palette, __toString,    arginfo_palette_none,            ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Palette, count,         arginfo_palette_none,            ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, offsetExists,  arginfo_SDL_Palette_offset,      ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, offsetGet,     arginfo_SDL_Palette_offset,      ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, offsetExists,  arginfo_SDL_Palette_offsetExists,ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, offsetGet,     arginfo_SDL_Palette_offsetGet,   ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Palette, offsetSet,     arginfo_SDL_Palette_offsetSet,   ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, offsetUnset,   arginfo_SDL_Palette_offset,      ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, offsetUnset,   arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
 	PHP_FALIAS(Free,             SDL_FreePalette,           arginfo_palette_none)
@@ -1560,10 +1577,10 @@ static const zend_function_entry php_sdl_pixels_methods[] = {
 	PHP_ME(SDL_Pixels,    __construct,   arginfo_SDL_Pixels__construct,     ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels,    __toString,    arginfo_format_none,               ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels,    count,         arginfo_format_none,               ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    offsetExists,  arginfo_SDL_Pixels_offset,         ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    offsetGet,     arginfo_SDL_Pixels_offset,         ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels,    offsetExists,  arginfo_SDL_Pixels_offsetExists,   ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels,    offsetGet,     arginfo_SDL_Pixels_offsetGet,      ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels,    offsetSet,     arginfo_SDL_Pixels_offsetSet,      ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    offsetUnset,   arginfo_SDL_Pixels_offset,         ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels,    offsetUnset,   arginfo_SDL_Pixels_offsetUnset,    ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels,    GetByte,       arginfo_SDL_Pixels_GetByte,        ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels,    SetByte,       arginfo_SDL_Pixels_SetByte,        ZEND_ACC_PUBLIC)
 	PHP_FE_END

From 719c474eb70eb83e0a152c60655c93e8d907ed2b Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Wed, 19 Jan 2022 23:04:07 +0000
Subject: [PATCH 27/53] Use github actions

---
 .github/workflows/build-test.yml | 16 ++++++++++++++++
 .travis.yml                      | 11 -----------
 Dockerfile                       |  8 +++++---
 3 files changed, 21 insertions(+), 14 deletions(-)
 create mode 100644 .github/workflows/build-test.yml
 delete mode 100644 .travis.yml

diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
new file mode 100644
index 0000000..c08e836
--- /dev/null
+++ b/.github/workflows/build-test.yml
@@ -0,0 +1,16 @@
+name: Build and test
+
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+        - uses: actions/checkout@v1
+        - name: Build and tag image
+          run: docker build -t ponup/php-sdl .
+        - name: Run tests
+          run: docker run --rm ponup/php-sdl 
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index ad9cae6..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-language: php
-
-services:
-  - docker
-
-before_install:
-  - docker build -t ponup/php-sdl .
-
-script:
-  - docker run --rm ponup/php-sdl 
-
diff --git a/Dockerfile b/Dockerfile
index a77b5b9..46322f9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,6 @@
-FROM debian:10
+FROM debian:11
+
+ARG TARGET_PHP_VERSION=8.1
 
 RUN apt-get update
 RUN apt-get install -y make build-essential wget
@@ -6,7 +8,7 @@ RUN apt-get install -y lsb-release apt-transport-https ca-certificates
 RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
 RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
 RUN apt-get update
-RUN apt-get install -y php8.0-dev
+RUN apt-get install -y php${TARGET_PHP_VERSION}-dev
 RUN apt-get install -y libsdl2-dev
 RUN apt-get install -y xvfb
 COPY . /opt/php-sdl
@@ -15,7 +17,7 @@ RUN phpize
 RUN ./configure
 RUN make
 RUN make install
-RUN echo "extension=sdl.so" >> /etc/php/8.0/cli/php.ini
+RUN echo "extension=sdl.so" >> /etc/php/${TARGET_PHP_VERSION}/cli/php.ini
 
 ENTRYPOINT ["/opt/php-sdl/docker-entrypoint.sh"]
 

From a78881cb93fc61c1332ca99e5f06b440c3a01d7d Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Wed, 19 Jan 2022 23:07:30 +0000
Subject: [PATCH 28/53] Remove travis badge

---
 README.md | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/README.md b/README.md
index 67b0a6b..833e7cf 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,3 @@
-
-[![Build Status](https://travis-ci.org/Ponup/php-sdl.svg?branch=master)](https://travis-ci.org/Ponup/php-sdl)
-
 PHP-SDL
 =======
 

From 921984f21fcc2036fd6559a635e3405ec89e5edd Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sun, 23 Jan 2022 18:48:39 +0000
Subject: [PATCH 29/53] Show badge in readme

---
 .github/workflows/build-test.yml | 2 +-
 README.md                        | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index c08e836..2ea5cd9 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -6,7 +6,7 @@ on:
       - master
 
 jobs:
-  build:
+  main:
     runs-on: ubuntu-latest
     steps:
         - uses: actions/checkout@v1
diff --git a/README.md b/README.md
index 833e7cf..5f0c28f 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,5 @@
+[![Build and test](https://github.com/Ponup/php-sdl/actions/workflows/build-test.yml/badge.svg)](https://github.com/Ponup/php-sdl/actions/workflows/build-test.yml)
+
 PHP-SDL
 =======
 

From 00800c1dee42d2131caa7c7b438f73ad304d2c95 Mon Sep 17 00:00:00 2001
From: Manuel Baldassarri <kea@keasoft.it>
Date: Mon, 7 Mar 2022 20:26:35 +0100
Subject: [PATCH 30/53] Add SDL functions binding of float rect and float point
 render functions (#57)

* Add stub for rect

* Fix "wrong type" warnings

* Add SDL_FRect and SDL_FPoint classes

* Add SDL_FRectEmpty, SDL_HasIntersectionF and SDL_IntersectFRect

Add tests and some SDL_FRect/SDL_FPoint fixes

* Add SDL_RenderDrawPointF, SDL_RenderDrawLineF,SDL_RenderDrawRectF,SDL_RenderFillRectF, SDL_RenderCopyF and SDL_RenderCopyExF binding
---
 .gitignore                           |   1 +
 examples/011-draw-with-subpixels.php | 122 ++++++++++
 src/php_sdl.c                        |  20 +-
 src/pixels.c                         |  10 +-
 src/rect.c                           | 346 ++++++++++++++++++++++-----
 src/rect.h                           |  81 +------
 src/rect.stub.php                    |  76 ++++++
 src/rect_arginfo.h                   | 321 +++++++++++++++++++++++++
 src/render.c                         | 165 +++++++++++++
 src/render.h                         |  50 ++++
 src/surface.c                        |   6 +-
 tests/006-rect.phpt                  |  86 ++++++-
 tests/007-rect-oo.phpt               |  60 ++++-
 tests/014-version.phpt               |   2 +-
 tests/017-rwops-stream.phpt          |   2 +-
 tests/028-point.phpt                 |   6 +
 16 files changed, 1207 insertions(+), 147 deletions(-)
 create mode 100644 examples/011-draw-with-subpixels.php
 create mode 100644 src/rect.stub.php
 create mode 100644 src/rect_arginfo.h

diff --git a/.gitignore b/.gitignore
index cf929d8..4e12ae7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 *.lo
 *.la
 .deps
+*.dep
 .libs
 Makefile
 Makefile.fragments
diff --git a/examples/011-draw-with-subpixels.php b/examples/011-draw-with-subpixels.php
new file mode 100644
index 0000000..889d0a0
--- /dev/null
+++ b/examples/011-draw-with-subpixels.php
@@ -0,0 +1,122 @@
+<?php
+
+declare(strict_types=1);
+
+require 'bootstrap.php';
+
+const WINDOW_WIDTH = 800;
+const WINDOW_HEIGHT = 800;
+const SQUARE = WINDOW_WIDTH / 2 - 20;
+
+SDL_Init(SDL_INIT_VIDEO);
+$window = SDL_CreateWindow("Drawing lines on screen", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_WIDTH, WINDOW_HEIGHT, SDL_WINDOW_SHOWN);
+$renderer = SDL_CreateRenderer($window, 0, SDL_RENDERER_ACCELERATED);
+
+$image = SDL_LoadBMP(__DIR__."/spaceship.bmp");
+if ($image === null) {
+	exit('Unable to load image');
+}
+
+$texture = SDL_CreateTextureFromSurface($renderer, $image);
+$drect = $image->clip_rect;
+$drect->y = 500;
+$dfrect = new SDL_FRect($drect->x, $drect->y, $drect->w, $drect->h);
+
+// Draw lines
+function line($iteration, $renderer)
+{
+    $x1 = 40.0;
+    $y1 = 40.0 + $iteration;
+    $x2 = SQUARE;
+    $y2 = SQUARE - $iteration;
+
+    SDL_RenderDrawLineF($renderer, $x1, $y1, $x2, $y2);
+}
+
+// Draw rects
+function rect($iteration, $renderer)
+{
+    $x1 = SQUARE + 20 + $iteration/2;
+    $y1 = SQUARE + $iteration/2 + 20;
+    $w = SQUARE - 10 - $iteration;
+    $h = SQUARE - 10 - $iteration;
+    $rect1 = new SDL_FRect($x1, $y1, $w, $h);
+    $rect2 = new SDL_FRect($x1 + 50, $y1 + 50, $w - 100 , $h - 100);
+    SDL_RenderDrawRectF($renderer, $rect1);
+    SDL_RenderFillRectF($renderer, $rect2);
+}
+
+// Draw points
+function points($iteration, $renderer)
+{
+    for ($x = SQUARE + 80; $x < WINDOW_WIDTH - 60; $x++) {
+        $y = sin($x*6/SQUARE + $iteration/10) * 120 + 250;
+        SDL_RenderDrawPointF($renderer, (float) $x, $y);
+    }
+}
+
+// Draw sprites
+function sprites($iteration, $renderer, $destRect, $destFRect, $texture)
+{
+    $destFRect->x = $iteration;
+    $destRect->x = (int) $destFRect->x + 100;
+    if (SDL_RenderCopyEx($renderer, $texture, null, $destRect, $iteration, null, SDL_FLIP_NONE) != 0) {
+        echo SDL_GetError(), PHP_EOL;
+    }
+    if (SDL_RenderCopyExF($renderer, $texture, null, $destFRect, $iteration, null, SDL_FLIP_NONE) != 0) {
+        echo SDL_GetError(), PHP_EOL;
+    }
+
+    $destRect2 = clone $destRect;
+    $destFRect2 = clone $destFRect;
+    $destRect2->y += 100;
+    $destFRect2->y += 100;
+    if (SDL_RenderCopy($renderer, $texture, null, $destRect2) != 0) {
+        echo SDL_GetError(), PHP_EOL;
+    }
+    if (SDL_RenderCopyF($renderer, $texture, null, $destFRect2) != 0) {
+        echo SDL_GetError(), PHP_EOL;
+    }
+}
+
+function getIncrement($i, $increment)
+{
+    if ($i > SQUARE) {
+        return -0.20;
+    }
+
+    if ($i < 20.0) {
+        return 0.20;
+    }
+
+    return $increment;
+}
+
+// Wait for quit event
+$event = new SDL_Event;
+$i = .0;
+$increment = 0.20;
+
+while (true) {
+    if (SDL_PollEvent($event) && $event->type == SDL_QUIT) {
+        break;
+    }
+    // Clear screen
+    SDL_SetRenderDrawColor($renderer, 47, 79, 79, 255);
+    SDL_RenderClear($renderer);
+
+    SDL_SetRenderDrawColor($renderer, 230, 230, 230, 255);
+    $increment = getIncrement($i, $increment);
+    $i += $increment;
+    line($i, $renderer);
+    rect($i, $renderer);
+    points($i, $renderer);
+    sprites($i, $renderer, $drect, $dfrect, $texture);
+
+    SDL_RenderPresent($renderer);
+    SDL_Delay(5);
+}
+
+SDL_DestroyRenderer($renderer);
+SDL_DestroyWindow($window);
+SDL_Quit();
diff --git a/src/php_sdl.c b/src/php_sdl.c
index 5356520..2785d3e 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -33,6 +33,7 @@
 #include "power.h"
 #include "pixels.h"
 #include "rect.h"
+#include "rect_arginfo.h"
 #include "render.h"
 #include "rwops.h"
 #include "sdl.h"
@@ -220,6 +221,13 @@ static zend_function_entry sdl_functions[] = {
 	ZEND_FE(SDL_SetRenderTarget, arginfo_SDL_SetRenderTarget)
 	ZEND_FE(SDL_GetRendererOutputSize, arginfo_SDL_GetRendererOutputSize)
 
+	ZEND_FE(SDL_RenderDrawPointF, arginfo_SDL_RenderDrawPointF)
+	ZEND_FE(SDL_RenderDrawLineF, arginfo_SDL_RenderDrawLineF)
+	ZEND_FE(SDL_RenderDrawRectF, arginfo_SDL_RenderDrawRectF)
+	ZEND_FE(SDL_RenderFillRectF, arginfo_SDL_RenderFillRectF)
+	ZEND_FE(SDL_RenderCopyF, arginfo_SDL_RenderCopyF)
+	ZEND_FE(SDL_RenderCopyExF, arginfo_SDL_RenderCopyExF)
+
 	// Surface
 	ZEND_FE(SDL_CreateRGBSurface,			arginfo_SDL_CreateRGBSurface)
 	ZEND_FE(SDL_FreeSurface,				arginfo_SDL_Surface)
@@ -255,15 +263,19 @@ static zend_function_entry sdl_functions[] = {
 	//PHP_FALIAS(SDL_BlitScaled,    SDL_UpperBlitScaled,    arginfo_SDL_UpperBlit)
 
 	// Rect
-	ZEND_FE(SDL_RectEmpty,					arginfo_SDL_Rect)
-	ZEND_FE(SDL_RectEquals,					arginfo_SDL_Rect2)
-	ZEND_FE(SDL_HasIntersection,			arginfo_SDL_Rect2)
+	ZEND_FE(SDL_RectEmpty,					arginfo_SDL_RectEmpty)
+	ZEND_FE(SDL_RectEquals,					arginfo_SDL_RectEquals)
+	ZEND_FE(SDL_HasIntersection,			arginfo_SDL_HasIntersection)
 	ZEND_FE(SDL_IntersectRect,				arginfo_SDL_IntersectRect)
-	ZEND_FE(SDL_UnionRect,					arginfo_SDL_Rect3)
+	ZEND_FE(SDL_UnionRect,					arginfo_SDL_UnionRect)
 	ZEND_FE(SDL_IntersectRectAndLine,		arginfo_SDL_IntersectRectAndLine)
 	ZEND_FE(SDL_EnclosePoints,				arginfo_SDL_EnclosePoints)
 	ZEND_FE(SDL_PointInRect,				arginfo_SDL_PointInRect)
 
+	ZEND_FE(SDL_FRectEmpty,					arginfo_SDL_FRectEmpty)
+	ZEND_FE(SDL_HasIntersectionF,			arginfo_SDL_HasIntersectionF)
+	ZEND_FE(SDL_IntersectFRect,				arginfo_SDL_IntersectFRect)
+
 	// Events
 	ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent)
 	ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent)
diff --git a/src/pixels.c b/src/pixels.c
index 04af620..8f8cee0 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -699,15 +699,15 @@ PHP_FUNCTION(SDL_SetPaletteColors)
 	if (ncolors <= 0) {
 		ncolors = count;
 	} else if (ncolors > count) {
-		php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, ncolors);
+		php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, (long) ncolors);
 		ncolors = count;
 	}
 	if (first >= intern->palette->ncolors) {
-		php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", first, intern->palette->ncolors);
+		php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", (long) first, intern->palette->ncolors);
 		RETURN_LONG(-1);
 	}
 	if (first+ncolors > intern->palette->ncolors) {
-		php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", first+ncolors, intern->palette->ncolors);
+		php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", (long) (first+ncolors), intern->palette->ncolors);
 		RETURN_LONG(-1);
 	}
 	colors = emalloc(sizeof(SDL_Color) * ncolors);
@@ -1137,7 +1137,7 @@ PHP_METHOD(SDL_Pixels, GetByte)
 	intern = PHP_SDL_PIXELS_P(z_pixels);
 
 	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
+		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long) x, (long) y, intern->pixels.pitch, intern->pixels.h);
 		RETURN_FALSE;
 	}
 	RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
@@ -1164,7 +1164,7 @@ PHP_METHOD(SDL_Pixels, SetByte)
 	intern = PHP_SDL_PIXELS_P(z_pixels);
 
 	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h);
+		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long) x, (long) y, intern->pixels.pitch, intern->pixels.h);
 		RETURN_FALSE;
 	}
 	RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
diff --git a/src/rect.c b/src/rect.c
index 9e9cda1..11d8821 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -18,27 +18,50 @@
 */
 
 #include "rect.h"
+#include "rect_arginfo.h"
 
 static zend_class_entry *php_sdl_rect_ce;
 static zend_object_handlers php_sdl_rect_handlers;
 struct php_sdl_rect {
-	zend_object   zo;
+	zend_object zo;
+};
+
+static zend_class_entry *php_sdl_frect_ce;
+static zend_object_handlers php_sdl_frect_handlers;
+struct php_sdl_frect {
+	zend_object zo;
 };
 
 static zend_class_entry *php_sdl_point_ce;
 static zend_object_handlers php_sdl_point_handlers;
 struct php_sdl_point {
-	zend_object   zo;
+	zend_object zo;
 };
 
+static zend_class_entry *php_sdl_fpoint_ce;
+static zend_object_handlers php_sdl_fpoint_handlers;
+struct php_sdl_fpoint {
+	zend_object zo;
+};
+
+zend_class_entry *get_php_sdl_rect_ce(void)
+{
+	return php_sdl_rect_ce;
+}
+
+zend_class_entry *get_php_sdl_frect_ce(void)
+{
+	return php_sdl_frect_ce;
+}
+
 zend_class_entry *get_php_sdl_point_ce(void)
 {
 	return php_sdl_point_ce;
 }
 
-zend_class_entry *get_php_sdl_rect_ce(void)
+zend_class_entry *get_php_sdl_fpoint_ce(void)
 {
-	return php_sdl_rect_ce;
+	return php_sdl_fpoint_ce;
 }
 
 zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value)
@@ -56,6 +79,21 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value)
 	return 0;
 }
 
+zend_bool sdl_frect_to_zval(SDL_FRect *rect, zval *value)
+{
+	if (rect) {
+		object_init_ex(value, php_sdl_frect_ce);
+		zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, rect->x);
+		zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "y", 1, rect->y);
+		zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "w", 1, rect->w);
+		zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "h", 1, rect->h);
+
+		return 1;
+	}
+	ZVAL_NULL(value);
+	return 0;
+}
+
 zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
 {
 	if (pt) {
@@ -69,6 +107,19 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
 	return 0;
 }
 
+zend_bool sdl_fpoint_to_zval(SDL_FPoint *pt, zval *value)
+{
+	if (pt) {
+		object_init_ex(value, php_sdl_fpoint_ce);
+		zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, pt->x);
+		zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "y", 1, pt->y);
+
+		return 1;
+	}
+	ZVAL_NULL(value);
+	return 0;
+}
+
 zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
 {
 	if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) {
@@ -97,6 +148,34 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
 	return 0;
 }
 
+zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect)
+{
+	if (instanceof_function(Z_OBJCE_P(value), php_sdl_frect_ce)) {
+		zval *val, rv;
+
+		val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
+		convert_to_double(val);
+		Z_DVAL_P(val) = rect->x = (float)Z_DVAL_P(val);
+
+		val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "y", 1, 0, &rv);
+		convert_to_double(val);
+		Z_DVAL_P(val) = rect->y = (float)Z_DVAL_P(val);
+
+		val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "w", 1, 0, &rv);
+		convert_to_double(val);
+		Z_DVAL_P(val) = rect->w = (float)Z_DVAL_P(val);
+
+		val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "h", 1, 0, &rv);
+		convert_to_double(val);
+		Z_DVAL_P(val) = rect->h = (float)Z_DVAL_P(val);
+
+		return 1;
+	}
+	/* create an empty rect */
+	memset(rect, 0, sizeof(SDL_FRect));
+	return 0;
+}
+
 zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
 {
 	if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) {
@@ -117,15 +196,35 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
 	return 0;
 }
 
+zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *pt)
+{
+	if (instanceof_function(Z_OBJCE_P(value), php_sdl_fpoint_ce)) {
+		zval *val, rv;
+
+		val = zend_read_property(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
+		convert_to_double(val);
+		Z_DVAL_P(val) = pt->x = (float)Z_DVAL_P(val);
+
+		val = zend_read_property(php_sdl_fpoint_ce, Z_OBJ_P(value), "y", 1, 0, &rv);
+		convert_to_double(val);
+		Z_DVAL_P(val) = pt->y = (float)Z_DVAL_P(val);
+
+		return 1;
+	}
+	/* create an empty point */
+	memset(pt, 0, sizeof(SDL_FPoint));
+	return 0;
+}
+
 /* {{{ proto SDL_Rect::__construct(, int x, int y, int w, int h)
 
  *  \brief A rectangle, with the origin at the upper left.
 */
-static PHP_METHOD(SDL_Rect, __construct)
+PHP_METHOD(SDL_Rect, __construct)
 {
 	zend_long x = 0, y = 0, w = 0, h = 0;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|llll", &x, &y, &w, &h)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &x, &y, &w, &h)) {
 		return;
 	}
 
@@ -136,9 +235,8 @@ static PHP_METHOD(SDL_Rect, __construct)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Rect::__toString() */
-static PHP_METHOD(SDL_Rect, __toString)
+PHP_METHOD(SDL_Rect, __toString)
 {
 	zend_string *buf;
 	SDL_Rect rect;
@@ -153,11 +251,42 @@ static PHP_METHOD(SDL_Rect, __toString)
 }
 /* }}} */
 
+PHP_METHOD(SDL_FRect, __construct)
+{
+	double x = 0, y = 0, w = 0, h = 0;
+
+	ZEND_PARSE_PARAMETERS_START(4, 4)
+		Z_PARAM_DOUBLE(x)
+		Z_PARAM_DOUBLE(y)
+		Z_PARAM_DOUBLE(w)
+		Z_PARAM_DOUBLE(h)
+	ZEND_PARSE_PARAMETERS_END();
+
+	zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "x", 1, x);
+	zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "y", 1, y);
+	zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "w", 1, w);
+	zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "h", 1, h);
+}
+
+PHP_METHOD(SDL_FRect, __toString)
+{
+	zend_string *buf;
+	SDL_FRect rect;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	zval_to_sdl_frect(getThis(), &rect);
+	buf = strpprintf(0, "SDL_FRect(%f,%f,%f,%f)", rect.x, rect.y, rect.w, rect.h);
+	RETVAL_STR(buf);
+}
+
 /* {{{ proto SDL_Point::__construct(, int x, int y)
 
  *  \brief A rectangle, with the origin at the upper left.
 */
-static PHP_METHOD(SDL_Point, __construct)
+PHP_METHOD(SDL_Point, __construct)
 {
 	zend_long x, y;
 	zend_error_handling error_handling;
@@ -176,7 +305,7 @@ static PHP_METHOD(SDL_Point, __construct)
 
 
 /* {{{ proto SDL_Point::__toString() */
-static PHP_METHOD(SDL_Point, __toString)
+PHP_METHOD(SDL_Point, __toString)
 {
 	zend_string *buf;
 	SDL_Point point;
@@ -191,6 +320,32 @@ static PHP_METHOD(SDL_Point, __toString)
 }
 /* }}} */
 
+PHP_METHOD(SDL_FPoint, __construct)
+{
+	double x = 0, y = 0;
+
+	ZEND_PARSE_PARAMETERS_START(2, 2)
+		Z_PARAM_DOUBLE(x)
+		Z_PARAM_DOUBLE(y)
+	ZEND_PARSE_PARAMETERS_END();
+
+	zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(getThis()), "x", 1, x);
+	zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(getThis()), "y", 1, y);
+}
+
+PHP_METHOD(SDL_FPoint, __toString)
+{
+	zend_string *buf;
+	SDL_FPoint point;
+
+	if (zend_parse_parameters_none() == FAILURE) {
+		return;
+	}
+
+	zval_to_sdl_fpoint(getThis(), &point);
+	buf = strpprintf(0, "SDL_FPoint(%f,%f)", point.x, point.y);
+	RETVAL_STR(buf);
+}
 
 /* {{{ proto bool SDL_RectEmpty(SDL_Rect rect)
 
@@ -211,6 +366,18 @@ PHP_FUNCTION(SDL_RectEmpty)
 }
 /* }}} */
 
+PHP_FUNCTION(SDL_FRectEmpty)
+{
+	zval *object;
+	SDL_FRect rect;
+
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_frect_ce) == FAILURE) {
+		return;
+	}
+	zval_to_sdl_frect(object, &rect);
+
+	RETURN_BOOL((rect.w <= 0.0f) || (rect.h <= 0.0f));
+}
 
 /* {{{ proto bool SDL_RectEquals(SDL_Rect a, SDL_Rect b)
 
@@ -256,6 +423,53 @@ PHP_FUNCTION(SDL_HasIntersection)
 }
 /* }}} */
 
+PHP_FUNCTION(SDL_HasIntersectionF)
+{
+	zval *obj1, *obj2;
+	SDL_FRect A, B;
+	float Amin, Amax, Bmin, Bmax;
+
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce) == FAILURE) {
+		return;
+	}
+	zval_to_sdl_frect(obj1, &A);
+	zval_to_sdl_frect(obj2, &B);
+
+	/** SDL_HasIntersectionF not yet available as public API (SDL <= 2.0.20) */
+	/* Horizontal intersection */
+	Amin = A.x;
+	Amax = Amin + A.w;
+	Bmin = B.x;
+	Bmax = Bmin + B.w;
+	if (Bmin > Amin) {
+		Amin = Bmin;
+	}
+	if (Bmax < Amax) {
+		Amax = Bmax;
+	}
+	if (Amax <= Amin) {
+		RETURN_FALSE;
+	}
+
+	/* Vertical intersection */
+	Amin = A.y;
+	Amax = Amin + A.h;
+	Bmin = B.y;
+	Bmax = Bmin + B.h;
+	if (Bmin > Amin) {
+		Amin = Bmin;
+	}
+	if (Bmax < Amax) {
+		Amax = Bmax;
+	}
+	if (Amax <= Amin) {
+		RETURN_FALSE;
+	}
+
+	RETURN_TRUE;
+//	RETURN_BOOL(SDL_HasIntersectionF(&rect1, &rect2));
+}
+
 /* {{{ proto bool SDL_IntersectRect(SDL_Rect a, SDL_Rect b, SDL_Rect &result)
 
  *  \brief Calculate the intersection of two rectangles.
@@ -276,7 +490,7 @@ PHP_FUNCTION(SDL_IntersectRect)
 	zval_to_sdl_rect(obj1, &rect1);
 	zval_to_sdl_rect(obj2, &rect2);
 	if (SDL_IntersectRect(&rect1, &rect2, &rect3)) {
-		zval_dtor(result);
+		zval_ptr_dtor(result);
 		sdl_rect_to_zval(&rect3, result);
 		RETURN_TRUE;
 	}
@@ -284,6 +498,65 @@ PHP_FUNCTION(SDL_IntersectRect)
 }
 /* }}} */
 
+
+PHP_FUNCTION(SDL_IntersectFRect)
+{
+	zval *obj1, *obj2, *result;
+	SDL_FRect A, B, resultRect;
+	float Amin, Amax, Bmin, Bmax;
+
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce, &result) == FAILURE) {
+		return;
+	}
+	zval_to_sdl_frect(obj1, &A);
+	zval_to_sdl_frect(obj2, &B);
+
+	/** SDL_IntersectFRect does not exists (SDL <= 2.0.20) */
+	/* Special cases for empty rects */
+	if ((A.w <= 0.0f) || (A.h <= 0.0f) || (B.w <= 0.0f) || (B.h <= 0.0f)) {
+		resultRect.w = 0;
+		resultRect.h = 0;
+
+		zval_ptr_dtor(result);
+		sdl_frect_to_zval(&resultRect, result);
+
+		RETURN_FALSE;
+	}
+
+	/* Horizontal intersection */
+	Amin = A.x;
+	Amax = Amin + A.w;
+	Bmin = B.x;
+	Bmax = Bmin + B.w;
+	if (Bmin > Amin)
+		Amin = Bmin;
+	resultRect.x = Amin;
+	if (Bmax < Amax)
+		Amax = Bmax;
+	resultRect.w = Amax - Amin;
+
+	/* Vertical intersection */
+	Amin = A.y;
+	Amax = Amin + A.h;
+	Bmin = B.y;
+	Bmax = Bmin + B.h;
+	if (Bmin > Amin)
+		Amin = Bmin;
+	resultRect.y = Amin;
+	if (Bmax < Amax)
+		Amax = Bmax;
+	resultRect.h = Amax - Amin;
+
+	if (!((resultRect.w <= 0.0f) || (resultRect.h <= 0.0f))) { // !SDL_FRectEmpty
+		zval_ptr_dtor(result);
+		sdl_frect_to_zval(&resultRect, result);
+
+		RETURN_TRUE;
+	}
+
+	RETURN_FALSE;
+}
+
 /* {{{ proto bool SDL_UnionRect(SDL_Rect a, SDL_Rect b, SDL_Rect &result)
 
  *  \brief Calculate the union of two rectangles.
@@ -302,7 +575,7 @@ PHP_FUNCTION(SDL_UnionRect)
 	zval_to_sdl_rect(obj1, &rect1);
 	zval_to_sdl_rect(obj2, &rect2);
 	SDL_UnionRect(&rect1, &rect2, &rect3);
-	zval_dtor(result);
+	zval_ptr_dtor(result);
 	sdl_rect_to_zval(&rect3, result);
 }
 /* }}} */
@@ -356,7 +629,7 @@ PHP_FUNCTION(SDL_EnclosePoints)
 		php_error_docref(NULL, E_WARNING, "no point in provided array");
 
 	} else if (SDL_EnclosePoints(points, nb, &clip, &result)) {
-		zval_dtor(z_result);
+		zval_ptr_dtor(z_result);
 		sdl_rect_to_zval(&result, z_result);
 		RETVAL_TRUE;
 	}
@@ -423,55 +696,20 @@ PHP_FUNCTION(SDL_PointInRect)
 	RETURN_FALSE;
 }
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
-/* {{{ php_sdl_rect_methods[] */
-static const zend_function_entry php_sdl_rect_methods[] = {
-	PHP_ME(SDL_Rect, __construct,     arginfo_SDL_Rect__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Rect, __toString,      arginfo_none,                ZEND_ACC_PUBLIC)
-
-	/* non-static methods */
-	PHP_FALIAS(Empty,            SDL_RectEmpty,            arginfo_none)
-	PHP_FALIAS(Equal,            SDL_RectEquals,           arginfo_SDL_Rect)
-	PHP_FALIAS(HasIntersection,  SDL_HasIntersection,      arginfo_SDL_Rect)
-	PHP_FALIAS(Intersect,        SDL_IntersectRect,        arginfo_SDL_Rect_Result)
-	PHP_FALIAS(Union,            SDL_UnionRect,            arginfo_SDL_Rect_Result)
-	PHP_FALIAS(IntersectLine,    SDL_IntersectRectAndLine, arginfo_SDL_Rect_IntersectLine)
-
-	PHP_FE_END
-};
-/* }}} */
-
-/* {{{ php_sdl_point_methods[] */
-static const zend_function_entry php_sdl_point_methods[] = {
-	PHP_ME(SDL_Point, __construct,     arginfo_SDL_Point__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Point, __toString,      arginfo_none,                 ZEND_ACC_PUBLIC)
-
-	PHP_FE_END
-};
-/* }}} */
-
 /* {{{ MINIT */
 PHP_MINIT_FUNCTION(sdl_rect)
 {
-	zend_class_entry ce_rect, ce_point;
-
-	INIT_CLASS_ENTRY(ce_rect, "SDL_Rect", php_sdl_rect_methods);
-	php_sdl_rect_ce = zend_register_internal_class(&ce_rect);
+	php_sdl_rect_ce = register_class_SDL_Rect();
 	memcpy(&php_sdl_rect_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
-	zend_declare_property_long(php_sdl_rect_ce, "x", 1, 0, ZEND_ACC_PUBLIC);
-	zend_declare_property_long(php_sdl_rect_ce, "y", 1, 0, ZEND_ACC_PUBLIC);
-	zend_declare_property_long(php_sdl_rect_ce, "w", 1, 0, ZEND_ACC_PUBLIC);
-	zend_declare_property_long(php_sdl_rect_ce, "h", 1, 0, ZEND_ACC_PUBLIC);
+	php_sdl_frect_ce = register_class_SDL_FRect();
+	memcpy(&php_sdl_frect_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
-	INIT_CLASS_ENTRY(ce_point, "SDL_Point", php_sdl_point_methods);
-	php_sdl_point_ce = zend_register_internal_class(&ce_point);
+	php_sdl_point_ce = register_class_SDL_Point();
 	memcpy(&php_sdl_point_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
-	zend_declare_property_long(php_sdl_point_ce, "x", 1, 0, ZEND_ACC_PUBLIC);
-	zend_declare_property_long(php_sdl_point_ce, "y", 1, 0, ZEND_ACC_PUBLIC);
+	php_sdl_fpoint_ce = register_class_SDL_FPoint();
+	memcpy(&php_sdl_fpoint_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
 	return SUCCESS;
 }
diff --git a/src/rect.h b/src/rect.h
index 916337d..7552dab 100644
--- a/src/rect.h
+++ b/src/rect.h
@@ -35,84 +35,11 @@ zend_class_entry *get_php_sdl_rect_ce(void);
 zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value);
 zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect);
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect__construct, /*unused*/0, /*ret ref*/0, /*req num args*/0)
-       ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0)
-       ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0)
-       ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0)
-       ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0)
-ZEND_END_ARG_INFO()
+zend_class_entry *get_php_sdl_frect_ce(void);
+zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect);
 
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Point__construct, 0, 0, 2)
-       ZEND_ARG_INFO(0, x)
-       ZEND_ARG_INFO(0, y)
-ZEND_END_ARG_INFO()
-
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect, 0, 0, 1)
-       ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
-ZEND_END_ARG_INFO()
-
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect2, 0, 0, 2)
-       ZEND_ARG_OBJ_INFO(0, rectA, SDL_Rect, 0)
-       ZEND_ARG_OBJ_INFO(0, rectB, SDL_Rect, 0)
-ZEND_END_ARG_INFO()
-
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect3, 0, 0, 3)
-       ZEND_ARG_OBJ_INFO(0, rectA, SDL_Rect, 0)
-       ZEND_ARG_OBJ_INFO(0, rectB, SDL_Rect, 0)
-       ZEND_ARG_INFO(1, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_IntersectRect, 0, 0, 3)
-       ZEND_ARG_OBJ_INFO(0, rectA, SDL_Rect, 0)
-       ZEND_ARG_OBJ_INFO(0, rectB, SDL_Rect, 0)
-       ZEND_ARG_INFO(1, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect_Result, 0, 0, 2)
-       ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
-       ZEND_ARG_INFO(1, result)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_EnclosePoints, 0, 0, 4)
-       ZEND_ARG_ARRAY_INFO(0, point, 0)
-       ZEND_ARG_INFO(0, count)
-       ZEND_ARG_OBJ_INFO(0, clip, SDL_Rect, 0)
-       ZEND_ARG_INFO(1, rect)
-ZEND_END_ARG_INFO()
-
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_IntersectRectAndLine, 0, 0, 5)
-       ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
-       ZEND_ARG_INFO(1, X1)
-       ZEND_ARG_INFO(1, Y1)
-       ZEND_ARG_INFO(1, X2)
-       ZEND_ARG_INFO(1, Y2)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect_IntersectLine, 0, 0, 4)
-       ZEND_ARG_INFO(1, X1)
-       ZEND_ARG_INFO(1, Y1)
-       ZEND_ARG_INFO(1, X2)
-       ZEND_ARG_INFO(1, Y2)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_PointInRect, 0, 0, 2)
-       ZEND_ARG_OBJ_INFO(0, point, SDL_Point, 0)
-       ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
-ZEND_END_ARG_INFO()
-
-PHP_FUNCTION(SDL_RectEmpty);
-PHP_FUNCTION(SDL_RectEquals);
-PHP_FUNCTION(SDL_HasIntersection);
-PHP_FUNCTION(SDL_IntersectRect);
-PHP_FUNCTION(SDL_UnionRect);
-PHP_FUNCTION(SDL_EnclosePoints);
-PHP_FUNCTION(SDL_IntersectRectAndLine);
-PHP_FUNCTION(SDL_PointInRect);
+zend_class_entry *get_php_sdl_fpoint_ce(void);
+zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *rect);
 
 PHP_MINIT_FUNCTION(sdl_rect);
 
diff --git a/src/rect.stub.php b/src/rect.stub.php
new file mode 100644
index 0000000..00f827b
--- /dev/null
+++ b/src/rect.stub.php
@@ -0,0 +1,76 @@
+<?php
+
+/** @generate-class-entries */
+
+function SDL_PointInRect(SDL_Point $p, SDL_Rect $r): bool {}
+function SDL_RectEmpty(SDL_Rect $r): bool {}
+function SDL_RectEquals(SDL_Rect $a, SDL_Rect $b): bool {}
+function SDL_HasIntersection(SDL_Rect $A, SDL_Rect $B): bool {}
+function SDL_IntersectRect(SDL_Rect $A, SDL_Rect $B, ?SDL_Rect &$result): bool {}
+function SDL_UnionRect(SDL_Rect $A, SDL_Rect $B, ?SDL_Rect &$result): void {}
+function SDL_EnclosePoints(SDL_Point $points, int $count, SDL_Rect $clip, ?SDL_Rect &$result): bool {}
+function SDL_IntersectRectAndLine(SDL_Rect $rect, int &$X1, int &$Y1, int &$X2, int &$Y2): bool {}
+
+function SDL_FRectEmpty(SDL_FRect $r): bool {}
+function SDL_HasIntersectionF(SDL_FRect $A, SDL_FRect $B): bool {}
+function SDL_IntersectFRect(SDL_FRect $A, SDL_FRect $B, ?SDL_FRect &$result): bool {}
+
+class SDL_Point
+{
+    public int $x;
+    public int $y;
+
+    public function __construct(int $x, int $y) {}
+    public function __toString(): string {}
+}
+
+class SDL_Rect
+{
+    public int $x;
+    public int $y;
+    public int $w;
+    public int $h;
+
+    public function __construct(int $x, int $y, int $w, int $h) {}
+    public function __toString(): string {}
+
+    /** @alias SDL_RectEmpty */
+    public function Empty(): bool {}
+    /** @alias SDL_RectEquals */
+    public function Equal(SDL_Rect $b): bool {}
+    /** @alias SDL_HasIntersection */
+    public function HasIntersection(SDL_Rect $B): bool {}
+    /** @alias SDL_IntersectRect */
+    public function Intersect(SDL_Rect $B, ?SDL_Rect &$result): bool {}
+    /** @alias SDL_UnionRect */
+    public function Union(SDL_Rect $B, ?SDL_Rect &$result): void {}
+    /** @alias SDL_IntersectRectAndLine */
+    public function IntersectLine(int &$X1, int &$Y1, int &$X2, int &$Y2): bool {}
+}
+
+class SDL_FPoint
+{
+    public float $x;
+    public float $y;
+
+    public function __construct(float $x, float $y) {}
+    public function __toString(): string {}
+}
+
+class SDL_FRect
+{
+    public float $x;
+    public float $y;
+    public float $w;
+    public float $h;
+
+    public function __construct(float $x, float $y, float $w, float $h) {}
+    public function __toString(): string {}
+
+    /** @alias SDL_FRectEmpty */
+    public function Empty(): bool {}
+    /** @alias SDL_HasIntersectionF */
+    public function HasIntersection(SDL_FRect $B): bool {}
+    /** @alias SDL_IntersectFRect */
+    public function Intersect(SDL_FRect $B, ?SDL_FRect &$result): bool {}
+}
diff --git a/src/rect_arginfo.h b/src/rect_arginfo.h
new file mode 100644
index 0000000..15d3d5c
--- /dev/null
+++ b/src/rect_arginfo.h
@@ -0,0 +1,321 @@
+/* This is a generated file, edit the .stub.php file instead.
+ * Stub hash: b651cf1e4fe3661eec5954edc7d62636e1914987 */
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_PointInRect, 0, 2, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, p, SDL_Point, 0)
+	ZEND_ARG_OBJ_INFO(0, r, SDL_Rect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RectEmpty, 0, 1, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, r, SDL_Rect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RectEquals, 0, 2, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, a, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(0, b, SDL_Rect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_HasIntersection, 0, 2, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, A, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_Rect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_IntersectRect, 0, 3, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, A, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(1, result, SDL_Rect, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_UnionRect, 0, 3, IS_VOID, 0)
+	ZEND_ARG_OBJ_INFO(0, A, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(1, result, SDL_Rect, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_EnclosePoints, 0, 4, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, points, SDL_Point, 0)
+	ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0)
+	ZEND_ARG_OBJ_INFO(0, clip, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(1, result, SDL_Rect, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_IntersectRectAndLine, 0, 5, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
+	ZEND_ARG_TYPE_INFO(1, X1, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(1, Y1, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(1, X2, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(1, Y2, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_FRectEmpty, 0, 1, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, r, SDL_FRect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_HasIntersectionF, 0, 2, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, A, SDL_FRect, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_FRect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_IntersectFRect, 0, 3, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, A, SDL_FRect, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_FRect, 0)
+	ZEND_ARG_OBJ_INFO(1, result, SDL_FRect, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SDL_Point___construct, 0, 0, 2)
+	ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Point___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SDL_Rect___construct, 0, 0, 4)
+	ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SDL_Rect___toString arginfo_class_SDL_Point___toString
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Rect_Empty, 0, 0, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Rect_Equal, 0, 1, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, b, SDL_Rect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Rect_HasIntersection, 0, 1, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_Rect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Rect_Intersect, 0, 2, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(1, result, SDL_Rect, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Rect_Union, 0, 2, IS_VOID, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_Rect, 0)
+	ZEND_ARG_OBJ_INFO(1, result, SDL_Rect, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Rect_IntersectLine, 0, 4, _IS_BOOL, 0)
+	ZEND_ARG_TYPE_INFO(1, X1, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(1, Y1, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(1, X2, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(1, Y2, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SDL_FPoint___construct, 0, 0, 2)
+	ZEND_ARG_TYPE_INFO(0, x, IS_DOUBLE, 0)
+	ZEND_ARG_TYPE_INFO(0, y, IS_DOUBLE, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SDL_FPoint___toString arginfo_class_SDL_Point___toString
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SDL_FRect___construct, 0, 0, 4)
+	ZEND_ARG_TYPE_INFO(0, x, IS_DOUBLE, 0)
+	ZEND_ARG_TYPE_INFO(0, y, IS_DOUBLE, 0)
+	ZEND_ARG_TYPE_INFO(0, w, IS_DOUBLE, 0)
+	ZEND_ARG_TYPE_INFO(0, h, IS_DOUBLE, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_class_SDL_FRect___toString arginfo_class_SDL_Point___toString
+
+#define arginfo_class_SDL_FRect_Empty arginfo_class_SDL_Rect_Empty
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_FRect_HasIntersection, 0, 1, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_FRect, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_FRect_Intersect, 0, 2, _IS_BOOL, 0)
+	ZEND_ARG_OBJ_INFO(0, B, SDL_FRect, 0)
+	ZEND_ARG_OBJ_INFO(1, result, SDL_FRect, 1)
+ZEND_END_ARG_INFO()
+
+
+ZEND_FUNCTION(SDL_PointInRect);
+ZEND_FUNCTION(SDL_RectEmpty);
+ZEND_FUNCTION(SDL_RectEquals);
+ZEND_FUNCTION(SDL_HasIntersection);
+ZEND_FUNCTION(SDL_IntersectRect);
+ZEND_FUNCTION(SDL_UnionRect);
+ZEND_FUNCTION(SDL_EnclosePoints);
+ZEND_FUNCTION(SDL_IntersectRectAndLine);
+ZEND_FUNCTION(SDL_FRectEmpty);
+ZEND_FUNCTION(SDL_HasIntersectionF);
+ZEND_FUNCTION(SDL_IntersectFRect);
+ZEND_METHOD(SDL_Point, __construct);
+ZEND_METHOD(SDL_Point, __toString);
+ZEND_METHOD(SDL_Rect, __construct);
+ZEND_METHOD(SDL_Rect, __toString);
+ZEND_METHOD(SDL_FPoint, __construct);
+ZEND_METHOD(SDL_FPoint, __toString);
+ZEND_METHOD(SDL_FRect, __construct);
+ZEND_METHOD(SDL_FRect, __toString);
+
+
+static const zend_function_entry ext_functions[] = {
+	ZEND_FE(SDL_PointInRect, arginfo_SDL_PointInRect)
+	ZEND_FE(SDL_RectEmpty, arginfo_SDL_RectEmpty)
+	ZEND_FE(SDL_RectEquals, arginfo_SDL_RectEquals)
+	ZEND_FE(SDL_HasIntersection, arginfo_SDL_HasIntersection)
+	ZEND_FE(SDL_IntersectRect, arginfo_SDL_IntersectRect)
+	ZEND_FE(SDL_UnionRect, arginfo_SDL_UnionRect)
+	ZEND_FE(SDL_EnclosePoints, arginfo_SDL_EnclosePoints)
+	ZEND_FE(SDL_IntersectRectAndLine, arginfo_SDL_IntersectRectAndLine)
+	ZEND_FE(SDL_FRectEmpty, arginfo_SDL_FRectEmpty)
+	ZEND_FE(SDL_HasIntersectionF, arginfo_SDL_HasIntersectionF)
+	ZEND_FE(SDL_IntersectFRect, arginfo_SDL_IntersectFRect)
+	ZEND_FE_END
+};
+
+
+static const zend_function_entry class_SDL_Point_methods[] = {
+	ZEND_ME(SDL_Point, __construct, arginfo_class_SDL_Point___construct, ZEND_ACC_PUBLIC)
+	ZEND_ME(SDL_Point, __toString, arginfo_class_SDL_Point___toString, ZEND_ACC_PUBLIC)
+	ZEND_FE_END
+};
+
+
+static const zend_function_entry class_SDL_Rect_methods[] = {
+	ZEND_ME(SDL_Rect, __construct, arginfo_class_SDL_Rect___construct, ZEND_ACC_PUBLIC)
+	ZEND_ME(SDL_Rect, __toString, arginfo_class_SDL_Rect___toString, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(Empty, SDL_RectEmpty, arginfo_class_SDL_Rect_Empty, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(Equal, SDL_RectEquals, arginfo_class_SDL_Rect_Equal, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(HasIntersection, SDL_HasIntersection, arginfo_class_SDL_Rect_HasIntersection, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(Intersect, SDL_IntersectRect, arginfo_class_SDL_Rect_Intersect, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(Union, SDL_UnionRect, arginfo_class_SDL_Rect_Union, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(IntersectLine, SDL_IntersectRectAndLine, arginfo_class_SDL_Rect_IntersectLine, ZEND_ACC_PUBLIC)
+	ZEND_FE_END
+};
+
+
+static const zend_function_entry class_SDL_FPoint_methods[] = {
+	ZEND_ME(SDL_FPoint, __construct, arginfo_class_SDL_FPoint___construct, ZEND_ACC_PUBLIC)
+	ZEND_ME(SDL_FPoint, __toString, arginfo_class_SDL_FPoint___toString, ZEND_ACC_PUBLIC)
+	ZEND_FE_END
+};
+
+
+static const zend_function_entry class_SDL_FRect_methods[] = {
+	ZEND_ME(SDL_FRect, __construct, arginfo_class_SDL_FRect___construct, ZEND_ACC_PUBLIC)
+	ZEND_ME(SDL_FRect, __toString, arginfo_class_SDL_FRect___toString, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(Empty, SDL_FRectEmpty, arginfo_class_SDL_FRect_Empty, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(HasIntersection, SDL_HasIntersectionF, arginfo_class_SDL_FRect_HasIntersection, ZEND_ACC_PUBLIC)
+	ZEND_ME_MAPPING(Intersect, SDL_IntersectFRect, arginfo_class_SDL_FRect_Intersect, ZEND_ACC_PUBLIC)
+	ZEND_FE_END
+};
+
+static zend_class_entry *register_class_SDL_Point(void)
+{
+	zend_class_entry ce, *class_entry;
+
+	INIT_CLASS_ENTRY(ce, "SDL_Point", class_SDL_Point_methods);
+	class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+	zval property_x_default_value;
+	ZVAL_UNDEF(&property_x_default_value);
+	zend_string *property_x_name = zend_string_init("x", sizeof("x") - 1, 1);
+	zend_declare_typed_property(class_entry, property_x_name, &property_x_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+	zend_string_release(property_x_name);
+
+	zval property_y_default_value;
+	ZVAL_UNDEF(&property_y_default_value);
+	zend_string *property_y_name = zend_string_init("y", sizeof("y") - 1, 1);
+	zend_declare_typed_property(class_entry, property_y_name, &property_y_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+	zend_string_release(property_y_name);
+
+	return class_entry;
+}
+
+static zend_class_entry *register_class_SDL_Rect(void)
+{
+	zend_class_entry ce, *class_entry;
+
+	INIT_CLASS_ENTRY(ce, "SDL_Rect", class_SDL_Rect_methods);
+	class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+	zval property_x_default_value;
+	ZVAL_UNDEF(&property_x_default_value);
+	zend_string *property_x_name = zend_string_init("x", sizeof("x") - 1, 1);
+	zend_declare_typed_property(class_entry, property_x_name, &property_x_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+	zend_string_release(property_x_name);
+
+	zval property_y_default_value;
+	ZVAL_UNDEF(&property_y_default_value);
+	zend_string *property_y_name = zend_string_init("y", sizeof("y") - 1, 1);
+	zend_declare_typed_property(class_entry, property_y_name, &property_y_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+	zend_string_release(property_y_name);
+
+	zval property_w_default_value;
+	ZVAL_UNDEF(&property_w_default_value);
+	zend_string *property_w_name = zend_string_init("w", sizeof("w") - 1, 1);
+	zend_declare_typed_property(class_entry, property_w_name, &property_w_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+	zend_string_release(property_w_name);
+
+	zval property_h_default_value;
+	ZVAL_UNDEF(&property_h_default_value);
+	zend_string *property_h_name = zend_string_init("h", sizeof("h") - 1, 1);
+	zend_declare_typed_property(class_entry, property_h_name, &property_h_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+	zend_string_release(property_h_name);
+
+	return class_entry;
+}
+
+static zend_class_entry *register_class_SDL_FPoint(void)
+{
+	zend_class_entry ce, *class_entry;
+
+	INIT_CLASS_ENTRY(ce, "SDL_FPoint", class_SDL_FPoint_methods);
+	class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+	zval property_x_default_value;
+	ZVAL_UNDEF(&property_x_default_value);
+	zend_string *property_x_name = zend_string_init("x", sizeof("x") - 1, 1);
+	zend_declare_typed_property(class_entry, property_x_name, &property_x_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE));
+	zend_string_release(property_x_name);
+
+	zval property_y_default_value;
+	ZVAL_UNDEF(&property_y_default_value);
+	zend_string *property_y_name = zend_string_init("y", sizeof("y") - 1, 1);
+	zend_declare_typed_property(class_entry, property_y_name, &property_y_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE));
+	zend_string_release(property_y_name);
+
+	return class_entry;
+}
+
+static zend_class_entry *register_class_SDL_FRect(void)
+{
+	zend_class_entry ce, *class_entry;
+
+	INIT_CLASS_ENTRY(ce, "SDL_FRect", class_SDL_FRect_methods);
+	class_entry = zend_register_internal_class_ex(&ce, NULL);
+
+	zval property_x_default_value;
+	ZVAL_UNDEF(&property_x_default_value);
+	zend_string *property_x_name = zend_string_init("x", sizeof("x") - 1, 1);
+	zend_declare_typed_property(class_entry, property_x_name, &property_x_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE));
+	zend_string_release(property_x_name);
+
+	zval property_y_default_value;
+	ZVAL_UNDEF(&property_y_default_value);
+	zend_string *property_y_name = zend_string_init("y", sizeof("y") - 1, 1);
+	zend_declare_typed_property(class_entry, property_y_name, &property_y_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE));
+	zend_string_release(property_y_name);
+
+	zval property_w_default_value;
+	ZVAL_UNDEF(&property_w_default_value);
+	zend_string *property_w_name = zend_string_init("w", sizeof("w") - 1, 1);
+	zend_declare_typed_property(class_entry, property_w_name, &property_w_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE));
+	zend_string_release(property_w_name);
+
+	zval property_h_default_value;
+	ZVAL_UNDEF(&property_h_default_value);
+	zend_string *property_h_name = zend_string_init("h", sizeof("h") - 1, 1);
+	zend_declare_typed_property(class_entry, property_h_name, &property_h_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE));
+	zend_string_release(property_h_name);
+
+	return class_entry;
+}
diff --git a/src/render.c b/src/render.c
index 8f1d143..8d75b3f 100644
--- a/src/render.c
+++ b/src/render.c
@@ -361,6 +361,171 @@ PHP_FUNCTION(SDL_QueryTexture)
 	RETURN_LONG(result);
 }
 
+PHP_FUNCTION(SDL_RenderDrawPointF)
+{
+	zval *RENDERER;
+	SDL_Renderer *renderer;
+	double x, y;
+
+	ZEND_PARSE_PARAMETERS_START(3, 3);
+		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
+		Z_PARAM_ZVAL(RENDERER)
+		Z_PARAM_DOUBLE(x)
+		Z_PARAM_DOUBLE(y)
+	ZEND_PARSE_PARAMETERS_END();
+//	renderer = php_sdl_renderer_from_zval_p(RENDERER);
+	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+
+	int result = SDL_RenderDrawPointF(renderer, (float) x, (float) y);
+
+	RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderDrawLineF)
+{
+	zval *RENDERER;
+	SDL_Renderer *renderer;
+	double x1, y1, x2, y2;
+
+	ZEND_PARSE_PARAMETERS_START(5, 5);
+		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
+		Z_PARAM_ZVAL(RENDERER)
+		Z_PARAM_DOUBLE(x1)
+		Z_PARAM_DOUBLE(y1)
+		Z_PARAM_DOUBLE(x2)
+		Z_PARAM_DOUBLE(y2)
+	ZEND_PARSE_PARAMETERS_END();
+	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
+	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+
+	int result = SDL_RenderDrawLineF(renderer, (float) x1, (float) y1, (float) x2, (float) y2);
+
+	RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderDrawRectF)
+{
+	zval *RENDERER;
+	SDL_Renderer *renderer;
+	zval *RECT;
+	SDL_FRect rect;
+
+	ZEND_PARSE_PARAMETERS_START(2, 2);
+		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
+		Z_PARAM_ZVAL(RENDERER)
+		Z_PARAM_OBJECT_OF_CLASS(RECT, get_php_sdl_frect_ce())
+	ZEND_PARSE_PARAMETERS_END();
+	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
+	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+	zval_to_sdl_frect(RECT, &rect);
+	int result = SDL_RenderDrawRectF(renderer, (const SDL_FRect*) &rect);
+
+	RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderFillRectF)
+{
+	zval *RENDERER, *RECT;
+	SDL_Renderer *renderer;
+	SDL_FRect rect;
+
+	ZEND_PARSE_PARAMETERS_START(2, 2);
+		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
+		Z_PARAM_ZVAL(RENDERER)
+		Z_PARAM_OBJECT_OF_CLASS(RECT, get_php_sdl_frect_ce())
+	ZEND_PARSE_PARAMETERS_END();
+	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
+	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+	zval_to_sdl_frect(RECT, &rect);
+	int result = SDL_RenderFillRectF(renderer, (const SDL_FRect*) &rect);
+
+	RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderCopyF)
+{
+	zval *RENDERER, *TEXTURE, *SRCRECT, *DSTRECT;
+	SDL_Renderer *renderer;
+	SDL_Texture *texture;
+	SDL_Rect *srcrect = NULL;
+	SDL_Rect def_srcrect;
+	SDL_FRect *dstrect = NULL;
+	SDL_FRect def_dstrect;
+
+	ZEND_PARSE_PARAMETERS_START(4, 4);
+		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
+		Z_PARAM_ZVAL(RENDERER)
+		// Z_PARAM_OBJECT_OF_CLASS(TEXTURE, sdl_texture_ce)
+		Z_PARAM_ZVAL(TEXTURE)
+		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(SRCRECT, get_php_sdl_rect_ce())
+		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(DSTRECT, get_php_sdl_frect_ce())
+	ZEND_PARSE_PARAMETERS_END();
+	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
+	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+	texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(TEXTURE), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+
+	if(SRCRECT != NULL && Z_TYPE_P(SRCRECT) != IS_NULL) {
+		srcrect = &def_srcrect;
+		zval_to_sdl_rect(SRCRECT, srcrect);
+	}
+	if(DSTRECT != NULL && Z_TYPE_P(DSTRECT) != IS_NULL) {
+		dstrect = &def_dstrect;
+		zval_to_sdl_frect(DSTRECT, dstrect);
+	}
+
+	int result = SDL_RenderCopyF(renderer, texture, (const SDL_Rect*) srcrect, (const SDL_FRect*) dstrect);
+
+	RETURN_LONG(result);
+}
+
+PHP_FUNCTION(SDL_RenderCopyExF)
+{
+	zval *RENDERER, *TEXTURE, *SRCRECT, *DSTRECT, *CENTER;
+	SDL_Renderer *renderer;
+	SDL_Texture *texture;
+	SDL_Rect *srcrect = NULL;
+	SDL_Rect def_srcrect;
+	SDL_FRect *dstrect = NULL;;
+	SDL_FRect def_dstrect;
+	SDL_FPoint *center = NULL;;
+	SDL_FPoint def_center;
+	// @todo SDL_RendererFlip
+	zend_long flip;
+	double angle;
+
+	ZEND_PARSE_PARAMETERS_START(7, 7);
+		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
+		Z_PARAM_ZVAL(RENDERER)
+		// Z_PARAM_OBJECT_OF_CLASS(TEXTURE, sdl_texture_ce)
+		Z_PARAM_ZVAL(TEXTURE)
+		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(SRCRECT, get_php_sdl_rect_ce())
+		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(DSTRECT, get_php_sdl_frect_ce())
+		Z_PARAM_DOUBLE(angle)
+		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(CENTER, get_php_sdl_fpoint_ce())
+		Z_PARAM_LONG(flip)
+	ZEND_PARSE_PARAMETERS_END();
+	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
+	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+	texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(TEXTURE), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+
+	if (SRCRECT != NULL && Z_TYPE_P(SRCRECT) != IS_NULL) {
+		srcrect = &def_srcrect;
+		zval_to_sdl_rect(SRCRECT, srcrect);
+	}
+	if (DSTRECT != NULL && Z_TYPE_P(DSTRECT) != IS_NULL) {
+		dstrect = &def_dstrect;
+		zval_to_sdl_frect(DSTRECT, dstrect);
+	}
+	if (CENTER != NULL && Z_TYPE_P(CENTER) != IS_NULL) {
+		center = &def_center;
+		zval_to_sdl_fpoint(CENTER, center);
+	}
+
+	int result = SDL_RenderCopyExF(renderer, texture, (const SDL_Rect*)srcrect, (const SDL_FRect*)dstrect, angle, (const SDL_FPoint*)center, flip);
+
+	RETURN_LONG(result);
+}
+
 /* {{{ MINIT */
 PHP_MINIT_FUNCTION(sdl_render)
 {
diff --git a/src/render.h b/src/render.h
index 34b5687..659bcad 100644
--- a/src/render.h
+++ b/src/render.h
@@ -135,6 +135,50 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetRendererOutputSize, 0, 0, 3)
 	ZEND_ARG_INFO(1, h)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawPointF, 0, 3, IS_LONG, 0)
+	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+	ZEND_ARG_INFO(0, renderer)
+	ZEND_ARG_TYPE_INFO(0, x, IS_DOUBLE, 0)
+	ZEND_ARG_TYPE_INFO(0, y, IS_DOUBLE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawLineF, 0, 5, IS_LONG, 0)
+	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+	ZEND_ARG_INFO(0, renderer)
+	ZEND_ARG_TYPE_INFO(0, x1, IS_DOUBLE, 0)
+	ZEND_ARG_TYPE_INFO(0, y1, IS_DOUBLE, 0)
+	ZEND_ARG_TYPE_INFO(0, x2, IS_DOUBLE, 0)
+	ZEND_ARG_TYPE_INFO(0, y2, IS_DOUBLE, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawRectF, 0, 2, IS_LONG, 0)
+	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+	ZEND_ARG_INFO(0, renderer)
+	ZEND_ARG_OBJ_INFO(0, rect, SDL_FRect, 0)
+ZEND_END_ARG_INFO()
+
+#define arginfo_SDL_RenderFillRectF arginfo_SDL_RenderDrawRectF
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyF, 0, 4, IS_LONG, 0)
+	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+	ZEND_ARG_INFO(0, renderer)
+	ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
+	ZEND_ARG_OBJ_INFO(0, srcrect, SDL_Rect, 1)
+	ZEND_ARG_OBJ_INFO(0, dstrect, SDL_FRect, 1)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyExF, 0, 7, IS_LONG, 0)
+	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+	ZEND_ARG_INFO(0, renderer)
+	ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
+	ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, srcrect, SDL_Rect, 1, "null")
+	ZEND_ARG_OBJ_INFO(0, dstrect, SDL_FRect, 1)
+	ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, angle, IS_DOUBLE, 0, "0.0")
+	ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, center, SDL_FPoint, 1, "null")
+	ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flip, IS_LONG, 0, "SDL_FLIP_NONE")
+ZEND_END_ARG_INFO()
+
+
 PHP_FUNCTION(SDL_SetRenderDrawColor);
 PHP_FUNCTION(SDL_RenderClear);
 PHP_FUNCTION(SDL_DestroyRenderer);
@@ -152,6 +196,12 @@ PHP_FUNCTION(SDL_CreateRenderer);
 PHP_FUNCTION(SDL_RenderCopy);
 PHP_FUNCTION(SDL_RenderCopyEx);
 PHP_FUNCTION(SDL_GetRendererOutputSize);
+ZEND_FUNCTION(SDL_RenderDrawPointF);
+ZEND_FUNCTION(SDL_RenderDrawLineF);
+ZEND_FUNCTION(SDL_RenderDrawRectF);
+ZEND_FUNCTION(SDL_RenderFillRectF);
+ZEND_FUNCTION(SDL_RenderCopyF);
+ZEND_FUNCTION(SDL_RenderCopyExF);
 
 PHP_MINIT_FUNCTION(sdl_render);
 
diff --git a/src/surface.c b/src/surface.c
index ec39c4c..0ad8c2e 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -1195,15 +1195,15 @@ PHP_FUNCTION(SDL_ConvertPixels)
 	}
 	if (h < 0 || h > src->h || h > dst->h) {
 		h = (src->h > dst->h ? dst->h : src->h);
-		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h);
+		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %lld", h);
 	}
 	if (sp != src->pitch) {
 		sp = src->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp);
+		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %lld", sp);
 	}
 	if (dp != dst->pitch) {
 		dp = dst->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp);
+		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %lld", dp);
 	}
 	RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp));
 }
diff --git a/tests/006-rect.phpt b/tests/006-rect.phpt
index 1dd5ff1..f44d83b 100644
--- a/tests/006-rect.phpt
+++ b/tests/006-rect.phpt
@@ -10,16 +10,28 @@ $r = new SDL_Rect(0,0,0,0);
 var_dump($r);
 var_dump(SDL_RectEmpty($r));
 
+$r = new SDL_FRect(.0,.0,.0,.0);
+var_dump($r);
+var_dump(SDL_FRectEmpty($r));
+
 echo "+++ Empty (false)\n";
 $r = new SDL_Rect(1,2,3,4);
 var_dump($r);
 var_dump(SDL_RectEmpty($r));
 
+$r = new SDL_FRect(1.0,2.0,3.0,4.0);
+var_dump($r);
+var_dump(SDL_FRectEmpty($r));
+
 $r1 = new SDL_Rect(10,10,20,20);
 $r2 = new SDL_Rect(10,10,20,20);
 $r3 = new SDL_Rect(16,17,22,24);
 $r4 = new SDL_Rect(100,10,20,20);
 
+$fr2 = new SDL_FRect(10.1, 10.1, 20.1, 20.1);
+$fr3 = new SDL_FRect(16.1, 17.1, 22.1, 24.1);
+$fr4 = new SDL_FRect(100.1, 10.1, 20.1, 20.1);
+
 echo "+++ Equal (true)\n";
 var_dump(SDL_RectEquals($r1, $r1));
 var_dump(SDL_RectEquals($r1, $r2));
@@ -32,11 +44,19 @@ var_dump(SDL_HasIntersection($r2, $r3));
 var_dump(SDL_IntersectRect($r2, $r3, $x));
 var_dump($x); unset($x);
 
+var_dump(SDL_HasIntersectionF($fr2, $fr3));
+var_dump(SDL_IntersectFRect($fr2, $fr3, $x));
+var_dump($x); unset($x);
+
 echo "+++ Inter (false)\n";
 var_dump(SDL_HasIntersection($r2, $r4));
 var_dump(SDL_IntersectRect($r2, $r4, $x));
 var_dump($x); unset($x);
 
+var_dump(SDL_HasIntersectionF($fr2, $fr4));
+var_dump(SDL_IntersectFRect($fr2, $fr4, $x));
+var_dump($x); unset($x);
+
 echo "+++ Union\n";
 var_dump(SDL_UnionRect($r2, $r3, $x));
 var_dump($x); unset($x);
@@ -48,7 +68,7 @@ $x1=0; $y1=10; $x2=40; $y2=30;
 var_dump(SDL_IntersectRectAndLine($r1, $x1, $y1, $x2, $y2));
 var_dump($x1, $y1, $x2, $y2);
 $x1=0; $y1=2; $x2=40; $y2=6;
-var_dump($r1->IntersectLine($x1, $y1, $x2, $y2));
+var_dump(SDL_IntersectRectAndLine($r1, $x1, $y1, $x2, $y2));
 
 echo "+++ EnclosePoints\n";
 $pts = array(
@@ -61,6 +81,15 @@ var_dump($pts[0]." ".$pts[1]." ".$pts[2]." ".$pts[3]);
 var_dump(SDL_EnclosePoints($pts, 0, $r1, $res1), $res1);
 $pts[]="foo";
 var_dump(SDL_EnclosePoints($pts, 6, $r4, $res2), $res2);
+
+echo "+++ SDL_FRect\n";
+$r = new SDL_FRect(1.1, 2.2, 3.3, 4.4);
+var_dump($r);
+
+echo "+++ SDL_FPoint\n";
+$r = new SDL_FPoint(1.1, 2.2);
+var_dump($r);
+
 ?>
 Done
 --EXPECTF--
@@ -76,6 +105,17 @@ object(SDL_Rect)#%d (4) {
   int(0)
 }
 bool(true)
+object(SDL_FRect)#%d (4) {
+  ["x"]=>
+  float(0)
+  ["y"]=>
+  float(0)
+  ["w"]=>
+  float(0)
+  ["h"]=>
+  float(0)
+}
+bool(true)
 +++ Empty (false)
 object(SDL_Rect)#%d (4) {
   ["x"]=>
@@ -88,6 +128,17 @@ object(SDL_Rect)#%d (4) {
   int(4)
 }
 bool(false)
+object(SDL_FRect)#%d (4) {
+  ["x"]=>
+  float(1)
+  ["y"]=>
+  float(2)
+  ["w"]=>
+  float(3)
+  ["h"]=>
+  float(4)
+}
+bool(false)
 +++ Equal (true)
 bool(true)
 bool(true)
@@ -107,10 +158,25 @@ object(SDL_Rect)#%d (4) {
   ["h"]=>
   int(13)
 }
+bool(true)
+bool(true)
+object(SDL_FRect)#%d (4) {
+  ["x"]=>
+  float(16.100000381469727)
+  ["y"]=>
+  float(17.100000381469727)
+  ["w"]=>
+  float(14.100000381469727)
+  ["h"]=>
+  float(13.100000381469727)
+}
 +++ Inter (false)
 bool(false)
 bool(false)
 NULL
+bool(false)
+bool(false)
+NULL
 +++ Union
 NULL
 object(SDL_Rect)#%d (4) {
@@ -160,5 +226,23 @@ Warning: SDL_EnclosePoints(): point #4 is not a SDL_Point object in %s/006-rect.
 Warning: SDL_EnclosePoints(): point #5 missing in %s/006-rect.php on line %d
 bool(false)
 NULL
++++ SDL_FRect
+object(SDL_FRect)#%d (4) {
+  ["x"]=>
+  float(1.1)
+  ["y"]=>
+  float(2.2)
+  ["w"]=>
+  float(3.3)
+  ["h"]=>
+  float(4.4)
+}
++++ SDL_FPoint
+object(SDL_FPoint)#2 (2) {
+  ["x"]=>
+  float(1.1)
+  ["y"]=>
+  float(2.2)
+}
 Done
 
diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt
index 951f744..8e23672 100644
--- a/tests/007-rect-oo.phpt
+++ b/tests/007-rect-oo.phpt
@@ -8,18 +8,30 @@ require 'test-functions.php';
 echo "+++ Empty (true)\n";
 $r = new SDL_Rect(0,0,0,0);
 var_dump($r, "$r");
-var_dump(SDL_RectEmpty($r));
+var_dump($r->Empty());
+
+$r = new SDL_FRect(.0,.0,.0,.0);
+var_dump($r);
+var_dump($r->Empty());
 
 echo "+++ Empty (false)\n";
 $r = new SDL_Rect(1,2,3,4);
 var_dump($r, "$r");
 var_dump($r->Empty());
 
+$r = new SDL_FRect(1.1, 2.2, 3.3, 4.4);
+var_dump($r, "$r");
+var_dump($r->Empty());
+
 $r1 = new SDL_Rect(10,10,20,20);
 $r2 = new SDL_Rect(10,10,20,20);
 $r3 = new SDL_Rect(16,17,22,24);
 $r4 = new SDL_Rect(100,10,20,20);
 
+$fr2 = new SDL_FRect(10.1, 10.1, 20.1, 20.1);
+$fr3 = new SDL_FRect(16.1, 17.1, 22.1, 24.1);
+$fr4 = new SDL_FRect(100.1, 10.1, 20.1, 20.1);
+
 echo "+++ Equal (true)\n";
 var_dump($r1->Equal($r1));
 var_dump($r1->Equal($r2));
@@ -32,11 +44,19 @@ var_dump($r2->HasIntersection($r3));
 var_dump($r2->Intersect($r3, $x));
 var_dump($x); unset($x);
 
+var_dump($fr2->HasIntersection($fr3));
+var_dump($fr2->Intersect($fr3, $x));
+var_dump($x); unset($x);
+
 echo "+++ Inter (false)\n";
 var_dump($r2->HasIntersection($r4));
 var_dump($r2->Intersect($r4, $x));
 var_dump($x); unset($x);
 
+var_dump($fr2->HasIntersection($fr4));
+var_dump($fr2->Intersect($fr4, $x));
+var_dump($x); unset($x);
+
 echo "+++ Uninon\n";
 var_dump($r2->Union($r3, $x));
 var_dump($x); unset($x);
@@ -70,6 +90,17 @@ object(SDL_Rect)#%d (4) {
 }
 string(17) "SDL_Rect(0,0,0,0)"
 bool(true)
+object(SDL_FRect)#%d (4) {
+  ["x"]=>
+  float(0)
+  ["y"]=>
+  float(0)
+  ["w"]=>
+  float(0)
+  ["h"]=>
+  float(0)
+}
+bool(true)
 +++ Empty (false)
 object(SDL_Rect)#%d (4) {
   ["x"]=>
@@ -83,6 +114,18 @@ object(SDL_Rect)#%d (4) {
 }
 string(17) "SDL_Rect(1,2,3,4)"
 bool(false)
+object(SDL_FRect)#%d (4) {
+  ["x"]=>
+  float(1.100000023841858)
+  ["y"]=>
+  float(2.200000047683716)
+  ["w"]=>
+  float(3.299999952316284)
+  ["h"]=>
+  float(4.400000095367432)
+}
+string(46) "SDL_FRect(1.100000,2.200000,3.300000,4.400000)"
+bool(false)
 +++ Equal (true)
 bool(true)
 bool(true)
@@ -102,10 +145,25 @@ object(SDL_Rect)#%d (4) {
   ["h"]=>
   int(13)
 }
+bool(true)
+bool(true)
+object(SDL_FRect)#%d (4) {
+  ["x"]=>
+  float(16.100000381469727)
+  ["y"]=>
+  float(17.100000381469727)
+  ["w"]=>
+  float(14.100000381469727)
+  ["h"]=>
+  float(13.100000381469727)
+}
 +++ Inter (false)
 bool(false)
 bool(false)
 NULL
+bool(false)
+bool(false)
+NULL
 +++ Uninon
 NULL
 object(SDL_Rect)#%d (4) {
diff --git a/tests/014-version.phpt b/tests/014-version.phpt
index 49981f6..05889fe 100644
--- a/tests/014-version.phpt
+++ b/tests/014-version.phpt
@@ -4,7 +4,7 @@ SDL_version test suite
 <?php
 require 'test-functions.php';
 --INI--
-error_reporting = 32767;
+error_reporting = E_ALL & ~E_DEPRECATED;
 --FILE--
 <?php
 echo '= Constants', PHP_EOL;
diff --git a/tests/017-rwops-stream.phpt b/tests/017-rwops-stream.phpt
index acee259..0e89a77 100644
--- a/tests/017-rwops-stream.phpt
+++ b/tests/017-rwops-stream.phpt
@@ -8,7 +8,7 @@ getenv("SKIP_ONLINE_TESTS") or exit("skip test requiring internet connection");
 --FILE--
 <?php
 echo "= Read Stream\n";
-$stream = fopen("http://www.libsdl.org/media/SDL_logo.png", "r");
+$stream = fopen("https://www.libsdl.org/media/SDL_logo.png", "r");
 $ro = SDL_RWFromFP($stream);
 echo "size:"; var_dump($size=$ro->size());
 echo "read:"; var_dump($ro->read($buf, $size)==$size, strlen($buf)==$size);
diff --git a/tests/028-point.phpt b/tests/028-point.phpt
index dd3d3cb..2713cf0 100644
--- a/tests/028-point.phpt
+++ b/tests/028-point.phpt
@@ -10,10 +10,16 @@ echo 'TEST: Subclasses of SDL_Point can be converted properly', PHP_EOL;
 class CustomPoint extends \SDL_Point {}
 $customPoint = new CustomPoint(10, 20);
 echo strval($customPoint), PHP_EOL;
+
+echo 'TEST: SDL_FPoint to string', PHP_EOL;
+$fpoint = new SDL_FPoint(22.23, 42.43);
+echo (string) $fpoint, PHP_EOL;
 ?>
 SUITE: End
 --EXPECTF--
 SUITE: Start
 TEST: Subclasses of SDL_Point can be converted properly
 SDL_Point(10,20)
+TEST: SDL_FPoint to string
+SDL_FPoint(22.230000,42.430000)
 SUITE: End

From 456f57116d931406087625553469fdf12fb5d6c2 Mon Sep 17 00:00:00 2001
From: Manuel Baldassarri <kea@keasoft.it>
Date: Thu, 17 Mar 2022 20:42:52 +0100
Subject: [PATCH 31/53] Add manually the list of file to compile and add src as
 build dir (#59)

---
 config.m4   | 28 +++++++++++++++++++++++++++-
 package.xml |  2 ++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/config.m4 b/config.m4
index 06963bd..3ebd8ee 100644
--- a/config.m4
+++ b/config.m4
@@ -55,6 +55,32 @@ if test "$PHP_SDL" != "no"; then
   PHP_SUBST(SDL_SHARED_LIBADD)
   AC_DEFINE(HAVE_SDL2, 1, [ ])
 
-  SDL_SOURCE_FILES="`find src -name "*.c"`"
+  SDL_SOURCE_FILES="src/blendmode.c \
+	src/cpuinfo.c \
+	src/error.c \
+	src/event.c \
+	src/filesystem.c \
+	src/glcontext.c \
+	src/joystick.c \
+	src/keyboard.c \
+	src/messagebox.c \
+	src/mouse.c \
+	src/mutex.c \
+	src/php_sdl.c \
+	src/pixels.c \
+	src/platform.c \
+	src/power.c \
+	src/rect.c \
+	src/render.c \
+	src/rwops.c \
+	src/sdl.c \
+	src/shape.c \
+	src/surface.c \
+	src/timer.c \
+	src/version.c \
+	src/video.c \
+	src/window.c"
+
   PHP_NEW_EXTENSION(sdl, $SDL_SOURCE_FILES, $ext_shared,, $PHP_SDL_CFLAGS)
+  PHP_ADD_BUILD_DIR($ext_builddir/src)
 fi
diff --git a/package.xml b/package.xml
index a282e0e..3170ffd 100644
--- a/package.xml
+++ b/package.xml
@@ -73,6 +73,8 @@
         <file role="src" name="power.h"/>
         <file role="src" name="rect.c"/>
         <file role="src" name="rect.h"/>
+        <file role="src" name="rect.stub.php"/>
+        <file role="src" name="rect_arginfo.h"/>
         <file role="src" name="render.c"/>
         <file role="src" name="render.h"/>
         <file role="src" name="rwops.c"/>

From 17950bd127fc1ccc67614c6c87190c7b787f4122 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Thu, 17 Mar 2022 21:25:33 +0000
Subject: [PATCH 32/53] Remove long long int warnings

---
 src/surface.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/surface.c b/src/surface.c
index 0ad8c2e..ec39c4c 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -1195,15 +1195,15 @@ PHP_FUNCTION(SDL_ConvertPixels)
 	}
 	if (h < 0 || h > src->h || h > dst->h) {
 		h = (src->h > dst->h ? dst->h : src->h);
-		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %lld", h);
+		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h);
 	}
 	if (sp != src->pitch) {
 		sp = src->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %lld", sp);
+		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp);
 	}
 	if (dp != dst->pitch) {
 		dp = dst->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %lld", dp);
+		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp);
 	}
 	RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp));
 }

From 1c5aa8d41aa4cdf8b7ba84d5475c8f0361f8077e Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Thu, 17 Mar 2022 21:40:17 +0000
Subject: [PATCH 33/53] Increase version number. Remove PHP version 7
 references.

---
 package.xml      | 35 +++++++++++++++++++++++++++--------
 src/blendmode.c  |  2 --
 src/blendmode.h  |  2 --
 src/cpuinfo.c    |  2 --
 src/cpuinfo.h    |  2 --
 src/error.c      |  2 --
 src/error.h      |  2 --
 src/event.c      |  2 --
 src/event.h      |  2 --
 src/filesystem.c |  2 --
 src/filesystem.h |  2 --
 src/glcontext.c  |  2 --
 src/glcontext.h  |  2 --
 src/joystick.c   |  2 --
 src/joystick.h   |  2 --
 src/keyboard.c   |  2 --
 src/keyboard.h   |  2 --
 src/messagebox.c |  2 --
 src/messagebox.h |  2 --
 src/mouse.c      |  2 --
 src/mouse.h      |  2 --
 src/mutex.c      |  2 --
 src/mutex.h      |  2 --
 src/php_sdl.c    |  2 --
 src/php_sdl.h    |  4 +---
 src/pixels.c     |  2 --
 src/pixels.h     |  2 --
 src/platform.c   |  2 --
 src/platform.h   |  2 --
 src/power.c      |  2 --
 src/power.h      |  2 --
 src/rect.c       |  2 --
 src/rect.h       |  2 --
 src/render.c     |  2 --
 src/render.h     |  2 --
 src/rwops.c      |  2 --
 src/rwops.h      |  2 --
 src/sdl.c        |  2 --
 src/sdl.h        |  2 --
 src/shape.c      |  2 --
 src/shape.h      |  2 --
 src/surface.c    |  2 --
 src/surface.h    |  2 --
 src/timer.c      |  2 --
 src/timer.h      |  2 --
 src/version.c    |  2 --
 src/version.h    |  2 --
 src/video.c      |  2 --
 src/video.h      |  2 --
 src/window.c     |  2 --
 src/window.h     |  2 --
 51 files changed, 28 insertions(+), 109 deletions(-)

diff --git a/package.xml b/package.xml
index 3170ffd..367f667 100644
--- a/package.xml
+++ b/package.xml
@@ -19,20 +19,22 @@
     <active>yes</active>
   </lead>
   <!-- Current version -->
-  <date>2021-06-18</date>
+  <date>2022-03-17</date>
   <time>12:00:00</time>
   <version>
-    <release>2.5.0</release>
-    <api>2.5.0</api>
+    <release>2.6.0</release>
+    <api>2.6.0</api>
   </version>
   <stability>
-    <release>devel</release>
-    <api>devel</api>
+    <release>beta</release>
+    <api>beta</api>
   </stability>
-  <license uri="http://www.php.net/license">PHP</license>
+  <license uri="https://www.php.net/license">PHP</license>
   <notes>
-    - Add support for PHP8 (Manuel Baldassarri)
-    - Remove support for PHP7 (Manuel Baldassarri)
+	- Add float rect and float point render functions (Manuel Baldassarri)
+	- Add config file for Windows (Zorobabel)
+	- Fix PECL build (Manuel Baldassarri)
+	- Rename width parameter in SDL_Rect constructor (Manuel Baldassarri)
   </notes>
   <!--/Current version -->
   <contents>
@@ -156,6 +158,23 @@
   <providesextension>sdl</providesextension>
   <extsrcrelease/>
   <changelog>
+  	<release>
+  		  <date>2021-06-18</date>
+  		  <time>12:00:00</time>
+  		  <version>
+    		<release>2.5.0</release>
+    		<api>2.5.0</api>
+  		  </version>
+  		  <stability>
+    		<release>devel</release>
+    		<api>devel</api>
+  		  </stability>
+  		  <license uri="http://www.php.net/license">PHP</license>
+  		  <notes>
+    		- Add support for PHP8 (Manuel Baldassarri)
+    		- Remove support for PHP7 (Manuel Baldassarri)
+  		  </notes>
+  	</release>
     <release>
       <date>2020-08-23</date>
       <time>12:00:00</time>
diff --git a/src/blendmode.c b/src/blendmode.c
index decb075..9b700b6 100644
--- a/src/blendmode.c
+++ b/src/blendmode.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/blendmode.h b/src/blendmode.h
index 214b33c..da2443f 100644
--- a/src/blendmode.h
+++ b/src/blendmode.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/cpuinfo.c b/src/cpuinfo.c
index eba2dae..73a7a53 100644
--- a/src/cpuinfo.c
+++ b/src/cpuinfo.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/cpuinfo.h b/src/cpuinfo.h
index d4504b3..edf4e9f 100644
--- a/src/cpuinfo.h
+++ b/src/cpuinfo.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/error.c b/src/error.c
index dc99886..a5156d3 100644
--- a/src/error.c
+++ b/src/error.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/error.h b/src/error.h
index 451ee67..b43c758 100644
--- a/src/error.h
+++ b/src/error.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/event.c b/src/event.c
index a015ed7..f199ee4 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/event.h b/src/event.h
index 63cb54a..297fcf2 100644
--- a/src/event.h
+++ b/src/event.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/filesystem.c b/src/filesystem.c
index 9bf9263..a999771 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/filesystem.h b/src/filesystem.h
index 20ca99d..5ff1836 100644
--- a/src/filesystem.h
+++ b/src/filesystem.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/glcontext.c b/src/glcontext.c
index f285047..38581cd 100644
--- a/src/glcontext.c
+++ b/src/glcontext.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/glcontext.h b/src/glcontext.h
index 237306c..3a73554 100644
--- a/src/glcontext.h
+++ b/src/glcontext.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/joystick.c b/src/joystick.c
index bfa771b..7e55812 100644
--- a/src/joystick.c
+++ b/src/joystick.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) The PHP Group                                          |
   +----------------------------------------------------------------------+
diff --git a/src/joystick.h b/src/joystick.h
index 47c65f5..b02ee80 100644
--- a/src/joystick.h
+++ b/src/joystick.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) The PHP Group                                          |
   +----------------------------------------------------------------------+
diff --git a/src/keyboard.c b/src/keyboard.c
index cec4b62..eccf18c 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/keyboard.h b/src/keyboard.h
index 95ebf33..ff9a1aa 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/messagebox.c b/src/messagebox.c
index 8613231..6cfcd3c 100644
--- a/src/messagebox.c
+++ b/src/messagebox.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2016 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/messagebox.h b/src/messagebox.h
index b304b0a..c296428 100644
--- a/src/messagebox.h
+++ b/src/messagebox.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/mouse.c b/src/mouse.c
index 3f60e05..890b2ca 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/mouse.h b/src/mouse.h
index d2468c4..391815a 100644
--- a/src/mouse.h
+++ b/src/mouse.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/mutex.c b/src/mutex.c
index d2825a5..143a269 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/mutex.h b/src/mutex.h
index 0cc85de..f7e23fe 100644
--- a/src/mutex.h
+++ b/src/mutex.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/php_sdl.c b/src/php_sdl.c
index 2785d3e..531f842 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/php_sdl.h b/src/php_sdl.h
index bd8a498..10912d1 100644
--- a/src/php_sdl.h
+++ b/src/php_sdl.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
@@ -32,7 +30,7 @@ extern "C" {
 #include <php.h>
 #include <zend_exceptions.h>
 
-#define PHP_SDL_VERSION "2.5.0"
+#define PHP_SDL_VERSION "2.6.0"
 
 #if defined(__APPLE__) && defined(__MACH__)
 #include <SDL2/SDL.h>
diff --git a/src/pixels.c b/src/pixels.c
index 8f8cee0..ef1525b 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/pixels.h b/src/pixels.h
index 2501cd2..8aedc44 100644
--- a/src/pixels.h
+++ b/src/pixels.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/platform.c b/src/platform.c
index 81f0baf..dada1e7 100644
--- a/src/platform.c
+++ b/src/platform.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/platform.h b/src/platform.h
index f7917a6..ee823ef 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/power.c b/src/power.c
index 8628c4e..42a4670 100644
--- a/src/power.c
+++ b/src/power.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/power.h b/src/power.h
index f889a62..c7b1e8c 100644
--- a/src/power.h
+++ b/src/power.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/rect.c b/src/rect.c
index 11d8821..6773f56 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/rect.h b/src/rect.h
index 7552dab..67ba131 100644
--- a/src/rect.h
+++ b/src/rect.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/render.c b/src/render.c
index 8d75b3f..f8e1f9c 100644
--- a/src/render.c
+++ b/src/render.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/render.h b/src/render.h
index 659bcad..0a8c0ab 100644
--- a/src/render.h
+++ b/src/render.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/rwops.c b/src/rwops.c
index 5d0400e..af3609b 100644
--- a/src/rwops.c
+++ b/src/rwops.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/rwops.h b/src/rwops.h
index 3bde6ec..f1aec7a 100644
--- a/src/rwops.h
+++ b/src/rwops.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/sdl.c b/src/sdl.c
index 2ab6bb3..65f0118 100644
--- a/src/sdl.c
+++ b/src/sdl.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/sdl.h b/src/sdl.h
index 3396c11..cd6d4f3 100644
--- a/src/sdl.h
+++ b/src/sdl.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/shape.c b/src/shape.c
index 99c086b..314ebde 100644
--- a/src/shape.c
+++ b/src/shape.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/shape.h b/src/shape.h
index 5f85548..9c5f85a 100644
--- a/src/shape.h
+++ b/src/shape.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/surface.c b/src/surface.c
index ec39c4c..8684487 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/surface.h b/src/surface.h
index 94f98f2..6506f0f 100644
--- a/src/surface.h
+++ b/src/surface.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/timer.c b/src/timer.c
index d0cd321..9a05500 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/timer.h b/src/timer.h
index 9babd80..4aecfed 100644
--- a/src/timer.h
+++ b/src/timer.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/version.c b/src/version.c
index 184bdfd..5251b6a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2016 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/version.h b/src/version.h
index 238c4a7..b0c2980 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/video.c b/src/video.c
index 5670e04..7e8315d 100644
--- a/src/video.c
+++ b/src/video.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/video.h b/src/video.h
index 658f166..a158a54 100644
--- a/src/video.h
+++ b/src/video.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/window.c b/src/window.c
index 71c6a16..3061f41 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+
diff --git a/src/window.h b/src/window.h
index a3d263d..95abb4c 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1,6 +1,4 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 7                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2018 The PHP Group                                |
   +----------------------------------------------------------------------+

From b5b348d886295603efb10fa99b826e82a58f7eea Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Thu, 17 Mar 2022 21:47:39 +0000
Subject: [PATCH 34/53] Add list of related projects to README

---
 README.md | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 5f0c28f..2877165 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allo
 ### Via PECL
 
 ```bash
-pecl install sdl-devel
+pecl install sdl-beta
 ```
 
 Then add 
@@ -54,6 +54,13 @@ unset($window); // will destroy the window
 
 Complete examples can be found in the [examples](examples) folder.
 
+## Related projects
+
+* [PHP-SDL_Mixer](https://github.com/kea/php-sdl-mixer)
+* [PHP-SDL_Image](https://github.com/kea/php-sdl-image)
+* [PHP-OpenGL](https://github.com/ponup/php-opengl)
+* [PHP-OpenAL](https://github.com/Ponup/php-openal)
+
 ## Projects using the extension
 
 * [CubeCraft](https://github.com/Ponup/cubecraft)

From 555aee64cba87f0eb740a456ce35bfb714a87d8f Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 21 Mar 2022 19:28:50 +0100
Subject: [PATCH 35/53] fix PHP 8.0 build (#60)

* fix PHP 8.0 build

* register rect functions in rect.c
---
 src/php_sdl.c | 18 +++---------------
 src/pixels.c  |  6 ++++++
 src/rect.c    | 11 +++++++++++
 src/rect.h    |  1 +
 4 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/php_sdl.c b/src/php_sdl.c
index 531f842..c409c6c 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -31,7 +31,6 @@
 #include "power.h"
 #include "pixels.h"
 #include "rect.h"
-#include "rect_arginfo.h"
 #include "render.h"
 #include "rwops.h"
 #include "sdl.h"
@@ -68,6 +67,7 @@ zend_bool php_sdl_check_overflow(int a, int b, int silent)
 
 
 #define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
+#define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
 
 /* {{{ PHP_MINIT_FUNCTION */
 PHP_MINIT_FUNCTION(sdl)
@@ -107,6 +107,8 @@ PHP_MINIT_FUNCTION(sdl)
 /* {{{ PHP_MSHUTDOWN_FUNCTION */
 PHP_MSHUTDOWN_FUNCTION(sdl)
 {
+	PHP_MSHUTDOWN_CALL(sdl_rect);
+
 	return SUCCESS;
 }
 /* }}} */
@@ -260,20 +262,6 @@ static zend_function_entry sdl_functions[] = {
 	//PHP_FALIAS(SDL_BlitSurface,   SDL_UpperBlit,          arginfo_SDL_UpperBlit)
 	//PHP_FALIAS(SDL_BlitScaled,    SDL_UpperBlitScaled,    arginfo_SDL_UpperBlit)
 
-	// Rect
-	ZEND_FE(SDL_RectEmpty,					arginfo_SDL_RectEmpty)
-	ZEND_FE(SDL_RectEquals,					arginfo_SDL_RectEquals)
-	ZEND_FE(SDL_HasIntersection,			arginfo_SDL_HasIntersection)
-	ZEND_FE(SDL_IntersectRect,				arginfo_SDL_IntersectRect)
-	ZEND_FE(SDL_UnionRect,					arginfo_SDL_UnionRect)
-	ZEND_FE(SDL_IntersectRectAndLine,		arginfo_SDL_IntersectRectAndLine)
-	ZEND_FE(SDL_EnclosePoints,				arginfo_SDL_EnclosePoints)
-	ZEND_FE(SDL_PointInRect,				arginfo_SDL_PointInRect)
-
-	ZEND_FE(SDL_FRectEmpty,					arginfo_SDL_FRectEmpty)
-	ZEND_FE(SDL_HasIntersectionF,			arginfo_SDL_HasIntersectionF)
-	ZEND_FE(SDL_IntersectFRect,				arginfo_SDL_IntersectFRect)
-
 	// Events
 	ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent)
 	ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent)
diff --git a/src/pixels.c b/src/pixels.c
index ef1525b..4594d58 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -20,6 +20,12 @@
 #include "zend_interfaces.h"
 #include "zend_operators.h"
 
+/* for PHP 8.0 */
+#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX
+#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
+        ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args)
+#endif
+
 static zend_class_entry *php_sdl_color_ce;
 static zend_object_handlers php_sdl_color_handlers;
 struct php_sdl_color {
diff --git a/src/rect.c b/src/rect.c
index 6773f56..926d1b2 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -697,6 +697,8 @@ PHP_FUNCTION(SDL_PointInRect)
 /* {{{ MINIT */
 PHP_MINIT_FUNCTION(sdl_rect)
 {
+	zend_register_functions(NULL, ext_functions, NULL, type);
+
 	php_sdl_rect_ce = register_class_SDL_Rect();
 	memcpy(&php_sdl_rect_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
@@ -712,3 +714,12 @@ PHP_MINIT_FUNCTION(sdl_rect)
 	return SUCCESS;
 }
 /* }}} */
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION */
+PHP_MSHUTDOWN_FUNCTION(sdl_rect)
+{
+	zend_unregister_functions(ext_functions, -1, NULL);
+
+	return SUCCESS;
+}
+/* }}} */
diff --git a/src/rect.h b/src/rect.h
index 67ba131..baddfd6 100644
--- a/src/rect.h
+++ b/src/rect.h
@@ -40,6 +40,7 @@ zend_class_entry *get_php_sdl_fpoint_ce(void);
 zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *rect);
 
 PHP_MINIT_FUNCTION(sdl_rect);
+PHP_MSHUTDOWN_FUNCTION(sdl_rect);
 
 #ifdef  __cplusplus
 } // extern "C" 

From 945cc94dbf88daacaecd6b663ffbb1687c7192e5 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 23 Mar 2022 19:13:44 +0100
Subject: [PATCH 36/53] deprecate SDL_GetRevisionNumber (#65)

---
 config.m4     | 4 ++++
 src/php_sdl.c | 4 +++-
 src/version.c | 2 ++
 src/version.h | 2 ++
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/config.m4 b/config.m4
index 3ebd8ee..e781c23 100644
--- a/config.m4
+++ b/config.m4
@@ -55,6 +55,10 @@ if test "$PHP_SDL" != "no"; then
   PHP_SUBST(SDL_SHARED_LIBADD)
   AC_DEFINE(HAVE_SDL2, 1, [ ])
 
+  PHP_CHECK_LIBRARY(SDL2, SDL_GetRevisionNumber, [
+    AC_DEFINE(HAVE_SDL_GETREVISIONNUMBER, 1, [ ])
+  ])
+
   SDL_SOURCE_FILES="src/blendmode.c \
 	src/cpuinfo.c \
 	src/error.c \
diff --git a/src/php_sdl.c b/src/php_sdl.c
index c409c6c..7ab5d78 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -193,7 +193,9 @@ static zend_function_entry sdl_functions[] = {
 
 	// Version
 	ZEND_FE(SDL_GetRevision,		arginfo_sdl_version_none)
-	ZEND_FE(SDL_GetRevisionNumber,		arginfo_sdl_version_none)
+#ifdef HAVE_SDL_GETREVISIONNUMBER
+	ZEND_DEP_FE(SDL_GetRevisionNumber,		arginfo_sdl_version_none)
+#endif
 	ZEND_FE(SDL_GetVersion,			arginfo_SDL_GetVersion)
 	ZEND_FE(SDL_VERSION,			arginfo_SDL_VERSION)
 	ZEND_FE(SDL_VERSIONNUM,			arginfo_SDL_VERSIONNUM)
diff --git a/src/version.c b/src/version.c
index 5251b6a..a889e79 100644
--- a/src/version.c
+++ b/src/version.c
@@ -59,6 +59,7 @@ PHP_FUNCTION(SDL_GetRevision)
 }
 /* }}} */
 
+#ifdef HAVE_SDL_GETREVISIONNUMBER
 /* {{{ proto int SDL_GetRevisionNumber()
 
  *  \brief Get the revision number of SDL that is linked against your program.
@@ -76,6 +77,7 @@ PHP_FUNCTION(SDL_GetRevisionNumber)
 	RETURN_LONG(SDL_GetRevisionNumber());
 }
 /* }}} */
+#endif
 
 /* {{{ proto void SDL_GetVersion(array &version)
 
diff --git a/src/version.h b/src/version.h
index b0c2980..4b08737 100644
--- a/src/version.h
+++ b/src/version.h
@@ -49,7 +49,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_VERSION_ATLEAST, 0, 0, 3)
 ZEND_END_ARG_INFO()
 
 PHP_FUNCTION(SDL_GetRevision);
+#ifdef HAVE_SDL_GETREVISIONNUMBER
 PHP_FUNCTION(SDL_GetRevisionNumber);
+#endif
 PHP_FUNCTION(SDL_GetVersion);
 PHP_FUNCTION(SDL_VERSION);
 PHP_FUNCTION(SDL_VERSIONNUM);

From 52e2a50c1f187ead639689acf4a01ef9d5880571 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 23 Mar 2022 22:35:44 +0100
Subject: [PATCH 37/53] relax test (event always initialized) (#64)

---
 tests/003-init-and-quit-subsystems.phpt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/003-init-and-quit-subsystems.phpt b/tests/003-init-and-quit-subsystems.phpt
index 07976bd..afa0a18 100644
--- a/tests/003-init-and-quit-subsystems.phpt
+++ b/tests/003-init-and-quit-subsystems.phpt
@@ -9,13 +9,13 @@ require 'test-functions.php';
 assertEquals(SDL_WasInit(), 0, 'before calling SDL_Init nothing is initialised');
 
 SDL_InitSubSystem(SDL_INIT_AUDIO);
-assertEquals(SDL_WasInit(), SDL_INIT_AUDIO, 'init first subsystem works');
+assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_AUDIO, 'init first subsystem works');
 
 SDL_InitSubSystem(SDL_INIT_TIMER);
-assertEquals(SDL_WasInit(), SDL_INIT_AUDIO + SDL_INIT_TIMER, 'init two subsystems works');
+assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_AUDIO + SDL_INIT_TIMER, 'init two subsystems works');
 
 SDL_QuitSubSystem(SDL_INIT_AUDIO);
-assertEquals(SDL_WasInit(), SDL_INIT_TIMER, 'quitting one subsystem works');
+assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_TIMER, 'quitting one subsystem works');
 
 SDL_Quit();
 assertEquals(SDL_WasInit(), 0, 'quitting everything works');

From f7971f18eff999ca31989188a952989100f8016f Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Wed, 23 Mar 2022 22:07:50 +0000
Subject: [PATCH 38/53] Remove travis reference from tests

---
 tests/005-video.phpt     | 1 -
 tests/test-functions.php | 7 ++-----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/tests/005-video.phpt b/tests/005-video.phpt
index 3d5973f..5ed8f2e 100644
--- a/tests/005-video.phpt
+++ b/tests/005-video.phpt
@@ -3,7 +3,6 @@ video group test
 --SKIPIF--
 <?php
 require 'test-functions.php';
-skipIfTravis();
 --FILE--
 <?php
 echo "== VideoDriver ==\n";
diff --git a/tests/test-functions.php b/tests/test-functions.php
index 6046469..ad0aeea 100644
--- a/tests/test-functions.php
+++ b/tests/test-functions.php
@@ -1,13 +1,10 @@
 <?php
 extension_loaded('sdl') or exit('skip SDL extension not loaded');
+
 function skipIncompleteTest() {
 	exit('skip test is not complete');
 }
-function skipIfTravis() {
-    if ((bool)getenv('TRAVIS')) {
-        exit('skip test if run on Travis');
-    }
-}
+
 function assertEquals($current, $expected, $assertionMessage) {
 	if($current === $expected) {
 		printf('PASS: %s.' . PHP_EOL, $assertionMessage);

From dc79e3a6954e56fb20f5804c58912c7e92318498 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Wed, 23 Mar 2022 22:08:47 +0000
Subject: [PATCH 39/53] Add Benoit to credits

---
 CREDITS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CREDITS b/CREDITS
index 19a36f5..ea3e033 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1,2 +1,2 @@
 SDL
-Santiago Lizardo, Remi Collet, Manuel Baldassarri
+Santiago Lizardo, Remi Collet, Manuel Baldassarri, Benoit Viguier

From 21a983c3299673fbe0f6e8923bc5c0de705af147 Mon Sep 17 00:00:00 2001
From: sensorario <sensorario@gmail.com>
Date: Sun, 15 May 2022 22:30:56 +0200
Subject: [PATCH 40/53] Update README.md (#66)

Help reader to understand where the ini file is.
---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index 2877165..9603609 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,8 @@ extension=sdl.so
 ```
 to your _php.ini_ file.
 
+> If you have no idea about your ini file position you can run `php -i | grep ini` and see the list of you ini files.
+
 ## Documentation
 
 The SDL extension mimics in almost every single aspect to the official C library, so until we write our own documentation, refer to the [C counterpart](https://wiki.libsdl.org/APIByCategory).

From b8308ce8093e627a24e539fcf9650e80bc11d731 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 22 Jul 2022 13:40:25 +0100
Subject: [PATCH 41/53] Allow new SDL_Rect with no arguments (default to 0,0
 0x0)

---
 src/rect.c             | 201 +++++++++++++++++++++++++----------------
 tests/006-rect.phpt    |   6 +-
 tests/007-rect-oo.phpt |   6 +-
 3 files changed, 129 insertions(+), 84 deletions(-)

diff --git a/src/rect.c b/src/rect.c
index 926d1b2..7a0a39d 100644
--- a/src/rect.c
+++ b/src/rect.c
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -20,25 +20,29 @@
 
 static zend_class_entry *php_sdl_rect_ce;
 static zend_object_handlers php_sdl_rect_handlers;
-struct php_sdl_rect {
+struct php_sdl_rect
+{
 	zend_object zo;
 };
 
 static zend_class_entry *php_sdl_frect_ce;
 static zend_object_handlers php_sdl_frect_handlers;
-struct php_sdl_frect {
+struct php_sdl_frect
+{
 	zend_object zo;
 };
 
 static zend_class_entry *php_sdl_point_ce;
 static zend_object_handlers php_sdl_point_handlers;
-struct php_sdl_point {
+struct php_sdl_point
+{
 	zend_object zo;
 };
 
 static zend_class_entry *php_sdl_fpoint_ce;
 static zend_object_handlers php_sdl_fpoint_handlers;
-struct php_sdl_fpoint {
+struct php_sdl_fpoint
+{
 	zend_object zo;
 };
 
@@ -64,7 +68,8 @@ zend_class_entry *get_php_sdl_fpoint_ce(void)
 
 zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value)
 {
-	if (rect) {
+	if (rect)
+	{
 		object_init_ex(value, php_sdl_rect_ce);
 		zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, rect->x);
 		zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "y", 1, rect->y);
@@ -79,7 +84,8 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value)
 
 zend_bool sdl_frect_to_zval(SDL_FRect *rect, zval *value)
 {
-	if (rect) {
+	if (rect)
+	{
 		object_init_ex(value, php_sdl_frect_ce);
 		zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, rect->x);
 		zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "y", 1, rect->y);
@@ -94,7 +100,8 @@ zend_bool sdl_frect_to_zval(SDL_FRect *rect, zval *value)
 
 zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
 {
-	if (pt) {
+	if (pt)
+	{
 		object_init_ex(value, php_sdl_point_ce);
 		zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, pt->x);
 		zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "y", 1, pt->y);
@@ -107,7 +114,8 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value)
 
 zend_bool sdl_fpoint_to_zval(SDL_FPoint *pt, zval *value)
 {
-	if (pt) {
+	if (pt)
+	{
 		object_init_ex(value, php_sdl_fpoint_ce);
 		zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, pt->x);
 		zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "y", 1, pt->y);
@@ -120,7 +128,8 @@ zend_bool sdl_fpoint_to_zval(SDL_FPoint *pt, zval *value)
 
 zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
 {
-	if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) {
+	if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce))
+	{
 		zval *val, rv;
 
 		val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
@@ -148,7 +157,8 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect)
 
 zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect)
 {
-	if (instanceof_function(Z_OBJCE_P(value), php_sdl_frect_ce)) {
+	if (instanceof_function(Z_OBJCE_P(value), php_sdl_frect_ce))
+	{
 		zval *val, rv;
 
 		val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
@@ -176,7 +186,8 @@ zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect)
 
 zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
 {
-	if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) {
+	if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce))
+	{
 		zval *val, rv;
 
 		val = zend_read_property(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
@@ -196,7 +207,8 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt)
 
 zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *pt)
 {
-	if (instanceof_function(Z_OBJCE_P(value), php_sdl_fpoint_ce)) {
+	if (instanceof_function(Z_OBJCE_P(value), php_sdl_fpoint_ce))
+	{
 		zval *val, rv;
 
 		val = zend_read_property(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, 0, &rv);
@@ -222,7 +234,8 @@ PHP_METHOD(SDL_Rect, __construct)
 {
 	zend_long x = 0, y = 0, w = 0, h = 0;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &x, &y, &w, &h)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|llll", &x, &y, &w, &h))
+	{
 		return;
 	}
 
@@ -239,7 +252,8 @@ PHP_METHOD(SDL_Rect, __toString)
 	zend_string *buf;
 	SDL_Rect rect;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -254,10 +268,10 @@ PHP_METHOD(SDL_FRect, __construct)
 	double x = 0, y = 0, w = 0, h = 0;
 
 	ZEND_PARSE_PARAMETERS_START(4, 4)
-		Z_PARAM_DOUBLE(x)
-		Z_PARAM_DOUBLE(y)
-		Z_PARAM_DOUBLE(w)
-		Z_PARAM_DOUBLE(h)
+	Z_PARAM_DOUBLE(x)
+	Z_PARAM_DOUBLE(y)
+	Z_PARAM_DOUBLE(w)
+	Z_PARAM_DOUBLE(h)
 	ZEND_PARSE_PARAMETERS_END();
 
 	zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "x", 1, x);
@@ -271,7 +285,8 @@ PHP_METHOD(SDL_FRect, __toString)
 	zend_string *buf;
 	SDL_FRect rect;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -290,7 +305,8 @@ PHP_METHOD(SDL_Point, __construct)
 	zend_error_handling error_handling;
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &x, &y)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &x, &y))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
@@ -301,14 +317,14 @@ PHP_METHOD(SDL_Point, __construct)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Point::__toString() */
 PHP_METHOD(SDL_Point, __toString)
 {
 	zend_string *buf;
 	SDL_Point point;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -323,8 +339,8 @@ PHP_METHOD(SDL_FPoint, __construct)
 	double x = 0, y = 0;
 
 	ZEND_PARSE_PARAMETERS_START(2, 2)
-		Z_PARAM_DOUBLE(x)
-		Z_PARAM_DOUBLE(y)
+	Z_PARAM_DOUBLE(x)
+	Z_PARAM_DOUBLE(y)
 	ZEND_PARSE_PARAMETERS_END();
 
 	zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(getThis()), "x", 1, x);
@@ -336,7 +352,8 @@ PHP_METHOD(SDL_FPoint, __toString)
 	zend_string *buf;
 	SDL_FPoint point;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -355,11 +372,12 @@ PHP_FUNCTION(SDL_RectEmpty)
 	zval *object;
 	SDL_Rect rect;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_rect_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_rect_ce) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_rect(object, &rect);
-	
+
 	RETURN_BOOL(SDL_RectEmpty(&rect));
 }
 /* }}} */
@@ -369,7 +387,8 @@ PHP_FUNCTION(SDL_FRectEmpty)
 	zval *object;
 	SDL_FRect rect;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_frect_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_frect_ce) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_frect(object, &rect);
@@ -387,36 +406,37 @@ PHP_FUNCTION(SDL_RectEquals)
 	zval *obj1, *obj2;
 	SDL_Rect rect1, rect2;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_rect(obj1, &rect1);
 	zval_to_sdl_rect(obj2, &rect2);
-	
+
 	RETURN_BOOL(SDL_RectEquals(&rect1, &rect2));
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_HasIntersection(SDL_Rect a, SDL_Rect b)
 
  *  \brief Determine whether two rectangles intersect.
  *
  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
-                                                      const SDL_Rect * B);
+													  const SDL_Rect * B);
  */
 PHP_FUNCTION(SDL_HasIntersection)
 {
 	zval *obj1, *obj2;
 	SDL_Rect rect1, rect2;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_rect(obj1, &rect1);
 	zval_to_sdl_rect(obj2, &rect2);
-	
+
 	RETURN_BOOL(SDL_HasIntersection(&rect1, &rect2));
 }
 /* }}} */
@@ -427,7 +447,8 @@ PHP_FUNCTION(SDL_HasIntersectionF)
 	SDL_FRect A, B;
 	float Amin, Amax, Bmin, Bmax;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_frect(obj1, &A);
@@ -439,13 +460,16 @@ PHP_FUNCTION(SDL_HasIntersectionF)
 	Amax = Amin + A.w;
 	Bmin = B.x;
 	Bmax = Bmin + B.w;
-	if (Bmin > Amin) {
+	if (Bmin > Amin)
+	{
 		Amin = Bmin;
 	}
-	if (Bmax < Amax) {
+	if (Bmax < Amax)
+	{
 		Amax = Bmax;
 	}
-	if (Amax <= Amin) {
+	if (Amax <= Amin)
+	{
 		RETURN_FALSE;
 	}
 
@@ -454,18 +478,21 @@ PHP_FUNCTION(SDL_HasIntersectionF)
 	Amax = Amin + A.h;
 	Bmin = B.y;
 	Bmax = Bmin + B.h;
-	if (Bmin > Amin) {
+	if (Bmin > Amin)
+	{
 		Amin = Bmin;
 	}
-	if (Bmax < Amax) {
+	if (Bmax < Amax)
+	{
 		Amax = Bmax;
 	}
-	if (Amax <= Amin) {
+	if (Amax <= Amin)
+	{
 		RETURN_FALSE;
 	}
 
 	RETURN_TRUE;
-//	RETURN_BOOL(SDL_HasIntersectionF(&rect1, &rect2));
+	//	RETURN_BOOL(SDL_HasIntersectionF(&rect1, &rect2));
 }
 
 /* {{{ proto bool SDL_IntersectRect(SDL_Rect a, SDL_Rect b, SDL_Rect &result)
@@ -474,20 +501,22 @@ PHP_FUNCTION(SDL_HasIntersectionF)
  *
  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
-                                                    const SDL_Rect * B,
-                                                    SDL_Rect * result);
+													const SDL_Rect * B,
+													SDL_Rect * result);
  */
 PHP_FUNCTION(SDL_IntersectRect)
 {
 	zval *obj1, *obj2, *result;
 	SDL_Rect rect1, rect2, rect3;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_rect(obj1, &rect1);
 	zval_to_sdl_rect(obj2, &rect2);
-	if (SDL_IntersectRect(&rect1, &rect2, &rect3)) {
+	if (SDL_IntersectRect(&rect1, &rect2, &rect3))
+	{
 		zval_ptr_dtor(result);
 		sdl_rect_to_zval(&rect3, result);
 		RETURN_TRUE;
@@ -496,14 +525,14 @@ PHP_FUNCTION(SDL_IntersectRect)
 }
 /* }}} */
 
-
 PHP_FUNCTION(SDL_IntersectFRect)
 {
 	zval *obj1, *obj2, *result;
 	SDL_FRect A, B, resultRect;
 	float Amin, Amax, Bmin, Bmax;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce, &result) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce, &result) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_frect(obj1, &A);
@@ -511,7 +540,8 @@ PHP_FUNCTION(SDL_IntersectFRect)
 
 	/** SDL_IntersectFRect does not exists (SDL <= 2.0.20) */
 	/* Special cases for empty rects */
-	if ((A.w <= 0.0f) || (A.h <= 0.0f) || (B.w <= 0.0f) || (B.h <= 0.0f)) {
+	if ((A.w <= 0.0f) || (A.h <= 0.0f) || (B.w <= 0.0f) || (B.h <= 0.0f))
+	{
 		resultRect.w = 0;
 		resultRect.h = 0;
 
@@ -545,7 +575,8 @@ PHP_FUNCTION(SDL_IntersectFRect)
 		Amax = Bmax;
 	resultRect.h = Amax - Amin;
 
-	if (!((resultRect.w <= 0.0f) || (resultRect.h <= 0.0f))) { // !SDL_FRectEmpty
+	if (!((resultRect.w <= 0.0f) || (resultRect.h <= 0.0f)))
+	{ // !SDL_FRectEmpty
 		zval_ptr_dtor(result);
 		sdl_frect_to_zval(&resultRect, result);
 
@@ -559,15 +590,16 @@ PHP_FUNCTION(SDL_IntersectFRect)
 
  *  \brief Calculate the union of two rectangles.
  extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
-                                            const SDL_Rect * B,
-                                            SDL_Rect * result);
+											const SDL_Rect * B,
+											SDL_Rect * result);
  */
 PHP_FUNCTION(SDL_UnionRect)
 {
 	zval *obj1, *obj2, *result;
 	SDL_Rect rect1, rect2, rect3;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_rect(obj1, &rect1);
@@ -578,17 +610,15 @@ PHP_FUNCTION(SDL_UnionRect)
 }
 /* }}} */
 
-
-
 /* {{{ proto bool SDL_EnclosePoints(array points, int count, SDL_Rect clip, SDL_Rect &result)
 
  *  \brief Calculate a minimal rectangle enclosing a set of points
  *
  *  \return SDL_TRUE if any points were within the clipping rect
  extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
-                                                    int count,
-                                                    const SDL_Rect * clip,
-                                                    SDL_Rect * result);
+													int count,
+													const SDL_Rect * clip,
+													SDL_Rect * result);
  */
 PHP_FUNCTION(SDL_EnclosePoints)
 {
@@ -599,34 +629,42 @@ PHP_FUNCTION(SDL_EnclosePoints)
 	SDL_Rect clip, result;
 	SDL_Point *points;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz/", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz/", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE)
+	{
 		return;
 	}
 	RETVAL_FALSE;
 
-	if (count<=0) {
+	if (count <= 0)
+	{
 		count = zend_hash_next_free_element(Z_ARRVAL_P(z_points));
 	}
-	points = emalloc(sizeof(SDL_Point)*count);
+	points = emalloc(sizeof(SDL_Point) * count);
 
 	zval_to_sdl_rect(z_clip, &clip);
-	for (i=0, nb=0 ; i<count ; i++) {
-		if (!(z_point = zend_hash_index_find(Z_ARRVAL_P(z_points), i))) {
+	for (i = 0, nb = 0; i < count; i++)
+	{
+		if (!(z_point = zend_hash_index_find(Z_ARRVAL_P(z_points), i)))
+		{
 			php_error_docref(NULL, E_WARNING, "point #%ld missing", i);
-
-		} else if (Z_TYPE(*z_point) != IS_OBJECT || Z_OBJCE_P(z_point) != php_sdl_point_ce) {
+		}
+		else if (Z_TYPE(*z_point) != IS_OBJECT || Z_OBJCE_P(z_point) != php_sdl_point_ce)
+		{
 			php_error_docref(NULL, E_WARNING, "point #%ld is not a SDL_Point object", i);
-
-		} else {
-			zval_to_sdl_point(z_point, points+nb);
+		}
+		else
+		{
+			zval_to_sdl_point(z_point, points + nb);
 			nb++;
 		}
 	}
 
-	if (!nb) {
+	if (!nb)
+	{
 		php_error_docref(NULL, E_WARNING, "no point in provided array");
-
-	} else if (SDL_EnclosePoints(points, nb, &clip, &result)) {
+	}
+	else if (SDL_EnclosePoints(points, nb, &clip, &result))
+	{
 		zval_ptr_dtor(z_result);
 		sdl_rect_to_zval(&result, z_result);
 		RETVAL_TRUE;
@@ -635,16 +673,15 @@ PHP_FUNCTION(SDL_EnclosePoints)
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_IntersectRectAndLine(const SDL_Rect *, int &x1, int &y1, int &x2, int &y2)
 
  *  \brief Calculate the intersection of a rectangle and line segment.
  *
  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
  extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
-                                                           rect, int *X1,
-                                                           int *Y1, int *X2,
-                                                           int *Y2);
+														   rect, int *X1,
+														   int *Y1, int *X2,
+														   int *Y2);
  */
 PHP_FUNCTION(SDL_IntersectRectAndLine)
 {
@@ -652,7 +689,8 @@ PHP_FUNCTION(SDL_IntersectRectAndLine)
 	SDL_Rect rect;
 	int x1, y1, x2, y2;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/z/", &object, php_sdl_rect_ce, &z_x1, &z_y1, &z_x2, &z_y2) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/z/", &object, php_sdl_rect_ce, &z_x1, &z_y1, &z_x2, &z_y2) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_rect(object, &rect);
@@ -665,7 +703,8 @@ PHP_FUNCTION(SDL_IntersectRectAndLine)
 	x2 = (int)Z_LVAL_P(z_x2);
 	y2 = (int)Z_LVAL_P(z_y2);
 
-	if (SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2)) {
+	if (SDL_IntersectRectAndLine(&rect, &x1, &y1, &x2, &y2))
+	{
 		Z_LVAL_P(z_x1) = x1;
 		Z_LVAL_P(z_y1) = y1;
 		Z_LVAL_P(z_x2) = x2;
@@ -682,13 +721,15 @@ PHP_FUNCTION(SDL_PointInRect)
 	SDL_Point point;
 	SDL_Rect rect;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_point, php_sdl_point_ce, &z_rect, php_sdl_rect_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_point, php_sdl_point_ce, &z_rect, php_sdl_rect_ce) == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_rect(z_rect, &rect);
 	zval_to_sdl_point(z_point, &point);
 
-	if (SDL_PointInRect(&point, &rect)) {
+	if (SDL_PointInRect(&point, &rect))
+	{
 		RETURN_TRUE;
 	}
 	RETURN_FALSE;
diff --git a/tests/006-rect.phpt b/tests/006-rect.phpt
index f44d83b..858a4d2 100644
--- a/tests/006-rect.phpt
+++ b/tests/006-rect.phpt
@@ -6,6 +6,9 @@ require 'test-functions.php';
 --FILE--
 <?php
 echo "+++ Empty (true)\n";
+$r = new SDL_Rect();
+echo $r, PHP_EOL;
+
 $r = new SDL_Rect(0,0,0,0);
 var_dump($r);
 var_dump(SDL_RectEmpty($r));
@@ -94,6 +97,7 @@ var_dump($r);
 Done
 --EXPECTF--
 +++ Empty (true)
+SDL_Rect(0,0,0,0)
 object(SDL_Rect)#%d (4) {
   ["x"]=>
   int(0)
@@ -238,7 +242,7 @@ object(SDL_FRect)#%d (4) {
   float(4.4)
 }
 +++ SDL_FPoint
-object(SDL_FPoint)#2 (2) {
+object(SDL_FPoint)#%d (2) {
   ["x"]=>
   float(1.1)
   ["y"]=>
diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt
index 8e23672..3a453ee 100644
--- a/tests/007-rect-oo.phpt
+++ b/tests/007-rect-oo.phpt
@@ -57,7 +57,7 @@ var_dump($fr2->HasIntersection($fr4));
 var_dump($fr2->Intersect($fr4, $x));
 var_dump($x); unset($x);
 
-echo "+++ Uninon\n";
+echo "+++ Union\n";
 var_dump($r2->Union($r3, $x));
 var_dump($x); unset($x);
 var_dump($r2->Union($r4, $x));
@@ -164,7 +164,7 @@ NULL
 bool(false)
 bool(false)
 NULL
-+++ Uninon
++++ Union
 NULL
 object(SDL_Rect)#%d (4) {
   ["x"]=>
@@ -196,4 +196,4 @@ int(24)
 bool(false)
 +++ Test subclasses of SDL_Rect can be passed to SDL functions
 bool(false)
-Done
\ No newline at end of file
+Done

From 4880c91330e972f1a41e11395a8c697af22af5b4 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 22 Jul 2022 15:14:30 +0100
Subject: [PATCH 42/53] Fix issue on SDL_GetKeyboardState

---
 examples/009-window-events.php | 11 ++++
 package.xml                    | 31 ++++++++---
 src/joystick.h                 |  6 ---
 src/keyboard.c                 | 98 ++++++++++++++++------------------
 src/keyboard.h                 | 86 ++++++++++++++---------------
 src/php_sdl.h                  | 42 ++++++++-------
 6 files changed, 146 insertions(+), 128 deletions(-)

diff --git a/examples/009-window-events.php b/examples/009-window-events.php
index 38222bd..5cfb804 100644
--- a/examples/009-window-events.php
+++ b/examples/009-window-events.php
@@ -16,6 +16,17 @@
 
 $event = new SDL_Event;
 while (!$quit) {
+	$keyboardState = SDL_GetKeyboardState($numkeys);
+    if($keyboardState[SDL_SCANCODE_RETURN]) {
+        echo 'SDL_SCANCODE_RETURN pressed', PHP_EOL;
+    }
+    if($keyboardState[SDL_SCANCODE_RIGHT]) {
+        echo 'SDL_SCANCODE_RIGHT pressed', PHP_EOL;
+    }
+    if($keyboardState[SDL_SCANCODE_UP]) {
+        echo 'SDL_SCANCODE_UP pressed', PHP_EOL;
+    }
+
     while (SDL_PollEvent($event)) {
         switch ($event->type) {
             case SDL_QUIT:
diff --git a/package.xml b/package.xml
index 367f667..a3e3615 100644
--- a/package.xml
+++ b/package.xml
@@ -19,11 +19,11 @@
     <active>yes</active>
   </lead>
   <!-- Current version -->
-  <date>2022-03-17</date>
+  <date>2022-07-22</date>
   <time>12:00:00</time>
   <version>
-    <release>2.6.0</release>
-    <api>2.6.0</api>
+    <release>2.7.0</release>
+    <api>2.7.0</api>
   </version>
   <stability>
     <release>beta</release>
@@ -31,10 +31,7 @@
   </stability>
   <license uri="https://www.php.net/license">PHP</license>
   <notes>
-	- Add float rect and float point render functions (Manuel Baldassarri)
-	- Add config file for Windows (Zorobabel)
-	- Fix PECL build (Manuel Baldassarri)
-	- Rename width parameter in SDL_Rect constructor (Manuel Baldassarri)
+  	  - Fix SDL_GetKeyboardState (https://github.com/Ponup/php-sdl/issues/68)
   </notes>
   <!--/Current version -->
   <contents>
@@ -158,6 +155,26 @@
   <providesextension>sdl</providesextension>
   <extsrcrelease/>
   <changelog>
+  	  <release>
+  <date>2022-03-17</date>
+  <time>12:00:00</time>
+  <version>
+    <release>2.6.0</release>
+    <api>2.6.0</api>
+  </version>
+  <stability>
+    <release>beta</release>
+    <api>beta</api>
+  </stability>
+  <license uri="https://www.php.net/license">PHP</license>
+  <notes>
+	- Add float rect and float point render functions (Manuel Baldassarri)
+	- Add config file for Windows (Zorobabel)
+	- Fix PECL build (Manuel Baldassarri)
+	- Rename width parameter in SDL_Rect constructor (Manuel Baldassarri)
+  </notes>
+
+  	  </release>
   	<release>
   		  <date>2021-06-18</date>
   		  <time>12:00:00</time>
diff --git a/src/joystick.h b/src/joystick.h
index b02ee80..5dbb44d 100644
--- a/src/joystick.h
+++ b/src/joystick.h
@@ -25,12 +25,6 @@ extern "C"
 
 #include "php_sdl.h"
 
-#define ARG_PASS_BY_REF 1
-#define ARG_NOT_PASS_BY_REF 0
-
-#define ARG_ALLOW_NULL 1
-#define ARG_NOT_ALLOW_NULL 0
-
   ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_NumJoysticks, 0, 0, 0)
   ZEND_END_ARG_INFO()
   PHP_FUNCTION(SDL_NumJoysticks);
diff --git a/src/keyboard.c b/src/keyboard.c
index eccf18c..145c523 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -26,19 +26,15 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
  */
 PHP_FUNCTION(SDL_GetKeyboardFocus)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	sdl_window_to_zval(SDL_GetKeyboardFocus(), return_value, SDL_DONTFREE);
 }
 /* }}} */
 
-/* {{{ proto array SDL_GetKeyboardState([int &numkeys [, bool allkeys=true ]])
-
-	Standard SDL API
-		with allkeys=true  return an array of scancode => state array
-	PHP Specific, (to reduce memory)
-		with allkeys=false return an array of scancode (which are set)
+/* {{{ proto array SDL_GetKeyboardState([int &numkeys])
 
  *  \brief Get a snapshot of the current state of the keyboard.
  *
@@ -58,32 +54,27 @@ PHP_FUNCTION(SDL_GetKeyboardFocus)
 PHP_FUNCTION(SDL_GetKeyboardState)
 {
 	zval *z_numkeys = NULL;
-	int i, nb, numkeys;
-	zend_bool allkeys=1;
+	int i, numkeys;
 	const Uint8 *state;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zb", &z_numkeys, &allkeys)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &z_numkeys))
+	{
 		return;
 	}
 	state = SDL_GetKeyboardState(&numkeys);
 	array_init(return_value);
-	for (nb=i=0 ; i<numkeys ; i++) {
-		if (allkeys) {
-			add_next_index_long(return_value, state[i]);
-			nb++;
-		} else if (state[i]) {
-			add_next_index_long(return_value, i);
-			nb++;
-		}
+	for (i = 0; i < numkeys; i++)
+	{
+		add_next_index_long(return_value, state[i]);
 	}
-	if (z_numkeys) {
-		zval_dtor(z_numkeys);
-		ZVAL_LONG(z_numkeys, nb);
+
+	if (z_numkeys)
+	{
+		ZEND_TRY_ASSIGN_REF_LONG(z_numkeys, numkeys);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GetModState(void)
 
  *  \brief Get the current key modifier state for the keyboard.
@@ -91,14 +82,14 @@ PHP_FUNCTION(SDL_GetKeyboardState)
  */
 PHP_FUNCTION(SDL_GetModState)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_GetModState());
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_SetModState(int modstate)
 
  *  \brief Set the current key modifier state for the keyboard.
@@ -110,14 +101,14 @@ PHP_FUNCTION(SDL_SetModState)
 {
 	zend_long modstate;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &modstate)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &modstate))
+	{
 		return;
 	}
 	SDL_SetModState(modstate);
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GetKeyFromScancode(int scancode)
 
  *  \brief Get the key code corresponding to the given scancode according
@@ -132,14 +123,14 @@ PHP_FUNCTION(SDL_GetKeyFromScancode)
 {
 	zend_long scancode;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &scancode)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &scancode))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_GetKeyFromScancode(scancode));
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GetScancodeFromKey(int key)
 
  *  \brief Get the scancode corresponding to the given key code according to the
@@ -154,14 +145,14 @@ PHP_FUNCTION(SDL_GetScancodeFromKey)
 {
 	zend_long key;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &key)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &key))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_GetScancodeFromKey(key));
 }
 /* }}} */
 
-
 /* {{{ proto string SDL_GetScancodeName(int scancode)
 
  *  \brief Get a human-readable name for a scancode.
@@ -177,14 +168,14 @@ PHP_FUNCTION(SDL_GetScancodeName)
 {
 	zend_long scancode;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &scancode)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &scancode))
+	{
 		return;
 	}
 	RETVAL_STRING(SDL_GetScancodeName(scancode));
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GetScancodeFromName(string name)
 
  *  \brief Get a scancode from a human-readable name
@@ -199,14 +190,14 @@ PHP_FUNCTION(SDL_GetScancodeFromName)
 	char *name;
 	size_t name_len;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_GetScancodeFromName(name));
 }
 /* }}} */
 
-
 /* {{{ proto string SDL_GetKeyName(int key)
 
  *  \brief Get a human-readable name for a key.
@@ -223,14 +214,14 @@ PHP_FUNCTION(SDL_GetKeyName)
 {
 	zend_long key;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &key)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &key))
+	{
 		return;
 	}
 	RETVAL_STRING(SDL_GetKeyName(key));
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GetKeyFromName(string name)
 
  *  \brief Get a key code from a human-readable name
@@ -245,14 +236,14 @@ PHP_FUNCTION(SDL_GetKeyFromName)
 	char *name;
 	size_t name_len;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_GetKeyFromName(name));
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_StartTextInput(void)
 
  *  \brief Start accepting Unicode text input events.
@@ -265,14 +256,14 @@ PHP_FUNCTION(SDL_GetKeyFromName)
  */
 PHP_FUNCTION(SDL_StartTextInput)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	SDL_StartTextInput();
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_IsTextInputActive(void)
 
  *  \brief Return whether or not Unicode text input events are enabled.
@@ -283,14 +274,14 @@ PHP_FUNCTION(SDL_StartTextInput)
  */
 PHP_FUNCTION(SDL_IsTextInputActive)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	RETVAL_BOOL(SDL_IsTextInputActive());
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_StopTextInput(void)
 
  *  \brief Stop receiving any text input events.
@@ -302,7 +293,8 @@ PHP_FUNCTION(SDL_IsTextInputActive)
  */
 PHP_FUNCTION(SDL_StopTextInput)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	SDL_StopTextInput();
@@ -322,16 +314,17 @@ PHP_FUNCTION(SDL_SetTextInputRect)
 	zval *z_rect;
 	SDL_Rect rect;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_rect, get_php_sdl_rect_ce())) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_rect, get_php_sdl_rect_ce()))
+	{
 		return;
 	}
-	if (zval_to_sdl_rect(z_rect, &rect)) {
+	if (zval_to_sdl_rect(z_rect, &rect))
+	{
 		SDL_SetTextInputRect(&rect);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_HasScreenKeyboardSupport(void)
 
  *  \brief Returns whether the platform has some screen keyboard support.
@@ -345,14 +338,14 @@ PHP_FUNCTION(SDL_SetTextInputRect)
  */
 PHP_FUNCTION(SDL_HasScreenKeyboardSupport)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	RETVAL_BOOL(SDL_HasScreenKeyboardSupport());
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_IsScreenKeyboardShown(SDL_Window window)
 
  *  \brief Returns whether the screen keyboard is shown for given window.
@@ -369,17 +362,18 @@ PHP_FUNCTION(SDL_IsScreenKeyboardShown)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce()))
+	{
 		return;
 	}
 	window = zval_to_sdl_window(z_window);
-	if (window) {
+	if (window)
+	{
 		RETVAL_BOOL(SDL_IsScreenKeyboardShown(window));
 	}
 }
 /* }}} */
 
-
 /* {{{ MINIT */
 PHP_MINIT_FUNCTION(sdl_keyboard)
 {
diff --git a/src/keyboard.h b/src/keyboard.h
index ff9a1aa..158e4e8 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -15,69 +15,65 @@
   +----------------------------------------------------------------------+
 */
 
-
 #ifndef PHP_SDL_KEYBOARD_H
 #define PHP_SDL_KEYBOARD_H
 
-#ifdef  __cplusplus
-extern "C" {
+#ifdef __cplusplus
+extern "C"
+{
 #endif
 
 #include "php_sdl.h"
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetKeyboardState, 0, 0, 0)
-       ZEND_ARG_INFO(1, numkeys)
-       ZEND_ARG_INFO(0, allkeys)
-ZEND_END_ARG_INFO()
-
+       ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetKeyboardState, 0, 0, 0)
+       ZEND_ARG_TYPE_INFO(ARG_PASS_BY_REF, numkeys, IS_LONG, ARG_ALLOW_NULL)
+       ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetModState, 0, 0, 1)
+       ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetModState, 0, 0, 1)
        ZEND_ARG_INFO(0, modstate)
-ZEND_END_ARG_INFO()
+       ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetTextInputRect, 0, 0, 1)
+       ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetTextInputRect, 0, 0, 1)
        ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
-ZEND_END_ARG_INFO()
+       ZEND_END_ARG_INFO()
 
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_IsScreenKeyboardShown, 0, 0, 1)
+       ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_IsScreenKeyboardShown, 0, 0, 1)
        ZEND_ARG_OBJ_INFO(0, window, SDL_Window, 0)
-ZEND_END_ARG_INFO()
+       ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_scancode, 0, 0, 1)
+       ZEND_BEGIN_ARG_INFO_EX(arginfo_scancode, 0, 0, 1)
        ZEND_ARG_INFO(0, scancode)
-ZEND_END_ARG_INFO()
+       ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_key, 0, 0, 1)
+       ZEND_BEGIN_ARG_INFO_EX(arginfo_key, 0, 0, 1)
        ZEND_ARG_INFO(0, key)
-ZEND_END_ARG_INFO()
+       ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_name, 0, 0, 1)
+       ZEND_BEGIN_ARG_INFO_EX(arginfo_name, 0, 0, 1)
        ZEND_ARG_INFO(0, name)
-ZEND_END_ARG_INFO()
-
-PHP_FUNCTION(SDL_GetKeyboardFocus);
-PHP_FUNCTION(SDL_GetKeyboardState);
-PHP_FUNCTION(SDL_GetModState);
-PHP_FUNCTION(SDL_SetModState);
-PHP_FUNCTION(SDL_GetKeyFromScancode);
-PHP_FUNCTION(SDL_GetScancodeFromKey);
-PHP_FUNCTION(SDL_GetScancodeName);
-PHP_FUNCTION(SDL_GetScancodeFromName);
-PHP_FUNCTION(SDL_GetKeyName);
-PHP_FUNCTION(SDL_GetKeyFromName);
-PHP_FUNCTION(SDL_StartTextInput);
-PHP_FUNCTION(SDL_IsTextInputActive);
-PHP_FUNCTION(SDL_StopTextInput);
-PHP_FUNCTION(SDL_SetTextInputRect);
-PHP_FUNCTION(SDL_HasScreenKeyboardSupport);
-PHP_FUNCTION(SDL_IsScreenKeyboardShown);
-
-PHP_MINIT_FUNCTION(sdl_keyboard);
-
-#ifdef  __cplusplus
-} // extern "C" 
+       ZEND_END_ARG_INFO()
+
+       PHP_FUNCTION(SDL_GetKeyboardFocus);
+       PHP_FUNCTION(SDL_GetKeyboardState);
+       PHP_FUNCTION(SDL_GetModState);
+       PHP_FUNCTION(SDL_SetModState);
+       PHP_FUNCTION(SDL_GetKeyFromScancode);
+       PHP_FUNCTION(SDL_GetScancodeFromKey);
+       PHP_FUNCTION(SDL_GetScancodeName);
+       PHP_FUNCTION(SDL_GetScancodeFromName);
+       PHP_FUNCTION(SDL_GetKeyName);
+       PHP_FUNCTION(SDL_GetKeyFromName);
+       PHP_FUNCTION(SDL_StartTextInput);
+       PHP_FUNCTION(SDL_IsTextInputActive);
+       PHP_FUNCTION(SDL_StopTextInput);
+       PHP_FUNCTION(SDL_SetTextInputRect);
+       PHP_FUNCTION(SDL_HasScreenKeyboardSupport);
+       PHP_FUNCTION(SDL_IsScreenKeyboardShown);
+
+       PHP_MINIT_FUNCTION(sdl_keyboard);
+
+#ifdef __cplusplus
+} // extern "C"
 #endif
 
 #endif /* PHP_SDL_KEYBOARD_H */
-
diff --git a/src/php_sdl.h b/src/php_sdl.h
index 10912d1..265088b 100644
--- a/src/php_sdl.h
+++ b/src/php_sdl.h
@@ -15,12 +15,18 @@
   +----------------------------------------------------------------------+
 */
 
-
 #ifndef PHP_PHPSDL_H
 #define PHP_PHPSDL_H
 
-#ifdef  __cplusplus
-extern "C" {
+#define ARG_PASS_BY_REF 1
+#define ARG_NOT_PASS_BY_REF 0
+
+#define ARG_ALLOW_NULL 1
+#define ARG_NOT_ALLOW_NULL 0
+
+#ifdef __cplusplus
+extern "C"
+{
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -30,7 +36,7 @@ extern "C" {
 #include <php.h>
 #include <zend_exceptions.h>
 
-#define PHP_SDL_VERSION "2.6.0"
+#define PHP_SDL_VERSION "2.7.0"
 
 #if defined(__APPLE__) && defined(__MACH__)
 #include <SDL2/SDL.h>
@@ -42,14 +48,15 @@ extern "C" {
 #include <SAPI.h>
 #include <ext/standard/info.h>
 #include <Zend/zend_extensions.h>
-#ifdef  __cplusplus
-} // extern "C" 
+#ifdef __cplusplus
+} // extern "C"
 #endif
-#ifdef  __cplusplus
-extern "C" {
+#ifdef __cplusplus
+extern "C"
+{
 #endif
 
-extern zend_module_entry sdl_module_entry;
+  extern zend_module_entry sdl_module_entry;
 #define phpext_sdl_ptr &sdl_module_entry
 
 #ifdef PHP_WIN32
@@ -58,21 +65,20 @@ extern zend_module_entry sdl_module_entry;
 #define PHP_SDL_API
 #endif
 
-PHP_MINIT_FUNCTION(sdl);
-PHP_MSHUTDOWN_FUNCTION(sdl);
-PHP_RINIT_FUNCTION(sdl);
-PHP_RSHUTDOWN_FUNCTION(sdl);
-PHP_MINFO_FUNCTION(sdl);
+  PHP_MINIT_FUNCTION(sdl);
+  PHP_MSHUTDOWN_FUNCTION(sdl);
+  PHP_RINIT_FUNCTION(sdl);
+  PHP_RSHUTDOWN_FUNCTION(sdl);
+  PHP_MINFO_FUNCTION(sdl);
 
-zend_bool php_sdl_check_overflow(int a, int b, int silent);
+  zend_bool php_sdl_check_overflow(int a, int b, int silent);
 
-#ifdef  __cplusplus
-} // extern "C" 
+#ifdef __cplusplus
+} // extern "C"
 #endif
 
 #endif /* PHP_PHPSDL_H */
 
-
 /*
  * Local variables:
  * tab-width: 4

From 38882fe972c0d788575848e8bc284fd12eab96be Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 22 Jul 2022 17:51:46 +0100
Subject: [PATCH 43/53] =?UTF-8?q?Remove=20extra=20=E2=80=98;=E2=80=99=20ou?=
 =?UTF-8?q?tside=20of=20functions?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/pixels.c | 957 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 527 insertions(+), 430 deletions(-)

diff --git a/src/pixels.c b/src/pixels.c
index 4594d58..3568551 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -15,7 +15,6 @@
   +----------------------------------------------------------------------+
 */
 
-
 #include "pixels.h"
 #include "zend_interfaces.h"
 #include "zend_operators.h"
@@ -23,37 +22,41 @@
 /* for PHP 8.0 */
 #ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX
 #define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
-        ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args)
+	ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args)
 #endif
 
 static zend_class_entry *php_sdl_color_ce;
 static zend_object_handlers php_sdl_color_handlers;
-struct php_sdl_color {
-	zend_object   zo;
+struct php_sdl_color
+{
+	zend_object zo;
 };
 
 static zend_class_entry *php_sdl_palette_ce;
 static zend_object_handlers php_sdl_palette_handlers;
-typedef struct _php_sdl_palette {
-	SDL_Palette   *palette;
-	Uint32        flags;
-	zend_object   zo;
+typedef struct _php_sdl_palette
+{
+	SDL_Palette *palette;
+	Uint32 flags;
+	zend_object zo;
 } php_sdl_palette;
 
 static zend_class_entry *php_sdl_pixelformat_ce;
 static zend_object_handlers php_sdl_pixelformat_handlers;
-typedef struct _php_sdl_pixelformat {
+typedef struct _php_sdl_pixelformat
+{
 	SDL_PixelFormat *format;
-	Uint32           flags;
-	zend_object      zo;
+	Uint32 flags;
+	zend_object zo;
 } php_sdl_pixelformat;
 
 static zend_class_entry *php_sdl_pixels_ce;
 static zend_object_handlers php_sdl_pixels_handlers;
-typedef struct _php_sdl_pixels {
-	SDL_Pixels       pixels;
-	Uint32           flags;
-	zend_object      zo;
+typedef struct _php_sdl_pixels
+{
+	SDL_Pixels pixels;
+	Uint32 flags;
+	zend_object zo;
 } php_sdl_pixels;
 
 zend_class_entry *get_php_sdl_color_ce(void)
@@ -76,48 +79,53 @@ zend_class_entry *get_php_sdl_pixels_ce(void)
 	return php_sdl_pixels_ce;
 }
 
-static inline php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) {
-	return (php_sdl_palette*)((char*)(obj) - XtOffsetOf(php_sdl_palette, zo));
+static inline php_sdl_palette *php_sdl_palette_from_obj(zend_object *obj)
+{
+	return (php_sdl_palette *)((char *)(obj)-XtOffsetOf(php_sdl_palette, zo));
 }
 
-#define FETCH_PALETTE(__ptr, __id, __check) \
-{ \
-		intern = PHP_SDL_PALETTE_P(__id);\
-		__ptr = intern->palette; \
-		if (__check && !__ptr) {\
-				php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-				RETURN_FALSE;\
-		}\
-}
+#define FETCH_PALETTE(__ptr, __id, __check)                                                        \
+	{                                                                                              \
+		intern = PHP_SDL_PALETTE_P(__id);                                                          \
+		__ptr = intern->palette;                                                                   \
+		if (__check && !__ptr)                                                                     \
+		{                                                                                          \
+			php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+			RETURN_FALSE;                                                                          \
+		}                                                                                          \
+	}
 
-#define PHP_SDL_PALETTE_P(zv)  php_sdl_palette_from_obj(Z_OBJ_P((zv)))
+#define PHP_SDL_PALETTE_P(zv) php_sdl_palette_from_obj(Z_OBJ_P((zv)))
 
-static inline php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_object *obj) {
-	return (php_sdl_pixelformat*)((char*)(obj) - XtOffsetOf(php_sdl_pixelformat, zo));
+static inline php_sdl_pixelformat *php_sdl_pixelformat_from_obj(zend_object *obj)
+{
+	return (php_sdl_pixelformat *)((char *)(obj)-XtOffsetOf(php_sdl_pixelformat, zo));
 }
 
-#define FETCH_PIXELFORMAT(__ptr, __id, __check) \
-{ \
-		intern = PHP_SDL_PIXELFORMAT_P(__id);\
-		__ptr = intern->format; \
-		if (__check && !__ptr) {\
-				php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-				RETURN_FALSE;\
-		}\
-}
+#define FETCH_PIXELFORMAT(__ptr, __id, __check)                                                    \
+	{                                                                                              \
+		intern = PHP_SDL_PIXELFORMAT_P(__id);                                                      \
+		__ptr = intern->format;                                                                    \
+		if (__check && !__ptr)                                                                     \
+		{                                                                                          \
+			php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+			RETURN_FALSE;                                                                          \
+		}                                                                                          \
+	}
 
-#define PHP_SDL_PIXELFORMAT_P(zv)  php_sdl_pixelformat_from_obj(Z_OBJ_P((zv)))
+#define PHP_SDL_PIXELFORMAT_P(zv) php_sdl_pixelformat_from_obj(Z_OBJ_P((zv)))
 
-static inline php_sdl_pixels* php_sdl_pixels_from_obj(zend_object *obj) {
-	return (php_sdl_pixels*)((char*)(obj) - XtOffsetOf(php_sdl_pixels, zo));
+static inline php_sdl_pixels *php_sdl_pixels_from_obj(zend_object *obj)
+{
+	return (php_sdl_pixels *)((char *)(obj)-XtOffsetOf(php_sdl_pixels, zo));
 }
 
-#define PHP_SDL_PIXELS_P(zv)  php_sdl_pixels_from_obj(Z_OBJ_P((zv)))
-
+#define PHP_SDL_PIXELS_P(zv) php_sdl_pixels_from_obj(Z_OBJ_P((zv)))
 
 zend_bool sdl_color_to_zval(SDL_Color *color, zval *value)
 {
-	if (color) {
+	if (color)
+	{
 		object_init_ex(value, php_sdl_color_ce);
 		zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, color->r);
 		zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "g", 1, color->g);
@@ -132,7 +140,8 @@ zend_bool sdl_color_to_zval(SDL_Color *color, zval *value)
 
 zend_bool zval_to_sdl_color(zval *value, SDL_Color *color)
 {
-	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_color_ce) {
+	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_color_ce)
+	{
 		zval *val, rv;
 
 		val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, 0, &rv);
@@ -158,11 +167,11 @@ zend_bool zval_to_sdl_color(zval *value, SDL_Color *color)
 	return 0;
 }
 
-
 /* {{{ sdl_palette_to_zval */
 zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags)
 {
-	if (palette) {
+	if (palette)
+	{
 		php_sdl_palette *intern;
 
 		object_init_ex(z_val, php_sdl_palette_ce);
@@ -177,11 +186,11 @@ zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags)
 }
 /* }}} */
 
-
 /* {{{ sdl_pixelformat_to_zval */
 zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 flags)
 {
-	if (format) {
+	if (format)
+	{
 		php_sdl_pixelformat *intern;
 
 		object_init_ex(z_val, php_sdl_pixelformat_ce);
@@ -200,13 +209,14 @@ zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 f
 /* {{{ sdl_pixels_to_zval */
 zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags)
 {
-	if (pixels) {
+	if (pixels)
+	{
 		php_sdl_pixels *intern;
 
 		object_init_ex(z_val, php_sdl_pixels_ce);
 		intern = PHP_SDL_PIXELS_P(z_val);
 		intern->pixels = *pixels;
-		intern->flags  = flags;
+		intern->flags = flags;
 
 		return 1;
 	}
@@ -218,12 +228,13 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags)
 /* {{{ zval_to_sdl_pixelformat */
 SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val)
 {
-	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce) {
+	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce)
+	{
 		php_sdl_pixelformat *intern;
 
 		intern = PHP_SDL_PIXELFORMAT_P(z_val);
 		return intern->format;
-		}
+	}
 	return NULL;
 }
 /* }}} */
@@ -231,12 +242,13 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val)
 /* {{{ zval_to_sdl_pixels */
 SDL_Pixels *zval_to_sdl_pixels(zval *z_val)
 {
-	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) {
+	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce)
+	{
 		php_sdl_pixels *intern;
 
 		intern = PHP_SDL_PIXELS_P(z_val);
 		return &intern->pixels;
-		}
+	}
 	return NULL;
 }
 /* }}} */
@@ -244,21 +256,22 @@ SDL_Pixels *zval_to_sdl_pixels(zval *z_val)
 /* {{{ zval_to_sdl_palette */
 SDL_Palette *zval_to_sdl_palette(zval *z_val)
 {
-	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce) {
+	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce)
+	{
 		php_sdl_palette *intern;
 
 		intern = PHP_SDL_PALETTE_P(z_val);
 		return intern->palette;
-		}
+	}
 	return NULL;
 }
 /* }}} */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Color__construct, 0, 0, 4)
-	   ZEND_ARG_INFO(0, r)
-	   ZEND_ARG_INFO(0, g)
-	   ZEND_ARG_INFO(0, b)
-	   ZEND_ARG_INFO(0, a)
+ZEND_ARG_INFO(0, r)
+ZEND_ARG_INFO(0, g)
+ZEND_ARG_INFO(0, b)
+ZEND_ARG_INFO(0, a)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Color::__construct(int r, int g, int b, int a) */
@@ -268,27 +281,28 @@ static PHP_METHOD(SDL_Color, __construct)
 	zend_error_handling error_handling;
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &r, &g, &b, &a)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &r, &g, &b, &a))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
-	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "r", 1, r&255);
-	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "g", 1, g&255);
-	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "b", 1, b&255);
-	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "a", 1, a&255);
+	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "r", 1, r & 255);
+	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "g", 1, g & 255);
+	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "b", 1, b & 255);
+	zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "a", 1, a & 255);
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Color::__toString() */
 static PHP_METHOD(SDL_Color, __toString)
 {
 	char *buf;
 	SDL_Color color;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -308,11 +322,13 @@ PHP_FUNCTION(SDL_GetPixelFormatName)
 	zend_long format;
 	const char *name;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format) == FAILURE)
+	{
 		RETURN_FALSE;
 	}
 	name = SDL_GetPixelFormatName((Uint32)format);
-	if (!name) {
+	if (!name)
+	{
 		RETURN_FALSE;
 	}
 	RETURN_STRING(name);
@@ -327,11 +343,11 @@ PHP_FUNCTION(SDL_GetPixelFormatName)
  *
  *  \sa SDL_MasksToPixelFormatEnum()
  extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
-                                                             int *bpp,
-                                                             Uint32 * Rmask,
-                                                             Uint32 * Gmask,
-                                                             Uint32 * Bmask,
-                                                             Uint32 * Amask);
+															 int *bpp,
+															 Uint32 * Rmask,
+															 Uint32 * Gmask,
+															 Uint32 * Bmask,
+															 Uint32 * Amask);
  */
 PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
 {
@@ -340,10 +356,12 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
 	int bpp;
 	Uint32 rmask, gmask, bmask, amask;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/z/z/z/z/", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/z/z/z/z/", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE)
+	{
 		RETURN_FALSE;
 	}
-	if (SDL_PixelFormatEnumToMasks((Uint32)format, &bpp, &rmask, &gmask, &bmask, &amask)) {
+	if (SDL_PixelFormatEnumToMasks((Uint32)format, &bpp, &rmask, &gmask, &bmask, &amask))
+	{
 		zval_dtor(z_bpp);
 		ZVAL_LONG(z_bpp, bpp);
 		zval_dtor(z_rmask);
@@ -361,7 +379,6 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_MasksToPixelFormatEnum(int format, int bpp, int Rmask, int Gmask, int Bmask, int Amask)
  *  \brief Convert a bpp and RGBA masks to an enumerated pixel format.
  *
@@ -370,16 +387,17 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks)
  *
  *  \sa SDL_PixelFormatEnumToMasks()
  extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
-                                                           Uint32 Rmask,
-                                                           Uint32 Gmask,
-                                                           Uint32 Bmask,
-                                                           Uint32 Amask);
+														   Uint32 Rmask,
+														   Uint32 Gmask,
+														   Uint32 Bmask,
+														   Uint32 Amask);
  */
 PHP_FUNCTION(SDL_MasksToPixelFormatEnum)
 {
 	zend_long bpp, rmask, gmask, bmask, amask;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lllll", &bpp, &rmask, &gmask, &bmask, &amask) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lllll", &bpp, &rmask, &gmask, &bmask, &amask) == FAILURE)
+	{
 		RETURN_FALSE;
 	}
 
@@ -397,7 +415,8 @@ PHP_FUNCTION(SDL_AllocFormat)
 	zend_long index;
 	SDL_PixelFormat *format;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index))
+	{
 		return;
 	}
 	format = SDL_AllocFormat((Uint32)index);
@@ -415,29 +434,33 @@ static PHP_METHOD(SDL_PixelFormat, __construct)
 	intern = PHP_SDL_PIXELFORMAT_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
 	intern->format = SDL_AllocFormat((Uint32)format);
-	if (intern->format) {
+	if (intern->format)
+	{
 		intern->flags = 0;
-	} else {
+	}
+	else
+	{
 		zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_PixelFormat::__toString() */
 static PHP_METHOD(SDL_PixelFormat, __toString)
 {
 	php_sdl_pixelformat *intern;
 	char *buf;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -447,7 +470,6 @@ static PHP_METHOD(SDL_PixelFormat, __toString)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_FreeFormat(SDL_PixelFormat format)
 
  *  \brief Free an SDL_PixelFormat structure.
@@ -459,7 +481,8 @@ PHP_FUNCTION(SDL_FreeFormat)
 	zval *object;
 	SDL_PixelFormat *format;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_pixelformat_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_pixelformat_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PIXELFORMAT(format, object, 1);
@@ -469,7 +492,6 @@ PHP_FUNCTION(SDL_FreeFormat)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Palette SDL_AllocPalette(int ncolors)
 
  *  \brief Create a palette structure with the specified number of color
@@ -487,7 +509,8 @@ PHP_FUNCTION(SDL_AllocPalette)
 	zend_long ncolors;
 	SDL_Palette *palette;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors))
+	{
 		return;
 	}
 	palette = SDL_AllocPalette((int)ncolors);
@@ -505,29 +528,33 @@ static PHP_METHOD(SDL_Palette, __construct)
 	intern = PHP_SDL_PALETTE_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
 	intern->palette = SDL_AllocPalette(ncolors);
-	if (intern->palette) {
+	if (intern->palette)
+	{
 		intern->flags = 0;
-	} else {
+	}
+	else
+	{
 		zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Palette::__toString() */
 static PHP_METHOD(SDL_Palette, __toString)
 {
 	php_sdl_palette *intern;
 	char *buf;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -537,14 +564,14 @@ static PHP_METHOD(SDL_Palette, __toString)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Palette, count(void)  */
 static PHP_METHOD(SDL_Palette, count)
 {
 	php_sdl_palette *intern;
 
 	intern = PHP_SDL_PALETTE_P(getThis());
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -553,8 +580,8 @@ static PHP_METHOD(SDL_Palette, count)
 /* }}} */
 
 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetExists, 0, 1, _IS_BOOL, 0)
-	ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO();
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Palette, offsetExists(int offset) */
 PHP_METHOD(SDL_Palette, offsetExists)
@@ -563,10 +590,12 @@ PHP_METHOD(SDL_Palette, offsetExists)
 	zend_long offset;
 
 	intern = PHP_SDL_PALETTE_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+	{
 		return;
 	}
-	if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) {
+	if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors))
+	{
 		RETURN_FALSE;
 	}
 	RETURN_TRUE;
@@ -574,8 +603,8 @@ PHP_METHOD(SDL_Palette, offsetExists)
 /* }}} */
 
 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetGet, 0, 1, IS_MIXED, 1)
-	ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO();
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Palette, offsetGet(int offset) */
 PHP_METHOD(SDL_Palette, offsetGet)
@@ -584,20 +613,22 @@ PHP_METHOD(SDL_Palette, offsetGet)
 	zend_long offset;
 
 	intern = PHP_SDL_PALETTE_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+	{
 		return;
 	}
-	if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) {
+	if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors))
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
 		RETURN_FALSE;
 	}
-	sdl_color_to_zval(intern->palette->colors+offset, return_value);
+	sdl_color_to_zval(intern->palette->colors + offset, return_value);
 }
 /* }}} */
 
 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetUnset, 0, 1, IS_VOID, 0)
-	ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO();
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Palette, offsetUnset(int offset) */
 PHP_METHOD(SDL_Palette, offsetUnset)
@@ -607,10 +638,12 @@ PHP_METHOD(SDL_Palette, offsetUnset)
 	SDL_Color color;
 
 	intern = PHP_SDL_PALETTE_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+	{
 		return;
 	}
-	if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) {
+	if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors))
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
 		RETURN_FALSE;
 	}
@@ -620,11 +653,10 @@ PHP_METHOD(SDL_Palette, offsetUnset)
 /* }}} */
 
 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 2, IS_VOID, 0)
-	   ZEND_ARG_INFO(0, offset)
-	   ZEND_ARG_INFO(0, color)
+ZEND_ARG_INFO(0, offset)
+ZEND_ARG_INFO(0, color)
 ZEND_END_ARG_INFO()
 
-
 /* {{{ proto SDL_Palette, offsetSet(int offset, int value) */
 PHP_METHOD(SDL_Palette, offsetSet)
 {
@@ -634,10 +666,12 @@ PHP_METHOD(SDL_Palette, offsetSet)
 	SDL_Color color;
 
 	intern = PHP_SDL_PALETTE_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO", &offset, &z_color, php_sdl_color_ce) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO", &offset, &z_color, php_sdl_color_ce) == FAILURE)
+	{
 		return;
 	}
-	if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) {
+	if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors))
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
 		RETURN_FALSE;
 	}
@@ -650,7 +684,7 @@ PHP_METHOD(SDL_Palette, offsetSet)
 
  *  \brief Set the palette for a pixel format structure.
  extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
-                                                       SDL_Palette *palette);
+													   SDL_Palette *palette);
  */
 PHP_FUNCTION(SDL_SetPixelFormatPalette)
 {
@@ -659,7 +693,8 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette)
 	SDL_Palette *palette;
 	SDL_PixelFormat *format;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_format, php_sdl_pixelformat_ce, &z_palette, php_sdl_palette_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_format, php_sdl_pixelformat_ce, &z_palette, php_sdl_palette_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PALETTE(palette, z_palette, 1);
@@ -669,7 +704,6 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_SetPaletteColors(SDL_Palette palette, array colors, int first, int ncolors)
 
  *  \brief Set a range of colors in a palette.
@@ -681,8 +715,8 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette)
  *
  *  \return 0 on success, or -1 if not all of the colors could be set.
  extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
-                                                  const SDL_Color * colors,
-                                                  int firstcolor, int ncolors);
+												  const SDL_Color * colors,
+												  int firstcolor, int ncolors);
  */
 PHP_FUNCTION(SDL_SetPaletteColors)
 {
@@ -691,44 +725,58 @@ PHP_FUNCTION(SDL_SetPaletteColors)
 	SDL_Palette *palette;
 	SDL_Color *colors;
 	int i, nb;
-	zend_long first=0, ncolors=0;
+	zend_long first = 0, ncolors = 0;
 	long count;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|ll", &object, php_sdl_palette_ce, &z_colors, &first, &ncolors) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|ll", &object, php_sdl_palette_ce, &z_colors, &first, &ncolors) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PALETTE(palette, object, 1);
 	count = zend_hash_next_free_element(Z_ARRVAL_P(z_colors));
 
-	if (ncolors <= 0) {
+	if (ncolors <= 0)
+	{
 		ncolors = count;
-	} else if (ncolors > count) {
-		php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, (long) ncolors);
+	}
+	else if (ncolors > count)
+	{
+		php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, (long)ncolors);
 		ncolors = count;
 	}
-	if (first >= intern->palette->ncolors) {
-		php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", (long) first, intern->palette->ncolors);
+	if (first >= intern->palette->ncolors)
+	{
+		php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", (long)first, intern->palette->ncolors);
 		RETURN_LONG(-1);
 	}
-	if (first+ncolors > intern->palette->ncolors) {
-		php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", (long) (first+ncolors), intern->palette->ncolors);
+	if (first + ncolors > intern->palette->ncolors)
+	{
+		php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", (long)(first + ncolors), intern->palette->ncolors);
 		RETURN_LONG(-1);
 	}
 	colors = emalloc(sizeof(SDL_Color) * ncolors);
-	for (nb=i=0 ; i<ncolors ; i++) {
-		if (!(z_color = zend_hash_index_find(Z_ARRVAL_P(z_colors), i))) {
+	for (nb = i = 0; i < ncolors; i++)
+	{
+		if (!(z_color = zend_hash_index_find(Z_ARRVAL_P(z_colors), i)))
+		{
 			php_error_docref(NULL, E_NOTICE, "Unable to find colors[%d]", i);
-
-		} else if (Z_TYPE_P(z_color) != IS_OBJECT || Z_OBJCE_P(z_color) != php_sdl_color_ce) {
+		}
+		else if (Z_TYPE_P(z_color) != IS_OBJECT || Z_OBJCE_P(z_color) != php_sdl_color_ce)
+		{
 			php_error_docref(NULL, E_NOTICE, "colors[%d] is not a SDL_Color object", i);
-		} else {
-			zval_to_sdl_color(z_color, colors+nb);
+		}
+		else
+		{
+			zval_to_sdl_color(z_color, colors + nb);
 			nb++;
 		}
 	}
-	if (nb) {
+	if (nb)
+	{
 		RETVAL_LONG(SDL_SetPaletteColors(palette, colors, (int)first, nb));
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "no color in provided array");
 		RETVAL_LONG(-1);
 	}
@@ -736,7 +784,6 @@ PHP_FUNCTION(SDL_SetPaletteColors)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_FreePalette(SDL_Palette palette)
 
  *  \brief Free a palette created with SDL_AllocPalette().
@@ -750,7 +797,8 @@ PHP_FUNCTION(SDL_FreePalette)
 	zval *object;
 	SDL_Palette *palette;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_palette_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_palette_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PALETTE(palette, object, 1);
@@ -760,15 +808,13 @@ PHP_FUNCTION(SDL_FreePalette)
 }
 /* }}} */
 
-
-
 /* {{{ proto int SDL_MapRGB(SDL_PixelFormat format, int r, int g, int b)
 
  *  \brief Maps an RGB triple to an opaque pixel value for a given pixel format.
  *
  *  \sa SDL_MapRGBA
  extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
-                                           Uint8 r, Uint8 g, Uint8 b);
+										   Uint8 r, Uint8 g, Uint8 b);
  */
 PHP_FUNCTION(SDL_MapRGB)
 {
@@ -777,7 +823,8 @@ PHP_FUNCTION(SDL_MapRGB)
 	SDL_PixelFormat *format;
 	zend_long r, g, b;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_format, php_sdl_pixelformat_ce, &r, &g, &b) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_format, php_sdl_pixelformat_ce, &r, &g, &b) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -786,16 +833,14 @@ PHP_FUNCTION(SDL_MapRGB)
 }
 /* }}} */
 
-
-
 /* {{{ proto int SDL_MapRGBA(SDL_PixelFormat format, int r, int g, int b, int a)
 
  *  \brief Maps an RGBA quadruple to a pixel value for a given pixel format.
  *
  *  \sa SDL_MapRGB
  extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
-                                            Uint8 r, Uint8 g, Uint8 b,
-                                            Uint8 a);
+											Uint8 r, Uint8 g, Uint8 b,
+											Uint8 a);
  */
 PHP_FUNCTION(SDL_MapRGBA)
 {
@@ -804,7 +849,8 @@ PHP_FUNCTION(SDL_MapRGBA)
 	SDL_PixelFormat *format;
 	zend_long r, g, b, a;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ollll", &z_format, php_sdl_pixelformat_ce, &r, &g, &b, &a) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ollll", &z_format, php_sdl_pixelformat_ce, &r, &g, &b, &a) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -819,8 +865,8 @@ PHP_FUNCTION(SDL_MapRGBA)
  *
  *  \sa SDL_GetRGBA
  extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
-                                         const SDL_PixelFormat * format,
-                                         Uint8 * r, Uint8 * g, Uint8 * b);
+										 const SDL_PixelFormat * format,
+										 Uint8 * r, Uint8 * g, Uint8 * b);
  */
 PHP_FUNCTION(SDL_GetRGB)
 {
@@ -830,7 +876,8 @@ PHP_FUNCTION(SDL_GetRGB)
 	Uint8 r, g, b;
 	zend_long pix;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOz/z/z/", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOz/z/z/", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -844,12 +891,11 @@ PHP_FUNCTION(SDL_GetRGB)
 }
 /* }}} */
 
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_PixelFormat_GetRGB, 0, 0, 4)
-	   ZEND_ARG_INFO(0, pixel)
-	   ZEND_ARG_INFO(1, r)
-	   ZEND_ARG_INFO(1, g)
-	   ZEND_ARG_INFO(1, b)
+ZEND_ARG_INFO(0, pixel)
+ZEND_ARG_INFO(1, r)
+ZEND_ARG_INFO(1, g)
+ZEND_ARG_INFO(1, b)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto int SDL_PixelFormat::GetRGB(int pixel, int &r, int &g, int &b)
@@ -864,7 +910,8 @@ PHP_METHOD(SDL_PixelFormat, GetRGB)
 	Uint8 r, g, b;
 	zend_long pix;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz/z/z/", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz/z/z/", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -884,9 +931,9 @@ PHP_METHOD(SDL_PixelFormat, GetRGB)
  *
  *  \sa SDL_GetRGB
  extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
-                                          const SDL_PixelFormat * format,
-                                          Uint8 * r, Uint8 * g, Uint8 * b,
-                                          Uint8 * a);
+										  const SDL_PixelFormat * format,
+										  Uint8 * r, Uint8 * g, Uint8 * b,
+										  Uint8 * a);
  */
 PHP_FUNCTION(SDL_GetRGBA)
 {
@@ -896,7 +943,8 @@ PHP_FUNCTION(SDL_GetRGBA)
 	Uint8 r, g, b, a;
 	zend_long pix;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOz/z/z/z/", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b, &z_a) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOz/z/z/z/", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b, &z_a) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -912,7 +960,6 @@ PHP_FUNCTION(SDL_GetRGBA)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_PixelFormat::GetRGBA(int pixel, int &r, int &g, int &b, int &a)
 
  Duplicate implementation because for param order
@@ -925,7 +972,8 @@ PHP_METHOD(SDL_PixelFormat, GetRGBA)
 	Uint8 r, g, b, a;
 	zend_long pix;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz/z/z/z/", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b, &z_a) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz/z/z/z/", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b, &z_a) == FAILURE)
+	{
 		return;
 	}
 	FETCH_PIXELFORMAT(format, z_format, 1);
@@ -941,7 +989,6 @@ PHP_METHOD(SDL_PixelFormat, GetRGBA)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_CalculateGammaRamp(float gamma, array &ramp)
 
  *  \brief Calculate a 256 entry gamma ramp for a gamma value.
@@ -954,22 +1001,23 @@ PHP_FUNCTION(SDL_CalculateGammaRamp)
 	Uint16 ramp[256];
 	int i;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "dz/", &gamma, &z_ramp) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "dz/", &gamma, &z_ramp) == FAILURE)
+	{
 		RETURN_FALSE;
 	}
 	SDL_CalculateGammaRamp((float)gamma, ramp);
 	zval_dtor(z_ramp);
 	array_init(z_ramp);
-	for (i=0 ; i<256 ; i++) {
+	for (i = 0; i < 256; i++)
+	{
 		add_next_index_long(z_ramp, ramp[i]);
 	}
 }
 /* }}} */
 
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels__construct, 0, 0, 2)
-	   ZEND_ARG_INFO(0, pitch)
-	   ZEND_ARG_INFO(0, h)
+ZEND_ARG_INFO(0, pitch)
+ZEND_ARG_INFO(0, h)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Pixels::__construct(int pitch, int h) */
@@ -982,34 +1030,39 @@ static PHP_METHOD(SDL_Pixels, __construct)
 	intern = PHP_SDL_PIXELS_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &pitch, &h)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &pitch, &h))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
-	if (php_sdl_check_overflow((int)pitch, (int)h, 1)) {
+	if (php_sdl_check_overflow((int)pitch, (int)h, 1))
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid size", 0);
-	} else {
-		if (pitch & 3) {
+	}
+	else
+	{
+		if (pitch & 3)
+		{
 			pitch = (pitch + 3) & ~3;
 			php_error_docref(NULL, E_NOTICE, "Pitch set to %d", (int)pitch);
 		}
 		intern->pixels.pixels = ecalloc((int)pitch, (int)h);
-		intern->pixels.pitch  = (int)pitch;
-		intern->pixels.h      = (int)h;
+		intern->pixels.pitch = (int)pitch;
+		intern->pixels.h = (int)h;
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Pixels::__toString() */
 static PHP_METHOD(SDL_Pixels, __toString)
 {
 	php_sdl_pixels *intern;
 	char *buf;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -1019,14 +1072,14 @@ static PHP_METHOD(SDL_Pixels, __toString)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Pixels, count(void) */
 static PHP_METHOD(SDL_Pixels, count)
 {
 	php_sdl_pixels *intern;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -1035,8 +1088,8 @@ static PHP_METHOD(SDL_Pixels, count)
 /* }}} */
 
 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetExists, 0, 1, _IS_BOOL, 0)
-	ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO();
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Pixels, offsetExists(int offset) */
 PHP_METHOD(SDL_Pixels, offsetExists)
@@ -1045,10 +1098,12 @@ PHP_METHOD(SDL_Pixels, offsetExists)
 	zend_long offset;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+	{
 		return;
 	}
-	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) {
+	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch))
+	{
 		RETURN_FALSE;
 	}
 	RETURN_TRUE;
@@ -1056,8 +1111,8 @@ PHP_METHOD(SDL_Pixels, offsetExists)
 /* }}} */
 
 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetGet, 0, 1, IS_MIXED, 1)
-	ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO();
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Pixels, offsetGet(int offset) */
 PHP_METHOD(SDL_Pixels, offsetGet)
@@ -1066,10 +1121,12 @@ PHP_METHOD(SDL_Pixels, offsetGet)
 	zend_long offset;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+	{
 		return;
 	}
-	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) {
+	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch))
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
 		RETURN_FALSE;
 	}
@@ -1078,8 +1135,8 @@ PHP_METHOD(SDL_Pixels, offsetGet)
 /* }}} */
 
 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetUnset, 0, 1, IS_VOID, 0)
-	ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO();
+ZEND_ARG_INFO(0, offset)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Pixels, offsetUnset(int offset) */
 PHP_METHOD(SDL_Pixels, offsetUnset)
@@ -1088,10 +1145,12 @@ PHP_METHOD(SDL_Pixels, offsetUnset)
 	zend_long offset;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
+	{
 		return;
 	}
-	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) {
+	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch))
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
 		RETURN_FALSE;
 	}
@@ -1100,8 +1159,8 @@ PHP_METHOD(SDL_Pixels, offsetUnset)
 /* }}} */
 
 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 2, IS_VOID, 0)
-	   ZEND_ARG_INFO(0, offset)
-	   ZEND_ARG_INFO(0, value)
+ZEND_ARG_INFO(0, offset)
+ZEND_ARG_INFO(0, value)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */
@@ -1111,10 +1170,12 @@ PHP_METHOD(SDL_Pixels, offsetSet)
 	zend_long offset, value;
 
 	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE)
+	{
 		return;
 	}
-	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) {
+	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch))
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
 		RETURN_FALSE;
 	}
@@ -1122,10 +1183,9 @@ PHP_METHOD(SDL_Pixels, offsetSet)
 }
 /* }}} */
 
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_GetByte, 0, 0, 2)
-	   ZEND_ARG_INFO(0, x)
-	   ZEND_ARG_INFO(0, y)
+ZEND_ARG_INFO(0, x)
+ZEND_ARG_INFO(0, y)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto int SDL_Pixels::GetByte(int x, int y) */
@@ -1135,24 +1195,25 @@ PHP_METHOD(SDL_Pixels, GetByte)
 	zval *z_pixels;
 	zend_long x, y;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE)
+	{
 		return;
 	}
 	intern = PHP_SDL_PIXELS_P(z_pixels);
 
-	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long) x, (long) y, intern->pixels.pitch, intern->pixels.h);
+	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h)
+	{
+		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long)x, (long)y, intern->pixels.pitch, intern->pixels.h);
 		RETURN_FALSE;
 	}
-	RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
+	RETVAL_LONG(intern->pixels.pixels[y * intern->pixels.pitch + x]);
 }
 /* }}} */
 
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_SetByte, 0, 0, 3)
-	   ZEND_ARG_INFO(0, x)
-	   ZEND_ARG_INFO(0, y)
-	   ZEND_ARG_INFO(0, byte)
+ZEND_ARG_INFO(0, x)
+ZEND_ARG_INFO(0, y)
+ZEND_ARG_INFO(0, byte)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */
@@ -1162,30 +1223,32 @@ PHP_METHOD(SDL_Pixels, SetByte)
 	zval *z_pixels;
 	zend_long x, y, v;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE)
+	{
 		return;
 	}
 	intern = PHP_SDL_PIXELS_P(z_pixels);
 
-	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) {
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long) x, (long) y, intern->pixels.pitch, intern->pixels.h);
+	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h)
+	{
+		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long)x, (long)y, intern->pixels.pitch, intern->pixels.h);
 		RETURN_FALSE;
 	}
-	RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]);
-	intern->pixels.pixels[y*intern->pixels.pitch+x] = (Uint8)v;
+	RETVAL_LONG(intern->pixels.pixels[y * intern->pixels.pitch + x]);
+	intern->pixels.pixels[y * intern->pixels.pitch + x] = (Uint8)v;
 }
 /* }}} */
 
-
-
 /* {{{ php_sdl_palette_free
-	 */
+ */
 static void php_sdl_palette_free(zend_object *object)
 {
 	php_sdl_palette *intern = php_sdl_palette_from_obj(object);
 
-	if (intern->palette) {
-		if (!(intern->flags & SDL_DONTFREE)) {
+	if (intern->palette)
+	{
+		if (!(intern->flags & SDL_DONTFREE))
+		{
 			SDL_FreePalette(intern->palette);
 		}
 	}
@@ -1196,7 +1259,7 @@ static void php_sdl_palette_free(zend_object *object)
 
 /* {{{ php_sdl_palette_new
  */
-static zend_object* php_sdl_palette_new(zend_class_entry *class_type)
+static zend_object *php_sdl_palette_new(zend_class_entry *class_type)
 {
 	php_sdl_palette *intern = zend_object_alloc(sizeof(php_sdl_palette), class_type);
 
@@ -1204,7 +1267,7 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type)
 	object_properties_init(&intern->zo, class_type);
 
 	intern->palette = NULL;
-	intern->zo.handlers = (zend_object_handlers *) &php_sdl_palette_handlers;
+	intern->zo.handlers = (zend_object_handlers *)&php_sdl_palette_handlers;
 
 	return &intern->zo;
 }
@@ -1217,31 +1280,38 @@ zval *sdl_palette_read_property(zend_object *object, zend_string *member, int ty
 	char *member_val = ZSTR_VAL(member);
 	zval *retval;
 
-	if (!intern->palette) {
+	if (!intern->palette)
+	{
 		return zend_std_read_property(object, member, type, cache_slot, rv);
 	}
 
 	retval = rv;
 
-	if (!strcmp(member_val, "ncolors")) {
+	if (!strcmp(member_val, "ncolors"))
+	{
 		ZVAL_LONG(retval, intern->palette->ncolors);
-
-	} else if (!strcmp(member_val, "version")) {
+	}
+	else if (!strcmp(member_val, "version"))
+	{
 		ZVAL_LONG(retval, intern->palette->version);
-
-	} else if (!strcmp(member_val, "refcount")) {
+	}
+	else if (!strcmp(member_val, "refcount"))
+	{
 		ZVAL_LONG(retval, intern->palette->refcount);
-
-	} else if (!strcmp(member_val, "colors")) {
+	}
+	else if (!strcmp(member_val, "colors"))
+	{
 		int i;
 		zval z_color;
 		array_init(retval);
-		for (i=0 ; i<intern->palette->ncolors ; i++) {
-			sdl_color_to_zval(&intern->palette->colors[i], &z_color );
+		for (i = 0; i < intern->palette->ncolors; i++)
+		{
+			sdl_color_to_zval(&intern->palette->colors[i], &z_color);
 			add_next_index_zval(retval, &z_color);
 		}
-
-	} else {
+	}
+	else
+	{
 		retval = zend_std_read_property(object, member, type, cache_slot, rv);
 
 		return retval;
@@ -1251,9 +1321,9 @@ zval *sdl_palette_read_property(zend_object *object, zend_string *member, int ty
 }
 /* }}} */
 
-#define SDL_PALETTE_ADD_PROPERTY(n,f) \
-	ZVAL_LONG(&zv, f); \
-	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
+#define SDL_PALETTE_ADD_PROPERTY(n, f) \
+	ZVAL_LONG(&zv, f);                 \
+	zend_hash_str_update(props, n, sizeof(n) - 1, &zv);
 
 /* {{{ sdl_palette_get_properties*/
 static HashTable *sdl_palette_get_properties(zend_object *object)
@@ -1265,17 +1335,19 @@ static HashTable *sdl_palette_get_properties(zend_object *object)
 
 	props = zend_std_get_properties(object);
 
-	if (intern->palette) {
-		SDL_PALETTE_ADD_PROPERTY("ncolors",  intern->palette->ncolors);
-		SDL_PALETTE_ADD_PROPERTY("version",  intern->palette->version);
+	if (intern->palette)
+	{
+		SDL_PALETTE_ADD_PROPERTY("ncolors", intern->palette->ncolors);
+		SDL_PALETTE_ADD_PROPERTY("version", intern->palette->version);
 		SDL_PALETTE_ADD_PROPERTY("refcount", intern->palette->refcount);
 
 		array_init(&zv);
-		for (i=0 ; i<intern->palette->ncolors ; i++) {
-			sdl_color_to_zval(&intern->palette->colors[i], &z_color );
+		for (i = 0; i < intern->palette->ncolors; i++)
+		{
+			sdl_color_to_zval(&intern->palette->colors[i], &z_color);
 			add_next_index_zval(&zv, &z_color);
 		}
-		zend_hash_str_update(props, "colors", sizeof("colors")-1, &zv);
+		zend_hash_str_update(props, "colors", sizeof("colors") - 1, &zv);
 	}
 	return props;
 }
@@ -1290,13 +1362,15 @@ static zval *sdl_palette_write_property(zend_object *object, zend_string *name,
 /* }}} */
 
 /* {{{ php_sdl_pixelformat_free
-	 */
+ */
 static void php_sdl_pixelformat_free(zend_object *object)
 {
 	php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object);
 
-	if (intern->format) {
-		if (!(intern->flags & SDL_DONTFREE)) {
+	if (intern->format)
+	{
+		if (!(intern->flags & SDL_DONTFREE))
+		{
 			SDL_FreeFormat(intern->format);
 		}
 	}
@@ -1307,7 +1381,7 @@ static void php_sdl_pixelformat_free(zend_object *object)
 
 /* {{{ php_sdl_pixelformat_new
  */
-static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type)
+static zend_object *php_sdl_pixelformat_new(zend_class_entry *class_type)
 {
 	php_sdl_pixelformat *intern = zend_object_alloc(sizeof(php_sdl_pixelformat), class_type);
 
@@ -1315,7 +1389,7 @@ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type)
 	object_properties_init(&intern->zo, class_type);
 
 	intern->format = NULL;
-	intern->zo.handlers = (zend_object_handlers *) &php_sdl_pixelformat_handlers;
+	intern->zo.handlers = (zend_object_handlers *)&php_sdl_pixelformat_handlers;
 
 	return &intern->zo;
 }
@@ -1328,61 +1402,79 @@ zval *sdl_pixelformat_read_property(zend_object *object, zend_string *member, in
 	char *member_val = ZSTR_VAL(member);
 	zval *retval;
 
-	if (!intern->format) {
+	if (!intern->format)
+	{
 		return zend_std_read_property(object, member, type, cache_slot, rv);
 	}
 
 	retval = rv;
 
-	if (!strcmp(member_val, "format")) {
+	if (!strcmp(member_val, "format"))
+	{
 		ZVAL_LONG(retval, intern->format->format);
-
-	} else if (!strcmp(member_val, "BitsPerPixel")) {
+	}
+	else if (!strcmp(member_val, "BitsPerPixel"))
+	{
 		ZVAL_LONG(retval, intern->format->BitsPerPixel);
-
-	} else if (!strcmp(member_val, "BytesPerPixel")) {
+	}
+	else if (!strcmp(member_val, "BytesPerPixel"))
+	{
 		ZVAL_LONG(retval, intern->format->BytesPerPixel);
-
-	} else if (!strcmp(member_val, "Rmask")) {
+	}
+	else if (!strcmp(member_val, "Rmask"))
+	{
 		ZVAL_LONG(retval, intern->format->Rmask);
-
-	} else if (!strcmp(member_val, "Gmask")) {
+	}
+	else if (!strcmp(member_val, "Gmask"))
+	{
 		ZVAL_LONG(retval, intern->format->Gmask);
-
-	} else if (!strcmp(member_val, "Bmask")) {
+	}
+	else if (!strcmp(member_val, "Bmask"))
+	{
 		ZVAL_LONG(retval, intern->format->Bmask);
-
-	} else if (!strcmp(member_val, "Amask")) {
+	}
+	else if (!strcmp(member_val, "Amask"))
+	{
 		ZVAL_LONG(retval, intern->format->Amask);
-
-	} else if (!strcmp(member_val, "Rloss")) {
+	}
+	else if (!strcmp(member_val, "Rloss"))
+	{
 		ZVAL_LONG(retval, intern->format->Rloss);
-
-	} else if (!strcmp(member_val, "Gloss")) {
+	}
+	else if (!strcmp(member_val, "Gloss"))
+	{
 		ZVAL_LONG(retval, intern->format->Gloss);
-
-	} else if (!strcmp(member_val, "Bloss")) {
+	}
+	else if (!strcmp(member_val, "Bloss"))
+	{
 		ZVAL_LONG(retval, intern->format->Bloss);
-
-	} else if (!strcmp(member_val, "Aloss")) {
+	}
+	else if (!strcmp(member_val, "Aloss"))
+	{
 		ZVAL_LONG(retval, intern->format->Aloss);
-
-	} else if (!strcmp(member_val, "Rshift")) {
+	}
+	else if (!strcmp(member_val, "Rshift"))
+	{
 		ZVAL_LONG(retval, intern->format->Rshift);
-
-	} else if (!strcmp(member_val, "Gshift")) {
+	}
+	else if (!strcmp(member_val, "Gshift"))
+	{
 		ZVAL_LONG(retval, intern->format->Gshift);
-
-	} else if (!strcmp(member_val, "Bshift")) {
+	}
+	else if (!strcmp(member_val, "Bshift"))
+	{
 		ZVAL_LONG(retval, intern->format->Bshift);
-
-	} else if (!strcmp(member_val, "Ashift")) {
+	}
+	else if (!strcmp(member_val, "Ashift"))
+	{
 		ZVAL_LONG(retval, intern->format->Ashift);
-
-	} else if (!strcmp(member_val, "palette")) {
+	}
+	else if (!strcmp(member_val, "palette"))
+	{
 		sdl_palette_to_zval(intern->format->palette, retval, SDL_DONTFREE);
-
-	} else {
+	}
+	else
+	{
 		retval = zend_std_read_property(object, member, type, cache_slot, rv);
 
 		return retval;
@@ -1392,9 +1484,9 @@ zval *sdl_pixelformat_read_property(zend_object *object, zend_string *member, in
 }
 /* }}} */
 
-#define SDL_PIXELFORMAT_ADD_PROPERTY(n,f) \
-	ZVAL_LONG(&zv, f); \
-	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
+#define SDL_PIXELFORMAT_ADD_PROPERTY(n, f) \
+	ZVAL_LONG(&zv, f);                     \
+	zend_hash_str_update(props, n, sizeof(n) - 1, &zv);
 
 /* {{{ sdl_pixelformat_read_property*/
 static HashTable *sdl_pixelformat_get_properties(zend_object *object)
@@ -1405,25 +1497,26 @@ static HashTable *sdl_pixelformat_get_properties(zend_object *object)
 	intern = php_sdl_pixelformat_from_obj(object);
 	props = zend_std_get_properties(object);
 
-	if (intern->format) {
-		SDL_PIXELFORMAT_ADD_PROPERTY("format",        intern->format->format);
-		SDL_PIXELFORMAT_ADD_PROPERTY("BitsPerPixel",  intern->format->BitsPerPixel);
+	if (intern->format)
+	{
+		SDL_PIXELFORMAT_ADD_PROPERTY("format", intern->format->format);
+		SDL_PIXELFORMAT_ADD_PROPERTY("BitsPerPixel", intern->format->BitsPerPixel);
 		SDL_PIXELFORMAT_ADD_PROPERTY("BytesPerPixel", intern->format->BytesPerPixel);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Rmask",         intern->format->Rmask);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Gmask",         intern->format->Gmask);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Bmask",         intern->format->Bmask);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Amask",         intern->format->Amask);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Rloss",         intern->format->Rloss);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Gloss",         intern->format->Gloss);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Bloss",         intern->format->Bloss);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Aloss",         intern->format->Aloss);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Rshift",        intern->format->Rshift);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Gshift",        intern->format->Gshift);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Bshift",        intern->format->Bshift);
-		SDL_PIXELFORMAT_ADD_PROPERTY("Ashift",        intern->format->Ashift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Rmask", intern->format->Rmask);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Gmask", intern->format->Gmask);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Bmask", intern->format->Bmask);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Amask", intern->format->Amask);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Rloss", intern->format->Rloss);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Gloss", intern->format->Gloss);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Bloss", intern->format->Bloss);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Aloss", intern->format->Aloss);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Rshift", intern->format->Rshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Gshift", intern->format->Gshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Bshift", intern->format->Bshift);
+		SDL_PIXELFORMAT_ADD_PROPERTY("Ashift", intern->format->Ashift);
 
 		sdl_palette_to_zval(intern->format->palette, &zv, SDL_DONTFREE);
-		zend_hash_str_update(props, "palette", sizeof("palette")-1, &zv);
+		zend_hash_str_update(props, "palette", sizeof("palette") - 1, &zv);
 	}
 	return props;
 }
@@ -1438,13 +1531,15 @@ static zval *sdl_pixelformat_write_property(zend_object *object, zend_string *na
 /* }}} */
 
 /* {{{ php_sdl_pixels_free
-	 */
+ */
 static void php_sdl_pixels_free(zend_object *object)
 {
 	php_sdl_pixels *intern = php_sdl_pixels_from_obj(object);
 
-	if (intern->pixels.pixels) {
-		if (!(intern->flags & SDL_DONTFREE)) {
+	if (intern->pixels.pixels)
+	{
+		if (!(intern->flags & SDL_DONTFREE))
+		{
 			efree(intern->pixels.pixels);
 		}
 	}
@@ -1455,21 +1550,21 @@ static void php_sdl_pixels_free(zend_object *object)
 
 /* {{{ php_sdl_pixels_new
  */
-static zend_object* php_sdl_pixels_new(zend_class_entry *class_type)
+static zend_object *php_sdl_pixels_new(zend_class_entry *class_type)
 {
 	php_sdl_pixels *intern = zend_object_alloc(sizeof(php_sdl_pixels), class_type);
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
 
-	intern->zo.handlers = (zend_object_handlers *) &php_sdl_pixels_handlers;
+	intern->zo.handlers = (zend_object_handlers *)&php_sdl_pixels_handlers;
 
 	return &intern->zo;
 }
 /* }}} */
 
 /* {{{ sdl_pixels_read_property*/
-zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv )
+zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv)
 {
 	php_sdl_pixels *intern;
 	intern = php_sdl_pixels_from_obj(object);
@@ -1477,22 +1572,27 @@ zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int typ
 
 	zval *retval;
 
-	if (!intern->pixels.pixels) {
+	if (!intern->pixels.pixels)
+	{
 		return zend_std_read_property(object, member, type, cache_slot, rv);
 	}
 
 	retval = rv;
 
-	if (!strcmp(member_val, "h")) {
+	if (!strcmp(member_val, "h"))
+	{
 		ZVAL_LONG(retval, intern->pixels.h);
-
-	} else if (!strcmp(member_val, "pitch")) {
+	}
+	else if (!strcmp(member_val, "pitch"))
+	{
 		ZVAL_LONG(retval, intern->pixels.pitch);
-
-	} else if (!strcmp(member_val, "count")) {
+	}
+	else if (!strcmp(member_val, "count"))
+	{
 		ZVAL_LONG(retval, intern->pixels.pitch * intern->pixels.h);
-
-	} else {
+	}
+	else
+	{
 		retval = zend_std_read_property(object, member, type, cache_slot, rv);
 
 		return retval;
@@ -1502,9 +1602,9 @@ zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int typ
 }
 /* }}} */
 
-#define SDL_PIXELS_ADD_PROPERTY(n,f) \
-	ZVAL_LONG(&zv, f); \
-	zend_hash_str_update(props, n, sizeof(n)-1, &zv);
+#define SDL_PIXELS_ADD_PROPERTY(n, f) \
+	ZVAL_LONG(&zv, f);                \
+	zend_hash_str_update(props, n, sizeof(n) - 1, &zv);
 
 /* {{{ sdl_pixels_read_properties */
 static HashTable *sdl_pixels_get_properties(zend_object *object)
@@ -1515,10 +1615,11 @@ static HashTable *sdl_pixels_get_properties(zend_object *object)
 
 	props = zend_std_get_properties(object);
 
-	if (intern->pixels.pixels) {
-		SDL_PIXELS_ADD_PROPERTY("pitch",  intern->pixels.pitch);
-		SDL_PIXELS_ADD_PROPERTY("h",      intern->pixels.h);
-		SDL_PIXELS_ADD_PROPERTY("count",  intern->pixels.h * intern->pixels.pitch);
+	if (intern->pixels.pixels)
+	{
+		SDL_PIXELS_ADD_PROPERTY("pitch", intern->pixels.pitch);
+		SDL_PIXELS_ADD_PROPERTY("h", intern->pixels.h);
+		SDL_PIXELS_ADD_PROPERTY("count", intern->pixels.h * intern->pixels.pitch);
 	}
 	return props;
 }
@@ -1534,61 +1635,57 @@ static zval *sdl_pixels_write_property(zend_object *object, zend_string *name, z
 
 /* {{{ php_sdl_color_methods[] */
 static const zend_function_entry php_sdl_color_methods[] = {
-	PHP_ME(SDL_Color, __construct,     arginfo_SDL_Color__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Color, __toString,      arginfo_palette_none,         ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_Color, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
 
-	PHP_FE_END
-};
+			PHP_FE_END};
 /* }}} */
 
 /* {{{ php_sdl_palette_methods[] */
 static const zend_function_entry php_sdl_palette_methods[] = {
-	PHP_ME(SDL_Palette, __construct,   arginfo_SDL_AllocPalette,        ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, __toString,    arginfo_palette_none,            ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, count,         arginfo_palette_none,            ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, offsetExists,  arginfo_SDL_Palette_offsetExists,ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, offsetGet,     arginfo_SDL_Palette_offsetGet,   ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, offsetSet,     arginfo_SDL_Palette_offsetSet,   ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Palette, offsetUnset,   arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_Palette, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
+			PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC)
+				PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists, ZEND_ACC_PUBLIC)
+					PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC)
+						PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC)
+							PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
-	PHP_FALIAS(Free,             SDL_FreePalette,           arginfo_palette_none)
-	PHP_FALIAS(SetColors,        SDL_SetPaletteColors,      arginfo_SDL_Palette_SetColors)
+	PHP_FALIAS(Free, SDL_FreePalette, arginfo_palette_none)
+		PHP_FALIAS(SetColors, SDL_SetPaletteColors, arginfo_SDL_Palette_SetColors)
 
-	PHP_FE_END
-};
+			PHP_FE_END};
 /* }}} */
 
 /* {{{ php_sdl_pixelformat_methods[] */
 static const zend_function_entry php_sdl_pixelformat_methods[] = {
-	PHP_ME(SDL_PixelFormat, __construct,  arginfo_SDL_AllocFormat,            ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_PixelFormat, __toString,   arginfo_palette_none,               ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_PixelFormat, GetRGB,       arginfo_SDL_PixelFormat_GetRGB,     ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_PixelFormat, GetRGBA,      arginfo_SDL_PixelFormat_GetRGBA,    ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_PixelFormat, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
+			PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC)
+				PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
-	PHP_FALIAS(Free,             SDL_FreeFormat,             arginfo_format_none)
-	PHP_FALIAS(SetPalette,       SDL_SetPixelFormatPalette,  arginfo_SDL_PixelFormat_SetPalette)
-	PHP_FALIAS(MapRGB,           SDL_MapRGB,                 arginfo_SDL_PixelFormat_MapRGB)
-	PHP_FALIAS(MapRGBA,          SDL_MapRGBA,                arginfo_SDL_PixelFormat_MapRGBA)
+	PHP_FALIAS(Free, SDL_FreeFormat, arginfo_format_none)
+		PHP_FALIAS(SetPalette, SDL_SetPixelFormatPalette, arginfo_SDL_PixelFormat_SetPalette)
+			PHP_FALIAS(MapRGB, SDL_MapRGB, arginfo_SDL_PixelFormat_MapRGB)
+				PHP_FALIAS(MapRGBA, SDL_MapRGBA, arginfo_SDL_PixelFormat_MapRGBA)
 
-	PHP_FE_END
-};
+					PHP_FE_END};
 /* }}} */
 
 /* {{{ php_sdl_pixels_methods[] */
 static const zend_function_entry php_sdl_pixels_methods[] = {
-	PHP_ME(SDL_Pixels,    __construct,   arginfo_SDL_Pixels__construct,     ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    __toString,    arginfo_format_none,               ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    count,         arginfo_format_none,               ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    offsetExists,  arginfo_SDL_Pixels_offsetExists,   ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    offsetGet,     arginfo_SDL_Pixels_offsetGet,      ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    offsetSet,     arginfo_SDL_Pixels_offsetSet,      ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    offsetUnset,   arginfo_SDL_Pixels_offsetUnset,    ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    GetByte,       arginfo_SDL_Pixels_GetByte,        ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels,    SetByte,       arginfo_SDL_Pixels_SetByte,        ZEND_ACC_PUBLIC)
-	PHP_FE_END
-};
+	PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_Pixels, __toString, arginfo_format_none, ZEND_ACC_PUBLIC)
+			PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC)
+				PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC)
+					PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC)
+						PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC)
+							PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC)
+								PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC)
+									PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC)
+										PHP_FE_END};
 /* }}} */
 
 #define REGISTER_COLOR_PROP(name) \
@@ -1622,7 +1719,7 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_palette_ce->create_object = php_sdl_palette_new;
 	zend_class_implements(php_sdl_palette_ce, 1, zend_ce_arrayaccess);
 	memcpy(&php_sdl_palette_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-	php_sdl_palette_handlers.read_property  = sdl_palette_read_property;
+	php_sdl_palette_handlers.read_property = sdl_palette_read_property;
 	php_sdl_palette_handlers.get_properties = sdl_palette_get_properties;
 	php_sdl_palette_handlers.write_property = sdl_palette_write_property;
 	php_sdl_palette_handlers.free_obj = php_sdl_palette_free;
@@ -1637,7 +1734,7 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_pixelformat_ce = zend_register_internal_class(&ce_pixelformat);
 	php_sdl_pixelformat_ce->create_object = php_sdl_pixelformat_new;
 	memcpy(&php_sdl_pixelformat_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-	php_sdl_pixelformat_handlers.read_property  = sdl_pixelformat_read_property;
+	php_sdl_pixelformat_handlers.read_property = sdl_pixelformat_read_property;
 	php_sdl_pixelformat_handlers.get_properties = sdl_pixelformat_get_properties;
 	php_sdl_pixelformat_handlers.write_property = sdl_pixelformat_write_property;
 	php_sdl_pixelformat_handlers.free_obj = php_sdl_pixelformat_free;
@@ -1665,7 +1762,7 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	php_sdl_pixels_ce->create_object = php_sdl_pixels_new;
 	zend_class_implements(php_sdl_pixels_ce, 1, zend_ce_arrayaccess);
 	memcpy(&php_sdl_pixels_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-	php_sdl_pixels_handlers.read_property  = sdl_pixels_read_property;
+	php_sdl_pixels_handlers.read_property = sdl_pixels_read_property;
 	php_sdl_pixels_handlers.get_properties = sdl_pixels_get_properties;
 	php_sdl_pixels_handlers.write_property = sdl_pixels_write_property;
 	php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free;
@@ -1676,83 +1773,83 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	REGISTER_PIXELS_PROP("count");
 
 	/* Pixel type. */
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_UNKNOWN",          SDL_PIXELTYPE_UNKNOWN,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX1",           SDL_PIXELTYPE_INDEX1,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX4",           SDL_PIXELTYPE_INDEX4,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX8",           SDL_PIXELTYPE_INDEX8,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED8",          SDL_PIXELTYPE_PACKED8,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED16",         SDL_PIXELTYPE_PACKED16,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED32",         SDL_PIXELTYPE_PACKED32,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU8",          SDL_PIXELTYPE_ARRAYU8,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU16",         SDL_PIXELTYPE_ARRAYU16,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU32",         SDL_PIXELTYPE_ARRAYU32,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF16",         SDL_PIXELTYPE_ARRAYF16,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF32",         SDL_PIXELTYPE_ARRAYF32,           CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_UNKNOWN", SDL_PIXELTYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX1", SDL_PIXELTYPE_INDEX1, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX4", SDL_PIXELTYPE_INDEX4, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX8", SDL_PIXELTYPE_INDEX8, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED8", SDL_PIXELTYPE_PACKED8, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED16", SDL_PIXELTYPE_PACKED16, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED32", SDL_PIXELTYPE_PACKED32, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU8", SDL_PIXELTYPE_ARRAYU8, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU16", SDL_PIXELTYPE_ARRAYU16, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU32", SDL_PIXELTYPE_ARRAYU32, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF16", SDL_PIXELTYPE_ARRAYF16, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF32", SDL_PIXELTYPE_ARRAYF32, CONST_CS | CONST_PERSISTENT);
 
 	/* Bitmap pixel order, high bit -> low bit. */
-	REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_NONE",           SDL_BITMAPORDER_NONE,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_4321",           SDL_BITMAPORDER_4321,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_1234",           SDL_BITMAPORDER_1234,             CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_NONE", SDL_BITMAPORDER_NONE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_4321", SDL_BITMAPORDER_4321, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_1234", SDL_BITMAPORDER_1234, CONST_CS | CONST_PERSISTENT);
 
 	/* Packed component order, high bit -> low bit. */
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_NONE",           SDL_PACKEDORDER_NONE,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XRGB",           SDL_PACKEDORDER_XRGB,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBX",           SDL_PACKEDORDER_RGBX,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ARGB",           SDL_PACKEDORDER_ARGB,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBA",           SDL_PACKEDORDER_RGBA,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XBGR",           SDL_PACKEDORDER_XBGR,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRX",           SDL_PACKEDORDER_BGRX,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ABGR",           SDL_PACKEDORDER_ABGR,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRA",           SDL_PACKEDORDER_BGRA,             CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_NONE", SDL_PACKEDORDER_NONE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XRGB", SDL_PACKEDORDER_XRGB, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBX", SDL_PACKEDORDER_RGBX, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ARGB", SDL_PACKEDORDER_ARGB, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBA", SDL_PACKEDORDER_RGBA, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XBGR", SDL_PACKEDORDER_XBGR, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRX", SDL_PACKEDORDER_BGRX, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ABGR", SDL_PACKEDORDER_ABGR, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRA", SDL_PACKEDORDER_BGRA, CONST_CS | CONST_PERSISTENT);
 
 	/* Packed component layout. */
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_NONE",          SDL_PACKEDLAYOUT_NONE,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_332",           SDL_PACKEDLAYOUT_332,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_4444",          SDL_PACKEDLAYOUT_4444,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1555",          SDL_PACKEDLAYOUT_1555,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_5551",          SDL_PACKEDLAYOUT_5551,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_565",           SDL_PACKEDLAYOUT_565,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_8888",          SDL_PACKEDLAYOUT_8888,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_2101010",       SDL_PACKEDLAYOUT_2101010,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1010102",       SDL_PACKEDLAYOUT_1010102,         CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_NONE", SDL_PACKEDLAYOUT_NONE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_332", SDL_PACKEDLAYOUT_332, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_4444", SDL_PACKEDLAYOUT_4444, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1555", SDL_PACKEDLAYOUT_1555, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_5551", SDL_PACKEDLAYOUT_5551, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_565", SDL_PACKEDLAYOUT_565, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_8888", SDL_PACKEDLAYOUT_8888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_2101010", SDL_PACKEDLAYOUT_2101010, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1010102", SDL_PACKEDLAYOUT_1010102, CONST_CS | CONST_PERSISTENT);
 
 	/* Pixel format */
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UNKNOWN",        SDL_PIXELFORMAT_UNKNOWN,          CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1LSB",      SDL_PIXELFORMAT_INDEX1LSB,        CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1MSB",      SDL_PIXELFORMAT_INDEX1MSB,        CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4LSB",      SDL_PIXELFORMAT_INDEX4LSB,        CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4MSB",      SDL_PIXELFORMAT_INDEX4MSB,        CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX8",         SDL_PIXELFORMAT_INDEX8,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB332",         SDL_PIXELFORMAT_RGB332,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB444",         SDL_PIXELFORMAT_RGB444,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB555",         SDL_PIXELFORMAT_RGB555,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR555",         SDL_PIXELFORMAT_BGR555,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB4444",       SDL_PIXELFORMAT_ARGB4444,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA4444",       SDL_PIXELFORMAT_RGBA4444,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR4444",       SDL_PIXELFORMAT_ABGR4444,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA4444",       SDL_PIXELFORMAT_BGRA4444,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB1555",       SDL_PIXELFORMAT_ARGB1555,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA5551",       SDL_PIXELFORMAT_RGBA5551,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR1555",       SDL_PIXELFORMAT_ABGR1555,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA5551",       SDL_PIXELFORMAT_BGRA5551,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB565",         SDL_PIXELFORMAT_RGB565,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR565",         SDL_PIXELFORMAT_BGR565,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB24",          SDL_PIXELFORMAT_RGB24,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR24",          SDL_PIXELFORMAT_BGR24,            CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB888",         SDL_PIXELFORMAT_RGB888,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBX8888",       SDL_PIXELFORMAT_RGBX8888,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR888",         SDL_PIXELFORMAT_BGR888,           CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRX8888",       SDL_PIXELFORMAT_BGRX8888,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB8888",       SDL_PIXELFORMAT_ARGB8888,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA8888",       SDL_PIXELFORMAT_RGBA8888,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR8888",       SDL_PIXELFORMAT_ABGR8888,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA8888",       SDL_PIXELFORMAT_BGRA8888,         CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB2101010",    SDL_PIXELFORMAT_ARGB2101010,      CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YV12",           SDL_PIXELFORMAT_YV12,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_IYUV",           SDL_PIXELFORMAT_IYUV,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YUY2",           SDL_PIXELFORMAT_YUY2,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UYVY",           SDL_PIXELFORMAT_UYVY,             CONST_CS | CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YVYU",           SDL_PIXELFORMAT_YVYU,             CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UNKNOWN", SDL_PIXELFORMAT_UNKNOWN, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1LSB", SDL_PIXELFORMAT_INDEX1LSB, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1MSB", SDL_PIXELFORMAT_INDEX1MSB, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4LSB", SDL_PIXELFORMAT_INDEX4LSB, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4MSB", SDL_PIXELFORMAT_INDEX4MSB, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX8", SDL_PIXELFORMAT_INDEX8, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB332", SDL_PIXELFORMAT_RGB332, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB444", SDL_PIXELFORMAT_RGB444, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB555", SDL_PIXELFORMAT_RGB555, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR555", SDL_PIXELFORMAT_BGR555, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB4444", SDL_PIXELFORMAT_ARGB4444, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA4444", SDL_PIXELFORMAT_RGBA4444, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR4444", SDL_PIXELFORMAT_ABGR4444, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA4444", SDL_PIXELFORMAT_BGRA4444, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB1555", SDL_PIXELFORMAT_ARGB1555, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA5551", SDL_PIXELFORMAT_RGBA5551, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR1555", SDL_PIXELFORMAT_ABGR1555, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA5551", SDL_PIXELFORMAT_BGRA5551, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB565", SDL_PIXELFORMAT_RGB565, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR565", SDL_PIXELFORMAT_BGR565, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB24", SDL_PIXELFORMAT_RGB24, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR24", SDL_PIXELFORMAT_BGR24, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB888", SDL_PIXELFORMAT_RGB888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBX8888", SDL_PIXELFORMAT_RGBX8888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR888", SDL_PIXELFORMAT_BGR888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRX8888", SDL_PIXELFORMAT_BGRX8888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB8888", SDL_PIXELFORMAT_ARGB8888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA8888", SDL_PIXELFORMAT_RGBA8888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR8888", SDL_PIXELFORMAT_ABGR8888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA8888", SDL_PIXELFORMAT_BGRA8888, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB2101010", SDL_PIXELFORMAT_ARGB2101010, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YV12", SDL_PIXELFORMAT_YV12, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_IYUV", SDL_PIXELFORMAT_IYUV, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YUY2", SDL_PIXELFORMAT_YUY2, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UYVY", SDL_PIXELFORMAT_UYVY, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YVYU", SDL_PIXELFORMAT_YVYU, CONST_CS | CONST_PERSISTENT);
 
 	return SUCCESS;
 }

From 09a795cbbb4247c855fc6e3ab0a655998988e86e Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 22 Jul 2022 19:07:04 +0100
Subject: [PATCH 44/53] Use bool instead of zend_bool

---
 src/mouse.c   | 268 +++++++++++----------
 src/surface.c | 642 ++++++++++++++++++++++++++++----------------------
 src/window.c  | 564 ++++++++++++++++++++++++--------------------
 3 files changed, 813 insertions(+), 661 deletions(-)

diff --git a/src/mouse.c b/src/mouse.c
index 890b2ca..88d4e0b 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -21,10 +21,11 @@
 
 static zend_class_entry *php_sdl_cursor_ce;
 static zend_object_handlers php_sdl_cursor_handlers;
-struct php_sdl_cursor {
-	SDL_Cursor   *cursor;
-	Uint32        flags;
-	zend_object   zo;
+struct php_sdl_cursor
+{
+	SDL_Cursor *cursor;
+	Uint32 flags;
+	zend_object zo;
 };
 
 /* {{{ get_php_sdl_cursor_ce */
@@ -34,28 +35,30 @@ zend_class_entry *get_php_sdl_cursor_ce(void)
 }
 /* }}} */
 
-#define FETCH_CURSOR(__ptr, __id, __check) \
-{ \
-		zend_object* zo = Z_OBJ_P(__id);\
-		intern = (struct php_sdl_cursor *)((char*)zo - zo->handlers->offset);\
-        __ptr = intern->cursor; \
-        if (__check && !__ptr) {\
-                php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-                RETURN_FALSE;\
-        }\
-}
+#define FETCH_CURSOR(__ptr, __id, __check)                                                         \
+	{                                                                                              \
+		zend_object *zo = Z_OBJ_P(__id);                                                           \
+		intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset);                     \
+		__ptr = intern->cursor;                                                                    \
+		if (__check && !__ptr)                                                                     \
+		{                                                                                          \
+			php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+			RETURN_FALSE;                                                                          \
+		}                                                                                          \
+	}
 
 /* {{{ sdl_cursor_to_zval */
 zend_bool sdl_cursor_to_zval(SDL_Cursor *cursor, zval *z_val, Uint32 flags)
 {
-	if (cursor) {
+	if (cursor)
+	{
 		struct php_sdl_cursor *intern;
 
 		object_init_ex(z_val, php_sdl_cursor_ce);
-		zend_object* zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_cursor *)((char*)zo - zo->handlers->offset);
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset);
 		intern->cursor = cursor;
-		intern->flags  = flags;
+		intern->flags = flags;
 
 		return 1;
 	}
@@ -64,28 +67,28 @@ zend_bool sdl_cursor_to_zval(SDL_Cursor *cursor, zval *z_val, Uint32 flags)
 }
 /* }}} */
 
-
 /* {{{ zval_to_sdl_cursor */
 SDL_GLContext zval_to_sdl_cursor(zval *z_val)
 {
 	struct php_sdl_cursor *intern;
 
-	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_cursor_ce) {
-		zend_object* zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_cursor*)((char*)zo - zo->handlers->offset);
+	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_cursor_ce)
+	{
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset);
 		return intern->cursor;
 	}
 	return NULL;
 }
 /* }}} */
 
-
 /* {{{ php_sdl_cursor_free */
 static void php_sdl_cursor_free(zend_object *object)
 {
-	struct php_sdl_cursor *intern = (struct php_sdl_cursor *)((char*)object - object->handlers->offset);
+	struct php_sdl_cursor *intern = (struct php_sdl_cursor *)((char *)object - object->handlers->offset);
 
-	if (intern->cursor && !(intern->flags & SDL_DONTFREE)) {
+	if (intern->cursor && !(intern->flags & SDL_DONTFREE))
+	{
 		SDL_FreeCursor(intern->cursor);
 	}
 
@@ -93,10 +96,9 @@ static void php_sdl_cursor_free(zend_object *object)
 }
 /* }}} */
 
-
 /* {{{ php_sdl_cursor_new
  */
-static zend_object* php_sdl_cursor_new(zend_class_entry *class_type)
+static zend_object *php_sdl_cursor_new(zend_class_entry *class_type)
 {
 	struct php_sdl_cursor *intern;
 
@@ -126,44 +128,48 @@ static PHP_METHOD(SDL_Cursor, __construct)
 	intern = (struct php_sdl_cursor *)Z_OBJ_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
-	if (w<=0 || w&7 || h<=0) {
+	if (w <= 0 || w & 7 || h <= 0)
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid cursor size", 0);
 		return;
 	}
-	size = w/8 * h;
-	if (data_len!=size || mask_len!=size) {
+	size = w / 8 * h;
+	if (data_len != size || mask_len != size)
+	{
 		zend_throw_exception_ex(zend_exception_get_default(), 0, "Invalid data or mask, size must be %ld", size);
 		return;
 	}
 	intern->cursor = SDL_CreateCursor((Uint8 *)data, (Uint8 *)mask, (int)w, (int)h, (int)x, (int)y);
-	if (intern->cursor) {
+	if (intern->cursor)
+	{
 		intern->flags = 0;
-	} else {
+	}
+	else
+	{
 		zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Cursor::__toString()
-*/
+ */
 static PHP_METHOD(SDL_Cursor, __toString)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	RETVAL_STRING("SDL_Cursor()");
 }
 /* }}} */
 
-
-
 /* {{{ proto SDL_Cursor SDL_CreateCursor(string data, string mask, int w, int h, int hot_x, int hot_y)
 
  *  \brief Create a cursor, using the specified bitmap data and
@@ -183,9 +189,9 @@ static PHP_METHOD(SDL_Cursor, __toString)
  *
  *  \sa SDL_FreeCursor()
  extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
-                                                      const Uint8 * mask,
-                                                      int w, int h, int hot_x,
-                                                      int hot_y);
+													  const Uint8 * mask,
+													  int w, int h, int hot_x,
+													  int hot_y);
  */
 PHP_FUNCTION(SDL_CreateCursor)
 {
@@ -195,15 +201,18 @@ PHP_FUNCTION(SDL_CreateCursor)
 	long size;
 	SDL_Cursor *cursor;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y))
+	{
 		return;
 	}
-	if (w<=0 || w&7 || h<=0) {
+	if (w <= 0 || w & 7 || h <= 0)
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid cursor size");
 		return;
 	}
-	size = w/8 * h;
-	if (data_len!=size || mask_len!=size) {
+	size = w / 8 * h;
+	if (data_len != size || mask_len != size)
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid data or mask, size must be %ld", size);
 		return;
 	}
@@ -212,8 +221,6 @@ PHP_FUNCTION(SDL_CreateCursor)
 }
 /* }}} */
 
-
-
 /* {{{ proto SDL_Cursor SDL_CreateSystemCursor(int id)
 
  *  \brief Create a system cursor.
@@ -226,7 +233,8 @@ PHP_FUNCTION(SDL_CreateSystemCursor)
 	zend_long id;
 	SDL_Cursor *cursor;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id))
+	{
 		return;
 	}
 	cursor = SDL_CreateSystemCursor(id);
@@ -234,15 +242,14 @@ PHP_FUNCTION(SDL_CreateSystemCursor)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Cursor SDL_CreateSystemCursor(int id)
 
  *  \brief Create a color cursor.
  *
  *  \sa SDL_FreeCursor()
  extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
-                                                           int hot_x,
-                                                           int hot_y);
+														   int hot_x,
+														   int hot_y);
  */
 PHP_FUNCTION(SDL_CreateColorCursor)
 {
@@ -251,20 +258,23 @@ PHP_FUNCTION(SDL_CreateColorCursor)
 	SDL_Surface *surface;
 	SDL_Cursor *cursor;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_surface, get_php_sdl_surface_ce(), &x, &y)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_surface, get_php_sdl_surface_ce(), &x, &y))
+	{
 		return;
 	}
 	surface = zval_to_sdl_surface(z_surface);
-	if (surface) {
+	if (surface)
+	{
 		cursor = SDL_CreateColorCursor(surface, (int)x, (int)y);
 		sdl_cursor_to_zval(cursor, return_value, 0);
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
 	}
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_FreeCursor(SDL_Cursor cursor)
 
  *  \brief Frees a cursor created with SDL_CreateCursor().
@@ -278,7 +288,8 @@ PHP_FUNCTION(SDL_FreeCursor)
 	zval *z_cursor;
 	SDL_Cursor *cursor;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_CURSOR(cursor, z_cursor, 1);
@@ -299,7 +310,8 @@ PHP_FUNCTION(SDL_SetCursor)
 	zval *z_cursor;
 	SDL_Cursor *cursor;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_CURSOR(cursor, z_cursor, 1);
@@ -308,7 +320,6 @@ PHP_FUNCTION(SDL_SetCursor)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Cursor SDL_GetCursor(void)
 
  *  \brief Return the active cursor.
@@ -318,7 +329,8 @@ PHP_FUNCTION(SDL_GetCursor)
 {
 	SDL_Cursor *cursor;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	cursor = SDL_GetCursor();
@@ -326,7 +338,6 @@ PHP_FUNCTION(SDL_GetCursor)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Cursor SDL_GetDefaultCursor(void)
 
  *  \brief Return the default cursor.
@@ -336,7 +347,8 @@ PHP_FUNCTION(SDL_GetDefaultCursor)
 {
 	SDL_Cursor *cursor;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	cursor = SDL_GetDefaultCursor();
@@ -344,7 +356,6 @@ PHP_FUNCTION(SDL_GetDefaultCursor)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_ShowCursor(bool toogle)
 
  *  \brief Toggle whether or not the cursor is shown.
@@ -357,16 +368,16 @@ PHP_FUNCTION(SDL_GetDefaultCursor)
  */
 PHP_FUNCTION(SDL_ShowCursor)
 {
-	zend_bool toggle;
+	bool toggle;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &toggle)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &toggle))
+	{
 		return;
 	}
 	RETVAL_BOOL(SDL_ShowCursor(toggle));
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Window SDL_GetMouseFocus(void)
 
  *  \brief Get the window which currently has mouse focus.
@@ -374,13 +385,13 @@ PHP_FUNCTION(SDL_ShowCursor)
  */
 PHP_FUNCTION(SDL_GetMouseFocus)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	sdl_window_to_zval(SDL_GetMouseFocus(), return_value, SDL_DONTFREE);
 }
 
-
 /* {{{ proto int SDL_GetMouseState(int &x, int &y)
 
  *  \brief Retrieve the current state of the mouse.
@@ -393,19 +404,22 @@ PHP_FUNCTION(SDL_GetMouseFocus)
  */
 PHP_FUNCTION(SDL_GetMouseState)
 {
-	zval *z_x=NULL, *z_y=NULL;
+	zval *z_x = NULL, *z_y = NULL;
 	int x, y;
 	Uint32 state;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y))
+	{
 		return;
 	}
 	state = SDL_GetMouseState(&x, &y);
-	if (z_x) {
+	if (z_x)
+	{
 		zval_dtor(z_x);
 		ZVAL_LONG(z_x, x);
 	}
-	if (z_y) {
+	if (z_y)
+	{
 		zval_dtor(z_y);
 		ZVAL_LONG(z_y, y);
 	}
@@ -413,7 +427,6 @@ PHP_FUNCTION(SDL_GetMouseState)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GetRelativeMouseState(int &x, int &y)
 
  *  \brief Retrieve the relative state of the mouse.
@@ -425,19 +438,22 @@ PHP_FUNCTION(SDL_GetMouseState)
  */
 PHP_FUNCTION(SDL_GetRelativeMouseState)
 {
-	zval *z_x=NULL, *z_y=NULL;
+	zval *z_x = NULL, *z_y = NULL;
 	int x, y;
 	Uint32 state;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y))
+	{
 		return;
 	}
 	state = SDL_GetRelativeMouseState(&x, &y);
-	if (z_x) {
+	if (z_x)
+	{
 		zval_dtor(z_x);
 		ZVAL_LONG(z_x, x);
 	}
-	if (z_y) {
+	if (z_y)
+	{
 		zval_dtor(z_y);
 		ZVAL_LONG(z_y, y);
 	}
@@ -445,7 +461,6 @@ PHP_FUNCTION(SDL_GetRelativeMouseState)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_WarpMouseInWindow(SDL_Window window, int x, int y)
 
  *  \brief Moves the mouse to the given position within the window.
@@ -456,7 +471,7 @@ PHP_FUNCTION(SDL_GetRelativeMouseState)
  *
  *  \note This function generates a mouse motion event
  extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
-                                                    int x, int y);
+													int x, int y);
  */
 PHP_FUNCTION(SDL_WarpMouseInWindow)
 {
@@ -464,19 +479,22 @@ PHP_FUNCTION(SDL_WarpMouseInWindow)
 	SDL_Window *window;
 	zend_long x, y;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_window, get_php_sdl_window_ce(), &x, &y)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_window, get_php_sdl_window_ce(), &x, &y))
+	{
 		return;
 	}
 	window = zval_to_sdl_window(z_window);
-	if (window) {
+	if (window)
+	{
 		SDL_WarpMouseInWindow(window, (int)x, (int)y);
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
 	}
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_SetRelativeMouseMode(bool enabled)
 
  *  \brief Set relative mouse mode.
@@ -497,16 +515,16 @@ PHP_FUNCTION(SDL_WarpMouseInWindow)
  */
 PHP_FUNCTION(SDL_SetRelativeMouseMode)
 {
-	zend_bool enabled;
+	bool enabled;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &enabled)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &enabled))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_SetRelativeMouseMode(enabled));
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_GetRelativeMouseMode(void)
 
  *  \brief Query whether relative mouse mode is enabled.
@@ -516,39 +534,37 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
  */
 PHP_FUNCTION(SDL_GetRelativeMouseMode)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	RETVAL_BOOL(SDL_GetRelativeMouseMode());
 }
 
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0)
 ZEND_END_ARG_INFO()
 
-
 /* {{{ sdl_cursor_methods[] */
 static const zend_function_entry php_sdl_cursor_methods[] = {
-	PHP_ME(SDL_Cursor,       __construct,                arginfo_SDL_Cursor__construct,     ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Cursor,       __toString,                 arginfo_none,                      ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Cursor, __construct, arginfo_SDL_Cursor__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_Cursor, __toString, arginfo_none, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
-	PHP_FALIAS(Free,          SDL_FreeCursor,            arginfo_none)
-	PHP_FALIAS(Set,           SDL_SetCursor,             arginfo_none)
+	PHP_FALIAS(Free, SDL_FreeCursor, arginfo_none)
+		PHP_FALIAS(Set, SDL_SetCursor, arginfo_none)
 
 	/* static methods */
-	ZEND_FENTRY(Create,       ZEND_FN(SDL_CreateCursor),        arginfo_SDL_Cursor__construct,  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-	ZEND_FENTRY(CreateSystem, ZEND_FN(SDL_CreateSystemCursor),  arginfo_SDL_CreateSystemCursor, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-	ZEND_FENTRY(CreateColor,  ZEND_FN(SDL_CreateColorCursor),   arginfo_SDL_CreateColorCursor,  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-	ZEND_FENTRY(Get,          ZEND_FN(SDL_GetCursor),           arginfo_none,                   ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-	ZEND_FENTRY(GetDefault,   ZEND_FN(SDL_GetDefaultCursor),    arginfo_none,                   ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-	ZEND_FENTRY(Show,         ZEND_FN(SDL_ShowCursor),          arginfo_SDL_ShowCursor,         ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-
-	ZEND_FE_END
-};
+	ZEND_FENTRY(Create, ZEND_FN(SDL_CreateCursor), arginfo_SDL_Cursor__construct, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+		ZEND_FENTRY(CreateSystem, ZEND_FN(SDL_CreateSystemCursor), arginfo_SDL_CreateSystemCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+			ZEND_FENTRY(CreateColor, ZEND_FN(SDL_CreateColorCursor), arginfo_SDL_CreateColorCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+				ZEND_FENTRY(Get, ZEND_FN(SDL_GetCursor), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+					ZEND_FENTRY(GetDefault, ZEND_FN(SDL_GetDefaultCursor), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+						ZEND_FENTRY(Show, ZEND_FN(SDL_ShowCursor), arginfo_SDL_ShowCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+
+							ZEND_FE_END};
 /* }}} */
 
-#define REGISTER_CURSOR_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_CURSOR_CLASS_CONST_LONG(const_name, value)                                      \
 	REGISTER_LONG_CONSTANT("SDL_SYSTEM_CURSOR_" const_name, value, CONST_CS | CONST_PERSISTENT); \
 	zend_declare_class_constant_long(php_sdl_cursor_ce, ZEND_STRL(const_name), value)
 
@@ -561,25 +577,25 @@ PHP_MINIT_FUNCTION(sdl_mouse)
 	php_sdl_cursor_ce = zend_register_internal_class(&ce);
 	php_sdl_cursor_ce->create_object = php_sdl_cursor_new;
 	memcpy(&php_sdl_cursor_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-	php_sdl_cursor_handlers.free_obj = php_sdl_cursor_free; 
+	php_sdl_cursor_handlers.free_obj = php_sdl_cursor_free;
 	php_sdl_cursor_handlers.offset = XtOffsetOf(struct php_sdl_cursor, zo);
 
 	/* Cursor types for SDL_CreateSystemCursor.
 	   typedef enum SDL_SystemCursor; */
-	REGISTER_CURSOR_CLASS_CONST_LONG("ARROW",     SDL_SYSTEM_CURSOR_ARROW);
-	REGISTER_CURSOR_CLASS_CONST_LONG("IBEAM",     SDL_SYSTEM_CURSOR_IBEAM);
-	REGISTER_CURSOR_CLASS_CONST_LONG("WAIT",      SDL_SYSTEM_CURSOR_WAIT);
+	REGISTER_CURSOR_CLASS_CONST_LONG("ARROW", SDL_SYSTEM_CURSOR_ARROW);
+	REGISTER_CURSOR_CLASS_CONST_LONG("IBEAM", SDL_SYSTEM_CURSOR_IBEAM);
+	REGISTER_CURSOR_CLASS_CONST_LONG("WAIT", SDL_SYSTEM_CURSOR_WAIT);
 	REGISTER_CURSOR_CLASS_CONST_LONG("CROSSHAIR", SDL_SYSTEM_CURSOR_CROSSHAIR);
 	REGISTER_CURSOR_CLASS_CONST_LONG("WAITARROW", SDL_SYSTEM_CURSOR_WAITARROW);
-	REGISTER_CURSOR_CLASS_CONST_LONG("SIZENWSE",  SDL_SYSTEM_CURSOR_SIZENWSE);
-	REGISTER_CURSOR_CLASS_CONST_LONG("SIZENESW",  SDL_SYSTEM_CURSOR_SIZENESW);
-	REGISTER_CURSOR_CLASS_CONST_LONG("SIZEWE",    SDL_SYSTEM_CURSOR_SIZEWE);
-	REGISTER_CURSOR_CLASS_CONST_LONG("SIZENS",    SDL_SYSTEM_CURSOR_SIZENS);
-	REGISTER_CURSOR_CLASS_CONST_LONG("SIZEALL",   SDL_SYSTEM_CURSOR_SIZEALL);
-	REGISTER_CURSOR_CLASS_CONST_LONG("NO",        SDL_SYSTEM_CURSOR_NO);
-	REGISTER_CURSOR_CLASS_CONST_LONG("HAND",      SDL_SYSTEM_CURSOR_HAND);
-
-	REGISTER_LONG_CONSTANT("SDL_NUM_SYSTEM_CURSORS",      SDL_NUM_SYSTEM_CURSORS, CONST_CS | CONST_PERSISTENT);
+	REGISTER_CURSOR_CLASS_CONST_LONG("SIZENWSE", SDL_SYSTEM_CURSOR_SIZENWSE);
+	REGISTER_CURSOR_CLASS_CONST_LONG("SIZENESW", SDL_SYSTEM_CURSOR_SIZENESW);
+	REGISTER_CURSOR_CLASS_CONST_LONG("SIZEWE", SDL_SYSTEM_CURSOR_SIZEWE);
+	REGISTER_CURSOR_CLASS_CONST_LONG("SIZENS", SDL_SYSTEM_CURSOR_SIZENS);
+	REGISTER_CURSOR_CLASS_CONST_LONG("SIZEALL", SDL_SYSTEM_CURSOR_SIZEALL);
+	REGISTER_CURSOR_CLASS_CONST_LONG("NO", SDL_SYSTEM_CURSOR_NO);
+	REGISTER_CURSOR_CLASS_CONST_LONG("HAND", SDL_SYSTEM_CURSOR_HAND);
+
+	REGISTER_LONG_CONSTANT("SDL_NUM_SYSTEM_CURSORS", SDL_NUM_SYSTEM_CURSORS, CONST_CS | CONST_PERSISTENT);
 	zend_declare_class_constant_long(php_sdl_cursor_ce, ZEND_STRL("NUM_SYSTEM"), SDL_NUM_SYSTEM_CURSORS);
 
 	/*
@@ -588,16 +604,16 @@ PHP_MINIT_FUNCTION(sdl_mouse)
 	 *   - Button 2:  Middle mouse button
 	 *   - Button 3:  Right mouse button
 	 */
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_LEFT",   SDL_BUTTON_LEFT,   CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_MIDDLE", SDL_BUTTON_MIDDLE, CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_RIGHT",  SDL_BUTTON_RIGHT,  CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_X1",     SDL_BUTTON_X1,     CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_X2",     SDL_BUTTON_X2,     CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_LMASK",  SDL_BUTTON_LMASK,  CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_MMASK",  SDL_BUTTON_MMASK,  CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_RMASK",  SDL_BUTTON_RMASK,  CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_X1MASK", SDL_BUTTON_X1MASK, CONST_CS | CONST_PERSISTENT); \
-	REGISTER_LONG_CONSTANT("SDL_BUTTON_X2MASK", SDL_BUTTON_X2MASK, CONST_CS | CONST_PERSISTENT); \
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_LEFT", SDL_BUTTON_LEFT, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_MIDDLE", SDL_BUTTON_MIDDLE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_RIGHT", SDL_BUTTON_RIGHT, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_X1", SDL_BUTTON_X1, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_X2", SDL_BUTTON_X2, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_LMASK", SDL_BUTTON_LMASK, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_MMASK", SDL_BUTTON_MMASK, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_RMASK", SDL_BUTTON_RMASK, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_X1MASK", SDL_BUTTON_X1MASK, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_BUTTON_X2MASK", SDL_BUTTON_X2MASK, CONST_CS | CONST_PERSISTENT);
 
 	return SUCCESS;
 }
diff --git a/src/surface.c b/src/surface.c
index 8684487..76a17f6 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -23,10 +23,11 @@
 
 static zend_class_entry *php_sdl_surface_ce;
 static zend_object_handlers php_sdl_surface_handlers;
-struct php_sdl_surface {
-	SDL_Surface   *surface;
-	Uint32        flags;
-	zend_object   zo;
+struct php_sdl_surface
+{
+	SDL_Surface *surface;
+	Uint32 flags;
+	zend_object zo;
 };
 
 zend_class_entry *get_php_sdl_surface_ce(void)
@@ -34,26 +35,28 @@ zend_class_entry *get_php_sdl_surface_ce(void)
 	return php_sdl_surface_ce;
 }
 
-#define FETCH_SURFACE(__ptr, __id, __check) \
-{ \
-		zend_object* zox = Z_OBJ_P(__id);\
-		intern = (struct php_sdl_surface*)((char*)zox - zox->handlers->offset);\
-        __ptr = intern->surface; \
-        if (__check && !__ptr) {\
-                php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-                RETURN_FALSE;\
-        }\
-}
+#define FETCH_SURFACE(__ptr, __id, __check)                                                        \
+	{                                                                                              \
+		zend_object *zox = Z_OBJ_P(__id);                                                          \
+		intern = (struct php_sdl_surface *)((char *)zox - zox->handlers->offset);                  \
+		__ptr = intern->surface;                                                                   \
+		if (__check && !__ptr)                                                                     \
+		{                                                                                          \
+			php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+			RETURN_FALSE;                                                                          \
+		}                                                                                          \
+	}
 
 /* {{{ sdl_surface_to_zval */
 zend_bool sdl_surface_to_zval(SDL_Surface *surface, zval *z_val)
 {
-	if (surface) {
+	if (surface)
+	{
 		struct php_sdl_surface *intern;
 
 		object_init_ex(z_val, php_sdl_surface_ce);
-		zend_object* zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset);
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset);
 		intern->surface = surface;
 		/* copy flags to be able to check before access to surface */
 		intern->flags = surface->flags;
@@ -70,17 +73,16 @@ SDL_Surface *zval_to_sdl_surface(zval *z_val)
 {
 	struct php_sdl_surface *intern;
 
-	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_surface_ce) {
-		zend_object* zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset);
+	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_surface_ce)
+	{
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset);
 		return intern->surface;
-		}
+	}
 	return NULL;
 }
 /* }}} */
 
-
-
 /* {{{ proto SDL_Surface SDL_CreateRGBSurface(int flags, int width, int height, int depth, int Rmask, int Gmask, int Bmask, int Amask)
 
  *  Allocate and free an RGB surface.
@@ -100,15 +102,16 @@ SDL_Surface *zval_to_sdl_surface(zval *z_val)
  *  \param Bmask The blue mask of the surface to create.
  *  \param Amask The alpha mask of the surface to create.
  extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
-     (Uint32 flags, int width, int height, int depth,
-      Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
+	 (Uint32 flags, int width, int height, int depth,
+	  Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
 */
 PHP_FUNCTION(SDL_CreateRGBSurface)
 {
 	zend_long flags, width, height, depth, rmask, gmask, bmask, amask;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask))
+	{
 		return;
 	}
 	surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask);
@@ -126,7 +129,7 @@ PHP_FUNCTION(SDL_CreateRGBSurface)
  *
  *  \return the new surface, or NULL if there was an error.
  extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
-                                                     int freesrc);
+													 int freesrc);
  */
 PHP_FUNCTION(SDL_LoadBMP_RW)
 {
@@ -135,12 +138,14 @@ PHP_FUNCTION(SDL_LoadBMP_RW)
 	SDL_Surface *surface;
 	SDL_RWops *rwops;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &z_rwops, get_php_sdl_rwops_ce(), &freesrc)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &z_rwops, get_php_sdl_rwops_ce(), &freesrc))
+	{
 		return;
 	}
 	rwops = zval_to_sdl_rwops(z_rwops);
 	surface = SDL_LoadBMP_RW(rwops, 0);
-	if (freesrc) {
+	if (freesrc)
+	{
 		/* we close the SDL_RWops ourself, to free the PHP object */
 		zval_dtor(z_rwops);
 		ZVAL_NULL(z_rwops);
@@ -149,8 +154,6 @@ PHP_FUNCTION(SDL_LoadBMP_RW)
 }
 /* }}} */
 
-
-
 /* {{{ proto SDL_Surface SDL_LoadBMP(string file)
 
 	PHP note: stream are supported
@@ -166,7 +169,8 @@ PHP_FUNCTION(SDL_LoadBMP)
 	size_t path_len;
 	SDL_Surface *surface = NULL;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &path_len)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &path_len))
+	{
 		return;
 	}
 
@@ -176,7 +180,6 @@ PHP_FUNCTION(SDL_LoadBMP)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Surface::__construct(int flags, int width, int height, int depth, int Rmask, int Gmask, int Bmask, int Amask) */
 static PHP_METHOD(SDL_Surface, __construct)
 {
@@ -184,56 +187,61 @@ static PHP_METHOD(SDL_Surface, __construct)
 	zend_long flags, width, height, depth, rmask, gmask, bmask, amask;
 	zend_error_handling error_handling;
 
-	zend_object* zo = Z_OBJ_P(getThis());
-	intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset);
+	zend_object *zo = Z_OBJ_P(getThis());
+	intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset);
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
 	intern->surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask);
-	if (intern->surface) {
+	if (intern->surface)
+	{
 		/* copy flags to be able to check before access to surface */
 		intern->flags = intern->surface->flags;
-	} else {
+	}
+	else
+	{
 		zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Surface::__toString() */
 static PHP_METHOD(SDL_Surface, __toString)
 {
 	struct php_sdl_surface *intern;
 	char *buf;
-    size_t buf_len;
+	size_t buf_len;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
-	zend_object* zo = Z_OBJ_P(getThis());
-	intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset);
+	zend_object *zo = Z_OBJ_P(getThis());
+	intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset);
 
-	if (intern->surface) {
+	if (intern->surface)
+	{
 		buf_len = spprintf(&buf, 100, "SDL_Surface(%u,%d,%d,%u,0x%x,0x%x,0x%x,0x%x)",
-			intern->surface->flags, intern->surface->w, intern->surface->h,
-			intern->surface->format->BitsPerPixel, intern->surface->format->Rmask,
-			intern->surface->format->Gmask, intern->surface->format->Bmask, intern->surface->format->Amask);
+						   intern->surface->flags, intern->surface->w, intern->surface->h,
+						   intern->surface->format->BitsPerPixel, intern->surface->format->Rmask,
+						   intern->surface->format->Gmask, intern->surface->format->Bmask, intern->surface->format->Amask);
 		RETVAL_STRINGL(buf, buf_len);
-        efree(buf);
-	} else {
+		efree(buf);
+	}
+	else
+	{
 		RETVAL_STRING("SDL_Surface()");
 	}
 }
 /* }}} */
 
-
-
 /* {{{ proto int SDL_SaveBMP_RW(SDL_Surface surface, SDL_RWops &dst, int freedst)
 
  *  Save a surface to a seekable SDL data stream (memory or file).
@@ -242,7 +250,7 @@ static PHP_METHOD(SDL_Surface, __toString)
  *
  *  \return 0 if successful or -1 if there was an error.
  extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
-     (SDL_Surface * surface, SDL_RWops * dst, int freedst);
+	 (SDL_Surface * surface, SDL_RWops * dst, int freedst);
  */
 PHP_FUNCTION(SDL_SaveBMP_RW)
 {
@@ -253,20 +261,23 @@ PHP_FUNCTION(SDL_SaveBMP_RW)
 	SDL_RWops *rwops;
 	int result;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_surface, php_sdl_surface_ce, &z_rwops, get_php_sdl_rwops_ce(), &freedst) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_surface, php_sdl_surface_ce, &z_rwops, get_php_sdl_rwops_ce(), &freedst) == FAILURE)
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
 	rwops = zval_to_sdl_rwops(z_rwops);
 
-	if (!rwops) {
+	if (!rwops)
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_RWops object");
 		RETURN_LONG(-1);
 	}
 
 	result = SDLCALL SDL_SaveBMP_RW(surface, rwops, 0);
 
-	if (freedst) {
+	if (freedst)
+	{
 		/* we close the SDL_RWops ourself, to free the PHP object */
 		zval_dtor(z_rwops);
 		ZVAL_NULL(z_rwops);
@@ -275,14 +286,12 @@ PHP_FUNCTION(SDL_SaveBMP_RW)
 }
 /* }}} */
 
-
-
 /* {{{ proto int SDL_SaveBMP(SDL_Surface surface, string path)
 
 	PHP note: stream are "partially" supported (only when PHP_STREAM_AS_STDIO)
 
  define SDL_SaveBMP(surface, file) \
-         SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
+		 SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
 
  */
 PHP_FUNCTION(SDL_SaveBMP)
@@ -296,7 +305,8 @@ PHP_FUNCTION(SDL_SaveBMP)
 	int result = -1;
 	php_stream *stream;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_surface, php_sdl_surface_ce, &path, &path_len) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_surface, php_sdl_surface_ce, &path, &path_len) == FAILURE)
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -305,7 +315,8 @@ PHP_FUNCTION(SDL_SaveBMP)
 	php_stream_to_zval_rwops(stream, &z_rwops, 0);
 
 	rwops = zval_to_sdl_rwops(&z_rwops);
-	if (rwops) {
+	if (rwops)
+	{
 		result = SDLCALL SDL_SaveBMP_RW(surface, rwops, 0);
 	}
 	zval_dtor(&z_rwops);
@@ -314,7 +325,6 @@ PHP_FUNCTION(SDL_SaveBMP)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_FreeSurface(SDL_Surface surface)
 
  *  \brief Destroy a window.
@@ -326,7 +336,8 @@ PHP_FUNCTION(SDL_FreeSurface)
 	zval *object;
 	SDL_Surface *surface;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_surface_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_surface_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, object, 1);
@@ -336,8 +347,6 @@ PHP_FUNCTION(SDL_FreeSurface)
 }
 /* }}} */
 
-
-
 /* {{{ proto SDL_FillRect(SDL_Surface surface, SDL_Rect rect, int color)
 
  *  Performs a fast fill of the given rectangle with \c color.
@@ -349,7 +358,7 @@ PHP_FUNCTION(SDL_FreeSurface)
  *
  *  \return 0 on success, or -1 on error.
 extern DECLSPEC int SDLCALL SDL_FillRect
-    (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
+	(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
  */
 PHP_FUNCTION(SDL_FillRect)
 {
@@ -359,7 +368,8 @@ PHP_FUNCTION(SDL_FillRect)
 	SDL_Rect rect;
 	SDL_Surface *surface;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOl", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce(), &color) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOl", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce(), &color) == FAILURE)
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -369,11 +379,10 @@ PHP_FUNCTION(SDL_FillRect)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_FillRects(SDL_Surface surface, SDL_Rect rect, int count, int color)
 
 extern DECLSPEC int SDLCALL SDL_FillRects
-    (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
+	(SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
 */
 PHP_FUNCTION(SDL_FillRects)
 {
@@ -384,32 +393,40 @@ PHP_FUNCTION(SDL_FillRects)
 	SDL_Rect *rects;
 	SDL_Surface *surface;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oall", &z_surface, php_sdl_surface_ce, &z_rects, &count, &color) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oall", &z_surface, php_sdl_surface_ce, &z_rects, &count, &color) == FAILURE)
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
-	if (count<=0) {
+	if (count <= 0)
+	{
 		count = zend_hash_next_free_element(Z_ARRVAL_P(z_rects));
 	}
-	rects = emalloc(sizeof(SDL_Rect)*count);
+	rects = emalloc(sizeof(SDL_Rect) * count);
 
-	for (i=nb=0 ; i<count ; i++) {
-		if (!(z_rect = zend_hash_index_find(Z_ARRVAL_P(z_rects), i))) {
+	for (i = nb = 0; i < count; i++)
+	{
+		if (!(z_rect = zend_hash_index_find(Z_ARRVAL_P(z_rects), i)))
+		{
 			php_error_docref(NULL, E_WARNING, "rects[%d] missing", i);
-
-		} else if (Z_TYPE_P(z_rect) != IS_OBJECT || Z_OBJCE_P(z_rect) != get_php_sdl_rect_ce()) {
+		}
+		else if (Z_TYPE_P(z_rect) != IS_OBJECT || Z_OBJCE_P(z_rect) != get_php_sdl_rect_ce())
+		{
 			php_error_docref(NULL, E_WARNING, "rects[%d] is not a SDL_Rect object", i);
-
-		} else {
-			zval_to_sdl_rect(z_rect, rects+nb);
+		}
+		else
+		{
+			zval_to_sdl_rect(z_rect, rects + nb);
 			nb++;
 		}
 	}
 
-	if (nb) {
+	if (nb)
+	{
 		RETVAL_LONG(SDL_FillRects(surface, rects, nb, (Uint32)color));
-
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "no rect in provided array");
 		RETVAL_LONG(-1);
 	}
@@ -417,7 +434,6 @@ PHP_FUNCTION(SDL_FillRects)
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_MUSTLOCK(SDL_Surface surface)
 
  *  Evaluates to true if the surface needs to be locked before access.
@@ -429,7 +445,8 @@ PHP_FUNCTION(SDL_MUSTLOCK)
 	zval *z_surface;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_surface, php_sdl_surface_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_surface, php_sdl_surface_ce))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -438,7 +455,6 @@ PHP_FUNCTION(SDL_MUSTLOCK)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_LockSurface(SDL_Surface surface)
 
  *  \brief Sets up a surface for directly accessing the pixels.
@@ -466,7 +482,8 @@ PHP_FUNCTION(SDL_LockSurface)
 	zval *z_surface;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_surface, php_sdl_surface_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_surface, php_sdl_surface_ce))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -475,7 +492,6 @@ PHP_FUNCTION(SDL_LockSurface)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_UnlockSurface(SDL_Surface surface)
 
 extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
@@ -486,7 +502,8 @@ PHP_FUNCTION(SDL_UnlockSurface)
 	zval *z_surface;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_surface, php_sdl_surface_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_surface, php_sdl_surface_ce))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -495,7 +512,6 @@ PHP_FUNCTION(SDL_UnlockSurface)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_UpperBlit(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst [, SDL_rect &dstrect])
 
  *  Performs a fast blit from the source surface to the destination surface.
@@ -512,44 +528,44 @@ PHP_FUNCTION(SDL_UnlockSurface)
  *  The blit semantics for surfaces with and without blending and colorkey
  *  are defined as follows:
  *  \verbatim
-    RGBA->RGB:
-      Source surface blend mode set to SDL_BLENDMODE_BLEND:
-        alpha-blend (using the source alpha-channel and per-surface alpha)
-        SDL_SRCCOLORKEY ignored.
-      Source surface blend mode set to SDL_BLENDMODE_NONE:
-        copy RGB.
-        if SDL_SRCCOLORKEY set, only copy the pixels matching the
-        RGB values of the source color key, ignoring alpha in the
-        comparison.
-
-    RGB->RGBA:
-      Source surface blend mode set to SDL_BLENDMODE_BLEND:
-        alpha-blend (using the source per-surface alpha)
-      Source surface blend mode set to SDL_BLENDMODE_NONE:
-        copy RGB, set destination alpha to source per-surface alpha value.
-      both:
-        if SDL_SRCCOLORKEY set, only copy the pixels matching the
-        source color key.
-
-    RGBA->RGBA:
-      Source surface blend mode set to SDL_BLENDMODE_BLEND:
-        alpha-blend (using the source alpha-channel and per-surface alpha)
-        SDL_SRCCOLORKEY ignored.
-      Source surface blend mode set to SDL_BLENDMODE_NONE:
-        copy all of RGBA to the destination.
-        if SDL_SRCCOLORKEY set, only copy the pixels matching the
-        RGB values of the source color key, ignoring alpha in the
-        comparison.
-
-    RGB->RGB:
-      Source surface blend mode set to SDL_BLENDMODE_BLEND:
-        alpha-blend (using the source per-surface alpha)
-      Source surface blend mode set to SDL_BLENDMODE_NONE:
-        copy RGB.
-      both:
-        if SDL_SRCCOLORKEY set, only copy the pixels matching the
-        source color key.
-    \endverbatim
+	RGBA->RGB:
+	  Source surface blend mode set to SDL_BLENDMODE_BLEND:
+		alpha-blend (using the source alpha-channel and per-surface alpha)
+		SDL_SRCCOLORKEY ignored.
+	  Source surface blend mode set to SDL_BLENDMODE_NONE:
+		copy RGB.
+		if SDL_SRCCOLORKEY set, only copy the pixels matching the
+		RGB values of the source color key, ignoring alpha in the
+		comparison.
+
+	RGB->RGBA:
+	  Source surface blend mode set to SDL_BLENDMODE_BLEND:
+		alpha-blend (using the source per-surface alpha)
+	  Source surface blend mode set to SDL_BLENDMODE_NONE:
+		copy RGB, set destination alpha to source per-surface alpha value.
+	  both:
+		if SDL_SRCCOLORKEY set, only copy the pixels matching the
+		source color key.
+
+	RGBA->RGBA:
+	  Source surface blend mode set to SDL_BLENDMODE_BLEND:
+		alpha-blend (using the source alpha-channel and per-surface alpha)
+		SDL_SRCCOLORKEY ignored.
+	  Source surface blend mode set to SDL_BLENDMODE_NONE:
+		copy all of RGBA to the destination.
+		if SDL_SRCCOLORKEY set, only copy the pixels matching the
+		RGB values of the source color key, ignoring alpha in the
+		comparison.
+
+	RGB->RGB:
+	  Source surface blend mode set to SDL_BLENDMODE_BLEND:
+		alpha-blend (using the source per-surface alpha)
+	  Source surface blend mode set to SDL_BLENDMODE_NONE:
+		copy RGB.
+	  both:
+		if SDL_SRCCOLORKEY set, only copy the pixels matching the
+		source color key.
+	\endverbatim
 
  *
  *  You should call SDL_BlitSurface() unless you know exactly how SDL
@@ -559,8 +575,8 @@ PHP_FUNCTION(SDL_UnlockSurface)
  *  This is the public blit function, SDL_BlitSurface(), and it performs
  *  rectangle validation and clipping before passing it to SDL_LowerBlit()
  extern DECLSPEC int SDLCALL SDL_UpperBlit
-     (SDL_Surface * src, const SDL_Rect * srcrect,
-      SDL_Surface * dst, SDL_Rect * dstrect);
+	 (SDL_Surface * src, const SDL_Rect * srcrect,
+	  SDL_Surface * dst, SDL_Rect * dstrect);
  */
 PHP_FUNCTION(SDL_UpperBlit)
 {
@@ -570,42 +586,44 @@ PHP_FUNCTION(SDL_UpperBlit)
 	SDL_Rect srect, drect;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect))
+	{
 		return;
 	}
 	FETCH_SURFACE(src, z_src, 1);
 	FETCH_SURFACE(dst, z_dst, 1);
-	if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) {
+	if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect)))
+	{
 		php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object");
 		return;
 	}
-        /*
-	if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
-		php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
-		return;
-	} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
-		php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
-	}
-         * */
+	/*
+if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
+	php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
+	return;
+} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
+	php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
+}
+	 * */
 
-	result = SDL_UpperBlit(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect),
-	                       dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect));
+	result = SDL_UpperBlit(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect),
+						   dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect));
 
-	if (result==0 && z_drect && Z_TYPE_P(z_drect)==IS_OBJECT) {
+	if (result == 0 && z_drect && Z_TYPE_P(z_drect) == IS_OBJECT)
+	{
 		sdl_rect_to_zval(&drect, z_drect);
 	}
 	RETURN_LONG(result);
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_LowerBlit(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst , SDL_rect &dstrect)
 
  *  This is a semi-private blit function and it performs low-level surface
  *  blitting only.
  extern DECLSPEC int SDLCALL SDL_LowerBlit
-     (SDL_Surface * src, SDL_Rect * srcrect,
-      SDL_Surface * dst, SDL_Rect * dstrect);
+	 (SDL_Surface * src, SDL_Rect * srcrect,
+	  SDL_Surface * dst, SDL_Rect * dstrect);
  */
 PHP_FUNCTION(SDL_LowerBlit)
 {
@@ -615,7 +633,8 @@ PHP_FUNCTION(SDL_LowerBlit)
 	SDL_Rect srect, drect;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce())) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce()))
+	{
 		return;
 	}
 	FETCH_SURFACE(src, z_src, 1);
@@ -625,7 +644,8 @@ PHP_FUNCTION(SDL_LowerBlit)
 
 	result = SDL_LowerBlit(src, &srect, dst, &drect);
 
-	if (result==0) {
+	if (result == 0)
+	{
 		zval_dtor(z_srect);
 		sdl_rect_to_zval(&srect, z_srect);
 		zval_dtor(z_drect);
@@ -635,14 +655,13 @@ PHP_FUNCTION(SDL_LowerBlit)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_UpperBlitScaled(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst [, SDL_rect &dstrect])
 
  *  This is the public scaled blit function, SDL_BlitScaled(), and it performs
  *  rectangle validation and clipping before passing it to SDL_LowerBlitScaled()
  extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
-     (SDL_Surface * src, const SDL_Rect * srcrect,
-     SDL_Surface * dst, SDL_Rect * dstrect);
+	 (SDL_Surface * src, const SDL_Rect * srcrect,
+	 SDL_Surface * dst, SDL_Rect * dstrect);
  define SDL_BlitScaled SDL_UpperBlitScaled
  */
 PHP_FUNCTION(SDL_UpperBlitScaled)
@@ -653,42 +672,44 @@ PHP_FUNCTION(SDL_UpperBlitScaled)
 	SDL_Rect srect, drect;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect))
+	{
 		return;
 	}
 	FETCH_SURFACE(src, z_src, 1);
 	FETCH_SURFACE(dst, z_dst, 1);
-	if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) {
+	if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect)))
+	{
 		php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object");
 		return;
 	}
-        /*
-	if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
-		php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
-		return;
-	} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
-		php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
-	}
-         * */
+	/*
+if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
+	php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
+	return;
+} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
+	php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
+}
+	 * */
 
-	result = SDL_UpperBlitScaled(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect),
-	                       dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect));
+	result = SDL_UpperBlitScaled(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect),
+								 dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect));
 
-	if (result==0 && z_drect && Z_TYPE_P(z_drect)==IS_OBJECT) {
+	if (result == 0 && z_drect && Z_TYPE_P(z_drect) == IS_OBJECT)
+	{
 		sdl_rect_to_zval(&drect, z_drect);
 	}
 	RETURN_LONG(result);
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_LowerBlitScaled(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst , SDL_rect &dstrect)
 
  *  This is a semi-private blit function and it performs low-level surface
  *  scaled blitting only.
  extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
-     (SDL_Surface * src, SDL_Rect * srcrect,
-     SDL_Surface * dst, SDL_Rect * dstrect);
+	 (SDL_Surface * src, SDL_Rect * srcrect,
+	 SDL_Surface * dst, SDL_Rect * dstrect);
  */
 PHP_FUNCTION(SDL_LowerBlitScaled)
 {
@@ -698,7 +719,8 @@ PHP_FUNCTION(SDL_LowerBlitScaled)
 	SDL_Rect srect, drect;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce())) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce()))
+	{
 		return;
 	}
 	FETCH_SURFACE(src, z_src, 1);
@@ -708,7 +730,8 @@ PHP_FUNCTION(SDL_LowerBlitScaled)
 
 	result = SDL_LowerBlitScaled(src, &srect, dst, &drect);
 
-	if (result==0) {
+	if (result == 0)
+	{
 		zval_dtor(z_srect);
 		sdl_rect_to_zval(&srect, z_srect);
 		zval_dtor(z_drect);
@@ -718,7 +741,6 @@ PHP_FUNCTION(SDL_LowerBlitScaled)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_SoftStretch(SDL_Surface src, SDL_rect srcrect, SDL_Surface dst [, SDL_rect dstrect])
 
  *  \brief Perform a fast, low quality, stretch blit between two surfaces of the
@@ -726,9 +748,9 @@ PHP_FUNCTION(SDL_LowerBlitScaled)
  *
  *  \note This function uses a static buffer, and is not thread-safe.
  extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
-                                             const SDL_Rect * srcrect,
-                                             SDL_Surface * dst,
-                                             const SDL_Rect * dstrect);
+											 const SDL_Rect * srcrect,
+											 SDL_Surface * dst,
+											 const SDL_Rect * dstrect);
 
  */
 PHP_FUNCTION(SDL_SoftStretch)
@@ -739,30 +761,34 @@ PHP_FUNCTION(SDL_SoftStretch)
 	SDL_Rect srect, drect;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect))
+	{
 		return;
 	}
 	FETCH_SURFACE(src, z_src, 1);
 	FETCH_SURFACE(dst, z_dst, 1);
-	if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) {
+	if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect)))
+	{
 		php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object");
 		return;
 	}
-	if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) {
+	if (z_drect && !(Z_TYPE_P(z_drect) == IS_NULL || zval_to_sdl_rect(z_drect, &drect)))
+	{
 		php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object");
 		return;
-	} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) {
+	}
+	else if (z_drect && Z_TYPE_P(z_drect) == IS_NULL)
+	{
 		php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored");
 	}
 
-	result = SDL_SoftStretch(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect),
-	                         dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect));
+	result = SDL_SoftStretch(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect),
+							 dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect));
 
 	RETURN_LONG(result);
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_SetSurfaceRLE(SDL_Surface src, int flag)
 
  *  \brief Sets the RLE acceleration hint for a surface.
@@ -772,7 +798,7 @@ PHP_FUNCTION(SDL_SoftStretch)
  *  \note If RLE is enabled, colorkey and alpha blending blits are much faster,
  *        but the surface must be locked before directly accessing the pixels.
  extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
-                                               int flag);
+											   int flag);
  */
 PHP_FUNCTION(SDL_SetSurfaceRLE)
 {
@@ -781,7 +807,8 @@ PHP_FUNCTION(SDL_SetSurfaceRLE)
 	zend_long flag;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &flag)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &flag))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -801,17 +828,18 @@ PHP_FUNCTION(SDL_SetSurfaceRLE)
  *
  *  You can pass SDL_RLEACCEL to enable RLE accelerated blits.
  extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
-                                             int flag, Uint32 key);
+											 int flag, Uint32 key);
  */
 PHP_FUNCTION(SDL_SetColorKey)
 {
 	struct php_sdl_surface *intern;
 	zval *z_surface;
-	zend_bool flag;
+	bool flag;
 	zend_long key = 0;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob|l", &z_surface, php_sdl_surface_ce, &flag, &key)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob|l", &z_surface, php_sdl_surface_ce, &flag, &key))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -830,7 +858,7 @@ PHP_FUNCTION(SDL_SetColorKey)
  *  \return 0 on success, or -1 if the surface is not valid or colorkey is not
  *          enabled.
  extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
-                                             Uint32 * key);
+											 Uint32 * key);
  */
 PHP_FUNCTION(SDL_GetColorKey)
 {
@@ -840,12 +868,14 @@ PHP_FUNCTION(SDL_GetColorKey)
 	SDL_Surface *surface;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_key)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_key))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
 	result = SDL_GetColorKey(surface, &key);
-	if (result == 0) {
+	if (result == 0)
+	{
 		zval_dtor(z_key);
 		ZVAL_LONG(z_key, (long)key);
 	}
@@ -866,7 +896,7 @@ PHP_FUNCTION(SDL_GetColorKey)
  *
  *  \sa SDL_GetSurfaceColorMod()
  extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
-                                                    Uint8 r, Uint8 g, Uint8 b);
+													Uint8 r, Uint8 g, Uint8 b);
  */
 PHP_FUNCTION(SDL_SetSurfaceColorMod)
 {
@@ -875,7 +905,8 @@ PHP_FUNCTION(SDL_SetSurfaceColorMod)
 	zend_long r, g, b;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_surface, php_sdl_surface_ce, &r, &g, &b)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_surface, php_sdl_surface_ce, &r, &g, &b))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -896,8 +927,8 @@ PHP_FUNCTION(SDL_SetSurfaceColorMod)
  *
  *  \sa SDL_SetSurfaceColorMod()
  extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
-                                                    Uint8 * r, Uint8 * g,
-                                                    Uint8 * b);
+													Uint8 * r, Uint8 * g,
+													Uint8 * b);
  */
 PHP_FUNCTION(SDL_GetSurfaceColorMod)
 {
@@ -907,12 +938,14 @@ PHP_FUNCTION(SDL_GetSurfaceColorMod)
 	SDL_Surface *surface;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
 	result = SDL_GetSurfaceColorMod(surface, &r, &g, &b);
-	if (result == 0) {
+	if (result == 0)
+	{
 		zval_dtor(z_r);
 		ZVAL_LONG(z_r, (long)r);
 		zval_dtor(z_g);
@@ -935,7 +968,7 @@ PHP_FUNCTION(SDL_GetSurfaceColorMod)
  *
  *  \sa SDL_GetSurfaceAlphaMod()
  extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
-                                                    Uint8 alpha);
+													Uint8 alpha);
  */
 PHP_FUNCTION(SDL_SetSurfaceAlphaMod)
 {
@@ -944,7 +977,8 @@ PHP_FUNCTION(SDL_SetSurfaceAlphaMod)
 	zend_long a;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &a)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &a))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -963,7 +997,7 @@ PHP_FUNCTION(SDL_SetSurfaceAlphaMod)
  *
  *  \sa SDL_SetSurfaceAlphaMod()
  extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
-                                                    Uint8 * alpha);
+													Uint8 * alpha);
  */
 PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
 {
@@ -973,12 +1007,14 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
 	SDL_Surface *surface;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_a)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_a))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
 	result = SDL_GetSurfaceAlphaMod(surface, &a);
-	if (result == 0) {
+	if (result == 0)
+	{
 		zval_dtor(z_a);
 		ZVAL_LONG(z_a, (long)a);
 	}
@@ -986,7 +1022,6 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_SetSurfaceBlendMode(SDL_Surface src, int blendmode)
  *  \brief Set the blend mode used for blit operations.
  *
@@ -997,7 +1032,7 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod)
  *
  *  \sa SDL_GetSurfaceBlendMode()
  extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
-                                                     SDL_BlendMode blendMode);
+													 SDL_BlendMode blendMode);
  */
 PHP_FUNCTION(SDL_SetSurfaceBlendMode)
 {
@@ -1006,7 +1041,8 @@ PHP_FUNCTION(SDL_SetSurfaceBlendMode)
 	zend_long mode;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &mode)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &mode))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -1025,7 +1061,7 @@ PHP_FUNCTION(SDL_SetSurfaceBlendMode)
  *
  *  \sa SDL_SetSurfaceBlendMode()
  extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
-                                                     SDL_BlendMode *blendMode);
+													 SDL_BlendMode *blendMode);
  */
 PHP_FUNCTION(SDL_GetSurfaceBlendMode)
 {
@@ -1035,12 +1071,14 @@ PHP_FUNCTION(SDL_GetSurfaceBlendMode)
 	SDL_Surface *surface;
 	int result;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_mode)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_mode))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
 	result = SDL_GetSurfaceBlendMode(surface, &mode);
-	if (result == 0) {
+	if (result == 0)
+	{
 		zval_dtor(z_mode);
 		ZVAL_LONG(z_mode, (long)mode);
 	}
@@ -1062,7 +1100,7 @@ PHP_FUNCTION(SDL_GetSurfaceBlendMode)
  *  Note that blits are automatically clipped to the edges of the source
  *  and destination surfaces.
  extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
-                                                  const SDL_Rect * rect);
+												  const SDL_Rect * rect);
  */
 PHP_FUNCTION(SDL_SetClipRect)
 {
@@ -1071,11 +1109,13 @@ PHP_FUNCTION(SDL_SetClipRect)
 	SDL_Rect rect;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce())) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce()))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
-	if (zval_to_sdl_rect(z_rect, &rect)) {
+	if (zval_to_sdl_rect(z_rect, &rect))
+	{
 		RETURN_BOOL(SDL_SetClipRect(surface, &rect));
 	}
 	php_error_docref(NULL, E_WARNING, "Invalid SDL_Rect object");
@@ -1090,7 +1130,7 @@ PHP_FUNCTION(SDL_SetClipRect)
  *  \c rect must be a pointer to a valid rectangle which will be filled
  *  with the correct values.
  extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface,
-                                              SDL_Rect * rect);
+											  SDL_Rect * rect);
  */
 PHP_FUNCTION(SDL_GetClipRect)
 {
@@ -1099,7 +1139,8 @@ PHP_FUNCTION(SDL_GetClipRect)
 	SDL_Rect rect;
 	SDL_Surface *surface;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_rect)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_rect))
+	{
 		return;
 	}
 	FETCH_SURFACE(surface, z_surface, 1);
@@ -1120,7 +1161,7 @@ PHP_FUNCTION(SDL_GetClipRect)
  *  SDL will try to RLE accelerate colorkey and alpha blits in the resulting
  *  surface.
  extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
-     (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
+	 (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags);
  */
 PHP_FUNCTION(SDL_ConvertSurface)
 {
@@ -1130,15 +1171,19 @@ PHP_FUNCTION(SDL_ConvertSurface)
 	SDL_Surface *src, *dst;
 	SDL_PixelFormat *format;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_src, php_sdl_surface_ce, &z_format, get_php_sdl_pixelformat_ce(), &flags)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_src, php_sdl_surface_ce, &z_format, get_php_sdl_pixelformat_ce(), &flags))
+	{
 		return;
 	}
 	FETCH_SURFACE(src, z_src, 1);
 	format = zval_to_sdl_pixelformat(z_format);
-	if (format) {
+	if (format)
+	{
 		dst = SDL_ConvertSurface(src, format, (Uint32)flags);
 		sdl_surface_to_zval(dst, return_value);
-	} else {
+	}
+	else
+	{
 		RETVAL_NULL();
 	}
 }
@@ -1147,7 +1192,7 @@ PHP_FUNCTION(SDL_ConvertSurface)
 /* {{{ proto void SDL_ConvertSurfaceFormat(SDL_Surface src, int format [, int flags])
 
  extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
-     (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
+	 (SDL_Surface * src, Uint32 pixel_format, Uint32 flags);
  */
 PHP_FUNCTION(SDL_ConvertSurfaceFormat)
 {
@@ -1156,7 +1201,8 @@ PHP_FUNCTION(SDL_ConvertSurfaceFormat)
 	zend_long format, flags = 0;
 	SDL_Surface *src, *dst;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_src, php_sdl_surface_ce, &format, &flags)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_src, php_sdl_surface_ce, &format, &flags))
+	{
 		return;
 	}
 	FETCH_SURFACE(src, z_src, 1);
@@ -1171,10 +1217,10 @@ PHP_FUNCTION(SDL_ConvertSurfaceFormat)
  *
  *  \return 0 on success, or -1 if there was an error
  extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
-                                               Uint32 src_format,
-                                               const void * src, int src_pitch,
-                                               Uint32 dst_format,
-                                               void * dst, int dst_pitch);
+											   Uint32 src_format,
+											   const void * src, int src_pitch,
+											   Uint32 dst_format,
+											   void * dst, int dst_pitch);
  */
 PHP_FUNCTION(SDL_ConvertPixels)
 {
@@ -1182,24 +1228,30 @@ PHP_FUNCTION(SDL_ConvertPixels)
 	zend_long w, h, sf, sp, df, dp;
 	SDL_Pixels *src, *dst;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &sf, &z_src, get_php_sdl_pixels_ce(), &sp, &df, &z_dst, get_php_sdl_pixels_ce(), &dp)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &sf, &z_src, get_php_sdl_pixels_ce(), &sp, &df, &z_dst, get_php_sdl_pixels_ce(), &dp))
+	{
 		return;
 	}
-	if (!(src = zval_to_sdl_pixels(z_src))) {
+	if (!(src = zval_to_sdl_pixels(z_src)))
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid source SDL_Pixels object");
 	}
-	if (!(dst = zval_to_sdl_pixels(z_dst))) {
+	if (!(dst = zval_to_sdl_pixels(z_dst)))
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid destination SDL_Pixels object");
 	}
-	if (h < 0 || h > src->h || h > dst->h) {
+	if (h < 0 || h > src->h || h > dst->h)
+	{
 		h = (src->h > dst->h ? dst->h : src->h);
 		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h);
 	}
-	if (sp != src->pitch) {
+	if (sp != src->pitch)
+	{
 		sp = src->pitch;
 		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp);
 	}
-	if (dp != dst->pitch) {
+	if (dp != dst->pitch)
+	{
 		dp = dst->pitch;
 		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp);
 	}
@@ -1212,53 +1264,54 @@ PHP_FUNCTION(SDL_ConvertPixels)
 #undef SDL_BlitScaled
 
 static const zend_function_entry php_sdl_surface_methods[] = {
-	PHP_ME(SDL_Surface, __construct, arginfo_SDL_CreateRGBSurface, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Surface, __toString,  arginfo_surface_none,         ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Surface, __construct, arginfo_SDL_CreateRGBSurface, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_Surface, __toString, arginfo_surface_none, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
-	PHP_FALIAS(Free,             SDL_FreeSurface,           arginfo_surface_none)
-	PHP_FALIAS(FillRect,         SDL_FillRect,              arginfo_SDL_Surface_FillRect)
-	PHP_FALIAS(FillRects,        SDL_FillRects,             arginfo_SDL_Surface_FillRects)
-	PHP_FALIAS(MustLock,         SDL_MUSTLOCK,              arginfo_surface_none)
-	PHP_FALIAS(Lock,             SDL_LockSurface,           arginfo_surface_none)
-	PHP_FALIAS(Unlock,           SDL_UnlockSurface,         arginfo_surface_none)
-	PHP_FALIAS(Blit,             SDL_UpperBlit,             arginfo_SDL_Surface_UpperBlit)
-	PHP_FALIAS(UpperBlit,        SDL_UpperBlit,             arginfo_SDL_Surface_UpperBlit)
-	PHP_FALIAS(LowerBlit,        SDL_LowerBlit,             arginfo_SDL_Surface_LowerBlit)
-	PHP_FALIAS(BlitScaled,       SDL_UpperBlitScaled,       arginfo_SDL_Surface_UpperBlit)
-	PHP_FALIAS(UpperBlitScaled,  SDL_UpperBlitScaled,       arginfo_SDL_Surface_UpperBlit)
-	PHP_FALIAS(LowerBlitScaled,  SDL_LowerBlitScaled,       arginfo_SDL_Surface_LowerBlit)
-	PHP_FALIAS(SoftStretch,      SDL_SoftStretch,           arginfo_SDL_Surface_UpperBlit)
-	PHP_FALIAS(SaveBMP_RW,       SDL_SaveBMP_RW,            arginfo_SDL_Surface_SaveBMP_RW)
-	PHP_FALIAS(SaveBMP,          SDL_SaveBMP,               arginfo_SDL_Surface_SaveBMP)
-	PHP_FALIAS(SetRLE,           SDL_SetSurfaceRLE,         arginfo_SDL_Surface_SetRLE)
-	PHP_FALIAS(SetColorKey,      SDL_SetColorKey,           arginfo_SDL_Surface_SetColorKey)
-	PHP_FALIAS(GetColorKey,      SDL_GetColorKey,           arginfo_SDL_Surface_GetColorKey)
-	PHP_FALIAS(SetColorMod,      SDL_SetSurfaceColorMod,    arginfo_SDL_Surface_SetColorMod)
-	PHP_FALIAS(GetColorMod,      SDL_GetSurfaceColorMod,    arginfo_SDL_Surface_GetColorMod)
-	PHP_FALIAS(SetAlphaMod,      SDL_SetSurfaceAlphaMod,    arginfo_SDL_Surface_SetAlphaMod)
-	PHP_FALIAS(GetAlphaMod,      SDL_GetSurfaceAlphaMod,    arginfo_SDL_Surface_GetAlphaMod)
-	PHP_FALIAS(SetBlendMode,     SDL_SetSurfaceBlendMode,   arginfo_SDL_Surface_SetBlendMode)
-	PHP_FALIAS(GetBlendMode,     SDL_GetSurfaceBlendMode,   arginfo_SDL_Surface_GetBlendMode)
-	PHP_FALIAS(SetClipRect,      SDL_SetClipRect,           arginfo_SDL_Surface_SetClipRect)
-	PHP_FALIAS(GetClipRect,      SDL_GetClipRect,           arginfo_SDL_Surface_GetClipRect)
-	PHP_FALIAS(Convert,          SDL_ConvertSurface,        arginfo_SDL_Surface_Convert)
-	PHP_FALIAS(ConvertFormat,    SDL_ConvertSurfaceFormat,  arginfo_SDL_Surface_ConvertFormat)
+	PHP_FALIAS(Free, SDL_FreeSurface, arginfo_surface_none)
+		PHP_FALIAS(FillRect, SDL_FillRect, arginfo_SDL_Surface_FillRect)
+			PHP_FALIAS(FillRects, SDL_FillRects, arginfo_SDL_Surface_FillRects)
+				PHP_FALIAS(MustLock, SDL_MUSTLOCK, arginfo_surface_none)
+					PHP_FALIAS(Lock, SDL_LockSurface, arginfo_surface_none)
+						PHP_FALIAS(Unlock, SDL_UnlockSurface, arginfo_surface_none)
+							PHP_FALIAS(Blit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit)
+								PHP_FALIAS(UpperBlit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit)
+									PHP_FALIAS(LowerBlit, SDL_LowerBlit, arginfo_SDL_Surface_LowerBlit)
+										PHP_FALIAS(BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit)
+											PHP_FALIAS(UpperBlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit)
+												PHP_FALIAS(LowerBlitScaled, SDL_LowerBlitScaled, arginfo_SDL_Surface_LowerBlit)
+													PHP_FALIAS(SoftStretch, SDL_SoftStretch, arginfo_SDL_Surface_UpperBlit)
+														PHP_FALIAS(SaveBMP_RW, SDL_SaveBMP_RW, arginfo_SDL_Surface_SaveBMP_RW)
+															PHP_FALIAS(SaveBMP, SDL_SaveBMP, arginfo_SDL_Surface_SaveBMP)
+																PHP_FALIAS(SetRLE, SDL_SetSurfaceRLE, arginfo_SDL_Surface_SetRLE)
+																	PHP_FALIAS(SetColorKey, SDL_SetColorKey, arginfo_SDL_Surface_SetColorKey)
+																		PHP_FALIAS(GetColorKey, SDL_GetColorKey, arginfo_SDL_Surface_GetColorKey)
+																			PHP_FALIAS(SetColorMod, SDL_SetSurfaceColorMod, arginfo_SDL_Surface_SetColorMod)
+																				PHP_FALIAS(GetColorMod, SDL_GetSurfaceColorMod, arginfo_SDL_Surface_GetColorMod)
+																					PHP_FALIAS(SetAlphaMod, SDL_SetSurfaceAlphaMod, arginfo_SDL_Surface_SetAlphaMod)
+																						PHP_FALIAS(GetAlphaMod, SDL_GetSurfaceAlphaMod, arginfo_SDL_Surface_GetAlphaMod)
+																							PHP_FALIAS(SetBlendMode, SDL_SetSurfaceBlendMode, arginfo_SDL_Surface_SetBlendMode)
+																								PHP_FALIAS(GetBlendMode, SDL_GetSurfaceBlendMode, arginfo_SDL_Surface_GetBlendMode)
+																									PHP_FALIAS(SetClipRect, SDL_SetClipRect, arginfo_SDL_Surface_SetClipRect)
+																										PHP_FALIAS(GetClipRect, SDL_GetClipRect, arginfo_SDL_Surface_GetClipRect)
+																											PHP_FALIAS(Convert, SDL_ConvertSurface, arginfo_SDL_Surface_Convert)
+																												PHP_FALIAS(ConvertFormat, SDL_ConvertSurfaceFormat, arginfo_SDL_Surface_ConvertFormat)
 
 	/* static methods */
-	ZEND_FENTRY(LoadRW,    ZEND_FN(SDL_LoadBMP_RW),  arginfo_SDL_LoadBMP_RW,  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-	ZEND_FENTRY(LoadBMP,   ZEND_FN(SDL_LoadBMP),     arginfo_SDL_LoadBMP,     ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+	ZEND_FENTRY(LoadRW, ZEND_FN(SDL_LoadBMP_RW), arginfo_SDL_LoadBMP_RW, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+		ZEND_FENTRY(LoadBMP, ZEND_FN(SDL_LoadBMP), arginfo_SDL_LoadBMP, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
 
-	PHP_FE_END
-};
+			PHP_FE_END};
 
 /* {{{ php_sdl_surface_free
-	 */
+ */
 static void php_sdl_surface_free(zend_object *object)
 {
-	struct php_sdl_surface *intern = (struct php_sdl_surface*)((char*)object - object->handlers->offset);
-	if (intern->surface) {
-		if (!(intern->flags & SDL_DONTFREE)) {
+	struct php_sdl_surface *intern = (struct php_sdl_surface *)((char *)object - object->handlers->offset);
+	if (intern->surface)
+	{
+		if (!(intern->flags & SDL_DONTFREE))
+		{
 			SDL_FreeSurface(intern->surface);
 		}
 	}
@@ -1269,24 +1322,25 @@ static void php_sdl_surface_free(zend_object *object)
 
 /* {{{ php_sdl_surface_new
  */
-static zend_object* php_sdl_surface_new(zend_class_entry *class_type)
+static zend_object *php_sdl_surface_new(zend_class_entry *class_type)
 {
 	struct php_sdl_surface *intern;
 
-	intern = (struct php_sdl_surface*)zend_object_alloc(sizeof(struct php_sdl_surface), class_type);
+	intern = (struct php_sdl_surface *)zend_object_alloc(sizeof(struct php_sdl_surface), class_type);
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
 
 	intern->surface = NULL;
-	intern->zo.handlers = (zend_object_handlers *) &php_sdl_surface_handlers;
+	intern->zo.handlers = (zend_object_handlers *)&php_sdl_surface_handlers;
 
 	return &intern->zo;
 }
 /* }}} */
 
-static inline struct php_sdl_surface* php_sdl_surface_from_obj(zend_object *obj) {
-	return (struct php_sdl_surface *) ((char *) (obj) - obj->handlers->offset);
+static inline struct php_sdl_surface *php_sdl_surface_from_obj(zend_object *obj)
+{
+	return (struct php_sdl_surface *)((char *)(obj)-obj->handlers->offset);
 }
 
 /* {{{ sdl_surface_read_property*/
@@ -1298,32 +1352,50 @@ zval *sdl_surface_read_property(zend_object *object, zend_string *member, int ty
 	intern = php_sdl_surface_from_obj(object);
 	member_val = ZSTR_VAL(member);
 
-	if (!intern->surface) {
+	if (!intern->surface)
+	{
 		retval = zend_std_read_property(object, member, type, cache_slot, retval);
 		return retval;
 	}
 
-	if (!strcmp(member_val, "flags")) {
+	if (!strcmp(member_val, "flags"))
+	{
 		ZVAL_LONG(retval, intern->surface->flags);
- 	} else if (!strcmp(member_val, "w")) {
+	}
+	else if (!strcmp(member_val, "w"))
+	{
 		ZVAL_LONG(retval, intern->surface->w);
- 	} else if (!strcmp(member_val, "h")) {
+	}
+	else if (!strcmp(member_val, "h"))
+	{
 		ZVAL_LONG(retval, intern->surface->h);
- 	} else if (!strcmp(member_val, "pitch")) {
+	}
+	else if (!strcmp(member_val, "pitch"))
+	{
 		ZVAL_LONG(retval, intern->surface->pitch);
- 	} else if (!strcmp(member_val, "locked")) {
+	}
+	else if (!strcmp(member_val, "locked"))
+	{
 		ZVAL_LONG(retval, intern->surface->locked);
- 	} else if (!strcmp(member_val, "format")) {
+	}
+	else if (!strcmp(member_val, "format"))
+	{
 		sdl_pixelformat_to_zval(intern->surface->format, retval, SDL_DONTFREE);
- 	} else if (!strcmp(member_val, "clip_rect")) {
+	}
+	else if (!strcmp(member_val, "clip_rect"))
+	{
 		sdl_rect_to_zval(&intern->surface->clip_rect, retval);
- 	} else if (!strcmp(member_val, "pixels")) {
+	}
+	else if (!strcmp(member_val, "pixels"))
+	{
 		SDL_Pixels pix;
- 		pix.pitch  = intern->surface->pitch;
-		pix.h      = intern->surface->h;
+		pix.pitch = intern->surface->pitch;
+		pix.h = intern->surface->h;
 		pix.pixels = (Uint8 *)intern->surface->pixels;
 		sdl_pixels_to_zval(&pix, retval, SDL_DONTFREE);
- 	} else {
+	}
+	else
+	{
 		retval = zend_std_read_property(object, member, type, cache_slot, retval);
 		return retval;
 	}
@@ -1332,7 +1404,7 @@ zval *sdl_surface_read_property(zend_object *object, zend_string *member, int ty
 }
 /* }}} */
 
-#define REGISTER_SURFACE_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_SURFACE_CLASS_CONST_LONG(const_name, value)                       \
 	REGISTER_LONG_CONSTANT("SDL_" const_name, value, CONST_CS | CONST_PERSISTENT); \
 	zend_declare_class_constant_long(php_sdl_surface_ce, ZEND_STRL(const_name), value)
 
@@ -1360,10 +1432,10 @@ PHP_MINIT_FUNCTION(sdl_surface)
 	zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("clip_rect"), ZEND_ACC_PUBLIC);
 	zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("pixels"), ZEND_ACC_PUBLIC);
 
-	REGISTER_SURFACE_CLASS_CONST_LONG("SWSURFACE",         SDL_SWSURFACE);
-	REGISTER_SURFACE_CLASS_CONST_LONG("PREALLOC",          SDL_PREALLOC);
-	REGISTER_SURFACE_CLASS_CONST_LONG("RLEACCEL",          SDL_RLEACCEL);
-	REGISTER_SURFACE_CLASS_CONST_LONG("DONTFREE",          SDL_DONTFREE);
+	REGISTER_SURFACE_CLASS_CONST_LONG("SWSURFACE", SDL_SWSURFACE);
+	REGISTER_SURFACE_CLASS_CONST_LONG("PREALLOC", SDL_PREALLOC);
+	REGISTER_SURFACE_CLASS_CONST_LONG("RLEACCEL", SDL_RLEACCEL);
+	REGISTER_SURFACE_CLASS_CONST_LONG("DONTFREE", SDL_DONTFREE);
 
 	return SUCCESS;
 }
diff --git a/src/window.c b/src/window.c
index 3061f41..83d28b1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -28,15 +28,16 @@
 
 static zend_class_entry *php_sdl_window_ce;
 static zend_object_handlers php_sdl_window_handlers;
-struct php_sdl_window {
-	SDL_Window   *window;
+struct php_sdl_window
+{
+	SDL_Window *window;
 	int flags;
-	zend_object   zo;
+	zend_object zo;
 };
 
 typedef struct php_sdl_window php_sdl_window_t;
 
-static inline php_sdl_window_t* php_sdl_window_fetch_object(zend_object* obj);
+static inline php_sdl_window_t *php_sdl_window_fetch_object(zend_object *obj);
 
 zend_class_entry *get_php_sdl_window_ce(void)
 {
@@ -46,11 +47,12 @@ zend_class_entry *get_php_sdl_window_ce(void)
 /* {{{ zval_to_sdl_window */
 SDL_Window *zval_to_sdl_window(zval *z_val)
 {
-	if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_window_ce) {
-		zend_object* zo = Z_OBJ_P(z_val);
+	if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_window_ce)
+	{
+		zend_object *zo = Z_OBJ_P(z_val);
 
 		struct php_sdl_window *intern;
-		intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset);
+		intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset);
 		return intern->window;
 	}
 	return NULL;
@@ -60,7 +62,7 @@ SDL_Window *zval_to_sdl_window(zval *z_val)
 static inline void sdl_window_add_long_property(HashTable *props, const char *name, zend_long value)
 {
 	zval zvalue;
-    zend_string *zname = zend_string_init(name, strlen(name), 0);
+	zend_string *zname = zend_string_init(name, strlen(name), 0);
 	ZVAL_LONG(&zvalue, value);
 	zend_hash_update(props, zname, &zvalue);
 	zend_string_release(zname);
@@ -70,13 +72,14 @@ static inline void sdl_window_add_long_property(HashTable *props, const char *na
 static HashTable *sdl_window_get_properties(zend_object *object)
 {
 	HashTable *props;
-    zend_string* z_string;
+	zend_string *z_string;
 	zval zv;
-	struct php_sdl_window* intern = php_sdl_window_fetch_object(object);
+	struct php_sdl_window *intern = php_sdl_window_fetch_object(object);
 
 	props = zend_std_get_properties(object);
 
-	if (intern->window) {
+	if (intern->window)
+	{
 		int w, h, x, y;
 
 		SDL_GetWindowSize(intern->window, &w, &h);
@@ -88,7 +91,7 @@ static HashTable *sdl_window_get_properties(zend_object *object)
 		sdl_window_add_long_property(props, "w", w);
 		sdl_window_add_long_property(props, "h", h);
 		ZVAL_STRING(&zv, SDL_GetWindowTitle(intern->window));
-        z_string = zend_string_init("title", 6, 0);
+		z_string = zend_string_init("title", 6, 0);
 		zend_hash_update(props, z_string, &zv);
 		zend_string_release(z_string);
 	}
@@ -96,22 +99,22 @@ static HashTable *sdl_window_get_properties(zend_object *object)
 }
 /* }}} */
 
-static inline php_sdl_window_t* php_sdl_window_fetch_object(zend_object* obj)
+static inline php_sdl_window_t *php_sdl_window_fetch_object(zend_object *obj)
 {
-	return (php_sdl_window_t*) ((char*) obj - XtOffsetOf(php_sdl_window_t, zo));
-}
-
-#define FETCH_WINDOW(__ptr, __id, __check) \
-{ \
-		zend_object* zox = Z_OBJ_P(__id);\
-		intern = (struct php_sdl_window*)((char*)zox - zox->handlers->offset);\
-        __ptr = intern->window; \
-        if (__check && !__ptr) {\
-                php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-                RETURN_FALSE;\
-        }\
+	return (php_sdl_window_t *)((char *)obj - XtOffsetOf(php_sdl_window_t, zo));
 }
 
+#define FETCH_WINDOW(__ptr, __id, __check)                                                         \
+	{                                                                                              \
+		zend_object *zox = Z_OBJ_P(__id);                                                          \
+		intern = (struct php_sdl_window *)((char *)zox - zox->handlers->offset);                   \
+		__ptr = intern->window;                                                                    \
+		if (__check && !__ptr)                                                                     \
+		{                                                                                          \
+			php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+			RETURN_FALSE;                                                                          \
+		}                                                                                          \
+	}
 
 /* {{{ proto void SDL_GetWindowDisplayIndex(SDL_Window window)
 
@@ -127,7 +130,8 @@ PHP_FUNCTION(SDL_GetWindowDisplayIndex)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -151,8 +155,8 @@ PHP_FUNCTION(SDL_GetWindowDisplayIndex)
  *  \sa SDL_GetWindowDisplayMode()
  *  \sa SDL_SetWindowFullscreen()
  extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window,
-                                                      const SDL_DisplayMode
-                                                          * mode);
+													  const SDL_DisplayMode
+														  * mode);
  */
 PHP_FUNCTION(SDL_SetWindowDisplayMode)
 {
@@ -161,11 +165,13 @@ PHP_FUNCTION(SDL_SetWindowDisplayMode)
 	SDL_Window *window;
 	SDL_DisplayMode mode;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_mode, get_php_sdl_displaymode_ce()) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_mode, get_php_sdl_displaymode_ce()) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
-	if (zval_to_sdl_displaymode(z_mode, &mode)) {
+	if (zval_to_sdl_displaymode(z_mode, &mode))
+	{
 		RETVAL_LONG(SDL_SetWindowDisplayMode(window, &mode));
 	}
 }
@@ -179,7 +185,7 @@ PHP_FUNCTION(SDL_SetWindowDisplayMode)
  *  \sa SDL_SetWindowDisplayMode()
  *  \sa SDL_SetWindowFullscreen()
  extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window,
-                                                      SDL_DisplayMode * mode);
+													  SDL_DisplayMode * mode);
  */
 PHP_FUNCTION(SDL_GetWindowDisplayMode)
 {
@@ -189,12 +195,14 @@ PHP_FUNCTION(SDL_GetWindowDisplayMode)
 	SDL_DisplayMode mode;
 	int res;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_window, php_sdl_window_ce, &z_mode) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_window, php_sdl_window_ce, &z_mode) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 	res = SDL_GetWindowDisplayMode(window, &mode);
-	if (0==res) {
+	if (0 == res)
+	{
 		zval_dtor(z_mode);
 		sdl_displaymode_to_zval(&mode, z_mode);
 	}
@@ -202,7 +210,6 @@ PHP_FUNCTION(SDL_GetWindowDisplayMode)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GetWindowPixelFormat(SDL_Window window)
 
  *  \brief Get the pixel format associated with the window.
@@ -214,7 +221,8 @@ PHP_FUNCTION(SDL_GetWindowPixelFormat)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -222,7 +230,6 @@ PHP_FUNCTION(SDL_GetWindowPixelFormat)
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GetWindowID(SDL_Window window)
 
  *  \brief Get the numeric ID of a window, for logging purposes.
@@ -234,7 +241,8 @@ PHP_FUNCTION(SDL_GetWindowID)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -253,7 +261,8 @@ PHP_FUNCTION(SDL_GetWindowFlags)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -268,7 +277,7 @@ PHP_FUNCTION(SDL_GetWindowFlags)
  *  \param window The window for which the icon should be set.
  *  \param icon The icon for the window.
  extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window,
-                                                SDL_Surface * icon);
+												SDL_Surface * icon);
  */
 PHP_FUNCTION(SDL_SetWindowIcon)
 {
@@ -277,15 +286,19 @@ PHP_FUNCTION(SDL_SetWindowIcon)
 	SDL_Window *window;
 	SDL_Surface *icon;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_icon, get_php_sdl_surface_ce())) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_icon, get_php_sdl_surface_ce()))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 	icon = zval_to_sdl_surface(z_icon);
 
-	if (icon) {
+	if (icon)
+	{
 		SDL_SetWindowIcon(window, icon);
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_Surface object");
 	}
 }
@@ -297,15 +310,15 @@ PHP_FUNCTION(SDL_SetWindowIcon)
  *
  *  \param window   The window to reposition.
  *  \param x        The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
-                    ::SDL_WINDOWPOS_UNDEFINED.
+					::SDL_WINDOWPOS_UNDEFINED.
  *  \param y        The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or
-                    ::SDL_WINDOWPOS_UNDEFINED.
+					::SDL_WINDOWPOS_UNDEFINED.
  *
  *  \note The window coordinate origin is the upper left of the display.
  *
  *  \sa SDL_GetWindowPosition()
  extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window,
-                                                    int x, int y);
+													int x, int y);
  */
 PHP_FUNCTION(SDL_SetWindowPosition)
 {
@@ -314,7 +327,8 @@ PHP_FUNCTION(SDL_SetWindowPosition)
 	zend_long x, y;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -330,14 +344,14 @@ PHP_FUNCTION(SDL_WINDOWPOS_CENTERED_DISPLAY)
 {
 	zend_long display;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_WINDOWPOS_CENTERED_DISPLAY(display));
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int)
 
  define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X)  (SDL_WINDOWPOS_UNDEFINED_MASK|(X))
@@ -346,7 +360,8 @@ PHP_FUNCTION(SDL_WINDOWPOS_UNDEFINED_DISPLAY)
 {
 	zend_long display;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_WINDOWPOS_UNDEFINED_DISPLAY(display));
@@ -363,32 +378,34 @@ PHP_FUNCTION(SDL_WINDOWPOS_UNDEFINED_DISPLAY)
  *
  *  \sa SDL_SetWindowPosition()
  extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
-                                                    int *x, int *y);
+													int *x, int *y);
  */
 PHP_FUNCTION(SDL_GetWindowPosition)
 {
 	struct php_sdl_window *intern;
-	zval *z_window, *z_x=NULL, *z_y=NULL;
+	zval *z_window, *z_x = NULL, *z_y = NULL;
 	int x, y;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 	SDL_GetWindowPosition(window, &x, &y);
-	if (z_x) {
+	if (z_x)
+	{
 		zval_dtor(z_x);
 		ZVAL_LONG(z_x, x);
 	}
-	if (z_y) {
+	if (z_y)
+	{
 		zval_dtor(z_y);
 		ZVAL_LONG(z_y, y);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_SetWindowSize(SDL Window window, int x, int y)
 
  *  \brief Set the size of a window's client area.
@@ -402,7 +419,7 @@ PHP_FUNCTION(SDL_GetWindowPosition)
  *
  *  \sa SDL_GetWindowSize()
  extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w,
-                                                int h);
+												int h);
  */
 PHP_FUNCTION(SDL_SetWindowSize)
 {
@@ -411,7 +428,8 @@ PHP_FUNCTION(SDL_SetWindowSize)
 	zend_long x, y;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -429,32 +447,34 @@ PHP_FUNCTION(SDL_SetWindowSize)
  *
  *  \sa SDL_SetWindowSize()
  extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w,
-                                                int *h);
+												int *h);
  */
 PHP_FUNCTION(SDL_GetWindowSize)
 {
 	struct php_sdl_window *intern;
-	zval *z_window, *z_x=NULL, *z_y=NULL;
+	zval *z_window, *z_x = NULL, *z_y = NULL;
 	int x, y;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 	SDL_GetWindowSize(window, &x, &y);
-	if (z_x) {
+	if (z_x)
+	{
 		zval_dtor(z_x);
 		ZVAL_LONG(z_x, x);
 	}
-	if (z_y) {
+	if (z_y)
+	{
 		zval_dtor(z_y);
 		ZVAL_LONG(z_y, y);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_SetWindowMinimumSize(SDL Window window, int x, int y)
 
  *  \brief Set the minimum size of a window's client area.
@@ -469,7 +489,7 @@ PHP_FUNCTION(SDL_GetWindowSize)
  *  \sa SDL_GetWindowMinimumSize()
  *  \sa SDL_SetWindowMaximumSize()
  extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window,
-                                                       int min_w, int min_h);
+													   int min_w, int min_h);
  */
 PHP_FUNCTION(SDL_SetWindowMinimumSize)
 {
@@ -478,7 +498,8 @@ PHP_FUNCTION(SDL_SetWindowMinimumSize)
 	zend_long x, y;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -497,32 +518,34 @@ PHP_FUNCTION(SDL_SetWindowMinimumSize)
  *  \sa SDL_GetWindowMaximumSize()
  *  \sa SDL_SetWindowMinimumSize()
  extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window,
-                                                       int *w, int *h);
+													   int *w, int *h);
  */
 PHP_FUNCTION(SDL_GetWindowMinimumSize)
 {
 	struct php_sdl_window *intern;
-	zval *z_window, *z_x=NULL, *z_y=NULL;
+	zval *z_window, *z_x = NULL, *z_y = NULL;
 	int x, y;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 	SDL_GetWindowMinimumSize(window, &x, &y);
-	if (z_x) {
+	if (z_x)
+	{
 		zval_dtor(z_x);
 		ZVAL_LONG(z_x, x);
 	}
-	if (z_y) {
+	if (z_y)
+	{
 		zval_dtor(z_y);
 		ZVAL_LONG(z_y, y);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_SetWindowMaximumSize(SDL Window window, int x, int y)
 
  *  \brief Set the maximum size of a window's client area.
@@ -537,7 +560,7 @@ PHP_FUNCTION(SDL_GetWindowMinimumSize)
  *  \sa SDL_GetWindowMaximumSize()
  *  \sa SDL_SetWindowMinimumSize()
  extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window,
-                                                       int max_w, int max_h);
+													   int max_w, int max_h);
  */
 PHP_FUNCTION(SDL_SetWindowMaximumSize)
 {
@@ -546,7 +569,8 @@ PHP_FUNCTION(SDL_SetWindowMaximumSize)
 	zend_long x, y;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -565,25 +589,28 @@ PHP_FUNCTION(SDL_SetWindowMaximumSize)
  *  \sa SDL_GetWindowMinimumSize()
  *  \sa SDL_SetWindowMaximumSize()
  extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window,
-                                                       int *w, int *h);
+													   int *w, int *h);
  */
 PHP_FUNCTION(SDL_GetWindowMaximumSize)
 {
 	struct php_sdl_window *intern;
-	zval *z_window, *z_x=NULL, *z_y=NULL;
+	zval *z_window, *z_x = NULL, *z_y = NULL;
 	int x, y;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 	SDL_GetWindowMaximumSize(window, &x, &y);
-	if (z_x) {
+	if (z_x)
+	{
 		zval_dtor(z_x);
 		ZVAL_LONG(z_x, x);
 	}
-	if (z_y) {
+	if (z_y)
+	{
 		zval_dtor(z_y);
 		ZVAL_LONG(z_y, y);
 	}
@@ -605,16 +632,17 @@ PHP_FUNCTION(SDL_GetWindowMaximumSize)
  *
  *  \sa SDL_GetWindowFlags()
  extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window,
-                                                    SDL_bool bordered);
+													SDL_bool bordered);
  */
 PHP_FUNCTION(SDL_SetWindowBordered)
 {
 	struct php_sdl_window *intern;
 	zval *z_window;
-	zend_bool bordered;
+	bool bordered;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &z_window, php_sdl_window_ce, &bordered)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &z_window, php_sdl_window_ce, &bordered))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -622,7 +650,6 @@ PHP_FUNCTION(SDL_SetWindowBordered)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_ShowWindow(SDL_Window window)
 
  *  \brief Show a window.
@@ -636,7 +663,8 @@ PHP_FUNCTION(SDL_ShowWindow)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -645,7 +673,6 @@ PHP_FUNCTION(SDL_ShowWindow)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_HideWindow(SDL_Window window)
 
  *  \brief Hide a window.
@@ -659,7 +686,8 @@ PHP_FUNCTION(SDL_HideWindow)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -668,7 +696,6 @@ PHP_FUNCTION(SDL_HideWindow)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_RaiseWindow(SDL_Window window)
 
  *  \brief Raise a window above other windows and set the input focus.
@@ -680,7 +707,8 @@ PHP_FUNCTION(SDL_RaiseWindow)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -689,7 +717,6 @@ PHP_FUNCTION(SDL_RaiseWindow)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_MaximizeWindow(SDL_Window window)
 
  *  \brief Make a window as large as possible.
@@ -703,7 +730,8 @@ PHP_FUNCTION(SDL_MaximizeWindow)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -712,7 +740,6 @@ PHP_FUNCTION(SDL_MaximizeWindow)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_MinimizeWindow(SDL_Window window)
 
  *  \brief Minimize a window to an iconic representation.
@@ -726,7 +753,8 @@ PHP_FUNCTION(SDL_MinimizeWindow)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -735,7 +763,6 @@ PHP_FUNCTION(SDL_MinimizeWindow)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_RestoreWindow(SDL_Window window)
 
  *  \brief Restore the size and position of a minimized or maximized window.
@@ -750,7 +777,8 @@ PHP_FUNCTION(SDL_RestoreWindow)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -768,7 +796,7 @@ PHP_FUNCTION(SDL_RestoreWindow)
  *  \sa SDL_SetWindowDisplayMode()
  *  \sa SDL_GetWindowDisplayMode()
  extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
-                                                     Uint32 flags);
+													 Uint32 flags);
  */
 PHP_FUNCTION(SDL_SetWindowFullscreen)
 {
@@ -777,7 +805,8 @@ PHP_FUNCTION(SDL_SetWindowFullscreen)
 	SDL_Window *window;
 	zend_long flags;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, php_sdl_window_ce, &flags) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, php_sdl_window_ce, &flags) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -786,7 +815,6 @@ PHP_FUNCTION(SDL_SetWindowFullscreen)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_GetWindowSurface(SDL_Window window)
 
  *  \brief Get the SDL surface associated with the window.
@@ -809,7 +837,8 @@ PHP_FUNCTION(SDL_GetWindowSurface)
 	SDL_Window *window = NULL;
 	SDL_Surface *surface = NULL;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -828,8 +857,8 @@ PHP_FUNCTION(SDL_GetWindowSurface)
  *  \sa SDL_GetWindowSurface()
  *  \sa SDL_UpdateWindowSurfaceRect()
  extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
-                                                          const SDL_Rect * rects,
-                                                          int numrects);
+														  const SDL_Rect * rects,
+														  int numrects);
  */
 PHP_FUNCTION(SDL_UpdateWindowSurfaceRects)
 {
@@ -840,35 +869,46 @@ PHP_FUNCTION(SDL_UpdateWindowSurfaceRects)
 	SDL_Window *window;
 	SDL_Rect *rects;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|l", &z_window, php_sdl_window_ce, &z_array, &num)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|l", &z_window, php_sdl_window_ce, &z_array, &num))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 
-	nb  = 0;
+	nb = 0;
 	max = (int)(num ? num : zend_hash_num_elements(Z_ARRVAL_P(z_array)));
-	if (max) {
+	if (max)
+	{
 		zval *ppzval;
 		rects = emalloc(max * sizeof(SDL_Rect));
 
-		ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_array), ppzval) {
-				if (zval_to_sdl_rect(ppzval, rects+nb)) {
-					nb++;
-				} else {
-					php_error_docref(NULL, E_NOTICE, "Ignore rect, not a SDL_Rect object");
-				}
+		ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_array), ppzval)
+		{
+			if (zval_to_sdl_rect(ppzval, rects + nb))
+			{
+				nb++;
+			}
+			else
+			{
+				php_error_docref(NULL, E_NOTICE, "Ignore rect, not a SDL_Rect object");
+			}
 		}
 		ZEND_HASH_FOREACH_END();
 	}
-	if (!nb) {
+	if (!nb)
+	{
 		php_error_docref(NULL, E_WARNING, "No SDL_Rect provided");
-	} else {
-		if (num && nb<max) {
+	}
+	else
+	{
+		if (num && nb < max)
+		{
 			php_error_docref(NULL, E_NOTICE, "Only %d SDL_Rect provided, %d expected", nb, max);
 		}
 		RETVAL_LONG(SDL_UpdateWindowSurfaceRects(window, rects, nb));
 	}
-	if (max) {
+	if (max)
+	{
 		efree(rects);
 	}
 }
@@ -883,16 +923,17 @@ PHP_FUNCTION(SDL_UpdateWindowSurfaceRects)
  *
  *  \sa SDL_GetWindowGrab()
  extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window,
-                                                SDL_bool grabbed);
+												SDL_bool grabbed);
  */
 PHP_FUNCTION(SDL_SetWindowGrab)
 {
 	struct php_sdl_window *intern;
 	zval *z_window;
-	zend_bool grabbed;
+	bool grabbed;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &z_window, php_sdl_window_ce, &grabbed)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &z_window, php_sdl_window_ce, &grabbed))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -915,7 +956,8 @@ PHP_FUNCTION(SDL_GetWindowGrab)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -939,7 +981,8 @@ PHP_FUNCTION(SDL_SetWindowBrightness)
 	double brightness;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Od", &z_window, php_sdl_window_ce, &brightness)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Od", &z_window, php_sdl_window_ce, &brightness))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -947,7 +990,6 @@ PHP_FUNCTION(SDL_SetWindowBrightness)
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_GetWindowBrightness(SDL Window window)
 
  *  \brief Get the brightness (gamma correction) for a window.
@@ -963,7 +1005,8 @@ PHP_FUNCTION(SDL_GetWindowBrightness)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -986,9 +1029,9 @@ PHP_FUNCTION(SDL_GetWindowBrightness)
  *  \return 0 on success, or -1 if gamma ramps are unsupported.
  *
  extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window,
-                                                    Uint16 * red,
-                                                    Uint16 * green,
-                                                    Uint16 * blue);
+													Uint16 * red,
+													Uint16 * green,
+													Uint16 * blue);
  */
 PHP_FUNCTION(SDL_GetWindowGammaRamp)
 {
@@ -996,16 +1039,18 @@ PHP_FUNCTION(SDL_GetWindowGammaRamp)
 	zval *z_window, *z_r, *z_g, *z_b;
 	SDL_Window *window;
 	Uint16 r[256], g[256], b[256];
-// 	zval *tmp;
+	// 	zval *tmp;
 	int i, ret;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozzz", &z_window, php_sdl_window_ce, &z_r, &z_g, &z_b)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozzz", &z_window, php_sdl_window_ce, &z_r, &z_g, &z_b))
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 
 	ret = SDL_GetWindowGammaRamp(window, r, g, b);
-	if (ret == 0) {
+	if (ret == 0)
+	{
 		zval_dtor(z_r);
 		array_init(z_r);
 		zval_dtor(z_g);
@@ -1013,7 +1058,8 @@ PHP_FUNCTION(SDL_GetWindowGammaRamp)
 		zval_dtor(z_b);
 		array_init(z_b);
 
-		for (i=0 ; i<256 ; i++) {
+		for (i = 0; i < 256; i++)
+		{
 			add_next_index_long(z_r, r[i]);
 			add_next_index_long(z_g, g[i]);
 			add_next_index_long(z_b, b[i]);
@@ -1023,7 +1069,6 @@ PHP_FUNCTION(SDL_GetWindowGammaRamp)
 }
 /* }}} */
 
-
 static void php_create_window(INTERNAL_FUNCTION_PARAMETERS, int opt)
 {
 	struct php_sdl_window *intern;
@@ -1032,17 +1077,20 @@ static void php_create_window(INTERNAL_FUNCTION_PARAMETERS, int opt)
 	size_t title_len;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "slllll", &title, &title_len, &x, &y, &w, &h, &flags)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "slllll", &title, &title_len, &x, &y, &w, &h, &flags))
+	{
 		return;
 	}
-	switch(opt) {
-		case 1:
-			window = SDL_CreateShapedWindow(title, x, y, w, h, flags);
-			break;
-		default:
-			window = SDL_CreateWindow(title, x, y, w, h, flags);
+	switch (opt)
+	{
+	case 1:
+		window = SDL_CreateShapedWindow(title, x, y, w, h, flags);
+		break;
+	default:
+		window = SDL_CreateWindow(title, x, y, w, h, flags);
 	}
-	if (window) {
+	if (window)
+	{
 		object_init_ex(return_value, php_sdl_window_ce);
 		intern = php_sdl_window_fetch_object(Z_OBJ_P(return_value));
 		intern->window = window;
@@ -1101,8 +1149,8 @@ PHP_FUNCTION(SDL_CreateShapedWindow)
  *
  *  \sa SDL_DestroyWindow()
  extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
-                                                       int x, int y, int w,
-                                                       int h, Uint32 flags);
+													   int x, int y, int w,
+													   int h, Uint32 flags);
 */
 PHP_FUNCTION(SDL_CreateWindow)
 {
@@ -1122,7 +1170,8 @@ static PHP_METHOD(SDL_Window, __construct)
 	intern = php_sdl_window_fetch_object(Z_OBJ_P(getThis()));
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "slllll", &title, &title_len, &x, &y, &w, &h, &flags)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "slllll", &title, &title_len, &x, &y, &w, &h, &flags))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
@@ -1130,41 +1179,46 @@ static PHP_METHOD(SDL_Window, __construct)
 
 	intern->window = SDL_CreateWindow(title, x, y, w, h, flags);
 	intern->flags = 0;
-	if (intern->window) {
+	if (intern->window)
+	{
 		SDL_SetWindowData(intern->window, PHP_SDL_MAGICDATA, (void *)(unsigned long)Z_OBJ_HANDLE_P(getThis()));
-	} else {
+	}
+	else
+	{
 		zend_throw_exception(zend_exception_get_default(), "Can't create window", 0);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Window::__toString() */
 static PHP_METHOD(SDL_Window, __toString)
 {
 	struct php_sdl_window *intern;
 	char *buf = NULL;
-    int buf_len;
+	int buf_len;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
 	intern = php_sdl_window_fetch_object(Z_OBJ_P(getThis()));
-	if (0 && intern->window) {
+	if (0 && intern->window)
+	{
 		int x, y, w, h;
 
 		SDL_GetWindowPosition(intern->window, &x, &y);
 		SDL_GetWindowSize(intern->window, &w, &h);
 		buf_len = spprintf(&buf, 0, "SDL_Window(\"%s\",%d,%d,%d,%d,%u)", SDL_GetWindowTitle(intern->window), x, y, w, h, SDL_GetWindowFlags(intern->window));
 		RETURN_STRINGL(buf, buf_len);
-	} else {
+	}
+	else
+	{
 		RETURN_STRING("SDL_Window()");
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_UpdateWindowSurface(SDL_Window window)
 
  *  \brief Copy the window surface to the screen.
@@ -1181,7 +1235,8 @@ PHP_FUNCTION(SDL_UpdateWindowSurface)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
@@ -1189,7 +1244,6 @@ PHP_FUNCTION(SDL_UpdateWindowSurface)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_DestroyWindow(SDL_Window window)
 
  *  \brief Destroy a window.
@@ -1201,7 +1255,8 @@ PHP_FUNCTION(SDL_DestroyWindow)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -1211,7 +1266,6 @@ PHP_FUNCTION(SDL_DestroyWindow)
 }
 /* }}} */
 
-
 /* {{{ proto string SDL_GetWindowTitle(SDL_Window window)
 
  *  \brief Get the title of a window, in UTF-8 format.
@@ -1225,7 +1279,8 @@ PHP_FUNCTION(SDL_GetWindowTitle)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -1240,7 +1295,7 @@ PHP_FUNCTION(SDL_GetWindowTitle)
  *
  *  \sa SDL_GetWindowTitle()
  extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window,
-                                                 const char *title);
+												 const char *title);
  */
 PHP_FUNCTION(SDL_SetWindowTitle)
 {
@@ -1250,7 +1305,8 @@ PHP_FUNCTION(SDL_SetWindowTitle)
 	char *title;
 	size_t title_len;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, php_sdl_window_ce, &title, &title_len) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, php_sdl_window_ce, &title, &title_len) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -1259,7 +1315,6 @@ PHP_FUNCTION(SDL_SetWindowTitle)
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_IsShapedWindow(SDL_Window window)
 
 * \brief Return whether the given window is a shaped window.
@@ -1276,7 +1331,8 @@ PHP_FUNCTION(SDL_IsShapedWindow)
 	zval *object;
 	SDL_Window *window;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, object, 1);
@@ -1308,20 +1364,24 @@ PHP_FUNCTION(SDL_SetWindowShape)
 	SDL_WindowShapeMode *mode;
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOO", &z_window, php_sdl_window_ce,
-			&z_surface, get_php_sdl_surface_ce(), &z_mode, get_php_sdl_windowshapemode_ce()) == FAILURE) {
+									 &z_surface, get_php_sdl_surface_ce(), &z_mode, get_php_sdl_windowshapemode_ce()) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 	surface = zval_to_sdl_surface(z_surface);
-	mode    = zval_to_sdl_windowshapemode(z_mode);
-	if (!surface) {
+	mode = zval_to_sdl_windowshapemode(z_mode);
+	if (!surface)
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_Surface object");
-
-	} else if (!mode) {
+	}
+	else if (!mode)
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_WindowShapeMode object");
-
-	} else {
-	  RETVAL_LONG(SDL_SetWindowShape(window, surface, mode));
+	}
+	else
+	{
+		RETVAL_LONG(SDL_SetWindowShape(window, surface, mode));
 	}
 }
 /* }}} */
@@ -1349,12 +1409,14 @@ PHP_FUNCTION(SDL_GetShapedWindowMode)
 	SDL_WindowShapeMode mode;
 	int ret;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce, &z_mode) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce, &z_mode) == FAILURE)
+	{
 		return;
 	}
 	FETCH_WINDOW(window, z_window, 1);
 	ret = SDL_GetShapedWindowMode(window, &mode);
-	if (ret==0) {
+	if (ret == 0)
+	{
 		zval_dtor(z_mode);
 		sdl_windowshapemode_to_zval(&mode, z_mode);
 	}
@@ -1363,69 +1425,70 @@ PHP_FUNCTION(SDL_GetShapedWindowMode)
 /* }}} */
 
 static const zend_function_entry php_sdl_window_methods[] = {
-	PHP_ME(SDL_Window, __construct,     arginfo_SDL_CreateWindow, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Window, __toString,      arginfo_window_none,      ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Window, __construct, arginfo_SDL_CreateWindow, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_Window, __toString, arginfo_window_none, ZEND_ACC_PUBLIC)
 
 	/* non-static functions */
-	PHP_FALIAS(UpdateSurface,      SDL_UpdateWindowSurface,      arginfo_window_none)
-	PHP_FALIAS(Destroy,            SDL_DestroyWindow,            arginfo_window_none)
-	PHP_FALIAS(GetTitle,           SDL_GetWindowTitle,           arginfo_window_none)
-	PHP_FALIAS(SetTitle,           SDL_SetWindowTitle,           arginfo_SDL_Window_SetTitle)
-	PHP_FALIAS(GetDisplayIndex,    SDL_GetWindowDisplayIndex,    arginfo_window_none)
-	PHP_FALIAS(Show,               SDL_ShowWindow,               arginfo_window_none)
-	PHP_FALIAS(Hide,               SDL_HideWindow,               arginfo_window_none)
-	PHP_FALIAS(Raise,              SDL_RaiseWindow,              arginfo_window_none)
-	PHP_FALIAS(Maximize,           SDL_MaximizeWindow,           arginfo_window_none)
-	PHP_FALIAS(Minimize,           SDL_MinimizeWindow,           arginfo_window_none)
-	PHP_FALIAS(Restore,            SDL_RestoreWindow,            arginfo_window_none)
-	PHP_FALIAS(GetSurface,         SDL_GetWindowSurface,         arginfo_window_none)
-	PHP_FALIAS(SetDisplayMode,     SDL_SetWindowDisplayMode,     arginfo_SDL_Window_SetDisplayMode)
-	PHP_FALIAS(GetDisplayMode,     SDL_GetWindowDisplayMode,     arginfo_SDL_Window_GetDisplayMode)
-	PHP_FALIAS(GetPixelFormat,     SDL_GetWindowPixelFormat,     arginfo_window_none)
-	PHP_FALIAS(GetID,              SDL_GetWindowID,              arginfo_window_none)
-	PHP_FALIAS(GetFlags,           SDL_GetWindowFlags,           arginfo_window_none)
-	PHP_FALIAS(SetIcon,            SDL_SetWindowIcon,            arginfo_SDL_Window_SetIcon)
-	PHP_FALIAS(SetPosition,        SDL_SetWindowPosition,        arginfo_SDL_Window_SetPosition)
-	PHP_FALIAS(GetPosition,        SDL_GetWindowPosition,        arginfo_SDL_Window_GetPosition)
-	PHP_FALIAS(SetSize,            SDL_SetWindowSize,            arginfo_SDL_Window_SetSize)
-	PHP_FALIAS(GetSize,            SDL_GetWindowSize,            arginfo_SDL_Window_GetSize)
-	PHP_FALIAS(SetMinimumSize,     SDL_SetWindowMinimumSize,     arginfo_SDL_Window_SetPosition)
-	PHP_FALIAS(GetMinimumSize,     SDL_GetWindowMinimumSize,     arginfo_SDL_Window_GetPosition)
-	PHP_FALIAS(SetMaximumSize,     SDL_SetWindowMaximumSize,     arginfo_SDL_Window_SetPosition)
-	PHP_FALIAS(GetMaximumSize,     SDL_GetWindowMaximumSize,     arginfo_SDL_Window_GetPosition)
-	PHP_FALIAS(SetBordered,        SDL_SetWindowBordered,        arginfo_SDL_Window_SetBordered)
-	PHP_FALIAS(SetFullscreen,      SDL_SetWindowFullscreen,      arginfo_SDL_Window_SetFullscreen)
-	PHP_FALIAS(UpdateSurfaceRects, SDL_UpdateWindowSurfaceRects, arginfo_SDL_Window_UpdateSurfaceRects)
-	PHP_FALIAS(SetGrab,            SDL_SetWindowGrab,            arginfo_SDL_Window_SetGrab)
-	PHP_FALIAS(GetGrab,            SDL_GetWindowGrab,            arginfo_window_none)
-	PHP_FALIAS(SetBrightness,      SDL_SetWindowBrightness,      arginfo_SDL_Window_SetBrightness)
-	PHP_FALIAS(GetBrightness,      SDL_GetWindowBrightness,      arginfo_window_none)
-	PHP_FALIAS(GetGammaRamp,       SDL_GetWindowGammaRamp,       arginfo_SDL_Window_GetGammaRamp)
-	PHP_FALIAS(GL_CreateContext,   SDL_GL_CreateContext,         arginfo_window_none)
-	PHP_FALIAS(GL_MakeCurrent,     SDL_GL_MakeCurrent,           arginfo_SDL_GLContext)
-#if SDL_VERSION_ATLEAST(2,0,1)
-	PHP_FALIAS(GL_GetDrawableSize, SDL_GL_GetDrawableSize,       arginfo_SDL_Window_GetPosition)
+	PHP_FALIAS(UpdateSurface, SDL_UpdateWindowSurface, arginfo_window_none)
+		PHP_FALIAS(Destroy, SDL_DestroyWindow, arginfo_window_none)
+			PHP_FALIAS(GetTitle, SDL_GetWindowTitle, arginfo_window_none)
+				PHP_FALIAS(SetTitle, SDL_SetWindowTitle, arginfo_SDL_Window_SetTitle)
+					PHP_FALIAS(GetDisplayIndex, SDL_GetWindowDisplayIndex, arginfo_window_none)
+						PHP_FALIAS(Show, SDL_ShowWindow, arginfo_window_none)
+							PHP_FALIAS(Hide, SDL_HideWindow, arginfo_window_none)
+								PHP_FALIAS(Raise, SDL_RaiseWindow, arginfo_window_none)
+									PHP_FALIAS(Maximize, SDL_MaximizeWindow, arginfo_window_none)
+										PHP_FALIAS(Minimize, SDL_MinimizeWindow, arginfo_window_none)
+											PHP_FALIAS(Restore, SDL_RestoreWindow, arginfo_window_none)
+												PHP_FALIAS(GetSurface, SDL_GetWindowSurface, arginfo_window_none)
+													PHP_FALIAS(SetDisplayMode, SDL_SetWindowDisplayMode, arginfo_SDL_Window_SetDisplayMode)
+														PHP_FALIAS(GetDisplayMode, SDL_GetWindowDisplayMode, arginfo_SDL_Window_GetDisplayMode)
+															PHP_FALIAS(GetPixelFormat, SDL_GetWindowPixelFormat, arginfo_window_none)
+																PHP_FALIAS(GetID, SDL_GetWindowID, arginfo_window_none)
+																	PHP_FALIAS(GetFlags, SDL_GetWindowFlags, arginfo_window_none)
+																		PHP_FALIAS(SetIcon, SDL_SetWindowIcon, arginfo_SDL_Window_SetIcon)
+																			PHP_FALIAS(SetPosition, SDL_SetWindowPosition, arginfo_SDL_Window_SetPosition)
+																				PHP_FALIAS(GetPosition, SDL_GetWindowPosition, arginfo_SDL_Window_GetPosition)
+																					PHP_FALIAS(SetSize, SDL_SetWindowSize, arginfo_SDL_Window_SetSize)
+																						PHP_FALIAS(GetSize, SDL_GetWindowSize, arginfo_SDL_Window_GetSize)
+																							PHP_FALIAS(SetMinimumSize, SDL_SetWindowMinimumSize, arginfo_SDL_Window_SetPosition)
+																								PHP_FALIAS(GetMinimumSize, SDL_GetWindowMinimumSize, arginfo_SDL_Window_GetPosition)
+																									PHP_FALIAS(SetMaximumSize, SDL_SetWindowMaximumSize, arginfo_SDL_Window_SetPosition)
+																										PHP_FALIAS(GetMaximumSize, SDL_GetWindowMaximumSize, arginfo_SDL_Window_GetPosition)
+																											PHP_FALIAS(SetBordered, SDL_SetWindowBordered, arginfo_SDL_Window_SetBordered)
+																												PHP_FALIAS(SetFullscreen, SDL_SetWindowFullscreen, arginfo_SDL_Window_SetFullscreen)
+																													PHP_FALIAS(UpdateSurfaceRects, SDL_UpdateWindowSurfaceRects, arginfo_SDL_Window_UpdateSurfaceRects)
+																														PHP_FALIAS(SetGrab, SDL_SetWindowGrab, arginfo_SDL_Window_SetGrab)
+																															PHP_FALIAS(GetGrab, SDL_GetWindowGrab, arginfo_window_none)
+																																PHP_FALIAS(SetBrightness, SDL_SetWindowBrightness, arginfo_SDL_Window_SetBrightness)
+																																	PHP_FALIAS(GetBrightness, SDL_GetWindowBrightness, arginfo_window_none)
+																																		PHP_FALIAS(GetGammaRamp, SDL_GetWindowGammaRamp, arginfo_SDL_Window_GetGammaRamp)
+																																			PHP_FALIAS(GL_CreateContext, SDL_GL_CreateContext, arginfo_window_none)
+																																				PHP_FALIAS(GL_MakeCurrent, SDL_GL_MakeCurrent, arginfo_SDL_GLContext)
+#if SDL_VERSION_ATLEAST(2, 0, 1)
+																																					PHP_FALIAS(GL_GetDrawableSize, SDL_GL_GetDrawableSize, arginfo_SDL_Window_GetPosition)
 #endif
-	PHP_FALIAS(GL_Swap,            SDL_GL_SwapWindow,            arginfo_window_none)
-	PHP_FALIAS(WarpMouse,          SDL_WarpMouseInWindow,        arginfo_SDL_Window_SetPosition)
-	PHP_FALIAS(IsShaped,           SDL_IsShapedWindow,           arginfo_window_none)
-	PHP_FALIAS(SetShape,           SDL_SetWindowShape,           arginfo_SDL_Window_SetShape)
-	PHP_FALIAS(GetShapedMode,      SDL_GetShapedWindowMode,      arginfo_SDL_Window_GetShapedMode)
+																																						PHP_FALIAS(GL_Swap, SDL_GL_SwapWindow, arginfo_window_none)
+																																							PHP_FALIAS(WarpMouse, SDL_WarpMouseInWindow, arginfo_SDL_Window_SetPosition)
+																																								PHP_FALIAS(IsShaped, SDL_IsShapedWindow, arginfo_window_none)
+																																									PHP_FALIAS(SetShape, SDL_SetWindowShape, arginfo_SDL_Window_SetShape)
+																																										PHP_FALIAS(GetShapedMode, SDL_GetShapedWindowMode, arginfo_SDL_Window_GetShapedMode)
 
 	/* static methods */
-	ZEND_FENTRY(GL_GetCurrent,      ZEND_FN(SDL_GL_GetCurrentWindow),    arginfo_window_none,         ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
-	ZEND_FENTRY(GetMouseFocus,      ZEND_FN(SDL_GetMouseFocus),          arginfo_window_none,         ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+	ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentWindow), arginfo_window_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
+		ZEND_FENTRY(GetMouseFocus, ZEND_FN(SDL_GetMouseFocus), arginfo_window_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
 
-	PHP_FE_END
-};
+			PHP_FE_END};
 
 /* {{{ php_sdl_window_free
-	 */
-static void php_sdl_window_free(zend_object* zo)
+ */
+static void php_sdl_window_free(zend_object *zo)
 {
-	struct php_sdl_window *intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset);
-	if (intern->window) {
-		if(!(intern->flags & SDL_DONTFREE)) {
+	struct php_sdl_window *intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset);
+	if (intern->window)
+	{
+		if (!(intern->flags & SDL_DONTFREE))
+		{
 			SDL_DestroyWindow(intern->window);
 		}
 	}
@@ -1436,19 +1499,19 @@ static void php_sdl_window_free(zend_object* zo)
 
 /* {{{ php_sdl_window_new
  */
-static zend_object* php_sdl_window_new(zend_class_entry *class_type)
+static zend_object *php_sdl_window_new(zend_class_entry *class_type)
 {
 	struct php_sdl_window *intern;
 
-	intern = (struct php_sdl_window*)ecalloc(1, sizeof(struct php_sdl_window) + zend_object_properties_size(class_type));
+	intern = (struct php_sdl_window *)ecalloc(1, sizeof(struct php_sdl_window) + zend_object_properties_size(class_type));
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
 
-	intern->window  = NULL;
+	intern->window = NULL;
 
 	php_sdl_window_handlers.offset = XtOffsetOf(struct php_sdl_window, zo);
-    php_sdl_window_handlers.free_obj = php_sdl_window_free;
+	php_sdl_window_handlers.free_obj = php_sdl_window_free;
 	intern->zo.handlers = &php_sdl_window_handlers;
 
 	return &intern->zo;
@@ -1458,12 +1521,13 @@ static zend_object* php_sdl_window_new(zend_class_entry *class_type)
 /* {{{ sdl_window_to_zval */
 zend_bool sdl_window_to_zval(SDL_Window *window, zval *z_val, int flags)
 {
-	if (window) {
+	if (window)
+	{
 		struct php_sdl_window *intern;
 
 		object_init_ex(z_val, php_sdl_window_ce);
-		zend_object* zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset);
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset);
 		intern->window = window;
 		intern->flags = flags;
 
@@ -1474,13 +1538,13 @@ zend_bool sdl_window_to_zval(SDL_Window *window, zval *z_val, int flags)
 }
 /* }}} */
 
-#define REGISTER_WINDOW_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_WINDOW_CLASS_CONST_LONG(const_name, value)                               \
 	REGISTER_LONG_CONSTANT("SDL_WINDOW_" const_name, value, CONST_CS | CONST_PERSISTENT); \
-	zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL(const_name), value); \
+	zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL(const_name), value);
 
-#define REGISTER_WINDOWPOS_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_WINDOWPOS_CLASS_CONST_LONG(const_name, value)                               \
 	REGISTER_LONG_CONSTANT("SDL_WINDOWPOS_" const_name, value, CONST_CS | CONST_PERSISTENT); \
-	zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL("POS_" const_name), value); \
+	zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL("POS_" const_name), value);
 
 #define REGISTER_WINDOW_PROP(name) \
 	zend_declare_property_long(php_sdl_window_ce, ZEND_STRL(name), 0, ZEND_ACC_PUBLIC)
@@ -1505,28 +1569,28 @@ PHP_MINIT_FUNCTION(sdl_window)
 	REGISTER_WINDOW_PROP("w");
 	REGISTER_WINDOW_PROP("h");
 
-	zend_declare_property_null(php_sdl_window_ce, ZEND_STRL("title"),  ZEND_ACC_PUBLIC);
-
-	REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN",         SDL_WINDOW_FULLSCREEN);
-	REGISTER_WINDOW_CLASS_CONST_LONG("OPENGL",             SDL_WINDOW_OPENGL);
-	REGISTER_WINDOW_CLASS_CONST_LONG("SHOWN",              SDL_WINDOW_SHOWN);
-	REGISTER_WINDOW_CLASS_CONST_LONG("HIDDEN",             SDL_WINDOW_HIDDEN);
-	REGISTER_WINDOW_CLASS_CONST_LONG("BORDERLESS",         SDL_WINDOW_BORDERLESS);
-	REGISTER_WINDOW_CLASS_CONST_LONG("RESIZABLE",          SDL_WINDOW_RESIZABLE);
-	REGISTER_WINDOW_CLASS_CONST_LONG("MINIMIZED",          SDL_WINDOW_MINIMIZED);
-	REGISTER_WINDOW_CLASS_CONST_LONG("MAXIMIZED",          SDL_WINDOW_MAXIMIZED);
-	REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_GRABBED",      SDL_WINDOW_INPUT_GRABBED);
-	REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_FOCUS",        SDL_WINDOW_INPUT_FOCUS);
-	REGISTER_WINDOW_CLASS_CONST_LONG("MOUSE_FOCUS",        SDL_WINDOW_MOUSE_FOCUS);
+	zend_declare_property_null(php_sdl_window_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC);
+
+	REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN", SDL_WINDOW_FULLSCREEN);
+	REGISTER_WINDOW_CLASS_CONST_LONG("OPENGL", SDL_WINDOW_OPENGL);
+	REGISTER_WINDOW_CLASS_CONST_LONG("SHOWN", SDL_WINDOW_SHOWN);
+	REGISTER_WINDOW_CLASS_CONST_LONG("HIDDEN", SDL_WINDOW_HIDDEN);
+	REGISTER_WINDOW_CLASS_CONST_LONG("BORDERLESS", SDL_WINDOW_BORDERLESS);
+	REGISTER_WINDOW_CLASS_CONST_LONG("RESIZABLE", SDL_WINDOW_RESIZABLE);
+	REGISTER_WINDOW_CLASS_CONST_LONG("MINIMIZED", SDL_WINDOW_MINIMIZED);
+	REGISTER_WINDOW_CLASS_CONST_LONG("MAXIMIZED", SDL_WINDOW_MAXIMIZED);
+	REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_GRABBED", SDL_WINDOW_INPUT_GRABBED);
+	REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_FOCUS", SDL_WINDOW_INPUT_FOCUS);
+	REGISTER_WINDOW_CLASS_CONST_LONG("MOUSE_FOCUS", SDL_WINDOW_MOUSE_FOCUS);
 	REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN_DESKTOP", SDL_WINDOW_FULLSCREEN_DESKTOP);
-	REGISTER_WINDOW_CLASS_CONST_LONG("FOREIGN",            SDL_WINDOW_FOREIGN);
+	REGISTER_WINDOW_CLASS_CONST_LONG("FOREIGN", SDL_WINDOW_FOREIGN);
 #if SDL_COMPILEDVERSION > 2000
-	REGISTER_WINDOW_CLASS_CONST_LONG("ALLOW_HIGHDPI",      SDL_WINDOW_ALLOW_HIGHDPI);
+	REGISTER_WINDOW_CLASS_CONST_LONG("ALLOW_HIGHDPI", SDL_WINDOW_ALLOW_HIGHDPI);
 #endif
-	REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED_MASK",  SDL_WINDOWPOS_UNDEFINED_MASK);
-	REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED",       SDL_WINDOWPOS_UNDEFINED);
-	REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED_MASK",   SDL_WINDOWPOS_CENTERED_MASK);
-	REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED",        SDL_WINDOWPOS_CENTERED);
+	REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED_MASK", SDL_WINDOWPOS_UNDEFINED_MASK);
+	REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED", SDL_WINDOWPOS_UNDEFINED);
+	REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED_MASK", SDL_WINDOWPOS_CENTERED_MASK);
+	REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED", SDL_WINDOWPOS_CENTERED);
 
 	return SUCCESS;
 }

From e63ec0543ca5486990b93fe088748ab3ef8553cc Mon Sep 17 00:00:00 2001
From: Santiago <santiagolizardo@users.noreply.github.com>
Date: Sat, 23 Jul 2022 11:26:03 +0100
Subject: [PATCH 45/53] Update README.md

---
 README.md | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 9603609..c60690b 100644
--- a/README.md
+++ b/README.md
@@ -46,18 +46,11 @@ SDL_SetWindowTitle($window, "Some new title");
 SDL_DestroyWindow($window);
 ```
 
-And is also available in object oriented style:
-
-```php
-$window = new SDL_Window( "Foo window", 100, 50, 350, 300, SDL_Window::SHOWN|SDL_Window::RESIZABLE);
-$window->SetTitle("Some new title");
-unset($window); // will destroy the window
-```
-
 Complete examples can be found in the [examples](examples) folder.
 
 ## Related projects
 
+* [PHP-SDL_TTF](https://github.com/Ponup/php-sdl-ttf)
 * [PHP-SDL_Mixer](https://github.com/kea/php-sdl-mixer)
 * [PHP-SDL_Image](https://github.com/kea/php-sdl-image)
 * [PHP-OpenGL](https://github.com/ponup/php-opengl)

From 4d0e9c30163278d4c3dd1cf556cf682cca370f79 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 2 Dec 2022 11:42:41 +0000
Subject: [PATCH 46/53] Update QueryTexture function

---
 src/php_sdl.c |  2 +-
 src/render.c  | 22 ++++++++++------------
 src/render.h  | 28 ++++++++--------------------
 src/shape.c   |  2 +-
 4 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/src/php_sdl.c b/src/php_sdl.c
index 7ab5d78..6c39112 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
diff --git a/src/render.c b/src/render.c
index f8e1f9c..54f7b9a 100644
--- a/src/render.c
+++ b/src/render.c
@@ -334,12 +334,12 @@ PHP_FUNCTION(SDL_GetRendererOutputSize)
 
 PHP_FUNCTION(SDL_QueryTexture)
 {
-	zval *z_texture, *z_format, *z_access, *z_width, *z_height;
+	zval *z_texture, *z_format = NULL, *z_access = NULL, *z_width = NULL, *z_height = NULL;
 	SDL_Texture *texture;
 	int w, h, access, result;
 	Uint32 format;
 
-	if( zend_parse_parameters(ZEND_NUM_ARGS(), "zz/z/z/z/", &z_texture, &z_format, &z_access, &z_width, &z_height) == FAILURE ) {
+	if( zend_parse_parameters(ZEND_NUM_ARGS(), "z|zzzz", &z_texture, &z_format, &z_access, &z_width, &z_height) == FAILURE ) {
 		return;
 	}
 
@@ -347,14 +347,14 @@ PHP_FUNCTION(SDL_QueryTexture)
 
 	result = SDL_QueryTexture(texture, &format, &access, &w, &h);
 
-	zval_dtor(z_format);
-	ZVAL_LONG(z_format, format);
-	zval_dtor(z_access);
-	ZVAL_LONG(z_access, access);
-	zval_dtor(z_width);
-	ZVAL_LONG(z_width, (long)w);
-	zval_dtor(z_height);
-	ZVAL_LONG(z_height, (long)h);
+	if(z_format)
+		ZEND_TRY_ASSIGN_REF_LONG(z_format, format);
+	if(z_access)
+		ZEND_TRY_ASSIGN_REF_LONG(z_access, access);
+	if(z_width)
+		ZEND_TRY_ASSIGN_REF_LONG(z_width, w);
+	if(z_height)
+		ZEND_TRY_ASSIGN_REF_LONG(z_height, h);
 
 	RETURN_LONG(result);
 }
@@ -366,12 +366,10 @@ PHP_FUNCTION(SDL_RenderDrawPointF)
 	double x, y;
 
 	ZEND_PARSE_PARAMETERS_START(3, 3);
-		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
 		Z_PARAM_ZVAL(RENDERER)
 		Z_PARAM_DOUBLE(x)
 		Z_PARAM_DOUBLE(y)
 	ZEND_PARSE_PARAMETERS_END();
-//	renderer = php_sdl_renderer_from_zval_p(RENDERER);
 	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
 
 	int result = SDL_RenderDrawPointF(renderer, (float) x, (float) y);
diff --git a/src/render.h b/src/render.h
index 0a8c0ab..10ef166 100644
--- a/src/render.h
+++ b/src/render.h
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
@@ -25,7 +25,6 @@ extern "C" {
 #include "php_sdl.h"
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderDrawColor, 0, 0, 5)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_INFO(0, r)
 	ZEND_ARG_INFO(0, g)
@@ -34,12 +33,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderDrawColor, 0, 0, 5)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderClear, 0, 0, 1)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_DestroyRenderer, 0, 0, 1)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 ZEND_END_ARG_INFO()
 
@@ -48,10 +45,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_DestroyTexture, 0, 0, 1)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderFillRect, 0, 0, 2)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0)
-	//ZEND_ARG_INFO(0, rect)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawRect, 0, 0, 2)
@@ -68,7 +63,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawLine, 0, 0, 4)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderPresent, 0, 0, 1)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 ZEND_END_ARG_INFO()
 
@@ -79,7 +73,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawPoint, 0, 0, 3)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTextureFromSurface, 0, 0, 2)
-	ZEND_ARG_INFO(0, renderer)//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_OBJ_INFO(0, surface, SDL_Surface, 0)
 ZEND_END_ARG_INFO()
 
@@ -91,12 +85,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTexture, 0, 0, 5)
 	ZEND_ARG_INFO(0, h)
 ZEND_END_ARG_INFO()
 
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 5)
-	ZEND_ARG_INFO(0, texture)
-	ZEND_ARG_INFO(1, format)
-	ZEND_ARG_INFO(1, access)
-	ZEND_ARG_INFO(1, w)
-	ZEND_ARG_INFO(1, h)
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 1)
+	ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
+	ZEND_ARG_TYPE_INFO(1, format, IS_LONG, 1)
+	ZEND_ARG_TYPE_INFO(1, access, IS_LONG, 1)
+	ZEND_ARG_TYPE_INFO(1, w, IS_LONG, 1)
+	ZEND_ARG_TYPE_INFO(1, h, IS_LONG, 1)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderTarget, 0, 0, 2)
@@ -134,14 +128,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetRendererOutputSize, 0, 0, 3)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawPointF, 0, 3, IS_LONG, 0)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_TYPE_INFO(0, x, IS_DOUBLE, 0)
 	ZEND_ARG_TYPE_INFO(0, y, IS_DOUBLE, 0)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawLineF, 0, 5, IS_LONG, 0)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_TYPE_INFO(0, x1, IS_DOUBLE, 0)
 	ZEND_ARG_TYPE_INFO(0, y1, IS_DOUBLE, 0)
@@ -150,7 +142,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawLineF, 0, 5, IS_LO
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawRectF, 0, 2, IS_LONG, 0)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_OBJ_INFO(0, rect, SDL_FRect, 0)
 ZEND_END_ARG_INFO()
@@ -158,7 +149,6 @@ ZEND_END_ARG_INFO()
 #define arginfo_SDL_RenderFillRectF arginfo_SDL_RenderDrawRectF
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyF, 0, 4, IS_LONG, 0)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
 	ZEND_ARG_OBJ_INFO(0, srcrect, SDL_Rect, 1)
@@ -166,7 +156,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyF, 0, 4, IS_LONG,
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyExF, 0, 7, IS_LONG, 0)
-	//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
 	ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, srcrect, SDL_Rect, 1, "null")
@@ -176,7 +165,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyExF, 0, 7, IS_LONG
 	ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flip, IS_LONG, 0, "SDL_FLIP_NONE")
 ZEND_END_ARG_INFO()
 
-
 PHP_FUNCTION(SDL_SetRenderDrawColor);
 PHP_FUNCTION(SDL_RenderClear);
 PHP_FUNCTION(SDL_DestroyRenderer);
diff --git a/src/shape.c b/src/shape.c
index 314ebde..2bdf8ec 100644
--- a/src/shape.c
+++ b/src/shape.c
@@ -1,6 +1,6 @@
 /*
   +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2018 The PHP Group                                |
+  | Copyright (c) 1997-2022 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |

From 4b4da68dec71fd8c3980787654e181fec25b4b0c Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Tue, 27 Dec 2022 22:54:24 +0000
Subject: [PATCH 47/53] Remove warnings on __toString class methods

---
 src/event.c      | 271 +++++++++++++------------
 src/glcontext.c  | 269 +++++++++++++------------
 src/messagebox.c | 331 +++++++++++++++++-------------
 src/mouse.c      |   7 +-
 src/mutex.c      |  12 +-
 src/php_sdl.c    | 510 ++++++++++++++++++++++-------------------------
 src/pixels.c     |  50 +++--
 src/rwops.c      |   5 +-
 src/shape.c      |   8 +-
 src/surface.c    |   5 +-
 src/video.c      |   5 +-
 src/window.c     |   5 +-
 12 files changed, 785 insertions(+), 693 deletions(-)

diff --git a/src/event.c b/src/event.c
index f199ee4..25da33e 100644
--- a/src/event.c
+++ b/src/event.c
@@ -20,7 +20,8 @@
 static zend_class_entry *php_sdl_event_ce;
 static zend_object_handlers php_sdl_event_handlers;
 
-struct php_sdl_event {
+struct php_sdl_event
+{
 	zend_object zo;
 };
 
@@ -31,11 +32,13 @@ zend_class_entry *get_php_sdl_event_ce(void)
 
 zend_bool sdl_event_to_zval(SDL_Event *event, zval *value)
 {
-	if(NULL == event) {
+	if (NULL == event)
+	{
 		ZVAL_NULL(value);
 		return 0;
 	}
-	if(value != NULL) {
+	if (value != NULL)
+	{
 		zval_ptr_dtor(value);
 	}
 
@@ -43,73 +46,86 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value)
 
 	zend_update_property_long(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), event->type);
 
-	switch(event->type) {
-		case SDL_MOUSEMOTION: {
-			zval motion;
-			object_init(&motion);
-			add_property_long(&motion, "state", event->motion.state);
-			add_property_long(&motion, "x", event->motion.x);
-  			add_property_long(&motion, "y", event->motion.y);
-			add_property_zval(value, "motion", &motion);
-			zval_ptr_dtor(&motion);
-			} break;
-		case SDL_MOUSEBUTTONDOWN: {
-			zval button;
-			object_init(&button);
-			add_property_long(&button, "button", event->button.button);
-			add_property_long(&button, "x", event->button.x);
-  			add_property_long(&button, "y", event->button.y);
-			add_property_zval(value, "button", &button);
-			zval_ptr_dtor(&button);
-			} break;
-		case SDL_KEYDOWN:
-		case SDL_KEYUP: {
-    		zval keysym;
-    		object_init(&keysym);
-			add_property_long(&keysym, "sym", event->key.keysym.sym);
-
-    		zval key;
-    		object_init(&key);
-			add_property_zval(&key, "keysym", &keysym);
-
-			add_property_zval(value, "key", &key);
-			zval_ptr_dtor(&key);
-			zval_ptr_dtor(&keysym);
-			} break;
-		case SDL_WINDOWEVENT: {
-			zval window;
-			object_init(&window);
-			add_property_long(&window, "event", event->window.event);
-			add_property_long(&window, "timestamp", event->window.timestamp);
-			add_property_long(&window, "windowID", event->window.windowID);
-			add_property_long(&window, "data1", event->window.data1);
-			add_property_long(&window, "data2", event->window.data2);
-			add_property_zval(value, "window", &window);
-			zval_ptr_dtor(&window);
-			} break;
-		case SDL_JOYBUTTONDOWN:
-		case SDL_JOYBUTTONUP: {
-			zval joybutton;
-			object_init(&joybutton);
-			add_property_long(&joybutton, "type", event->jbutton.type);
-			add_property_long(&joybutton, "timestamp", event->jbutton.timestamp);
-			add_property_long(&joybutton, "which", event->jbutton.which);
-			add_property_long(&joybutton, "button", event->jbutton.button);
-			add_property_long(&joybutton, "state", event->jbutton.state);
-			add_property_zval(value, "jbutton", &joybutton);
-			zval_ptr_dtor(&joybutton);
-		} break;
-		case SDL_JOYAXISMOTION: {
-			zval jaxis;
-			object_init(&jaxis);
-			add_property_long(&jaxis, "type", event->jaxis.type);
-			add_property_long(&jaxis, "timestamp", event->jaxis.timestamp);
-			add_property_long(&jaxis, "which", event->jaxis.which);
-			add_property_long(&jaxis, "axis", event->jaxis.axis);
-			add_property_long(&jaxis, "value", event->jaxis.value);
-			add_property_zval(value, "jaxis", &jaxis);
-			zval_ptr_dtor(&jaxis);
-		} break;
+	switch (event->type)
+	{
+	case SDL_MOUSEMOTION:
+	{
+		zval motion;
+		object_init(&motion);
+		add_property_long(&motion, "state", event->motion.state);
+		add_property_long(&motion, "x", event->motion.x);
+		add_property_long(&motion, "y", event->motion.y);
+		add_property_zval(value, "motion", &motion);
+		zval_ptr_dtor(&motion);
+	}
+	break;
+	case SDL_MOUSEBUTTONDOWN:
+	{
+		zval button;
+		object_init(&button);
+		add_property_long(&button, "button", event->button.button);
+		add_property_long(&button, "x", event->button.x);
+		add_property_long(&button, "y", event->button.y);
+		add_property_zval(value, "button", &button);
+		zval_ptr_dtor(&button);
+	}
+	break;
+	case SDL_KEYDOWN:
+	case SDL_KEYUP:
+	{
+		zval keysym;
+		object_init(&keysym);
+		add_property_long(&keysym, "sym", event->key.keysym.sym);
+
+		zval key;
+		object_init(&key);
+		add_property_zval(&key, "keysym", &keysym);
+
+		add_property_zval(value, "key", &key);
+		zval_ptr_dtor(&key);
+		zval_ptr_dtor(&keysym);
+	}
+	break;
+	case SDL_WINDOWEVENT:
+	{
+		zval window;
+		object_init(&window);
+		add_property_long(&window, "event", event->window.event);
+		add_property_long(&window, "timestamp", event->window.timestamp);
+		add_property_long(&window, "windowID", event->window.windowID);
+		add_property_long(&window, "data1", event->window.data1);
+		add_property_long(&window, "data2", event->window.data2);
+		add_property_zval(value, "window", &window);
+		zval_ptr_dtor(&window);
+	}
+	break;
+	case SDL_JOYBUTTONDOWN:
+	case SDL_JOYBUTTONUP:
+	{
+		zval joybutton;
+		object_init(&joybutton);
+		add_property_long(&joybutton, "type", event->jbutton.type);
+		add_property_long(&joybutton, "timestamp", event->jbutton.timestamp);
+		add_property_long(&joybutton, "which", event->jbutton.which);
+		add_property_long(&joybutton, "button", event->jbutton.button);
+		add_property_long(&joybutton, "state", event->jbutton.state);
+		add_property_zval(value, "jbutton", &joybutton);
+		zval_ptr_dtor(&joybutton);
+	}
+	break;
+	case SDL_JOYAXISMOTION:
+	{
+		zval jaxis;
+		object_init(&jaxis);
+		add_property_long(&jaxis, "type", event->jaxis.type);
+		add_property_long(&jaxis, "timestamp", event->jaxis.timestamp);
+		add_property_long(&jaxis, "which", event->jaxis.which);
+		add_property_long(&jaxis, "axis", event->jaxis.axis);
+		add_property_long(&jaxis, "value", event->jaxis.value);
+		add_property_zval(value, "jaxis", &jaxis);
+		zval_ptr_dtor(&jaxis);
+	}
+	break;
 	}
 
 	return 1;
@@ -118,8 +134,9 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value)
 zend_bool zval_to_sdl_event(zval *value, SDL_Event *event)
 {
 	zval *val, rv;
-	
-	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_event_ce) {
+
+	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_event_ce)
+	{
 		val = zend_read_property(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), 0, &rv);
 		convert_to_long(val);
 		Z_LVAL_P(val) = event->type = (int)Z_LVAL_P(val);
@@ -136,7 +153,8 @@ static PHP_METHOD(SDL_Event, __construct)
 	zend_error_handling error_handling;
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters_none()) {
+	if (FAILURE == zend_parse_parameters_none())
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
@@ -147,23 +165,27 @@ static PHP_METHOD(SDL_Event, __construct)
 static PHP_METHOD(SDL_Event, __toString)
 {
 	char *buf;
-        size_t buf_len;
+	size_t buf_len;
 	SDL_Event event;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
 	zval_to_sdl_event(getThis(), &event);
 	buf_len = spprintf(&buf, 100, "SDL_Event(type=%d)", event.type);
 	RETVAL_STRINGL(buf, buf_len);
-        efree(buf);
+	efree(buf);
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Event___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 static HashTable *sdl_event_get_properties(zend_object *object)
 {
-	HashTable *props;    
+	HashTable *props;
 	props = zend_std_get_properties(object);
 
 	return props;
@@ -175,7 +197,8 @@ PHP_FUNCTION(SDL_PollEvent)
 	SDL_Event event;
 	int ret;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE)
+	{
 		return;
 	}
 
@@ -191,13 +214,14 @@ PHP_FUNCTION(SDL_WaitEvent)
 	SDL_Event event;
 	int ret;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE)
+	{
 		return;
 	}
 
 	ret = SDL_WaitEvent(&event);
 	sdl_event_to_zval(&event, object);
-	
+
 	RETURN_LONG(ret);
 }
 
@@ -205,13 +229,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0)
 ZEND_END_ARG_INFO()
 
 static const zend_function_entry php_sdl_event_methods[] = {
-	PHP_ME(SDL_Event, __construct, arginfo_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Event, __toString, arginfo_none, ZEND_ACC_PUBLIC)
-
-	/* non-static methods */
-//	PHP_FALIAS(Empty,            SDL_RectEmpty,            arginfo_none)
-	PHP_FE_END
-};
+	PHP_ME(SDL_Event, __construct, arginfo_none, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_Event, __toString, arginfo_class_SDL_Event___toString, ZEND_ACC_PUBLIC)
+			PHP_FE_END};
 
 /* {{{ MINIT */
 PHP_MINIT_FUNCTION(sdl_event)
@@ -220,50 +240,50 @@ PHP_MINIT_FUNCTION(sdl_event)
 
 	REGISTER_LONG_CONSTANT("SDL_QUIT", SDL_QUIT, CONST_CS | CONST_PERSISTENT);
 
-	REGISTER_LONG_CONSTANT("SDL_APP_TERMINATING", SDL_APP_TERMINATING, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_APP_LOWMEMORY", SDL_APP_LOWMEMORY, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERBACKGROUND", SDL_APP_WILLENTERBACKGROUND, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERBACKGROUND", SDL_APP_DIDENTERBACKGROUND, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERFOREGROUND", SDL_APP_WILLENTERFOREGROUND, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERFOREGROUND", SDL_APP_DIDENTERFOREGROUND, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT", SDL_WINDOWEVENT, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_SYSWMEVENT", SDL_SYSWMEVENT, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_KEYDOWN", SDL_KEYDOWN, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_KEYUP", SDL_KEYUP, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_TEXTEDITING", SDL_TEXTEDITING, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_TEXTINPUT", SDL_TEXTINPUT, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_MOUSEMOTION", SDL_MOUSEMOTION, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONDOWN", SDL_MOUSEBUTTONDOWN, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONUP", SDL_MOUSEBUTTONUP, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_MOUSEWHEEL", SDL_MOUSEWHEEL, CONST_CS|CONST_PERSISTENT);
-	
+	REGISTER_LONG_CONSTANT("SDL_APP_TERMINATING", SDL_APP_TERMINATING, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_APP_LOWMEMORY", SDL_APP_LOWMEMORY, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERBACKGROUND", SDL_APP_WILLENTERBACKGROUND, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERBACKGROUND", SDL_APP_DIDENTERBACKGROUND, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERFOREGROUND", SDL_APP_WILLENTERFOREGROUND, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERFOREGROUND", SDL_APP_DIDENTERFOREGROUND, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT", SDL_WINDOWEVENT, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_SYSWMEVENT", SDL_SYSWMEVENT, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_KEYDOWN", SDL_KEYDOWN, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_KEYUP", SDL_KEYUP, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_TEXTEDITING", SDL_TEXTEDITING, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_TEXTINPUT", SDL_TEXTINPUT, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_MOUSEMOTION", SDL_MOUSEMOTION, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONDOWN", SDL_MOUSEBUTTONDOWN, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONUP", SDL_MOUSEBUTTONUP, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_MOUSEWHEEL", SDL_MOUSEWHEEL, CONST_CS | CONST_PERSISTENT);
+
 	// Joystick
-	REGISTER_LONG_CONSTANT("SDL_JOYAXISMOTION", SDL_JOYAXISMOTION, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_JOYBUTTONDOWN", SDL_JOYBUTTONDOWN, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_JOYBUTTONUP", SDL_JOYBUTTONUP, CONST_CS|CONST_PERSISTENT);
-
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SHOWN", SDL_WINDOWEVENT_SHOWN, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIDDEN", SDL_WINDOWEVENT_HIDDEN, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_EXPOSED", SDL_WINDOWEVENT_EXPOSED, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MOVED", SDL_WINDOWEVENT_MOVED, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESIZED", SDL_WINDOWEVENT_RESIZED, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SIZE_CHANGED", SDL_WINDOWEVENT_SIZE_CHANGED, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MINIMIZED", SDL_WINDOWEVENT_MINIMIZED, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MAXIMIZED", SDL_WINDOWEVENT_MAXIMIZED, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESTORED", SDL_WINDOWEVENT_RESTORED, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_ENTER", SDL_WINDOWEVENT_ENTER, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_LEAVE", SDL_WINDOWEVENT_LEAVE, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_GAINED", SDL_WINDOWEVENT_FOCUS_GAINED, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_LOST", SDL_WINDOWEVENT_FOCUS_LOST, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_CLOSE", SDL_WINDOWEVENT_CLOSE, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_TAKE_FOCUS", SDL_WINDOWEVENT_TAKE_FOCUS, CONST_CS|CONST_PERSISTENT);
-	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIT_TEST", SDL_WINDOWEVENT_HIT_TEST, CONST_CS|CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_JOYAXISMOTION", SDL_JOYAXISMOTION, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_JOYBUTTONDOWN", SDL_JOYBUTTONDOWN, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_JOYBUTTONUP", SDL_JOYBUTTONUP, CONST_CS | CONST_PERSISTENT);
+
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SHOWN", SDL_WINDOWEVENT_SHOWN, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIDDEN", SDL_WINDOWEVENT_HIDDEN, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_EXPOSED", SDL_WINDOWEVENT_EXPOSED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MOVED", SDL_WINDOWEVENT_MOVED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESIZED", SDL_WINDOWEVENT_RESIZED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SIZE_CHANGED", SDL_WINDOWEVENT_SIZE_CHANGED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MINIMIZED", SDL_WINDOWEVENT_MINIMIZED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MAXIMIZED", SDL_WINDOWEVENT_MAXIMIZED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESTORED", SDL_WINDOWEVENT_RESTORED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_ENTER", SDL_WINDOWEVENT_ENTER, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_LEAVE", SDL_WINDOWEVENT_LEAVE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_GAINED", SDL_WINDOWEVENT_FOCUS_GAINED, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_LOST", SDL_WINDOWEVENT_FOCUS_LOST, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_CLOSE", SDL_WINDOWEVENT_CLOSE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_TAKE_FOCUS", SDL_WINDOWEVENT_TAKE_FOCUS, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIT_TEST", SDL_WINDOWEVENT_HIT_TEST, CONST_CS | CONST_PERSISTENT);
 
 	INIT_CLASS_ENTRY(ce_event, "SDL_Event", php_sdl_event_methods);
 	php_sdl_event_ce = zend_register_internal_class(&ce_event);
 	memcpy(&php_sdl_event_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 	php_sdl_event_handlers.get_properties = sdl_event_get_properties;
-    php_sdl_event_handlers.offset = XtOffsetOf(struct php_sdl_event, zo);
+	php_sdl_event_handlers.offset = XtOffsetOf(struct php_sdl_event, zo);
 
 	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("type"), ZEND_ACC_PUBLIC);
 	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("key"), ZEND_ACC_PUBLIC);
@@ -272,4 +292,3 @@ PHP_MINIT_FUNCTION(sdl_event)
 	return SUCCESS;
 }
 /* }}} */
-
diff --git a/src/glcontext.c b/src/glcontext.c
index 38581cd..0392c37 100644
--- a/src/glcontext.c
+++ b/src/glcontext.c
@@ -15,7 +15,6 @@
   +----------------------------------------------------------------------+
 */
 
-
 /*
   +----------------------------------------------------------------------+
   | wrapper for SDL2/SDL_video.h (only SDL_GLContext)                    |
@@ -37,13 +36,13 @@
 
 static zend_class_entry *php_sdl_glcontext_ce;
 static zend_object_handlers php_sdl_glcontext_handlers;
-struct php_sdl_glcontext {
+struct php_sdl_glcontext
+{
 	SDL_GLContext glcontext;
-	Uint32        flags;
-	zend_object   zo;
+	Uint32 flags;
+	zend_object zo;
 };
 
-
 /* {{{ get_php_sdl_glcontext_ce */
 zend_class_entry *get_php_sdl_glcontext_ce(void)
 {
@@ -51,27 +50,28 @@ zend_class_entry *get_php_sdl_glcontext_ce(void)
 }
 /* }}} */
 
-
-#define FETCH_GLCONTEXT(__ptr, __id, __check) \
-{ \
-		zend_object* zox = Z_OBJ_P(__id);\
-		intern = (struct php_sdl_glcontext*)((char*)zox - zox->handlers->offset);\
-        __ptr = intern->glcontext; \
-        if (__check && !__ptr) {\
-                php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-                RETURN_FALSE;\
-        }\
-}
+#define FETCH_GLCONTEXT(__ptr, __id, __check)                                                      \
+	{                                                                                              \
+		zend_object *zox = Z_OBJ_P(__id);                                                          \
+		intern = (struct php_sdl_glcontext *)((char *)zox - zox->handlers->offset);                \
+		__ptr = intern->glcontext;                                                                 \
+		if (__check && !__ptr)                                                                     \
+		{                                                                                          \
+			php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+			RETURN_FALSE;                                                                          \
+		}                                                                                          \
+	}
 
 /* {{{ sdl_glcontext_to_zval */
 zend_bool sdl_glcontext_to_zval(SDL_GLContext glcontext, zval *z_val, Uint32 flags)
 {
-	if (glcontext) {
+	if (glcontext)
+	{
 		struct php_sdl_glcontext *intern;
 
 		object_init_ex(z_val, php_sdl_glcontext_ce);
-		zend_object* zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset);
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset);
 		intern->glcontext = glcontext;
 		intern->flags = flags;
 
@@ -82,30 +82,31 @@ zend_bool sdl_glcontext_to_zval(SDL_GLContext glcontext, zval *z_val, Uint32 fla
 }
 /* }}} */
 
-
 /* {{{ zval_to_sdl_glcontext */
 SDL_GLContext zval_to_sdl_glcontext(zval *z_val)
 {
 	struct php_sdl_glcontext *intern;
 
-	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_glcontext_ce) {
-		zend_object* zo = Z_OBJ_P(z_val);
-		intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset);
+	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_glcontext_ce)
+	{
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset);
 		return intern->glcontext;
 	}
 	return NULL;
 }
 /* }}} */
 
-
 /* {{{ php_sdl_glcontext_free
-	 */
+ */
 static void php_sdl_glcontext_free(zend_object *zo)
 {
-	struct php_sdl_glcontext* intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset);
+	struct php_sdl_glcontext *intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset);
 
-	if (intern->glcontext) {
-		if (!(intern->flags & SDL_DONTFREE)) {
+	if (intern->glcontext)
+	{
+		if (!(intern->flags & SDL_DONTFREE))
+		{
 			SDL_GL_DeleteContext(intern->glcontext);
 		}
 	}
@@ -114,40 +115,39 @@ static void php_sdl_glcontext_free(zend_object *zo)
 }
 /* }}} */
 
-
 /* {{{ php_sdl_glcontext_new
  */
-static zend_object* php_sdl_glcontext_new(zend_class_entry *class_type)
+static zend_object *php_sdl_glcontext_new(zend_class_entry *class_type)
 {
 	struct php_sdl_glcontext *intern;
 
-	intern = (struct php_sdl_glcontext*)ecalloc(1, sizeof(struct php_sdl_glcontext) + zend_object_properties_size(class_type));
+	intern = (struct php_sdl_glcontext *)ecalloc(1, sizeof(struct php_sdl_glcontext) + zend_object_properties_size(class_type));
 
 	zend_object_std_init(&intern->zo, class_type);
 	object_properties_init(&intern->zo, class_type);
 
 	intern->glcontext = NULL;
-	
-	intern->zo.handlers = (zend_object_handlers*)&php_sdl_glcontext_handlers;
 
-	return &intern->zo; 
+	intern->zo.handlers = (zend_object_handlers *)&php_sdl_glcontext_handlers;
+
+	return &intern->zo;
 }
 /* }}} */
 
-
 /* {{{ proto bool SDL_GL_ExtensionSupported(string extension)
 
  *  \brief Return true if an OpenGL extension is supported for the current
  *         context.
  extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char
-                                                            *extension);
+															*extension);
  */
 PHP_FUNCTION(SDL_GL_ExtensionSupported)
 {
 	char *ext;
 	size_t ext_len;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &ext, &ext_len)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &ext, &ext_len))
+	{
 		return;
 	}
 	RETVAL_BOOL(SDL_GL_ExtensionSupported(ext) == SDL_TRUE);
@@ -163,14 +163,14 @@ PHP_FUNCTION(SDL_GL_SetAttribute)
 {
 	zend_long attr, value;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &attr, &value)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &attr, &value))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_GL_SetAttribute((SDL_GLattr)attr, (int)value));
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GL_GetAttribute(int attr, int &value)
 
  *  \brief Get the actual value for an attribute from the current context.
@@ -182,11 +182,13 @@ PHP_FUNCTION(SDL_GL_GetAttribute)
 	zval *z_value;
 	int ret, value;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &attr, &z_value)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &attr, &z_value))
+	{
 		return;
 	}
 	ret = SDL_GL_GetAttribute((SDL_GLattr)attr, &value);
-	if (ret == 0) {
+	if (ret == 0)
+	{
 		zval_dtor(z_value);
 		ZVAL_LONG(z_value, value);
 	}
@@ -194,7 +196,6 @@ PHP_FUNCTION(SDL_GL_GetAttribute)
 }
 /* }}} */
 
-
 /* {{{ proto SDL_GLContext::__construct(void) */
 PHP_METHOD(SDL_GLContext, __construct)
 {
@@ -206,47 +207,59 @@ PHP_METHOD(SDL_GLContext, __construct)
 	intern = (struct php_sdl_glcontext *)Z_OBJ_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce()))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
 	window = zval_to_sdl_window(z_window);
-	if (window) {
+	if (window)
+	{
 		intern->glcontext = SDL_GL_CreateContext(window);
-		if (intern->glcontext) {
+		if (intern->glcontext)
+		{
 			intern->flags = 0;
-		} else {
+		}
+		else
+		{
 			zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0);
 		}
-	} else {
+	}
+	else
+	{
 		zend_throw_exception(zend_exception_get_default(), "Invalid SDL_Window object", 0);
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_GLContext::__toString() */
 PHP_METHOD(SDL_GLContext, __toString)
 {
 	struct php_sdl_glcontext *intern;
 	char *buf;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
 	intern = (struct php_sdl_glcontext *)Z_OBJ_P(getThis());
-	if (intern->glcontext) {
+	if (intern->glcontext)
+	{
 		spprintf(&buf, 100, "SDL_GLContext(%lx)", (long)intern->glcontext);
 		RETVAL_STRING(buf);
-	} else {
+	}
+	else
+	{
 		RETVAL_STRING("SDL_GLContext()");
 	}
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_GLContext__toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_GLContext SDL_GL_CreateContext(SDL_Window window)
 
@@ -255,7 +268,7 @@ PHP_METHOD(SDL_GLContext, __toString)
  *
  *  \sa SDL_GL_DeleteContext()
  extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window *
-                                                            window);
+															window);
  */
 PHP_FUNCTION(SDL_GL_CreateContext)
 {
@@ -263,20 +276,23 @@ PHP_FUNCTION(SDL_GL_CreateContext)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce()))
+	{
 		return;
 	}
 	window = zval_to_sdl_window(z_window);
-	if (window) {
+	if (window)
+	{
 		context = SDL_GL_CreateContext(window);
 		sdl_glcontext_to_zval(context, return_value, SDL_DONTFREE);
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
 	}
 }
 /* }}} */
 
-
 /* {{{ proto void SDL_GL_DeleteContext(SDL_GLContext context)
 
  *  \brief Delete an OpenGL context.
@@ -290,7 +306,8 @@ PHP_FUNCTION(SDL_GL_DeleteContext)
 	zval *z_context;
 	SDL_GLContext context;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_context, php_sdl_glcontext_ce) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_context, php_sdl_glcontext_ce) == FAILURE)
+	{
 		return;
 	}
 	FETCH_GLCONTEXT(context, z_context, 1);
@@ -300,15 +317,14 @@ PHP_FUNCTION(SDL_GL_DeleteContext)
 }
 /* }}} */
 
-
-#if SDL_VERSION_ATLEAST(2,0,1)
+#if SDL_VERSION_ATLEAST(2, 0, 1)
 /* {{{ proto int SDL_GL_MakeCurrent(SDL_Window window, SDL_GLContext context)
 
  *  \brief Set up an OpenGL context for rendering into an OpenGL window.
  *
  *  \note The context must have been created with a compatible window.
  extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window,
-                                                SDL_GLContext context);
+												SDL_GLContext context);
  */
 PHP_FUNCTION(SDL_GL_MakeCurrent)
 {
@@ -317,20 +333,23 @@ PHP_FUNCTION(SDL_GL_MakeCurrent)
 	SDL_GLContext context;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, get_php_sdl_window_ce(), &z_context, php_sdl_glcontext_ce)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, get_php_sdl_window_ce(), &z_context, php_sdl_glcontext_ce))
+	{
 		return;
 	}
 	FETCH_GLCONTEXT(context, z_context, 1);
 	window = zval_to_sdl_window(z_window);
-	if (window) {
+	if (window)
+	{
 		RETVAL_LONG(SDL_GL_MakeCurrent(window, context));
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
 	}
 }
 /* }}} */
 
-
 /* {{{ proto SDL_Window SDL_GL_GetCurrentWindow(void)
 
  *  \brief Get the currently active OpenGL window.
@@ -338,13 +357,13 @@ PHP_FUNCTION(SDL_GL_MakeCurrent)
  */
 PHP_FUNCTION(SDL_GL_GetCurrentWindow)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	sdl_window_to_zval(SDL_GL_GetCurrentWindow(), return_value, SDL_DONTFREE);
 }
 
-
 /* {{{ proto SDL_GLContext SDL_GL_GetCurrentContext(void)
 
  *  \brief Get the currently active OpenGL context.
@@ -352,7 +371,8 @@ PHP_FUNCTION(SDL_GL_GetCurrentWindow)
  */
 PHP_FUNCTION(SDL_GL_GetCurrentContext)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	sdl_glcontext_to_zval(SDL_GL_GetCurrentContext(), return_value, SDL_DONTFREE);
@@ -374,7 +394,7 @@ PHP_FUNCTION(SDL_GL_GetCurrentContext)
  *  \sa SDL_GetWindowSize()
  *  \sa SDL_CreateWindow()
  extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w,
-                                                     int *h);
+													 int *h);
  */
 PHP_FUNCTION(SDL_GL_GetDrawableSize)
 {
@@ -382,17 +402,21 @@ PHP_FUNCTION(SDL_GL_GetDrawableSize)
 	SDL_Window *window;
 	int w, h;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozz", &z_window, get_php_sdl_window_ce(), &z_w, &z_h)) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozz", &z_window, get_php_sdl_window_ce(), &z_w, &z_h))
+	{
 		return;
 	}
 	window = zval_to_sdl_window(z_window);
-	if (window) {
+	if (window)
+	{
 		SDL_GL_GetDrawableSize(window, &w, &h);
 		zval_dtor(z_w);
 		ZVAL_LONG(z_w, w);
 		zval_dtor(z_h);
 		ZVAL_LONG(z_h, h);
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
 	}
 }
@@ -410,19 +434,22 @@ PHP_FUNCTION(SDL_GL_SwapWindow)
 	zval *z_window;
 	SDL_Window *window;
 
-	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, get_php_sdl_window_ce())) {
+	if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, get_php_sdl_window_ce()))
+	{
 		return;
 	}
 	window = zval_to_sdl_window(z_window);
-	if (window) {
+	if (window)
+	{
 		SDL_GL_SwapWindow(window);
-	} else {
+	}
+	else
+	{
 		php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object");
 	}
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GL_SetSwapInterval(int interval)
 
  *  \brief Set the swap interval for the current OpenGL context.
@@ -441,14 +468,14 @@ PHP_FUNCTION(SDL_GL_SetSwapInterval)
 {
 	zend_long value;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value))
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_GL_SetSwapInterval((int)value));
 }
 /* }}} */
 
-
 /* {{{ proto int SDL_GL_GetSwapInterval()
 
  *  \brief Get the swap interval for the current OpenGL context.
@@ -464,37 +491,35 @@ PHP_FUNCTION(SDL_GL_SetSwapInterval)
  */
 PHP_FUNCTION(SDL_GL_GetSwapInterval)
 {
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	RETVAL_LONG(SDL_GL_GetSwapInterval());
 }
 /* }}} */
 
-
 /* {{{ sdl_glcontext_methods[] */
 static const zend_function_entry php_sdl_glcontext_methods[] = {
-	PHP_ME(SDL_GLContext,       __construct,                arginfo_SDL_GLContext__construct,     ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_GLContext,       __toString,                 arginfo_none,                         ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_GLContext, __construct, arginfo_SDL_GLContext__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_GLContext, __toString, arginfo_class_SDL_GLContext__toString, ZEND_ACC_PUBLIC)
 
 	/* non-static method */
-	PHP_FALIAS(Delete,          SDL_GL_DeleteContext,       arginfo_none)
+	PHP_FALIAS(Delete, SDL_GL_DeleteContext, arginfo_none)
 
 	/* static functions */
-	ZEND_FENTRY(GL_GetCurrent,      ZEND_FN(SDL_GL_GetCurrentContext),    arginfo_none,           ZEND_ACC_PUBLIC|ZEND_ACC_STATIC)
+	ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentContext), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
 
-	ZEND_FE_END
-};
+		ZEND_FE_END};
 /* }}} */
 
-#define REGISTER_GL_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_GL_CLASS_CONST_LONG(const_name, value)                               \
 	REGISTER_LONG_CONSTANT("SDL_GL_" const_name, value, CONST_CS | CONST_PERSISTENT); \
-	zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name)-1, value)
+	zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name) - 1, value)
 
-#define REGISTER_GLCONTEXT_CLASS_CONST_LONG(const_name, value) \
+#define REGISTER_GLCONTEXT_CLASS_CONST_LONG(const_name, value)                                \
 	REGISTER_LONG_CONSTANT("SDL_GL_CONTEXT_" const_name, value, CONST_CS | CONST_PERSISTENT); \
-	zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name)-1, value)
-
+	zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name) - 1, value)
 
 /* {{{ MINIT */
 PHP_MINIT_FUNCTION(sdl_glcontext)
@@ -509,44 +534,44 @@ PHP_MINIT_FUNCTION(sdl_glcontext)
 	php_sdl_glcontext_handlers.offset = XtOffsetOf(struct php_sdl_glcontext, zo);
 
 	/* typedef enum SDL_GLattr; */
-	REGISTER_GL_CLASS_CONST_LONG("RED_SIZE",                       SDL_GL_RED_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("GREEN_SIZE",                     SDL_GL_GREEN_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("BLUE_SIZE",                      SDL_GL_BLUE_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("ALPHA_SIZE",                     SDL_GL_ALPHA_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("BUFFER_SIZE",                    SDL_GL_BUFFER_SIZE),
-	REGISTER_GL_CLASS_CONST_LONG("DOUBLEBUFFER",                   SDL_GL_DOUBLEBUFFER);
-	REGISTER_GL_CLASS_CONST_LONG("DEPTH_SIZE",                     SDL_GL_DEPTH_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("STENCIL_SIZE",                   SDL_GL_STENCIL_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("ACCUM_RED_SIZE",                 SDL_GL_ACCUM_RED_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("ACCUM_GREEN_SIZE",               SDL_GL_ACCUM_GREEN_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("ACCUM_BLUE_SIZE",                SDL_GL_ACCUM_BLUE_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("ACCUM_ALPHA_SIZE",               SDL_GL_ACCUM_ALPHA_SIZE);
-	REGISTER_GL_CLASS_CONST_LONG("STEREO",                         SDL_GL_STEREO);
-	REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLEBUFFERS",             SDL_GL_MULTISAMPLEBUFFERS);
-	REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLESAMPLES",             SDL_GL_MULTISAMPLESAMPLES),
-	REGISTER_GL_CLASS_CONST_LONG("ACCELERATED_VISUAL",             SDL_GL_ACCELERATED_VISUAL);
-	REGISTER_GL_CLASS_CONST_LONG("RETAINED_BACKING",               SDL_GL_RETAINED_BACKING);
-	REGISTER_GL_CLASS_CONST_LONG("SHARE_WITH_CURRENT_CONTEXT",     SDL_GL_SHARE_WITH_CURRENT_CONTEXT);
-
-#if SDL_VERSION_ATLEAST(2,0,1)	
-	REGISTER_GL_CLASS_CONST_LONG("FRAMEBUFFER_SRGB_CAPABLE",       SDL_GL_FRAMEBUFFER_SRGB_CAPABLE);
+	REGISTER_GL_CLASS_CONST_LONG("RED_SIZE", SDL_GL_RED_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("GREEN_SIZE", SDL_GL_GREEN_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("BLUE_SIZE", SDL_GL_BLUE_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("ALPHA_SIZE", SDL_GL_ALPHA_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("BUFFER_SIZE", SDL_GL_BUFFER_SIZE),
+		REGISTER_GL_CLASS_CONST_LONG("DOUBLEBUFFER", SDL_GL_DOUBLEBUFFER);
+	REGISTER_GL_CLASS_CONST_LONG("DEPTH_SIZE", SDL_GL_DEPTH_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("STENCIL_SIZE", SDL_GL_STENCIL_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("ACCUM_RED_SIZE", SDL_GL_ACCUM_RED_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("ACCUM_GREEN_SIZE", SDL_GL_ACCUM_GREEN_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("ACCUM_BLUE_SIZE", SDL_GL_ACCUM_BLUE_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("ACCUM_ALPHA_SIZE", SDL_GL_ACCUM_ALPHA_SIZE);
+	REGISTER_GL_CLASS_CONST_LONG("STEREO", SDL_GL_STEREO);
+	REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLEBUFFERS", SDL_GL_MULTISAMPLEBUFFERS);
+	REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLESAMPLES", SDL_GL_MULTISAMPLESAMPLES),
+		REGISTER_GL_CLASS_CONST_LONG("ACCELERATED_VISUAL", SDL_GL_ACCELERATED_VISUAL);
+	REGISTER_GL_CLASS_CONST_LONG("RETAINED_BACKING", SDL_GL_RETAINED_BACKING);
+	REGISTER_GL_CLASS_CONST_LONG("SHARE_WITH_CURRENT_CONTEXT", SDL_GL_SHARE_WITH_CURRENT_CONTEXT);
+
+#if SDL_VERSION_ATLEAST(2, 0, 1)
+	REGISTER_GL_CLASS_CONST_LONG("FRAMEBUFFER_SRGB_CAPABLE", SDL_GL_FRAMEBUFFER_SRGB_CAPABLE);
 #endif
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("MAJOR_VERSION",           SDL_GL_CONTEXT_MAJOR_VERSION);
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("MINOR_VERSION",           SDL_GL_CONTEXT_MINOR_VERSION);
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("EGL",                     SDL_GL_CONTEXT_EGL);
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("FLAGS",                   SDL_GL_CONTEXT_FLAGS);
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_MASK",            SDL_GL_CONTEXT_PROFILE_MASK);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("MAJOR_VERSION", SDL_GL_CONTEXT_MAJOR_VERSION);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("MINOR_VERSION", SDL_GL_CONTEXT_MINOR_VERSION);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("EGL", SDL_GL_CONTEXT_EGL);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("FLAGS", SDL_GL_CONTEXT_FLAGS);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_MASK", SDL_GL_CONTEXT_PROFILE_MASK);
 
 	/* typedef enum SDL_GLprofile; */
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_CORE",            SDL_GL_CONTEXT_PROFILE_CORE);
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_COMPATIBILITY",   SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_ES",              SDL_GL_CONTEXT_PROFILE_ES);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_CORE", SDL_GL_CONTEXT_PROFILE_CORE);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_COMPATIBILITY", SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_ES", SDL_GL_CONTEXT_PROFILE_ES);
 
 	/* typedef enum SDL_GLcontextFlag; */
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("DEBUG_FLAG",              SDL_GL_CONTEXT_DEBUG_FLAG);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("DEBUG_FLAG", SDL_GL_CONTEXT_DEBUG_FLAG);
 	REGISTER_GLCONTEXT_CLASS_CONST_LONG("FORWARD_COMPATIBLE_FLAG", SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("ROBUST_ACCESS_FLAG",      SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);
-	REGISTER_GLCONTEXT_CLASS_CONST_LONG("RESET_ISOLATION_FLAG",    SDL_GL_CONTEXT_RESET_ISOLATION_FLAG);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("ROBUST_ACCESS_FLAG", SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG);
+	REGISTER_GLCONTEXT_CLASS_CONST_LONG("RESET_ISOLATION_FLAG", SDL_GL_CONTEXT_RESET_ISOLATION_FLAG);
 
 	return SUCCESS;
 }
diff --git a/src/messagebox.c b/src/messagebox.c
index 6cfcd3c..a3dfae2 100644
--- a/src/messagebox.c
+++ b/src/messagebox.c
@@ -20,22 +20,25 @@
 
 static zend_class_entry *php_sdl_messageboxcolor_ce;
 static zend_object_handlers php_sdl_messageboxcolor_handlers;
-struct php_sdl_messageboxcolor {
-	zend_object   zo;
+struct php_sdl_messageboxcolor
+{
+	zend_object zo;
 };
 
 static zend_class_entry *php_sdl_messageboxbuttondata_ce;
 static zend_object_handlers php_sdl_messageboxbuttondata_handlers;
-struct php_sdl_messageboxbuttondata {
-	zend_object   zo;
+struct php_sdl_messageboxbuttondata
+{
+	zend_object zo;
 };
 
 static zend_class_entry *php_sdl_messageboxdata_ce;
 static zend_object_handlers php_sdl_messageboxdata_handlers;
-struct php_sdl_messageboxdata {
-	zend_object          zo;
-	SDL_MessageBoxData  *data;
-	Uint32               flags;
+struct php_sdl_messageboxdata
+{
+	zend_object zo;
+	SDL_MessageBoxData *data;
+	Uint32 flags;
 };
 
 /* {{{ get_php_sdl_messageboxcolor_ce */
@@ -62,7 +65,8 @@ zend_class_entry *get_php_sdl_messageboxdata_ce(void)
 /* {{{ sdl_messageboxcolor_to_zval */
 zend_bool sdl_messageboxcolor_to_zval(const SDL_MessageBoxColor *color, zval *value)
 {
-	if (color) {
+	if (color)
+	{
 		object_init_ex(value, php_sdl_messageboxcolor_ce);
 		zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "r", 1, color->r);
 		zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "g", 1, color->g);
@@ -78,7 +82,8 @@ zend_bool sdl_messageboxcolor_to_zval(const SDL_MessageBoxColor *color, zval *va
 /* {{{ sdl_messageboxbuttondata_to_zval */
 zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data, zval *value)
 {
-	if (data) {
+	if (data)
+	{
 		object_init_ex(value, php_sdl_messageboxbuttondata_ce);
 		zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("flags"), data->flags);
 		zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("buttonid"), data->buttonid);
@@ -94,13 +99,14 @@ zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data,
 /* {{{ sdl_messageboxdata_to_zval */
 zend_bool sdl_messageboxdata_to_zval(SDL_MessageBoxData *data, zval *z_val, Uint32 flags)
 {
-	if (data) {
+	if (data)
+	{
 		struct php_sdl_messageboxdata *intern;
 
 		object_init_ex(z_val, php_sdl_messageboxdata_ce);
 		intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(z_val);
-		intern->data   = data;
-		intern->flags  = flags;
+		intern->data = data;
+		intern->flags = flags;
 
 		return 1;
 	}
@@ -112,7 +118,8 @@ zend_bool sdl_messageboxdata_to_zval(SDL_MessageBoxData *data, zval *z_val, Uint
 /* {{{ zval_to_sdl_messageboxcolor( */
 zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color)
 {
-	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxcolor_ce) {
+	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxcolor_ce)
+	{
 		zval *val, rv;
 
 		/* we convert the properties, without copy: yes ! */
@@ -140,7 +147,8 @@ zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color)
 /* {{{ zval_to_sdl_messageboxcolor( */
 zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData *data)
 {
-	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxbuttondata_ce) {
+	if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxbuttondata_ce)
+	{
 		zval *val, rv;
 
 		/* we convert the properties, without copy: yes ! */
@@ -168,30 +176,35 @@ zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData
 /* {{{ zval_to_sdl_messageboxdata */
 SDL_MessageBoxData *zval_to_sdl_messageboxdata(zval *z_val)
 {
-	if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_messageboxdata_ce) {
+	if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_messageboxdata_ce)
+	{
 		struct php_sdl_messageboxdata *intern;
 
 		intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(z_val);
 		return intern->data;
-		}
+	}
 	return NULL;
 }
 /* }}} */
 
 /* {{{ php_sdl_messageboxdata_free
-	 */
+ */
 static void php_sdl_messageboxdata_free(zend_object *object)
 {
-	struct php_sdl_messageboxdata *intern = (struct php_sdl_messageboxdata *) object;
+	struct php_sdl_messageboxdata *intern = (struct php_sdl_messageboxdata *)object;
 
-	if (intern->data) {
-		if (!(intern->flags & SDL_DONTFREE)) {
+	if (intern->data)
+	{
+		if (!(intern->flags & SDL_DONTFREE))
+		{
 			efree((void *)intern->data->title);
 			efree((void *)intern->data->message);
-			if (intern->data->buttons) {
+			if (intern->data->buttons)
+			{
 				efree((void *)intern->data->buttons);
 			}
-			if (intern->data->colorScheme) {
+			if (intern->data->colorScheme)
+			{
 				efree((void *)intern->data->colorScheme);
 			}
 			efree(intern->data);
@@ -204,7 +217,7 @@ static void php_sdl_messageboxdata_free(zend_object *object)
 
 /* {{{ php_sdl_messageboxdata_new
  */
-static zend_object* php_sdl_messageboxdata_new(zend_class_entry *class_type)
+static zend_object *php_sdl_messageboxdata_new(zend_class_entry *class_type)
 {
 	struct php_sdl_messageboxdata *intern;
 
@@ -221,11 +234,10 @@ static zend_object* php_sdl_messageboxdata_new(zend_class_entry *class_type)
 }
 /* }}} */
 
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxColor__construct, 0, 0, 3)
-       ZEND_ARG_INFO(0, r)
-       ZEND_ARG_INFO(0, g)
-       ZEND_ARG_INFO(0, b)
+ZEND_ARG_INFO(0, r)
+ZEND_ARG_INFO(0, g)
+ZEND_ARG_INFO(0, b)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_MessageBoxColor::__construct(int r, int g, int b, int a)
@@ -233,7 +245,7 @@ ZEND_END_ARG_INFO()
  * \brief RGB value used in a message box color scheme
 typedef struct
 {
-    Uint8 r, g, b;
+	Uint8 r, g, b;
 } SDL_MessageBoxColor;
 */
 static PHP_METHOD(SDL_MessageBoxColor, __construct)
@@ -242,18 +254,21 @@ static PHP_METHOD(SDL_MessageBoxColor, __construct)
 	zend_error_handling error_handling;
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &r, &g, &b)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &r, &g, &b))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
-	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "r", 1, r&255);
-	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "g", 1, g&255);
-	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "b", 1, b&255);
+	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "r", 1, r & 255);
+	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "g", 1, g & 255);
+	zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "b", 1, b & 255);
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxColor__toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_MessageBoxColor::__toString() */
 static PHP_METHOD(SDL_MessageBoxColor, __toString)
@@ -261,8 +276,9 @@ static PHP_METHOD(SDL_MessageBoxColor, __toString)
 	char *buf;
 	SDL_MessageBoxColor color;
 
-	//intern = (struct php_sdl_pixelformat *)Z_OBJ_P(__id);
-	if (zend_parse_parameters_none() == FAILURE) {
+	// intern = (struct php_sdl_pixelformat *)Z_OBJ_P(__id);
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
@@ -272,11 +288,10 @@ static PHP_METHOD(SDL_MessageBoxColor, __toString)
 }
 /* }}} */
 
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxButtonData__construct, 0, 0, 3)
-       ZEND_ARG_INFO(0, flags)
-       ZEND_ARG_INFO(0, buttonid)
-       ZEND_ARG_INFO(0, text)
+ZEND_ARG_INFO(0, flags)
+ZEND_ARG_INFO(0, buttonid)
+ZEND_ARG_INFO(0, text)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_MessageBoxButtonData::__construct(int r, int g, int b, int a)
@@ -284,9 +299,9 @@ ZEND_END_ARG_INFO()
  *  \brief Individual button data.
  typedef struct
  {
-     Uint32 flags;       *< ::SDL_MessageBoxButtonFlags *
-     int buttonid;       *< User defined button id (value returned via SDL_ShowMessageBox) *
-     const char * text;  *< The UTF-8 button text *
+	 Uint32 flags;       *< ::SDL_MessageBoxButtonFlags *
+	 int buttonid;       *< User defined button id (value returned via SDL_ShowMessageBox) *
+	 const char * text;  *< The UTF-8 button text *
  } SDL_MessageBoxButtonData;
 */
 static PHP_METHOD(SDL_MessageBoxButtonData, __construct)
@@ -297,7 +312,8 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __construct)
 	zend_error_handling error_handling;
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lls", &flags, &id, &text, &text_len)) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lls", &flags, &id, &text, &text_len))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
@@ -309,15 +325,18 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxButtonData___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_MessageBoxButtonData::__toString()
-*/
+ */
 static PHP_METHOD(SDL_MessageBoxButtonData, __toString)
 {
 	char *buf;
 	SDL_MessageBoxButtonData data;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 	zval_to_sdl_messageboxbuttondata(getThis(), &data);
@@ -326,14 +345,13 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __toString)
 }
 /* }}} */
 
-
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxData__construct, 0, 0, 3)
-       ZEND_ARG_INFO(0, flags)
-       ZEND_ARG_INFO(0, title)
-       ZEND_ARG_INFO(0, message)
-       ZEND_ARG_ARRAY_INFO(0, buttons, 0)
-       ZEND_ARG_ARRAY_INFO(0, colors, 0)
-       ZEND_ARG_OBJ_INFO(0, parentwindow, SDL_Window, 0)
+ZEND_ARG_INFO(0, flags)
+ZEND_ARG_INFO(0, title)
+ZEND_ARG_INFO(0, message)
+ZEND_ARG_ARRAY_INFO(0, buttons, 0)
+ZEND_ARG_ARRAY_INFO(0, colors, 0)
+ZEND_ARG_OBJ_INFO(0, parentwindow, SDL_Window, 0)
 ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_MessageBoxData::__construct(int flags, string title, string text [, array buttons [, array colors [, SDL_Window window ]]])
@@ -341,103 +359,126 @@ ZEND_END_ARG_INFO()
  *  \brief MessageBox structure containing title, text, window, etc.
  typedef struct
  {
-     Uint32 flags;                       **< ::SDL_MessageBoxFlags *
-     SDL_Window *window;                 **< Parent window, can be NULL *
-     const char *title;                  **< UTF-8 title *
-     const char *message;                **< UTF-8 message text *
+	 Uint32 flags;                       **< ::SDL_MessageBoxFlags *
+	 SDL_Window *window;                 **< Parent window, can be NULL *
+	 const char *title;                  **< UTF-8 title *
+	 const char *message;                **< UTF-8 message text *
 
-     int numbuttons;
-     const SDL_MessageBoxButtonData *buttons;
+	 int numbuttons;
+	 const SDL_MessageBoxButtonData *buttons;
 
-     const SDL_MessageBoxColorScheme *colorScheme;   **< ::SDL_MessageBoxColorScheme, can be NULL to use system settings *
+	 const SDL_MessageBoxColorScheme *colorScheme;   **< ::SDL_MessageBoxColorScheme, can be NULL to use system settings *
  } SDL_MessageBoxData;
  */
 static PHP_METHOD(SDL_MessageBoxData, __construct)
 {
 	struct php_sdl_messageboxdata *intern;
-	zval *z_window=NULL, *z_buttons=NULL, *z_colors=NULL;
+	zval *z_window = NULL, *z_buttons = NULL, *z_colors = NULL;
 	zend_long flags;
 	char *title, *text;
 	size_t title_len, text_len;
-	int  n, nb;
+	int n, nb;
 	zend_error_handling error_handling;
 
 	intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(getThis());
 
 	zend_replace_error_handling(EH_THROW, NULL, &error_handling);
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|aaO", &flags, &title, &title_len, &text, &text_len, &z_buttons, &z_colors, &z_window, get_php_sdl_window_ce())) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|aaO", &flags, &title, &title_len, &text, &text_len, &z_buttons, &z_colors, &z_window, get_php_sdl_window_ce()))
+	{
 		zend_restore_error_handling(&error_handling);
 		return;
 	}
 	zend_restore_error_handling(&error_handling);
 
-	intern->flags  = 0;
+	intern->flags = 0;
 	intern->data = emalloc(sizeof(SDL_MessageBoxData));
-	intern->data->title       = estrdup(title);
-	intern->data->message     = estrdup(text);
-	intern->data->flags       = (Uint32)flags;
-	intern->data->window      = zval_to_sdl_window(z_window);
-	intern->data->numbuttons  = 0;
-	intern->data->buttons     = NULL;
+	intern->data->title = estrdup(title);
+	intern->data->message = estrdup(text);
+	intern->data->flags = (Uint32)flags;
+	intern->data->window = zval_to_sdl_window(z_window);
+	intern->data->numbuttons = 0;
+	intern->data->buttons = NULL;
 	intern->data->colorScheme = NULL;
 
-	if (z_buttons) {
+	if (z_buttons)
+	{
 		zval *ppzval;
 		SDL_MessageBoxButtonData *buttons;
 
-		n  = 0;
+		n = 0;
 		nb = zend_hash_num_elements(Z_ARRVAL_P(z_buttons));
-		if (nb) {
+		if (nb)
+		{
 
 			buttons = emalloc(nb * sizeof(SDL_MessageBoxButtonData));
 
-			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_buttons), ppzval) {
-					if (zval_to_sdl_messageboxbuttondata(ppzval, buttons+n)) {
-						n++;
-					} else {
-						php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxButtonData object");
-					}
+			ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_buttons), ppzval)
+			{
+				if (zval_to_sdl_messageboxbuttondata(ppzval, buttons + n))
+				{
+					n++;
+				}
+				else
+				{
+					php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxButtonData object");
+				}
 			}
 			ZEND_HASH_FOREACH_END();
-			if (n) {
+			if (n)
+			{
 				intern->data->numbuttons = n;
-				intern->data->buttons    = buttons;
-			} else {
+				intern->data->buttons = buttons;
+			}
+			else
+			{
 				efree(buttons);
 			}
 		}
 	}
 
-	if (z_colors) {
+	if (z_colors)
+	{
 		zval *ppzval = NULL;
 		SDL_MessageBoxColorScheme *colors;
 
 		colors = emalloc(sizeof(SDL_MessageBoxColorScheme));
 		memset(colors, 0, sizeof(*colors));
 
-		n  = 0;
-		ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_colors), ppzval) {
-				if (SDL_MESSAGEBOX_COLOR_MAX == n) {
-					php_error_docref(NULL, E_NOTICE, "Ignore button, only %d accepted", SDL_MESSAGEBOX_COLOR_MAX);
-				} else if (zval_to_sdl_messageboxcolor(ppzval, &colors->colors[n])) {
-					n++;
-				} else {
-					php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxColor object");
-				}
+		n = 0;
+		ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_colors), ppzval)
+		{
+			if (SDL_MESSAGEBOX_COLOR_MAX == n)
+			{
+				php_error_docref(NULL, E_NOTICE, "Ignore button, only %d accepted", SDL_MESSAGEBOX_COLOR_MAX);
+			}
+			else if (zval_to_sdl_messageboxcolor(ppzval, &colors->colors[n]))
+			{
+				n++;
+			}
+			else
+			{
+				php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxColor object");
+			}
 		}
 		ZEND_HASH_FOREACH_END();
-		if (n) {
-			if (SDL_MESSAGEBOX_COLOR_MAX != n) {
+		if (n)
+		{
+			if (SDL_MESSAGEBOX_COLOR_MAX != n)
+			{
 				php_error_docref(NULL, E_NOTICE, "%d SDL_MessageBoxColors expected", SDL_MESSAGEBOX_COLOR_MAX);
 			}
 			intern->data->colorScheme = colors;
-		} else {
+		}
+		else
+		{
 			efree(colors);
 		}
 	}
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxData___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_MessageBoxData::__toString() */
 static PHP_METHOD(SDL_MessageBoxData, __toString)
@@ -445,33 +486,38 @@ static PHP_METHOD(SDL_MessageBoxData, __toString)
 	struct php_sdl_messageboxdata *intern;
 	char *buf;
 
-	if (zend_parse_parameters_none() == FAILURE) {
+	if (zend_parse_parameters_none() == FAILURE)
+	{
 		return;
 	}
 
 	intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(getThis());
-	if (intern->data) {
+	if (intern->data)
+	{
 		spprintf(&buf, 100, "SDL_MessageBoxData(\"%s\")", intern->data->title);
 		RETVAL_STRING(buf);
-	} else {
+	}
+	else
+	{
 		RETVAL_STRING("SDL_MessageBoxData()");
 	}
 }
 /* }}} */
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxData_Show, 0, 0, 1)
-       ZEND_ARG_INFO(1, buttonid)
+ZEND_ARG_INFO(1, buttonid)
 ZEND_END_ARG_INFO()
 
-#define FETCH_DATA(__ptr, __id, __check) \
-{ \
-        intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(__id);\
-        __ptr = intern->data; \
-        if (__check && !__ptr) {\
-                php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\
-                RETURN_FALSE;\
-        }\
-}
+#define FETCH_DATA(__ptr, __id, __check)                                                           \
+	{                                                                                              \
+		intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(__id);                                   \
+		__ptr = intern->data;                                                                      \
+		if (__check && !__ptr)                                                                     \
+		{                                                                                          \
+			php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \
+			RETURN_FALSE;                                                                          \
+		}                                                                                          \
+	}
 
 /* {{{ proto int SDL_ShowMessageBox(SDL_MessageBoxData messageboxdata, int &buttonid)
 
@@ -496,13 +542,15 @@ PHP_FUNCTION(SDL_ShowMessageBox)
 	SDL_MessageBoxData *data;
 	int id, res;
 
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_data, php_sdl_messageboxdata_ce, &z_id) == FAILURE) {
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_data, php_sdl_messageboxdata_ce, &z_id) == FAILURE)
+	{
 		return;
 	}
 	FETCH_DATA(data, z_data, 1);
 
 	res = SDL_ShowMessageBox(data, &id);
-	if (res==0) {
+	if (res == 0)
+	{
 		zval_dtor(z_id);
 		ZVAL_LONG(z_id, (long)id);
 	}
@@ -533,54 +581,49 @@ PHP_FUNCTION(SDL_ShowSimpleMessageBox)
 	zval *z_window = NULL;
 	SDL_Window *window = NULL;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|O!", &flags, &title, &title_len, &msg, &msg_len, &z_window, get_php_sdl_window_ce())) {
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|O!", &flags, &title, &title_len, &msg, &msg_len, &z_window, get_php_sdl_window_ce()))
+	{
 		return;
 	}
 
-	if( z_window != NULL ) {
+	if (z_window != NULL)
+	{
 		window = zval_to_sdl_window(z_window);
 	}
 	RETVAL_LONG(SDL_ShowSimpleMessageBox(flags, title, msg, window));
 }
 /* }}} */
 
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_messagebox_none, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
 /* {{{ php_sdl_messageboxcolor_methods[] */
 static const zend_function_entry php_sdl_messageboxcolor_methods[] = {
-	PHP_ME(SDL_MessageBoxColor, __construct, arginfo_SDL_MessageBoxColor__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_MessageBoxColor, __toString,  arginfo_messagebox_none,                ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_MessageBoxColor, __construct, arginfo_SDL_MessageBoxColor__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_MessageBoxColor, __toString, arginfo_class_SDL_MessageBoxColor__toString, ZEND_ACC_PUBLIC)
 
-	PHP_FE_END
-};
+			PHP_FE_END};
 /* }}} */
 
 /* {{{ php_sdl_messageboxbuttondata_methods[] */
 static const zend_function_entry php_sdl_messageboxbuttondata_methods[] = {
-	PHP_ME(SDL_MessageBoxButtonData, __construct, arginfo_SDL_MessageBoxButtonData__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_MessageBoxButtonData, __toString,  arginfo_messagebox_none,                     ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_MessageBoxButtonData, __construct, arginfo_SDL_MessageBoxButtonData__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_MessageBoxButtonData, __toString, arginfo_class_SDL_MessageBoxButtonData___toString, ZEND_ACC_PUBLIC)
 
-	PHP_FE_END
-};
+			PHP_FE_END};
 /* }}} */
 
 /* {{{ php_sdl_messageboxdata_methods[] */
 static const zend_function_entry php_sdl_messageboxdata_methods[] = {
-	PHP_ME(SDL_MessageBoxData, __construct, arginfo_SDL_MessageBoxData__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_MessageBoxData, __toString,  arginfo_messagebox_none,               ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_MessageBoxData, __construct, arginfo_SDL_MessageBoxData__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_MessageBoxData, __toString, arginfo_class_SDL_MessageBoxData___toString, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
-	PHP_FALIAS(Show,         SDL_ShowMessageBox,          arginfo_SDL_MessageBoxData_Show)
+	PHP_FALIAS(Show, SDL_ShowMessageBox, arginfo_SDL_MessageBoxData_Show)
 
-	PHP_FE_END
-};
+		PHP_FE_END};
 /* }}} */
 
-#define REGISTER_MESSAGEBOX_CLASS_CONST_LONG(prefix, const_name, value, ce) \
+#define REGISTER_MESSAGEBOX_CLASS_CONST_LONG(prefix, const_name, value, ce)                          \
 	REGISTER_LONG_CONSTANT("SDL_MESSAGEBOX_" prefix const_name, value, CONST_CS | CONST_PERSISTENT); \
-	zend_declare_class_constant_long(ce, ZEND_STRL(const_name), value); \
+	zend_declare_class_constant_long(ce, ZEND_STRL(const_name), value);
 
 #define REGISTER_MESSAGEBOXCOLOR_PROP(name) \
 	zend_declare_property_long(php_sdl_messageboxcolor_ce, ZEND_STRL(name), 0, ZEND_ACC_PUBLIC)
@@ -615,17 +658,17 @@ PHP_MINIT_FUNCTION(sdl_messagebox)
 	memcpy(&php_sdl_messageboxdata_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 	php_sdl_messageboxdata_handlers.free_obj = php_sdl_messageboxdata_free;
 
-	zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("flags"),      0,  ZEND_ACC_PUBLIC);
-	zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("title"),          ZEND_ACC_PUBLIC);
-	zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("message"),        ZEND_ACC_PUBLIC);
-	zend_declare_property_bool(php_sdl_messageboxdata_ce, ZEND_STRL("window"),     0,  ZEND_ACC_PUBLIC);
-	zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("numbuttons"), 0,  ZEND_ACC_PUBLIC);
-	zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("buttons"),        ZEND_ACC_PUBLIC);
-	zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("colors"),         ZEND_ACC_PUBLIC);
+	zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("flags"), 0, ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("message"), ZEND_ACC_PUBLIC);
+	zend_declare_property_bool(php_sdl_messageboxdata_ce, ZEND_STRL("window"), 0, ZEND_ACC_PUBLIC);
+	zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("numbuttons"), 0, ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("buttons"), ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("colors"), ZEND_ACC_PUBLIC);
 
 	/* enum SDL_MessageBoxFlags: If supported will display warning icon, etc. */
-	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "ERROR",       SDL_MESSAGEBOX_ERROR,       php_sdl_messageboxdata_ce);
-	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "WARNING",     SDL_MESSAGEBOX_WARNING,     php_sdl_messageboxdata_ce);
+	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "ERROR", SDL_MESSAGEBOX_ERROR, php_sdl_messageboxdata_ce);
+	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "WARNING", SDL_MESSAGEBOX_WARNING, php_sdl_messageboxdata_ce);
 	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "INFORMATION", SDL_MESSAGEBOX_INFORMATION, php_sdl_messageboxdata_ce);
 
 	/* enum SDL_MessageBoxButtonFlags: Flags for SDL_MessageBoxButtonData. */
@@ -633,12 +676,12 @@ PHP_MINIT_FUNCTION(sdl_messagebox)
 	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("BUTTON_", "ESCAPEKEY_DEFAULT", SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, php_sdl_messageboxbuttondata_ce);
 
 	/* enum SDL_MessageBoxColorType */
-	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BACKGROUND",        SDL_MESSAGEBOX_COLOR_BACKGROUND,        php_sdl_messageboxcolor_ce);
-	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "TEXT",              SDL_MESSAGEBOX_COLOR_TEXT,              php_sdl_messageboxcolor_ce);
-	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BORDER",     SDL_MESSAGEBOX_COLOR_BUTTON_BORDER,     php_sdl_messageboxcolor_ce);
+	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BACKGROUND", SDL_MESSAGEBOX_COLOR_BACKGROUND, php_sdl_messageboxcolor_ce);
+	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "TEXT", SDL_MESSAGEBOX_COLOR_TEXT, php_sdl_messageboxcolor_ce);
+	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BORDER", SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, php_sdl_messageboxcolor_ce);
 	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BACKGROUND", SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, php_sdl_messageboxcolor_ce);
-	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_SELECTED",   SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED,   php_sdl_messageboxcolor_ce);
-	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "MAX",               SDL_MESSAGEBOX_COLOR_MAX,               php_sdl_messageboxcolor_ce);
+	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_SELECTED", SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, php_sdl_messageboxcolor_ce);
+	REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "MAX", SDL_MESSAGEBOX_COLOR_MAX, php_sdl_messageboxcolor_ce);
 
 	return SUCCESS;
 }
diff --git a/src/mouse.c b/src/mouse.c
index 88d4e0b..ce4ed62 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -158,6 +158,9 @@ static PHP_METHOD(SDL_Cursor, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Cursor___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_Cursor::__toString()
  */
 static PHP_METHOD(SDL_Cursor, __toString)
@@ -547,11 +550,11 @@ ZEND_END_ARG_INFO()
 /* {{{ sdl_cursor_methods[] */
 static const zend_function_entry php_sdl_cursor_methods[] = {
 	PHP_ME(SDL_Cursor, __construct, arginfo_SDL_Cursor__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
-		PHP_ME(SDL_Cursor, __toString, arginfo_none, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Cursor, __toString, arginfo_class_SDL_Cursor___toString, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
 	PHP_FALIAS(Free, SDL_FreeCursor, arginfo_none)
-		PHP_FALIAS(Set, SDL_SetCursor, arginfo_none)
+	PHP_FALIAS(Set, SDL_SetCursor, arginfo_none)
 
 	/* static methods */
 	ZEND_FENTRY(Create, ZEND_FN(SDL_CreateCursor), arginfo_SDL_Cursor__construct, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
diff --git a/src/mutex.c b/src/mutex.c
index 143a269..72aba04 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -331,6 +331,8 @@ static PHP_METHOD(SDL_mutex, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Mutex___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_mutex::__toString() */
 static PHP_METHOD(SDL_mutex, __toString)
@@ -492,6 +494,8 @@ static PHP_METHOD(SDL_sem, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Sem___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_sem::__toString() */
 static PHP_METHOD(SDL_sem, __toString)
@@ -696,6 +700,8 @@ static PHP_METHOD(SDL_cond, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_cond___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_cond::__toString() */
 static PHP_METHOD(SDL_cond, __toString)
@@ -896,7 +902,7 @@ PHP_FUNCTION(SDL_DestroyCond)
 /* {{{ sdl_mutex_methods[] */
 static const zend_function_entry php_sdl_mutex_methods[] = {
 	PHP_ME(SDL_mutex,       __construct,                arginfo_none,          ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_mutex,       __toString,                 arginfo_none,          ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_mutex,       __toString,                 arginfo_class_SDL_Mutex___toString,          ZEND_ACC_PUBLIC)
 
 	/* non-static method */
 	PHP_FALIAS(Lock,        SDL_LockMutex,              arginfo_none)
@@ -912,7 +918,7 @@ static const zend_function_entry php_sdl_mutex_methods[] = {
 /* {{{ sdl_sem_methods[] */
 static const zend_function_entry php_sdl_sem_methods[] = {
 	PHP_ME(SDL_sem,        __construct,                arginfo_SDL_sem__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_sem,        __toString,                 arginfo_none,               ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_sem,        __toString,                 arginfo_class_SDL_Sem___toString,               ZEND_ACC_PUBLIC)
 
 	/* non-static method */
 	PHP_FALIAS(Wait,        SDL_SemWait,               arginfo_none)
@@ -930,7 +936,7 @@ static const zend_function_entry php_sdl_sem_methods[] = {
 /* {{{ sdl_cond_methods[] */
 static const zend_function_entry php_sdl_cond_methods[] = {
 	PHP_ME(SDL_cond,        __construct,               arginfo_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_cond,        __toString,                arginfo_none,               ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_cond,        __toString,                arginfo_class_SDL_cond___toString,               ZEND_ACC_PUBLIC)
 
 	/* non-static method */
 	PHP_FALIAS(Wait,        SDL_CondWait,              arginfo_SDL_Cond_Wait)
diff --git a/src/php_sdl.c b/src/php_sdl.c
index 6c39112..c902860 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -49,14 +49,18 @@ ZEND_GET_MODULE(sdl)
 /* {{{ php_sdl_check_overflow */
 zend_bool php_sdl_check_overflow(int a, int b, int silent)
 {
-	if(a <= 0 || b <= 0) {
-		if (!silent) {
+	if (a <= 0 || b <= 0)
+	{
+		if (!silent)
+		{
 			php_error_docref(NULL, E_WARNING, "one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully");
 		}
 		return 1;
 	}
-	if(a > INT_MAX / b) {
-		if (!silent) {
+	if (a > INT_MAX / b)
+	{
+		if (!silent)
+		{
 			php_error_docref(NULL, E_WARNING, "product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully");
 		}
 		return 1;
@@ -65,45 +69,20 @@ zend_bool php_sdl_check_overflow(int a, int b, int silent)
 }
 /* }}} */
 
-
 #define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU)
 #define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU)
 
 /* {{{ PHP_MINIT_FUNCTION */
 PHP_MINIT_FUNCTION(sdl)
 {
-	if (   SUCCESS == PHP_MINIT_CALL(sdl_blendmode)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_cpuinfo)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_error)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_event)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_glcontext)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_keyboard)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_messagebox)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_mouse)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_mutex)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_platform)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_power)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_filesystem)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_pixels)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_rect)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_render)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_rwops)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_sdl)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_shape)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_surface)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_timer)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_version)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_video)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_window)
-		&& SUCCESS == PHP_MINIT_CALL(sdl_joystick)
-		) {
+	if (SUCCESS == PHP_MINIT_CALL(sdl_blendmode) && SUCCESS == PHP_MINIT_CALL(sdl_cpuinfo) && SUCCESS == PHP_MINIT_CALL(sdl_error) && SUCCESS == PHP_MINIT_CALL(sdl_event) && SUCCESS == PHP_MINIT_CALL(sdl_glcontext) && SUCCESS == PHP_MINIT_CALL(sdl_keyboard) && SUCCESS == PHP_MINIT_CALL(sdl_messagebox) && SUCCESS == PHP_MINIT_CALL(sdl_mouse) && SUCCESS == PHP_MINIT_CALL(sdl_mutex) && SUCCESS == PHP_MINIT_CALL(sdl_platform) && SUCCESS == PHP_MINIT_CALL(sdl_power) && SUCCESS == PHP_MINIT_CALL(sdl_filesystem) && SUCCESS == PHP_MINIT_CALL(sdl_pixels) && SUCCESS == PHP_MINIT_CALL(sdl_rect) && SUCCESS == PHP_MINIT_CALL(sdl_render) && SUCCESS == PHP_MINIT_CALL(sdl_rwops) && SUCCESS == PHP_MINIT_CALL(sdl_sdl) && SUCCESS == PHP_MINIT_CALL(sdl_shape) && SUCCESS == PHP_MINIT_CALL(sdl_surface) && SUCCESS == PHP_MINIT_CALL(sdl_timer) && SUCCESS == PHP_MINIT_CALL(sdl_version) && SUCCESS == PHP_MINIT_CALL(sdl_video) && SUCCESS == PHP_MINIT_CALL(sdl_window) && SUCCESS == PHP_MINIT_CALL(sdl_joystick))
+	{
 		return SUCCESS;
 	}
 	return FAILURE;
 }
 /* }}} */
 
-
 /* {{{ PHP_MSHUTDOWN_FUNCTION */
 PHP_MSHUTDOWN_FUNCTION(sdl)
 {
@@ -148,58 +127,58 @@ static zend_function_entry sdl_functions[] = {
 	ZEND_FE(SDL_WasInit,					arginfo_SDL_WasInit)
 
 	// Window
-	ZEND_FE(SDL_CreateWindow,				arginfo_SDL_CreateWindow)
-	ZEND_FE(SDL_CreateShapedWindow,			arginfo_SDL_CreateWindow)
-	ZEND_FE(SDL_DestroyWindow,				arginfo_SDL_Window)
-	ZEND_FE(SDL_UpdateWindowSurface,		arginfo_SDL_Window)
-	ZEND_FE(SDL_GetWindowTitle,				arginfo_SDL_Window)
-	ZEND_FE(SDL_SetWindowTitle,				arginfo_SDL_SetWindowTitle)
-	ZEND_FE(SDL_GetWindowDisplayIndex,		arginfo_SDL_Window)
-	ZEND_FE(SDL_ShowWindow,					arginfo_SDL_Window)
-	ZEND_FE(SDL_HideWindow,					arginfo_SDL_Window)
-	ZEND_FE(SDL_RaiseWindow,				arginfo_SDL_Window)
-	ZEND_FE(SDL_MaximizeWindow,				arginfo_SDL_Window)
-	ZEND_FE(SDL_MinimizeWindow,				arginfo_SDL_Window)
-	ZEND_FE(SDL_RestoreWindow,				arginfo_SDL_Window)
-	ZEND_FE(SDL_GetWindowSurface,			arginfo_SDL_Window)
-	ZEND_FE(SDL_SetWindowDisplayMode,		arginfo_SDL_SetWindowDisplayMode)
-	ZEND_FE(SDL_GetWindowDisplayMode,		arginfo_SDL_GetWindowDisplayMode)
-	ZEND_FE(SDL_GetWindowPixelFormat,		arginfo_SDL_Window)
-	ZEND_FE(SDL_GetWindowID,				arginfo_SDL_Window)
-	ZEND_FE(SDL_GetWindowFlags,				arginfo_SDL_Window)
-	ZEND_FE(SDL_SetWindowIcon,				arginfo_SDL_SetWindowIcon)
-	ZEND_FE(SDL_SetWindowPosition,			arginfo_SDL_SetWindowPosition)
-	ZEND_FE(SDL_GetWindowPosition,			arginfo_SDL_GetWindowPosition)
-	ZEND_FE(SDL_SetWindowSize,				arginfo_SDL_SetWindowPosition)
-	ZEND_FE(SDL_GetWindowSize,				arginfo_SDL_GetWindowPosition)
-	ZEND_FE(SDL_SetWindowMinimumSize,		arginfo_SDL_SetWindowPosition)
-	ZEND_FE(SDL_GetWindowMinimumSize,		arginfo_SDL_GetWindowPosition)
-	ZEND_FE(SDL_SetWindowMaximumSize,		arginfo_SDL_SetWindowPosition)
-	ZEND_FE(SDL_GetWindowMaximumSize,		arginfo_SDL_GetWindowPosition)
-	ZEND_FE(SDL_SetWindowBordered,			arginfo_SDL_SetWindowBordered)
-	ZEND_FE(SDL_SetWindowFullscreen,		arginfo_SDL_SetWindowFullscreen)
-	ZEND_FE(SDL_UpdateWindowSurfaceRects,	arginfo_SDL_UpdateWindowSurfaceRects)
-	ZEND_FE(SDL_SetWindowGrab,				arginfo_SDL_SetWindowGrab)
-	ZEND_FE(SDL_GetWindowGrab,				arginfo_SDL_Window)
-	ZEND_FE(SDL_SetWindowBrightness,		arginfo_SDL_SetWindowBrightness)
-	ZEND_FE(SDL_GetWindowBrightness,		arginfo_SDL_Window)
-	ZEND_FE(SDL_GetWindowGammaRamp, 		arginfo_SDL_GetWindowGammaRamp)
-	ZEND_FE(SDL_IsShapedWindow,				arginfo_SDL_Window)
-	ZEND_FE(SDL_SetWindowShape,				arginfo_SDL_SetWindowShape)
-	ZEND_FE(SDL_GetShapedWindowMode,		arginfo_SDL_GetShapedWindowMode)
-
-	ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY,	arginfo_SDL_WINDOWPOS_DISPLAY)
-	ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY,	arginfo_SDL_WINDOWPOS_DISPLAY)
+	ZEND_FE(SDL_CreateWindow, arginfo_SDL_CreateWindow)
+		ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow)
+			ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window)
+				ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window)
+					ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window)
+						ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle)
+							ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window)
+								ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window)
+									ZEND_FE(SDL_HideWindow, arginfo_SDL_Window)
+										ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window)
+											ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window)
+												ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window)
+													ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window)
+														ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window)
+															ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode)
+																ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode)
+																	ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window)
+																		ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window)
+																			ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window)
+																				ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon)
+																					ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition)
+																						ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition)
+																							ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition)
+																								ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition)
+																									ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition)
+																										ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition)
+																											ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition)
+																												ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition)
+																													ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered)
+																														ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen)
+																															ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects)
+																																ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab)
+																																	ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window)
+																																		ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness)
+																																			ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window)
+																																				ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp)
+																																					ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window)
+																																						ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape)
+																																							ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode)
+
+																																								ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
+																																									ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
 
 	// Version
-	ZEND_FE(SDL_GetRevision,		arginfo_sdl_version_none)
+	ZEND_FE(SDL_GetRevision, arginfo_sdl_version_none)
 #ifdef HAVE_SDL_GETREVISIONNUMBER
-	ZEND_DEP_FE(SDL_GetRevisionNumber,		arginfo_sdl_version_none)
+		ZEND_DEP_FE(SDL_GetRevisionNumber, arginfo_sdl_version_none)
 #endif
-	ZEND_FE(SDL_GetVersion,			arginfo_SDL_GetVersion)
-	ZEND_FE(SDL_VERSION,			arginfo_SDL_VERSION)
-	ZEND_FE(SDL_VERSIONNUM,			arginfo_SDL_VERSIONNUM)
-	ZEND_FE(SDL_VERSION_ATLEAST,		arginfo_SDL_VERSION_ATLEAST)
+			ZEND_FE(SDL_GetVersion, arginfo_SDL_GetVersion)
+				ZEND_FE(SDL_VERSION, arginfo_SDL_VERSION)
+					ZEND_FE(SDL_VERSIONNUM, arginfo_SDL_VERSIONNUM)
+						ZEND_FE(SDL_VERSION_ATLEAST, arginfo_SDL_VERSION_ATLEAST)
 
 	// Timer
 	ZEND_FE(SDL_Delay, arginfo_SDL_Delay)
@@ -231,237 +210,233 @@ static zend_function_entry sdl_functions[] = {
 	ZEND_FE(SDL_RenderCopyExF, arginfo_SDL_RenderCopyExF)
 
 	// Surface
-	ZEND_FE(SDL_CreateRGBSurface,			arginfo_SDL_CreateRGBSurface)
-	ZEND_FE(SDL_FreeSurface,				arginfo_SDL_Surface)
-	ZEND_FE(SDL_FillRect,					arginfo_SDL_FillRect)
-	ZEND_FE(SDL_FillRects,					arginfo_SDL_FillRects)
-	ZEND_FE(SDL_MUSTLOCK,					arginfo_SDL_Surface)
-	ZEND_FE(SDL_LockSurface,				arginfo_SDL_Surface)
-	ZEND_FE(SDL_UnlockSurface,				arginfo_SDL_Surface)
-	ZEND_FE(SDL_LoadBMP_RW,					arginfo_SDL_LoadBMP_RW)
-	ZEND_FE(SDL_LoadBMP,					arginfo_SDL_LoadBMP)
-	ZEND_FE(SDL_UpperBlit,					arginfo_SDL_UpperBlit)
-	ZEND_FE(SDL_LowerBlit,					arginfo_SDL_LowerBlit)
-	ZEND_FE(SDL_UpperBlitScaled,			arginfo_SDL_UpperBlit)
-	ZEND_FE(SDL_LowerBlitScaled,			arginfo_SDL_LowerBlit)
-	ZEND_FE(SDL_SoftStretch,				arginfo_SDL_UpperBlit)
-	ZEND_FE(SDL_SaveBMP_RW,					arginfo_SDL_SaveBMP_RW)
-	ZEND_FE(SDL_SaveBMP,					arginfo_SDL_SaveBMP)
-	ZEND_FE(SDL_SetSurfaceRLE,				arginfo_SDL_SetSurfaceRLE)
-	ZEND_FE(SDL_SetColorKey,				arginfo_SDL_SetColorKey)
-	ZEND_FE(SDL_GetColorKey,				arginfo_SDL_GetColorKey)
-	ZEND_FE(SDL_SetSurfaceColorMod,			arginfo_SDL_SetSurfaceColorMod)
-	ZEND_FE(SDL_GetSurfaceColorMod,			arginfo_SDL_GetSurfaceColorMod)
-	ZEND_FE(SDL_SetSurfaceAlphaMod,			arginfo_SDL_SetSurfaceAlphaMod)
-	ZEND_FE(SDL_GetSurfaceAlphaMod,			arginfo_SDL_GetSurfaceAlphaMod)
-	ZEND_FE(SDL_SetSurfaceBlendMode,		arginfo_SDL_SetSurfaceBlendMode)
-	ZEND_FE(SDL_GetSurfaceBlendMode,		arginfo_SDL_GetSurfaceBlendMode)
-	ZEND_FE(SDL_SetClipRect,				arginfo_SDL_SetClipRect)
-	ZEND_FE(SDL_GetClipRect,				arginfo_SDL_GetClipRect)
-	ZEND_FE(SDL_ConvertSurface,				arginfo_SDL_ConvertSurface)
-	ZEND_FE(SDL_ConvertSurfaceFormat,		arginfo_SDL_ConvertSurfaceFormat)
-	ZEND_FE(SDL_ConvertPixels,				arginfo_SDL_ConvertPixels)
-	//PHP_FALIAS(SDL_BlitSurface,   SDL_UpperBlit,          arginfo_SDL_UpperBlit)
-	//PHP_FALIAS(SDL_BlitScaled,    SDL_UpperBlitScaled,    arginfo_SDL_UpperBlit)
+	ZEND_FE(SDL_CreateRGBSurface, arginfo_SDL_CreateRGBSurface)
+		ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface)
+			ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect)
+				ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects)
+					ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface)
+						ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface)
+							ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface)
+								ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW)
+									ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP)
+										ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit)
+											ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit)
+												ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit)
+													ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit)
+														ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit)
+															ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW)
+																ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP)
+																	ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE)
+																		ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey)
+																			ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey)
+																				ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod)
+																					ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod)
+																						ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod)
+																							ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod)
+																								ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode)
+																									ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode)
+																										ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect)
+																											ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect)
+																												ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface)
+																													ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat)
+																														ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels)
 
 	// Events
 	ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent)
-	ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent)
+		ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent)
 
 	// Message box
-	ZEND_FE(SDL_ShowSimpleMessageBox,     arginfo_SDL_ShowSimpleMessageBox)
-	ZEND_FE(SDL_ShowMessageBox,           arginfo_SDL_ShowMessageBox)
+	ZEND_FE(SDL_ShowSimpleMessageBox, arginfo_SDL_ShowSimpleMessageBox)
+		ZEND_FE(SDL_ShowMessageBox, arginfo_SDL_ShowMessageBox)
 
 	// Pixels
-	ZEND_FE(SDL_GetPixelFormatName,					arginfo_SDL_GetPixelFormatName)
-	ZEND_FE(SDL_PixelFormatEnumToMasks,				arginfo_SDL_PixelFormatEnumToMasks)
-	ZEND_FE(SDL_MasksToPixelFormatEnum,				arginfo_SDL_MasksToPixelFormatEnum)
-
-	ZEND_FE(SDL_AllocPalette,						arginfo_SDL_AllocPalette)
-	ZEND_FE(SDL_FreePalette,						arginfo_SDL_Palette)
-	ZEND_FE(SDL_SetPaletteColors,					arginfo_SDL_SetPaletteColors)
-
-	ZEND_FE(SDL_AllocFormat,						arginfo_SDL_AllocFormat)
-	ZEND_FE(SDL_FreeFormat,							arginfo_SDL_PixelFormat)
-	ZEND_FE(SDL_SetPixelFormatPalette,				arginfo_SDL_SetPixelFormatPalette)
-	ZEND_FE(SDL_MapRGB,								arginfo_SDL_MapRGB)
-	ZEND_FE(SDL_MapRGBA,							arginfo_SDL_MapRGBA)
-	ZEND_FE(SDL_GetRGB,								arginfo_SDL_GetRGB)
-	ZEND_FE(SDL_GetRGBA,							arginfo_SDL_GetRGBA)
-	ZEND_FE(SDL_CalculateGammaRamp,					arginfo_SDL_CalculateGammaRamp)
+	ZEND_FE(SDL_GetPixelFormatName, arginfo_SDL_GetPixelFormatName)
+		ZEND_FE(SDL_PixelFormatEnumToMasks, arginfo_SDL_PixelFormatEnumToMasks)
+			ZEND_FE(SDL_MasksToPixelFormatEnum, arginfo_SDL_MasksToPixelFormatEnum)
+
+				ZEND_FE(SDL_AllocPalette, arginfo_SDL_AllocPalette)
+					ZEND_FE(SDL_FreePalette, arginfo_SDL_Palette)
+						ZEND_FE(SDL_SetPaletteColors, arginfo_SDL_SetPaletteColors)
+
+							ZEND_FE(SDL_AllocFormat, arginfo_SDL_AllocFormat)
+								ZEND_FE(SDL_FreeFormat, arginfo_SDL_PixelFormat)
+									ZEND_FE(SDL_SetPixelFormatPalette, arginfo_SDL_SetPixelFormatPalette)
+										ZEND_FE(SDL_MapRGB, arginfo_SDL_MapRGB)
+											ZEND_FE(SDL_MapRGBA, arginfo_SDL_MapRGBA)
+												ZEND_FE(SDL_GetRGB, arginfo_SDL_GetRGB)
+													ZEND_FE(SDL_GetRGBA, arginfo_SDL_GetRGBA)
+														ZEND_FE(SDL_CalculateGammaRamp, arginfo_SDL_CalculateGammaRamp)
 
 	// Filesystem
 	ZEND_FE(SDL_GetBasePath, arginfo_SDL_GetBasePath)
-	ZEND_FE(SDL_GetPrefPath, arginfo_SDL_GetPrefPath)
+		ZEND_FE(SDL_GetPrefPath, arginfo_SDL_GetPrefPath)
 
 	// GL
-	ZEND_FE(SDL_GL_ExtensionSupported,                   arginfo_SDL_GL_ExtensionSupported)
-	ZEND_FE(SDL_GL_SetAttribute,                         arginfo_SDL_GL_SetAttribute)
-	ZEND_FE(SDL_GL_GetAttribute,                         arginfo_SDL_GL_GetAttribute)
-	ZEND_FE(SDL_GL_CreateContext,                        arginfo_SDL_GLContext__construct)
-	ZEND_FE(SDL_GL_DeleteContext,                        arginfo_SDL_GL_DeleteContext)
-	ZEND_FE(SDL_GL_MakeCurrent,                          arginfo_SDL_GL_MakeCurrent)
-	ZEND_FE(SDL_GL_GetCurrentWindow,                     arginfo_none)
-	ZEND_FE(SDL_GL_GetCurrentContext,                    arginfo_none)
-#if SDL_VERSION_ATLEAST(2,0,1)
-	ZEND_FE(SDL_GL_GetDrawableSize,                      arginfo_SDL_GL_GetDrawableSize)
+	ZEND_FE(SDL_GL_ExtensionSupported, arginfo_SDL_GL_ExtensionSupported)
+		ZEND_FE(SDL_GL_SetAttribute, arginfo_SDL_GL_SetAttribute)
+			ZEND_FE(SDL_GL_GetAttribute, arginfo_SDL_GL_GetAttribute)
+				ZEND_FE(SDL_GL_CreateContext, arginfo_SDL_GLContext__construct)
+					ZEND_FE(SDL_GL_DeleteContext, arginfo_SDL_GL_DeleteContext)
+						ZEND_FE(SDL_GL_MakeCurrent, arginfo_SDL_GL_MakeCurrent)
+							ZEND_FE(SDL_GL_GetCurrentWindow, arginfo_none)
+								ZEND_FE(SDL_GL_GetCurrentContext, arginfo_none)
+#if SDL_VERSION_ATLEAST(2, 0, 1)
+									ZEND_FE(SDL_GL_GetDrawableSize, arginfo_SDL_GL_GetDrawableSize)
 #endif
-	ZEND_FE(SDL_GL_SwapWindow,                           arginfo_SDL_Window)
-	ZEND_FE(SDL_GL_SetSwapInterval,                      arginfo_SDL_GL_SetSwapInterval)
-	ZEND_FE(SDL_GL_GetSwapInterval,                      arginfo_none)
+										ZEND_FE(SDL_GL_SwapWindow, arginfo_SDL_Window)
+											ZEND_FE(SDL_GL_SetSwapInterval, arginfo_SDL_GL_SetSwapInterval)
+												ZEND_FE(SDL_GL_GetSwapInterval, arginfo_none)
 
 	// CPU info
-	ZEND_FE(SDL_GetCPUCount,				arginfo_cpuinfo_none)
-	ZEND_FE(SDL_GetCPUCacheLineSize,		arginfo_cpuinfo_none)
-	ZEND_FE(SDL_HasRDTSC,					arginfo_cpuinfo_none)
-	ZEND_FE(SDL_HasAltiVec,					arginfo_cpuinfo_none)
-	ZEND_FE(SDL_HasMMX,						arginfo_cpuinfo_none)
-	ZEND_FE(SDL_Has3DNow,					arginfo_cpuinfo_none)
-	ZEND_FE(SDL_HasSSE,						arginfo_cpuinfo_none)
-	ZEND_FE(SDL_HasSSE2,					arginfo_cpuinfo_none)
-	ZEND_FE(SDL_HasSSE3,					arginfo_cpuinfo_none)
-	ZEND_FE(SDL_HasSSE41,					arginfo_cpuinfo_none)
-	ZEND_FE(SDL_HasSSE42,					arginfo_cpuinfo_none)
+	ZEND_FE(SDL_GetCPUCount, arginfo_cpuinfo_none)
+		ZEND_FE(SDL_GetCPUCacheLineSize, arginfo_cpuinfo_none)
+			ZEND_FE(SDL_HasRDTSC, arginfo_cpuinfo_none)
+				ZEND_FE(SDL_HasAltiVec, arginfo_cpuinfo_none)
+					ZEND_FE(SDL_HasMMX, arginfo_cpuinfo_none)
+						ZEND_FE(SDL_Has3DNow, arginfo_cpuinfo_none)
+							ZEND_FE(SDL_HasSSE, arginfo_cpuinfo_none)
+								ZEND_FE(SDL_HasSSE2, arginfo_cpuinfo_none)
+									ZEND_FE(SDL_HasSSE3, arginfo_cpuinfo_none)
+										ZEND_FE(SDL_HasSSE41, arginfo_cpuinfo_none)
+											ZEND_FE(SDL_HasSSE42, arginfo_cpuinfo_none)
 #if SDL_COMPILEDVERSION > 2000
-	ZEND_FE(SDL_GetSystemRAM,				arginfo_cpuinfo_none)
+												ZEND_FE(SDL_GetSystemRAM, arginfo_cpuinfo_none)
 #endif
 
 	// Error handling
-	ZEND_FE(SDL_SetError,     arginfo_SDL_SetError)
-	ZEND_FE(SDL_GetError,     arginfo_error_none)
-	ZEND_FE(SDL_ClearError,   arginfo_error_none)
+	ZEND_FE(SDL_SetError, arginfo_SDL_SetError)
+		ZEND_FE(SDL_GetError, arginfo_error_none)
+			ZEND_FE(SDL_ClearError, arginfo_error_none)
 
 	// Video
-	ZEND_FE(SDL_GetNumVideoDrivers,			arginfo_video_none)
-	ZEND_FE(SDL_GetVideoDriver,				arginfo_SDL_GetVideoDriver)
-	ZEND_FE(SDL_VideoInit,					arginfo_SDL_VideoInit)
-	ZEND_FE(SDL_VideoQuit,					arginfo_video_none)
-	ZEND_FE(SDL_GetCurrentVideoDriver,		arginfo_video_none)
-	ZEND_FE(SDL_GetNumVideoDisplays,		arginfo_video_none)
-	ZEND_FE(SDL_GetDisplayName,				arginfo_SDL_dysplayindex)
-	ZEND_FE(SDL_GetDisplayBounds,			arginfo_SDL_GetDisplayBounds)
-	ZEND_FE(SDL_GetNumDisplayModes,			arginfo_SDL_dysplayindex)
-	ZEND_FE(SDL_GetDisplayMode,				arginfo_SDL_GetDisplayMode)
-	ZEND_FE(SDL_GetDesktopDisplayMode,		arginfo_SDL_dysplayindex)
-	ZEND_FE(SDL_GetCurrentDisplayMode,		arginfo_SDL_dysplayindex)
-	ZEND_FE(SDL_GetClosestDisplayMode,		arginfo_SDL_GetClosestDisplayMode)
-	ZEND_FE(SDL_IsScreenSaverEnabled,		arginfo_video_none)
-	ZEND_FE(SDL_EnableScreenSaver,			arginfo_video_none)
-	ZEND_FE(SDL_DisableScreenSaver,			arginfo_video_none)
+	ZEND_FE(SDL_GetNumVideoDrivers, arginfo_video_none)
+		ZEND_FE(SDL_GetVideoDriver, arginfo_SDL_GetVideoDriver)
+			ZEND_FE(SDL_VideoInit, arginfo_SDL_VideoInit)
+				ZEND_FE(SDL_VideoQuit, arginfo_video_none)
+					ZEND_FE(SDL_GetCurrentVideoDriver, arginfo_video_none)
+						ZEND_FE(SDL_GetNumVideoDisplays, arginfo_video_none)
+							ZEND_FE(SDL_GetDisplayName, arginfo_SDL_dysplayindex)
+								ZEND_FE(SDL_GetDisplayBounds, arginfo_SDL_GetDisplayBounds)
+									ZEND_FE(SDL_GetNumDisplayModes, arginfo_SDL_dysplayindex)
+										ZEND_FE(SDL_GetDisplayMode, arginfo_SDL_GetDisplayMode)
+											ZEND_FE(SDL_GetDesktopDisplayMode, arginfo_SDL_dysplayindex)
+												ZEND_FE(SDL_GetCurrentDisplayMode, arginfo_SDL_dysplayindex)
+													ZEND_FE(SDL_GetClosestDisplayMode, arginfo_SDL_GetClosestDisplayMode)
+														ZEND_FE(SDL_IsScreenSaverEnabled, arginfo_video_none)
+															ZEND_FE(SDL_EnableScreenSaver, arginfo_video_none)
+																ZEND_FE(SDL_DisableScreenSaver, arginfo_video_none)
 
 	// Power
-	ZEND_FE(SDL_GetPowerInfo,	arginfo_SDL_GetPowerInfo)
+	ZEND_FE(SDL_GetPowerInfo, arginfo_SDL_GetPowerInfo)
 
 	// Platform
-	ZEND_FE(SDL_GetPlatform,	arginfo_SDL_GetPlatform)
+	ZEND_FE(SDL_GetPlatform, arginfo_SDL_GetPlatform)
 
 	// Keyboard
-	ZEND_FE(SDL_GetKeyboardFocus,                     arginfo_none)
-	ZEND_FE(SDL_GetKeyboardState,                     arginfo_SDL_GetKeyboardState)
-	ZEND_FE(SDL_GetModState,                          arginfo_none)
-	ZEND_FE(SDL_SetModState,                          arginfo_SDL_SetModState)
-	ZEND_FE(SDL_GetKeyFromScancode,                   arginfo_scancode)
-	ZEND_FE(SDL_GetScancodeFromKey,                   arginfo_key)
-	ZEND_FE(SDL_GetScancodeName,                      arginfo_scancode)
-	ZEND_FE(SDL_GetScancodeFromName,                  arginfo_name)
-	ZEND_FE(SDL_GetKeyName,                           arginfo_key)
-	ZEND_FE(SDL_GetKeyFromName,                       arginfo_name)
-	ZEND_FE(SDL_StartTextInput,                       arginfo_none)
-	ZEND_FE(SDL_IsTextInputActive,                    arginfo_none)
-	ZEND_FE(SDL_StopTextInput,                        arginfo_none)
-	ZEND_FE(SDL_SetTextInputRect,                     arginfo_SDL_SetTextInputRect)
-	ZEND_FE(SDL_HasScreenKeyboardSupport,             arginfo_none)
-	ZEND_FE(SDL_IsScreenKeyboardShown,                arginfo_SDL_IsScreenKeyboardShown)
+	ZEND_FE(SDL_GetKeyboardFocus, arginfo_none)
+		ZEND_FE(SDL_GetKeyboardState, arginfo_SDL_GetKeyboardState)
+			ZEND_FE(SDL_GetModState, arginfo_none)
+				ZEND_FE(SDL_SetModState, arginfo_SDL_SetModState)
+					ZEND_FE(SDL_GetKeyFromScancode, arginfo_scancode)
+						ZEND_FE(SDL_GetScancodeFromKey, arginfo_key)
+							ZEND_FE(SDL_GetScancodeName, arginfo_scancode)
+								ZEND_FE(SDL_GetScancodeFromName, arginfo_name)
+									ZEND_FE(SDL_GetKeyName, arginfo_key)
+										ZEND_FE(SDL_GetKeyFromName, arginfo_name)
+											ZEND_FE(SDL_StartTextInput, arginfo_none)
+												ZEND_FE(SDL_IsTextInputActive, arginfo_none)
+													ZEND_FE(SDL_StopTextInput, arginfo_none)
+														ZEND_FE(SDL_SetTextInputRect, arginfo_SDL_SetTextInputRect)
+															ZEND_FE(SDL_HasScreenKeyboardSupport, arginfo_none)
+																ZEND_FE(SDL_IsScreenKeyboardShown, arginfo_SDL_IsScreenKeyboardShown)
 
 	// Mouse/Cursor
-	ZEND_FE(SDL_CreateCursor,                   arginfo_SDL_Cursor__construct)
-	ZEND_FE(SDL_CreateSystemCursor,             arginfo_SDL_CreateSystemCursor)
-	ZEND_FE(SDL_CreateColorCursor,              arginfo_SDL_CreateColorCursor)
-	ZEND_FE(SDL_FreeCursor,                     arginfo_SDL_Cursor)
-	ZEND_FE(SDL_SetCursor,                      arginfo_SDL_Cursor)
-	ZEND_FE(SDL_GetCursor,                      arginfo_none)
-	ZEND_FE(SDL_GetDefaultCursor,               arginfo_none)
-	ZEND_FE(SDL_ShowCursor,                     arginfo_SDL_ShowCursor)
-	ZEND_FE(SDL_GetMouseFocus,                  arginfo_none)
-	ZEND_FE(SDL_GetMouseState,                  arginfo_SDL_GetMouseState)
-	ZEND_FE(SDL_GetRelativeMouseState,          arginfo_SDL_GetMouseState)
-	ZEND_FE(SDL_WarpMouseInWindow,              arginfo_SDL_WarpMouseInWindow)
-	ZEND_FE(SDL_SetRelativeMouseMode,           arginfo_SDL_SetRelativeMouseMode)
-	ZEND_FE(SDL_GetRelativeMouseMode,           arginfo_none)
+	ZEND_FE(SDL_CreateCursor, arginfo_SDL_Cursor__construct)
+		ZEND_FE(SDL_CreateSystemCursor, arginfo_SDL_CreateSystemCursor)
+			ZEND_FE(SDL_CreateColorCursor, arginfo_SDL_CreateColorCursor)
+				ZEND_FE(SDL_FreeCursor, arginfo_SDL_Cursor)
+					ZEND_FE(SDL_SetCursor, arginfo_SDL_Cursor)
+						ZEND_FE(SDL_GetCursor, arginfo_none)
+							ZEND_FE(SDL_GetDefaultCursor, arginfo_none)
+								ZEND_FE(SDL_ShowCursor, arginfo_SDL_ShowCursor)
+									ZEND_FE(SDL_GetMouseFocus, arginfo_none)
+										ZEND_FE(SDL_GetMouseState, arginfo_SDL_GetMouseState)
+											ZEND_FE(SDL_GetRelativeMouseState, arginfo_SDL_GetMouseState)
+												ZEND_FE(SDL_WarpMouseInWindow, arginfo_SDL_WarpMouseInWindow)
+													ZEND_FE(SDL_SetRelativeMouseMode, arginfo_SDL_SetRelativeMouseMode)
+														ZEND_FE(SDL_GetRelativeMouseMode, arginfo_none)
 
 	// Mutex
-	ZEND_FE(SDL_CreateMutex,                        arginfo_none)
-	ZEND_FE(SDL_LockMutex,                          arginfo_SDL_mutex)
-	ZEND_FE(SDL_TryLockMutex,                       arginfo_SDL_mutex)
-	ZEND_FE(SDL_UnlockMutex,                        arginfo_SDL_mutex)
-	ZEND_FE(SDL_DestroyMutex,                       arginfo_SDL_mutex)
+	ZEND_FE(SDL_CreateMutex, arginfo_none)
+		ZEND_FE(SDL_LockMutex, arginfo_SDL_mutex)
+			ZEND_FE(SDL_TryLockMutex, arginfo_SDL_mutex)
+				ZEND_FE(SDL_UnlockMutex, arginfo_SDL_mutex)
+					ZEND_FE(SDL_DestroyMutex, arginfo_SDL_mutex)
 
 	/* mutex aliases */
-	PHP_FALIAS(SDL_mutexP,      SDL_LockMutex,      arginfo_SDL_mutex)
-	PHP_FALIAS(SDL_mutexV,      SDL_UnlockMutex,    arginfo_SDL_mutex)
+	PHP_FALIAS(SDL_mutexP, SDL_LockMutex, arginfo_SDL_mutex)
+		PHP_FALIAS(SDL_mutexV, SDL_UnlockMutex, arginfo_SDL_mutex)
 
 	/* semaphore functions */
-	ZEND_FE(SDL_CreateSemaphore,                    arginfo_SDL_sem__construct)
-	ZEND_FE(SDL_SemWait,                            arginfo_SDL_sem)
-	ZEND_FE(SDL_SemTryWait,                         arginfo_SDL_sem)
-	ZEND_FE(SDL_SemPost,                            arginfo_SDL_sem)
-	ZEND_FE(SDL_SemValue,                           arginfo_SDL_sem)
-	ZEND_FE(SDL_SemWaitTimeout,                     arginfo_SDL_SemWaitTimeout)
-	ZEND_FE(SDL_DestroySemaphore,                   arginfo_SDL_sem)
+	ZEND_FE(SDL_CreateSemaphore, arginfo_SDL_sem__construct)
+		ZEND_FE(SDL_SemWait, arginfo_SDL_sem)
+			ZEND_FE(SDL_SemTryWait, arginfo_SDL_sem)
+				ZEND_FE(SDL_SemPost, arginfo_SDL_sem)
+					ZEND_FE(SDL_SemValue, arginfo_SDL_sem)
+						ZEND_FE(SDL_SemWaitTimeout, arginfo_SDL_SemWaitTimeout)
+							ZEND_FE(SDL_DestroySemaphore, arginfo_SDL_sem)
 
 	/* condition functions */
-	ZEND_FE(SDL_CreateCond,                         arginfo_none)
-	ZEND_FE(SDL_CondWait,                           arginfo_SDL_CondWait)
-	ZEND_FE(SDL_CondSignal,                         arginfo_SDL_cond)
-	ZEND_FE(SDL_CondBroadcast,                      arginfo_SDL_cond)
-	ZEND_FE(SDL_CondWaitTimeout,                    arginfo_SDL_CondWaitTimeout)
-	ZEND_FE(SDL_DestroyCond,                        arginfo_SDL_cond)
+	ZEND_FE(SDL_CreateCond, arginfo_none)
+		ZEND_FE(SDL_CondWait, arginfo_SDL_CondWait)
+			ZEND_FE(SDL_CondSignal, arginfo_SDL_cond)
+				ZEND_FE(SDL_CondBroadcast, arginfo_SDL_cond)
+					ZEND_FE(SDL_CondWaitTimeout, arginfo_SDL_CondWaitTimeout)
+						ZEND_FE(SDL_DestroyCond, arginfo_SDL_cond)
 
 	// Joystick
 	ZEND_FE(SDL_NumJoysticks, arginfo_SDL_NumJoysticks)
-	ZEND_FE(SDL_JoystickOpen, arginfo_SDL_JoystickOpen)
-	ZEND_FE(SDL_JoystickClose, arginfo_SDL_JoystickClose)
-	ZEND_FE(SDL_JoystickNumButtons, arginfo_SDL_JoystickNumButtons)
-	ZEND_FE(SDL_JoystickName, arginfo_SDL_JoystickName)
-	ZEND_FE(SDL_JoystickGetAxis, arginfo_SDL_JoystickGetAxis)
-	ZEND_FE(SDL_JoystickNameForIndex, arginfo_SDL_JoystickNameForIndex)
-	ZEND_FE(SDL_IsGameController, arginfo_SDL_IsGameController)
+		ZEND_FE(SDL_JoystickOpen, arginfo_SDL_JoystickOpen)
+			ZEND_FE(SDL_JoystickClose, arginfo_SDL_JoystickClose)
+				ZEND_FE(SDL_JoystickNumButtons, arginfo_SDL_JoystickNumButtons)
+					ZEND_FE(SDL_JoystickName, arginfo_SDL_JoystickName)
+						ZEND_FE(SDL_JoystickGetAxis, arginfo_SDL_JoystickGetAxis)
+							ZEND_FE(SDL_JoystickNameForIndex, arginfo_SDL_JoystickNameForIndex)
+								ZEND_FE(SDL_IsGameController, arginfo_SDL_IsGameController)
 
 	// Rwops
-	ZEND_FE(SDL_AllocRW,                      arginfo_none)
-	ZEND_FE(SDL_FreeRW,                       arginfo_SDL_RWops)
-	ZEND_FE(SDL_RWFromFile,                   arginfo_SDL_RWFromFile)
-	ZEND_FE(SDL_RWFromFP,                     arginfo_SDL_RWFromFP)
-	ZEND_FE(SDL_RWFromMem,                    arginfo_SDL_RWFromMem)
-	ZEND_FE(SDL_RWFromConstMem,               arginfo_SDL_RWFromConstMem)
-	ZEND_FE(SDL_RWsize,                       arginfo_SDL_RWops)
-	ZEND_FE(SDL_RWseek,                       arginfo_SDL_RWseek)
-	ZEND_FE(SDL_RWtell,                       arginfo_SDL_RWops)
-	ZEND_FE(SDL_RWread,                       arginfo_SDL_RWread)
-	ZEND_FE(SDL_RWwrite,                      arginfo_SDL_RWwrite)
-	ZEND_FE(SDL_RWclose,                      arginfo_SDL_RWops)
-	ZEND_FE(SDL_ReadU8,                       arginfo_SDL_RWops)
-	ZEND_FE(SDL_ReadLE16,                     arginfo_SDL_RWops)
-	ZEND_FE(SDL_ReadBE16,                     arginfo_SDL_RWops)
-	ZEND_FE(SDL_ReadLE32,                     arginfo_SDL_RWops)
-	ZEND_FE(SDL_ReadBE32,                     arginfo_SDL_RWops)
+	ZEND_FE(SDL_AllocRW, arginfo_none)
+		ZEND_FE(SDL_FreeRW, arginfo_SDL_RWops)
+			ZEND_FE(SDL_RWFromFile, arginfo_SDL_RWFromFile)
+				ZEND_FE(SDL_RWFromFP, arginfo_SDL_RWFromFP)
+					ZEND_FE(SDL_RWFromMem, arginfo_SDL_RWFromMem)
+						ZEND_FE(SDL_RWFromConstMem, arginfo_SDL_RWFromConstMem)
+							ZEND_FE(SDL_RWsize, arginfo_SDL_RWops)
+								ZEND_FE(SDL_RWseek, arginfo_SDL_RWseek)
+									ZEND_FE(SDL_RWtell, arginfo_SDL_RWops)
+										ZEND_FE(SDL_RWread, arginfo_SDL_RWread)
+											ZEND_FE(SDL_RWwrite, arginfo_SDL_RWwrite)
+												ZEND_FE(SDL_RWclose, arginfo_SDL_RWops)
+													ZEND_FE(SDL_ReadU8, arginfo_SDL_RWops)
+														ZEND_FE(SDL_ReadLE16, arginfo_SDL_RWops)
+															ZEND_FE(SDL_ReadBE16, arginfo_SDL_RWops)
+																ZEND_FE(SDL_ReadLE32, arginfo_SDL_RWops)
+																	ZEND_FE(SDL_ReadBE32, arginfo_SDL_RWops)
 #if SIZEOF_LONG > 4
-	ZEND_FE(SDL_ReadLE64,                     arginfo_SDL_RWops)
-	ZEND_FE(SDL_ReadBE64,                     arginfo_SDL_RWops)
+																		ZEND_FE(SDL_ReadLE64, arginfo_SDL_RWops)
+																			ZEND_FE(SDL_ReadBE64, arginfo_SDL_RWops)
 #endif
-	ZEND_FE(SDL_WriteU8,                      arginfo_SDL_write)
-	ZEND_FE(SDL_WriteLE16,                    arginfo_SDL_write)
-	ZEND_FE(SDL_WriteBE16,                    arginfo_SDL_write)
-	ZEND_FE(SDL_WriteLE32,                    arginfo_SDL_write)
-	ZEND_FE(SDL_WriteBE32,                    arginfo_SDL_write)
+																				ZEND_FE(SDL_WriteU8, arginfo_SDL_write)
+																					ZEND_FE(SDL_WriteLE16, arginfo_SDL_write)
+																						ZEND_FE(SDL_WriteBE16, arginfo_SDL_write)
+																							ZEND_FE(SDL_WriteLE32, arginfo_SDL_write)
+																								ZEND_FE(SDL_WriteBE32, arginfo_SDL_write)
 #if SIZEOF_LONG > 4
-	ZEND_FE(SDL_WriteLE64,                    arginfo_SDL_write)
-	ZEND_FE(SDL_WriteBE64,                    arginfo_SDL_write)
+																									ZEND_FE(SDL_WriteLE64, arginfo_SDL_write)
+																										ZEND_FE(SDL_WriteBE64, arginfo_SDL_write)
 #endif
 
-
-	ZEND_FE_END
-};
+																											ZEND_FE_END};
 /* }}} */
 
 /* {{{ sdl_module_entry
@@ -472,14 +447,13 @@ zend_module_entry sdl_module_entry = {
 	NULL,
 	"SDL",
 	sdl_functions,
-	PHP_MINIT(sdl),     /* Replace with NULL if there is nothing to do at php startup   */
+	PHP_MINIT(sdl),		/* Replace with NULL if there is nothing to do at php startup   */
 	PHP_MSHUTDOWN(sdl), /* Replace with NULL if there is nothing to do at php shutdown  */
-	NULL, /* RINIT */
-	NULL, /* RSHUTDOWN */
+	NULL,				/* RINIT */
+	NULL,				/* RSHUTDOWN */
 	PHP_MINFO(sdl),
 	PHP_SDL_VERSION,
-	STANDARD_MODULE_PROPERTIES
-};
+	STANDARD_MODULE_PROPERTIES};
 /* }}} */
 
 /*
diff --git a/src/pixels.c b/src/pixels.c
index 3568551..9f49dd7 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -295,6 +295,9 @@ static PHP_METHOD(SDL_Color, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Color___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_Color::__toString() */
 static PHP_METHOD(SDL_Color, __toString)
 {
@@ -453,6 +456,9 @@ static PHP_METHOD(SDL_PixelFormat, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_PixelFormat___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_PixelFormat::__toString() */
 static PHP_METHOD(SDL_PixelFormat, __toString)
 {
@@ -547,6 +553,9 @@ static PHP_METHOD(SDL_Palette, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Palette___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_Palette::__toString() */
 static PHP_METHOD(SDL_Palette, __toString)
 {
@@ -1055,6 +1064,9 @@ static PHP_METHOD(SDL_Pixels, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Pixels___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_Pixels::__toString() */
 static PHP_METHOD(SDL_Pixels, __toString)
 {
@@ -1636,7 +1648,7 @@ static zval *sdl_pixels_write_property(zend_object *object, zend_string *name, z
 /* {{{ php_sdl_color_methods[] */
 static const zend_function_entry php_sdl_color_methods[] = {
 	PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
-		PHP_ME(SDL_Color, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Color, __toString, arginfo_class_SDL_Color___toString, ZEND_ACC_PUBLIC)
 
 			PHP_FE_END};
 /* }}} */
@@ -1644,12 +1656,12 @@ static const zend_function_entry php_sdl_color_methods[] = {
 /* {{{ php_sdl_palette_methods[] */
 static const zend_function_entry php_sdl_palette_methods[] = {
 	PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_PUBLIC)
-		PHP_ME(SDL_Palette, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
-			PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC)
-				PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists, ZEND_ACC_PUBLIC)
-					PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC)
-						PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC)
-							PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, __toString, arginfo_class_SDL_Palette___toString, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
 	PHP_FALIAS(Free, SDL_FreePalette, arginfo_palette_none)
@@ -1661,9 +1673,9 @@ static const zend_function_entry php_sdl_palette_methods[] = {
 /* {{{ php_sdl_pixelformat_methods[] */
 static const zend_function_entry php_sdl_pixelformat_methods[] = {
 	PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_PUBLIC)
-		PHP_ME(SDL_PixelFormat, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC)
-			PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC)
-				PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_PixelFormat, __toString, arginfo_class_SDL_PixelFormat___toString, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
 	PHP_FALIAS(Free, SDL_FreeFormat, arginfo_format_none)
@@ -1677,15 +1689,15 @@ static const zend_function_entry php_sdl_pixelformat_methods[] = {
 /* {{{ php_sdl_pixels_methods[] */
 static const zend_function_entry php_sdl_pixels_methods[] = {
 	PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC)
-		PHP_ME(SDL_Pixels, __toString, arginfo_format_none, ZEND_ACC_PUBLIC)
-			PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC)
-				PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC)
-					PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC)
-						PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC)
-							PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC)
-								PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC)
-									PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC)
-										PHP_FE_END};
+	PHP_ME(SDL_Pixels, __toString, arginfo_class_SDL_Pixels___toString, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC)
+	PHP_FE_END};
 /* }}} */
 
 #define REGISTER_COLOR_PROP(name) \
diff --git a/src/rwops.c b/src/rwops.c
index af3609b..87485cb 100644
--- a/src/rwops.c
+++ b/src/rwops.c
@@ -142,6 +142,9 @@ static PHP_METHOD(SDL_RWops, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_RWops___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_RWops::__toString() */
 static PHP_METHOD(SDL_RWops, __toString)
 {
@@ -812,7 +815,7 @@ ZEND_END_ARG_INFO()
 /* {{{ sdl_rwops_methods[] */
 static const zend_function_entry php_sdl_rwops_methods[] = {
 	PHP_ME(SDL_RWops,        __construct,       arginfo_rwops_none,    ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_RWops,        __toString,        arginfo_rwops_none,    ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_RWops,        __toString,        arginfo_class_SDL_RWops___toString,    ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
 	PHP_FALIAS(Free,         SDL_FreeRW,        arginfo_rwops_none)
diff --git a/src/shape.c b/src/shape.c
index 2bdf8ec..58c6bd5 100644
--- a/src/shape.c
+++ b/src/shape.c
@@ -138,6 +138,8 @@ static PHP_METHOD(SDL_WindowShapeMode, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_WindowShapeMode___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
 
 /* {{{ proto SDL_WindowShapeMode::__toString() */
 static PHP_METHOD(SDL_WindowShapeMode, __toString)
@@ -172,14 +174,10 @@ static PHP_METHOD(SDL_WindowShapeMode, __toString)
 }
 /* }}} */
 
-/* generic arginfo */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
 /* {{{ php_sdl_windowshapemode_methods[] */
 static const zend_function_entry php_sdl_windowshapemode_methods[] = {
 	PHP_ME(SDL_WindowShapeMode,  __construct,  arginfo_SDL_WindowShapeMode__construct,    ZEND_ACC_CTOR|ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_WindowShapeMode,  __toString,   arginfo_none,                              ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_WindowShapeMode,  __toString,   arginfo_class_SDL_WindowShapeMode___toString, ZEND_ACC_PUBLIC)
 
 	PHP_FE_END
 };
diff --git a/src/surface.c b/src/surface.c
index 76a17f6..ce6f8bb 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -211,6 +211,9 @@ static PHP_METHOD(SDL_Surface, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Surface___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_Surface::__toString() */
 static PHP_METHOD(SDL_Surface, __toString)
 {
@@ -1265,7 +1268,7 @@ PHP_FUNCTION(SDL_ConvertPixels)
 
 static const zend_function_entry php_sdl_surface_methods[] = {
 	PHP_ME(SDL_Surface, __construct, arginfo_SDL_CreateRGBSurface, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
-		PHP_ME(SDL_Surface, __toString, arginfo_surface_none, ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_Surface, __toString, arginfo_class_SDL_Surface___toString, ZEND_ACC_PUBLIC)
 
 	/* non-static methods */
 	PHP_FALIAS(Free, SDL_FreeSurface, arginfo_surface_none)
diff --git a/src/video.c b/src/video.c
index 7e8315d..c77e508 100644
--- a/src/video.c
+++ b/src/video.c
@@ -109,6 +109,9 @@ static PHP_METHOD(SDL_DisplayMode, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_DisplayMode___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_DisplayMode::__toString() */
 static PHP_METHOD(SDL_DisplayMode, __toString)
 {
@@ -525,7 +528,7 @@ PHP_FUNCTION(SDL_DisableScreenSaver)
 /* {{{ php_sdl_displaymode_methods[] */
 static const zend_function_entry php_sdl_displaymode_methods[] = {
 	PHP_ME(SDL_DisplayMode, __construct, arginfo_SDL_DisplayMode__construct, ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_DisplayMode, __toString,  arginfo_video_none,                 ZEND_ACC_PUBLIC)
+	PHP_ME(SDL_DisplayMode, __toString,  arginfo_class_SDL_DisplayMode___toString,                 ZEND_ACC_PUBLIC)
 
 	PHP_FE_END
 };
diff --git a/src/window.c b/src/window.c
index 83d28b1..8ea9c11 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1190,6 +1190,9 @@ static PHP_METHOD(SDL_Window, __construct)
 }
 /* }}} */
 
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Window___toString, 0, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
 /* {{{ proto SDL_Window::__toString() */
 static PHP_METHOD(SDL_Window, __toString)
 {
@@ -1426,7 +1429,7 @@ PHP_FUNCTION(SDL_GetShapedWindowMode)
 
 static const zend_function_entry php_sdl_window_methods[] = {
 	PHP_ME(SDL_Window, __construct, arginfo_SDL_CreateWindow, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
-		PHP_ME(SDL_Window, __toString, arginfo_window_none, ZEND_ACC_PUBLIC)
+		PHP_ME(SDL_Window, __toString, arginfo_class_SDL_Window___toString, ZEND_ACC_PUBLIC)
 
 	/* non-static functions */
 	PHP_FALIAS(UpdateSurface, SDL_UpdateWindowSurface, arginfo_window_none)

From ee620e64e12265bc523784b2e278dc9e6bd2b30a Mon Sep 17 00:00:00 2001
From: Shish <webmaster@shishnet.org>
Date: Tue, 27 Dec 2022 23:25:54 +0000
Subject: [PATCH 48/53] Add some functions (#69)

* SDL_SetHint + SDL_HINT_RENDER_SCALE_QUALITY

* SDL_RenderSetLogicalSize

* SDL_CreateSoftwareRenderer

* SDL_UpdateTexture

Co-authored-by: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
---
 examples/005-draw-rectangle.php |   2 +
 src/php_sdl.c                   | 144 ++++++++++++++++----------------
 src/render.c                    |  75 +++++++++++++++--
 src/render.h                    |  20 +++++
 src/sdl.c                       |  20 +++++
 src/sdl.h                       |   7 ++
 6 files changed, 189 insertions(+), 79 deletions(-)

diff --git a/examples/005-draw-rectangle.php b/examples/005-draw-rectangle.php
index a42b230..3fa7611 100644
--- a/examples/005-draw-rectangle.php
+++ b/examples/005-draw-rectangle.php
@@ -6,6 +6,8 @@
 
 $window = SDL_CreateWindow('Primitive drawing example', SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
 $renderer = SDL_CreateRenderer($window, 0, SDL_RENDERER_SOFTWARE);
+SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
+SDL_RenderSetLogicalSize($renderer, 640, 480);
 
 SDL_SetRenderDrawColor($renderer, 255, 0, 0, 255);
 SDL_RenderClear($renderer);
diff --git a/src/php_sdl.c b/src/php_sdl.c
index c902860..cadb867 100644
--- a/src/php_sdl.c
+++ b/src/php_sdl.c
@@ -125,50 +125,51 @@ static zend_function_entry sdl_functions[] = {
 	ZEND_FE(SDL_Quit,						arginfo_SDL_Quit)
 	ZEND_FE(SDL_QuitSubSystem,				arginfo_SDL_QuitSubSystem)
 	ZEND_FE(SDL_WasInit,					arginfo_SDL_WasInit)
+	ZEND_FE(SDL_SetHint,					arginfo_SDL_SetHint)
 
 	// Window
 	ZEND_FE(SDL_CreateWindow, arginfo_SDL_CreateWindow)
-		ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow)
-			ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window)
-				ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window)
-					ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window)
-						ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle)
-							ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window)
-								ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window)
-									ZEND_FE(SDL_HideWindow, arginfo_SDL_Window)
-										ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window)
-											ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window)
-												ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window)
-													ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window)
-														ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window)
-															ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode)
-																ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode)
-																	ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window)
-																		ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window)
-																			ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window)
-																				ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon)
-																					ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition)
-																						ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition)
-																							ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition)
-																								ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition)
-																									ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition)
-																										ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition)
-																											ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition)
-																												ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition)
-																													ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered)
-																														ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen)
-																															ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects)
-																																ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab)
-																																	ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window)
-																																		ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness)
-																																			ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window)
-																																				ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp)
-																																					ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window)
-																																						ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape)
-																																							ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode)
-
-																																								ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
-																																									ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
+	ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow)
+	ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window)
+	ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window)
+	ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window)
+	ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle)
+	ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window)
+	ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window)
+	ZEND_FE(SDL_HideWindow, arginfo_SDL_Window)
+	ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window)
+	ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window)
+	ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window)
+	ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window)
+	ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window)
+	ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode)
+	ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode)
+	ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window)
+	ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window)
+	ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window)
+	ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon)
+	ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition)
+	ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition)
+	ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition)
+	ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition)
+	ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition)
+	ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition)
+	ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition)
+	ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition)
+	ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered)
+	ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen)
+	ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects)
+	ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab)
+	ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window)
+	ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness)
+	ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window)
+	ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp)
+	ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window)
+	ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape)
+	ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode)
+
+	ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
+	ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY)
 
 	// Version
 	ZEND_FE(SDL_GetRevision, arginfo_sdl_version_none)
@@ -185,6 +186,7 @@ static zend_function_entry sdl_functions[] = {
 
 	// Render
 	ZEND_FE(SDL_CreateRenderer, arginfo_SDL_CreateRenderer)
+	ZEND_FE(SDL_CreateSoftwareRenderer, arginfo_SDL_CreateSoftwareRenderer)
 	ZEND_FE(SDL_DestroyRenderer, arginfo_SDL_DestroyRenderer)
 	ZEND_FE(SDL_DestroyTexture, arginfo_SDL_DestroyTexture)
 	ZEND_FE(SDL_SetRenderDrawColor, arginfo_SDL_SetRenderDrawColor)
@@ -198,8 +200,10 @@ static zend_function_entry sdl_functions[] = {
 	ZEND_FE(SDL_RenderPresent, arginfo_SDL_RenderPresent)
 	ZEND_FE(SDL_CreateTextureFromSurface, arginfo_SDL_CreateTextureFromSurface)
 	ZEND_FE(SDL_CreateTexture, arginfo_SDL_CreateTexture)
+	ZEND_FE(SDL_UpdateTexture, arginfo_SDL_UpdateTexture)
 	ZEND_FE(SDL_QueryTexture, arginfo_SDL_QueryTexture)
 	ZEND_FE(SDL_SetRenderTarget, arginfo_SDL_SetRenderTarget)
+	ZEND_FE(SDL_RenderSetLogicalSize, arginfo_SDL_RenderSetLogicalSize)
 	ZEND_FE(SDL_GetRendererOutputSize, arginfo_SDL_GetRendererOutputSize)
 
 	ZEND_FE(SDL_RenderDrawPointF, arginfo_SDL_RenderDrawPointF)
@@ -211,35 +215,35 @@ static zend_function_entry sdl_functions[] = {
 
 	// Surface
 	ZEND_FE(SDL_CreateRGBSurface, arginfo_SDL_CreateRGBSurface)
-		ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface)
-			ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect)
-				ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects)
-					ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface)
-						ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface)
-							ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface)
-								ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW)
-									ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP)
-										ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit)
-											ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit)
-												ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit)
-													ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit)
-														ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit)
-															ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW)
-																ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP)
-																	ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE)
-																		ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey)
-																			ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey)
-																				ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod)
-																					ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod)
-																						ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod)
-																							ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod)
-																								ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode)
-																									ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode)
-																										ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect)
-																											ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect)
-																												ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface)
-																													ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat)
-																														ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels)
+	ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface)
+	ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect)
+	ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects)
+	ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface)
+	ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface)
+	ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface)
+	ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW)
+	ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP)
+	ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit)
+	ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit)
+	ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit)
+	ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit)
+	ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit)
+	ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW)
+	ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP)
+	ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE)
+	ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey)
+	ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey)
+	ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod)
+	ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod)
+	ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod)
+	ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod)
+	ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode)
+	ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode)
+	ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect)
+	ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect)
+	ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface)
+	ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat)
+	ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels)
 
 	// Events
 	ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent)
diff --git a/src/render.c b/src/render.c
index 54f7b9a..3a31ca4 100644
--- a/src/render.c
+++ b/src/render.c
@@ -18,6 +18,7 @@
 #include "render.h"
 #include "window.h"
 #include "surface.h"
+#include "pixels.h"
 #include "rect.h"
 
 #define SDL_RENDERER_RES_NAME "SDL Renderer"
@@ -210,6 +211,35 @@ PHP_FUNCTION(SDL_CreateTexture)
 	}
 }
 
+PHP_FUNCTION(SDL_UpdateTexture)
+{
+	zval *z_texture, *z_rect, *z_pixels;
+	zend_long pitch;
+
+	SDL_Rect def_rect;
+	SDL_Rect *rect = NULL;
+	SDL_Texture *texture = NULL;
+	SDL_Pixels *pixels;
+
+	if( zend_parse_parameters(ZEND_NUM_ARGS(), "zO!Ol", &z_texture, &z_rect, get_php_sdl_rect_ce(), &z_pixels, get_php_sdl_pixels_ce(), &pitch ) == FAILURE ) {
+		WRONG_PARAM_COUNT;
+	}
+	if(z_rect != NULL && Z_TYPE_P(z_rect) != IS_NULL) {
+		rect = &def_rect;
+		zval_to_sdl_rect(z_rect, rect);
+	}
+
+	if (!(pixels = zval_to_sdl_pixels(z_pixels)))
+	{
+		php_error_docref(NULL, E_WARNING, "Invalid source SDL_Pixels object");
+	}
+	texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);
+
+	if( texture ) {
+		RETURN_LONG(SDL_UpdateTexture(texture, rect, pixels, pitch));
+	}
+}
+
 PHP_FUNCTION(SDL_SetRenderTarget)
 {
 	zval *z_renderer, *z_texture;
@@ -247,6 +277,24 @@ PHP_FUNCTION(SDL_CreateRenderer)
 	RETURN_RES(zend_register_resource(renderer, le_sdl_renderer));
 }
 
+PHP_FUNCTION(SDL_CreateSoftwareRenderer)
+{
+	zval *z_surface;
+	SDL_Surface *surface = NULL;
+	SDL_Renderer *renderer = NULL;
+
+	if( zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_surface, get_php_sdl_surface_ce()) == FAILURE ) {
+		WRONG_PARAM_COUNT;
+	}
+
+	if( z_surface != NULL ) {
+		surface = zval_to_sdl_surface(z_surface);
+	}
+
+	renderer = SDL_CreateSoftwareRenderer(surface);
+	RETURN_RES(zend_register_resource(renderer, le_sdl_renderer));
+}
+
 PHP_FUNCTION(SDL_RenderCopy)
 {
 	zval *z_renderer, *z_texture;
@@ -312,6 +360,21 @@ PHP_FUNCTION(SDL_RenderCopyEx)
 	RETURN_LONG(SDL_RenderCopyEx(renderer, texture, srcrect, dstrect, angle, center, (Uint32)flip));
 }
 
+PHP_FUNCTION(SDL_RenderSetLogicalSize)
+{
+	zval *z_renderer;
+	zend_long w, h;
+	SDL_Renderer *renderer;
+
+	if( zend_parse_parameters(ZEND_NUM_ARGS(), "zll", &z_renderer, &w, &h) == FAILURE ) {
+		WRONG_PARAM_COUNT;
+	}
+
+    renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
+
+	RETURN_LONG(SDL_RenderSetLogicalSize(renderer, w, h));
+}
+
 PHP_FUNCTION(SDL_GetRendererOutputSize)
 {
 	zval *z_renderer, *z_width=NULL, *z_height=NULL;
@@ -384,14 +447,13 @@ PHP_FUNCTION(SDL_RenderDrawLineF)
 	double x1, y1, x2, y2;
 
 	ZEND_PARSE_PARAMETERS_START(5, 5);
-		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
 		Z_PARAM_ZVAL(RENDERER)
 		Z_PARAM_DOUBLE(x1)
 		Z_PARAM_DOUBLE(y1)
 		Z_PARAM_DOUBLE(x2)
 		Z_PARAM_DOUBLE(y2)
 	ZEND_PARSE_PARAMETERS_END();
-	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
+
 	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
 
 	int result = SDL_RenderDrawLineF(renderer, (float) x1, (float) y1, (float) x2, (float) y2);
@@ -407,11 +469,10 @@ PHP_FUNCTION(SDL_RenderDrawRectF)
 	SDL_FRect rect;
 
 	ZEND_PARSE_PARAMETERS_START(2, 2);
-		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
 		Z_PARAM_ZVAL(RENDERER)
 		Z_PARAM_OBJECT_OF_CLASS(RECT, get_php_sdl_frect_ce())
 	ZEND_PARSE_PARAMETERS_END();
-	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
+
 	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
 	zval_to_sdl_frect(RECT, &rect);
 	int result = SDL_RenderDrawRectF(renderer, (const SDL_FRect*) &rect);
@@ -426,11 +487,9 @@ PHP_FUNCTION(SDL_RenderFillRectF)
 	SDL_FRect rect;
 
 	ZEND_PARSE_PARAMETERS_START(2, 2);
-		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
 		Z_PARAM_ZVAL(RENDERER)
 		Z_PARAM_OBJECT_OF_CLASS(RECT, get_php_sdl_frect_ce())
 	ZEND_PARSE_PARAMETERS_END();
-	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
 	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
 	zval_to_sdl_frect(RECT, &rect);
 	int result = SDL_RenderFillRectF(renderer, (const SDL_FRect*) &rect);
@@ -449,14 +508,12 @@ PHP_FUNCTION(SDL_RenderCopyF)
 	SDL_FRect def_dstrect;
 
 	ZEND_PARSE_PARAMETERS_START(4, 4);
-		//Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce)
 		Z_PARAM_ZVAL(RENDERER)
-		// Z_PARAM_OBJECT_OF_CLASS(TEXTURE, sdl_texture_ce)
 		Z_PARAM_ZVAL(TEXTURE)
 		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(SRCRECT, get_php_sdl_rect_ce())
 		Z_PARAM_OBJECT_OF_CLASS_OR_NULL(DSTRECT, get_php_sdl_frect_ce())
 	ZEND_PARSE_PARAMETERS_END();
-	//renderer = php_sdl_renderer_from_zval_p(RENDERER);
+
 	renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer);
 	texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(TEXTURE), SDL_TEXTURE_RES_NAME, le_sdl_texture);
 
diff --git a/src/render.h b/src/render.h
index 10ef166..11da7f8 100644
--- a/src/render.h
+++ b/src/render.h
@@ -85,6 +85,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTexture, 0, 0, 5)
 	ZEND_ARG_INFO(0, h)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_UpdateTexture, 0, 0, 4)
+	ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
+	ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 1)
+    ZEND_ARG_OBJ_INFO(0, pixels, SDL_Pixels, 0)
+	ZEND_ARG_INFO(0, pitch)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 1)
 	ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
 	ZEND_ARG_TYPE_INFO(1, format, IS_LONG, 1)
@@ -104,6 +111,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateRenderer, 0, 0, 3)
 	ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateSoftwareRenderer, 0, 0, 1)
+	ZEND_ARG_OBJ_INFO(0, surface, SDL_Surface, 0)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderCopy, 0, 0, 4)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_INFO(0, texture)
@@ -121,6 +132,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderCopyEx, 0, 0, 7)
 	ZEND_ARG_INFO(0, flip)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderSetLogicalSize, 0, 0, 3)
+	ZEND_ARG_INFO(0, renderer)
+	ZEND_ARG_INFO(0, w)
+	ZEND_ARG_INFO(0, h)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetRendererOutputSize, 0, 0, 3)
 	ZEND_ARG_INFO(0, renderer)
 	ZEND_ARG_INFO(1, w)
@@ -176,11 +193,14 @@ PHP_FUNCTION(SDL_RenderPresent);
 PHP_FUNCTION(SDL_RenderDrawPoint);
 PHP_FUNCTION(SDL_CreateTextureFromSurface);
 PHP_FUNCTION(SDL_CreateTexture);
+PHP_FUNCTION(SDL_UpdateTexture);
 PHP_FUNCTION(SDL_QueryTexture);
 PHP_FUNCTION(SDL_SetRenderTarget);
 PHP_FUNCTION(SDL_CreateRenderer);
+PHP_FUNCTION(SDL_CreateSoftwareRenderer);
 PHP_FUNCTION(SDL_RenderCopy);
 PHP_FUNCTION(SDL_RenderCopyEx);
+PHP_FUNCTION(SDL_RenderSetLogicalSize);
 PHP_FUNCTION(SDL_GetRendererOutputSize);
 ZEND_FUNCTION(SDL_RenderDrawPointF);
 ZEND_FUNCTION(SDL_RenderDrawLineF);
diff --git a/src/sdl.c b/src/sdl.c
index 65f0118..5270028 100644
--- a/src/sdl.c
+++ b/src/sdl.c
@@ -112,6 +112,24 @@ PHP_FUNCTION(SDL_WasInit) {
 }
 /* }}} */
 
+/* {{{ proto int SDL_SetHint(string hint, string value)
+
+extern DECLSPEC Uint32 SDLCALL SDL_SetHint(char *hint, char *value);
+*/
+PHP_FUNCTION(SDL_SetHint) {
+	char *hint;
+	size_t hint_len;
+	char *value;
+	size_t value_len;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &hint, &hint_len, &value, &value_len) == FAILURE) {
+		RETURN_FALSE;
+	}
+
+	RETURN_LONG(SDL_SetHint(hint, value));
+}
+/* }}} */
+
 /* {{{ PHP_MINIT_FUNCTION */
 PHP_MINIT_FUNCTION(sdl_sdl)
 {
@@ -129,6 +147,8 @@ PHP_MINIT_FUNCTION(sdl_sdl)
 	REGISTER_LONG_CONSTANT("SDL_INIT_NOPARACHUTE",     SDL_INIT_NOPARACHUTE,       CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("SDL_INIT_EVERYTHING",      SDL_INIT_EVERYTHING,        CONST_CS | CONST_PERSISTENT);
 
+	REGISTER_STRING_CONSTANT("SDL_HINT_RENDER_SCALE_QUALITY", SDL_HINT_RENDER_SCALE_QUALITY, CONST_CS | CONST_PERSISTENT);
+
 	return SUCCESS;
 }
 /* }}} */
diff --git a/src/sdl.h b/src/sdl.h
index cd6d4f3..25df540 100644
--- a/src/sdl.h
+++ b/src/sdl.h
@@ -54,6 +54,13 @@ ZEND_END_ARG_INFO()
 
 PHP_FUNCTION(SDL_Quit);
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetHint, 0, 0, 2)
+       ZEND_ARG_INFO(0, flags)
+ZEND_END_ARG_INFO()
+
+PHP_FUNCTION(SDL_SetHint);
+
+
 PHP_MINIT_FUNCTION(sdl_sdl);
 
 #ifdef  __cplusplus

From 932b0a1b1d50affa2fcf04e7c366cc39dc1b85ac Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Fri, 30 Dec 2022 19:11:05 +0000
Subject: [PATCH 49/53] Declare window property on SDL_Event class

---
 src/event.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/event.c b/src/event.c
index 25da33e..c6440d4 100644
--- a/src/event.c
+++ b/src/event.c
@@ -288,6 +288,7 @@ PHP_MINIT_FUNCTION(sdl_event)
 	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("type"), ZEND_ACC_PUBLIC);
 	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("key"), ZEND_ACC_PUBLIC);
 	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("motion"), ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("window"), ZEND_ACC_PUBLIC);
 
 	return SUCCESS;
 }

From 3206f3cffc91aafe31e813996f02ec6be1b8d2b3 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sat, 31 Dec 2022 00:01:07 +0000
Subject: [PATCH 50/53] Fix SDL_UpdateTexture function

---
 src/event.c   |   1 +
 src/pixels.c  | 246 +++-----------------------------------------------
 src/pixels.h  |   2 -
 src/render.c  |   4 +-
 src/render.h  |   8 +-
 src/sdl.c     |   9 +-
 src/sdl.h     |   3 +-
 src/surface.c |  26 +-----
 8 files changed, 32 insertions(+), 267 deletions(-)

diff --git a/src/event.c b/src/event.c
index c6440d4..45942ee 100644
--- a/src/event.c
+++ b/src/event.c
@@ -289,6 +289,7 @@ PHP_MINIT_FUNCTION(sdl_event)
 	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("key"), ZEND_ACC_PUBLIC);
 	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("motion"), ZEND_ACC_PUBLIC);
 	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("window"), ZEND_ACC_PUBLIC);
+	zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("button"), ZEND_ACC_PUBLIC);
 
 	return SUCCESS;
 }
diff --git a/src/pixels.c b/src/pixels.c
index 9f49dd7..50c87a5 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -214,7 +214,8 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags)
 		php_sdl_pixels *intern;
 
 		object_init_ex(z_val, php_sdl_pixels_ce);
-		intern = PHP_SDL_PIXELS_P(z_val);
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (php_sdl_pixels*)((char *)zo - zo->handlers->offset);
 		intern->pixels = *pixels;
 		intern->flags = flags;
 
@@ -242,11 +243,12 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val)
 /* {{{ zval_to_sdl_pixels */
 SDL_Pixels *zval_to_sdl_pixels(zval *z_val)
 {
+	php_sdl_pixels *intern;
+
 	if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce)
 	{
-		php_sdl_pixels *intern;
-
-		intern = PHP_SDL_PIXELS_P(z_val);
+		zend_object *zo = Z_OBJ_P(z_val);
+		intern = (php_sdl_pixels*)((char *)zo - zo->handlers->offset);
 		return &intern->pixels;
 	}
 	return NULL;
@@ -1058,8 +1060,6 @@ static PHP_METHOD(SDL_Pixels, __construct)
 			php_error_docref(NULL, E_NOTICE, "Pitch set to %d", (int)pitch);
 		}
 		intern->pixels.pixels = ecalloc((int)pitch, (int)h);
-		intern->pixels.pitch = (int)pitch;
-		intern->pixels.h = (int)h;
 	}
 }
 /* }}} */
@@ -1070,7 +1070,6 @@ ZEND_END_ARG_INFO()
 /* {{{ proto SDL_Pixels::__toString() */
 static PHP_METHOD(SDL_Pixels, __toString)
 {
-	php_sdl_pixels *intern;
 	char *buf;
 
 	if (zend_parse_parameters_none() == FAILURE)
@@ -1078,179 +1077,11 @@ static PHP_METHOD(SDL_Pixels, __toString)
 		return;
 	}
 
-	intern = PHP_SDL_PIXELS_P(getThis());
-	spprintf(&buf, 100, "SDL_Pixels(%d,%d)", intern->pixels.pitch, intern->pixels.h);
+	spprintf(&buf, 100, "SDL_Pixels");
 	RETVAL_STRING(buf);
 }
 /* }}} */
 
-/* {{{ proto SDL_Pixels, count(void) */
-static PHP_METHOD(SDL_Pixels, count)
-{
-	php_sdl_pixels *intern;
-
-	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters_none() == FAILURE)
-	{
-		return;
-	}
-
-	RETURN_LONG(intern->pixels.h * intern->pixels.pitch);
-}
-/* }}} */
-
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetExists, 0, 1, _IS_BOOL, 0)
-ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto SDL_Pixels, offsetExists(int offset) */
-PHP_METHOD(SDL_Pixels, offsetExists)
-{
-	php_sdl_pixels *intern;
-	zend_long offset;
-
-	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
-	{
-		return;
-	}
-	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch))
-	{
-		RETURN_FALSE;
-	}
-	RETURN_TRUE;
-}
-/* }}} */
-
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetGet, 0, 1, IS_MIXED, 1)
-ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto SDL_Pixels, offsetGet(int offset) */
-PHP_METHOD(SDL_Pixels, offsetGet)
-{
-	php_sdl_pixels *intern;
-	zend_long offset;
-
-	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
-	{
-		return;
-	}
-	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch))
-	{
-		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
-		RETURN_FALSE;
-	}
-	RETVAL_LONG(intern->pixels.pixels[offset]);
-}
-/* }}} */
-
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetUnset, 0, 1, IS_VOID, 0)
-ZEND_ARG_INFO(0, offset)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto SDL_Pixels, offsetUnset(int offset) */
-PHP_METHOD(SDL_Pixels, offsetUnset)
-{
-	php_sdl_pixels *intern;
-	zend_long offset;
-
-	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE)
-	{
-		return;
-	}
-	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch))
-	{
-		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
-		RETURN_FALSE;
-	}
-	intern->pixels.pixels[offset] = 0;
-}
-/* }}} */
-
-ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 2, IS_VOID, 0)
-ZEND_ARG_INFO(0, offset)
-ZEND_ARG_INFO(0, value)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */
-PHP_METHOD(SDL_Pixels, offsetSet)
-{
-	php_sdl_pixels *intern;
-	zend_long offset, value;
-
-	intern = PHP_SDL_PIXELS_P(getThis());
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE)
-	{
-		return;
-	}
-	if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch))
-	{
-		zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0);
-		RETURN_FALSE;
-	}
-	intern->pixels.pixels[offset] = (Uint8)value;
-}
-/* }}} */
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_GetByte, 0, 0, 2)
-ZEND_ARG_INFO(0, x)
-ZEND_ARG_INFO(0, y)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto int SDL_Pixels::GetByte(int x, int y) */
-PHP_METHOD(SDL_Pixels, GetByte)
-{
-	php_sdl_pixels *intern;
-	zval *z_pixels;
-	zend_long x, y;
-
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE)
-	{
-		return;
-	}
-	intern = PHP_SDL_PIXELS_P(z_pixels);
-
-	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h)
-	{
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long)x, (long)y, intern->pixels.pitch, intern->pixels.h);
-		RETURN_FALSE;
-	}
-	RETVAL_LONG(intern->pixels.pixels[y * intern->pixels.pitch + x]);
-}
-/* }}} */
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_SetByte, 0, 0, 3)
-ZEND_ARG_INFO(0, x)
-ZEND_ARG_INFO(0, y)
-ZEND_ARG_INFO(0, byte)
-ZEND_END_ARG_INFO()
-
-/* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */
-PHP_METHOD(SDL_Pixels, SetByte)
-{
-	php_sdl_pixels *intern;
-	zval *z_pixels;
-	zend_long x, y, v;
-
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE)
-	{
-		return;
-	}
-	intern = PHP_SDL_PIXELS_P(z_pixels);
-
-	if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h)
-	{
-		php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long)x, (long)y, intern->pixels.pitch, intern->pixels.h);
-		RETURN_FALSE;
-	}
-	RETVAL_LONG(intern->pixels.pixels[y * intern->pixels.pitch + x]);
-	intern->pixels.pixels[y * intern->pixels.pitch + x] = (Uint8)v;
-}
-/* }}} */
-
 /* {{{ php_sdl_palette_free
  */
 static void php_sdl_palette_free(zend_object *object)
@@ -1584,30 +1415,18 @@ zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int typ
 
 	zval *retval;
 
-	if (!intern->pixels.pixels)
-	{
-		return zend_std_read_property(object, member, type, cache_slot, rv);
-	}
-
 	retval = rv;
 
-	if (!strcmp(member_val, "h"))
+	if (!strcmp(member_val, "pixels"))
 	{
-		ZVAL_LONG(retval, intern->pixels.h);
-	}
-	else if (!strcmp(member_val, "pitch"))
-	{
-		ZVAL_LONG(retval, intern->pixels.pitch);
-	}
-	else if (!strcmp(member_val, "count"))
-	{
-		ZVAL_LONG(retval, intern->pixels.pitch * intern->pixels.h);
+		if (!intern->pixels.pixels)
+		{
+			return zend_std_read_property(object, member, type, cache_slot, rv);
+		}
 	}
 	else
 	{
 		retval = zend_std_read_property(object, member, type, cache_slot, rv);
-
-		return retval;
 	}
 
 	return retval;
@@ -1618,33 +1437,6 @@ zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int typ
 	ZVAL_LONG(&zv, f);                \
 	zend_hash_str_update(props, n, sizeof(n) - 1, &zv);
 
-/* {{{ sdl_pixels_read_properties */
-static HashTable *sdl_pixels_get_properties(zend_object *object)
-{
-	HashTable *props;
-	zval zv;
-	php_sdl_pixels *intern = php_sdl_pixels_from_obj(object);
-
-	props = zend_std_get_properties(object);
-
-	if (intern->pixels.pixels)
-	{
-		SDL_PIXELS_ADD_PROPERTY("pitch", intern->pixels.pitch);
-		SDL_PIXELS_ADD_PROPERTY("h", intern->pixels.h);
-		SDL_PIXELS_ADD_PROPERTY("count", intern->pixels.h * intern->pixels.pitch);
-	}
-	return props;
-}
-/* }}} */
-
-/* {{{ sdl_pixels_write_property */
-static zval *sdl_pixels_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot)
-{
-	php_error_docref(NULL, E_ERROR, "Not supported, SDL_Pixels is read-only");
-	return value;
-}
-/* }}} */
-
 /* {{{ php_sdl_color_methods[] */
 static const zend_function_entry php_sdl_color_methods[] = {
 	PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC)
@@ -1690,13 +1482,6 @@ static const zend_function_entry php_sdl_pixelformat_methods[] = {
 static const zend_function_entry php_sdl_pixels_methods[] = {
 	PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC)
 	PHP_ME(SDL_Pixels, __toString, arginfo_class_SDL_Pixels___toString, ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC)
-	PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC)
 	PHP_FE_END};
 /* }}} */
 
@@ -1772,18 +1557,11 @@ PHP_MINIT_FUNCTION(sdl_pixels)
 	INIT_CLASS_ENTRY(ce_pixels, "SDL_Pixels", php_sdl_pixels_methods);
 	php_sdl_pixels_ce = zend_register_internal_class(&ce_pixels);
 	php_sdl_pixels_ce->create_object = php_sdl_pixels_new;
-	zend_class_implements(php_sdl_pixels_ce, 1, zend_ce_arrayaccess);
 	memcpy(&php_sdl_pixels_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 	php_sdl_pixels_handlers.read_property = sdl_pixels_read_property;
-	php_sdl_pixels_handlers.get_properties = sdl_pixels_get_properties;
-	php_sdl_pixels_handlers.write_property = sdl_pixels_write_property;
 	php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free;
 	php_sdl_pixels_handlers.offset = XtOffsetOf(php_sdl_pixels, zo);
 
-	REGISTER_PIXELS_PROP("pitch");
-	REGISTER_PIXELS_PROP("h");
-	REGISTER_PIXELS_PROP("count");
-
 	/* Pixel type. */
 	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_UNKNOWN", SDL_PIXELTYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX1", SDL_PIXELTYPE_INDEX1, CONST_CS | CONST_PERSISTENT);
diff --git a/src/pixels.h b/src/pixels.h
index 8aedc44..d6b32af 100644
--- a/src/pixels.h
+++ b/src/pixels.h
@@ -28,8 +28,6 @@ extern "C" {
 /* PHP specific struct to manage memory access */
 typedef struct SDL_Pixels
 {
-    int    h;
-    int    pitch;
     Uint8 *pixels;
 } SDL_Pixels;
 
diff --git a/src/render.c b/src/render.c
index 3a31ca4..a48d5ae 100644
--- a/src/render.c
+++ b/src/render.c
@@ -227,16 +227,18 @@ PHP_FUNCTION(SDL_UpdateTexture)
 	if(z_rect != NULL && Z_TYPE_P(z_rect) != IS_NULL) {
 		rect = &def_rect;
 		zval_to_sdl_rect(z_rect, rect);
+		rect = NULL; 
 	}
 
 	if (!(pixels = zval_to_sdl_pixels(z_pixels)))
 	{
 		php_error_docref(NULL, E_WARNING, "Invalid source SDL_Pixels object");
 	}
+
 	texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);
 
 	if( texture ) {
-		RETURN_LONG(SDL_UpdateTexture(texture, rect, pixels, pitch));
+		RETURN_LONG(SDL_UpdateTexture(texture, rect, pixels->pixels, pitch));
 	}
 }
 
diff --git a/src/render.h b/src/render.h
index 11da7f8..a67673f 100644
--- a/src/render.h
+++ b/src/render.h
@@ -89,7 +89,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_UpdateTexture, 0, 0, 4)
 	ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0)
 	ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 1)
     ZEND_ARG_OBJ_INFO(0, pixels, SDL_Pixels, 0)
-	ZEND_ARG_INFO(0, pitch)
+	ZEND_ARG_TYPE_INFO(0, pitch, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 1)
@@ -133,9 +133,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderCopyEx, 0, 0, 7)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderSetLogicalSize, 0, 0, 3)
-	ZEND_ARG_INFO(0, renderer)
-	ZEND_ARG_INFO(0, w)
-	ZEND_ARG_INFO(0, h)
+	ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0)
+	ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0)
+	ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetRendererOutputSize, 0, 0, 3)
diff --git a/src/sdl.c b/src/sdl.c
index 5270028..cde630a 100644
--- a/src/sdl.c
+++ b/src/sdl.c
@@ -122,11 +122,12 @@ PHP_FUNCTION(SDL_SetHint) {
 	char *value;
 	size_t value_len;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &hint, &hint_len, &value, &value_len) == FAILURE) {
-		RETURN_FALSE;
-	}
+	ZEND_PARSE_PARAMETERS_START(2, 2)
+	Z_PARAM_STRING(hint, hint_len)
+	Z_PARAM_STRING(value, value_len)
+	ZEND_PARSE_PARAMETERS_END();
 
-	RETURN_LONG(SDL_SetHint(hint, value));
+	RETURN_LONG(SDL_SetHint(hint, value) == SDL_TRUE);
 }
 /* }}} */
 
diff --git a/src/sdl.h b/src/sdl.h
index 25df540..93e51ae 100644
--- a/src/sdl.h
+++ b/src/sdl.h
@@ -55,7 +55,8 @@ ZEND_END_ARG_INFO()
 PHP_FUNCTION(SDL_Quit);
 
 ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetHint, 0, 0, 2)
-       ZEND_ARG_INFO(0, flags)
+       ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+       ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
 ZEND_END_ARG_INFO()
 
 PHP_FUNCTION(SDL_SetHint);
diff --git a/src/surface.c b/src/surface.c
index ce6f8bb..330ef51 100644
--- a/src/surface.c
+++ b/src/surface.c
@@ -114,7 +114,7 @@ PHP_FUNCTION(SDL_CreateRGBSurface)
 	{
 		return;
 	}
-	surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask);
+	surface = SDL_CreateRGBSurface((Uint32)flags, (int)width, (int)height, (int)depth, (Uint32)rmask, (Uint32)gmask, (Uint32)bmask, (Uint32)amask);
 	sdl_surface_to_zval(surface, return_value);
 }
 /* }}} */
@@ -1228,10 +1228,10 @@ PHP_FUNCTION(SDL_ConvertSurfaceFormat)
 PHP_FUNCTION(SDL_ConvertPixels)
 {
 	zval *z_src, *z_dst;
-	zend_long w, h, sf, sp, df, dp;
+	zend_long w, h, src_format, src_pitch, dst_format, dst_pitch;
 	SDL_Pixels *src, *dst;
 
-	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &sf, &z_src, get_php_sdl_pixels_ce(), &sp, &df, &z_dst, get_php_sdl_pixels_ce(), &dp))
+	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &src_format, &z_src, get_php_sdl_pixels_ce(), &src_pitch, &dst_format, &z_dst, get_php_sdl_pixels_ce(), &dst_pitch))
 	{
 		return;
 	}
@@ -1243,22 +1243,8 @@ PHP_FUNCTION(SDL_ConvertPixels)
 	{
 		php_error_docref(NULL, E_WARNING, "Invalid destination SDL_Pixels object");
 	}
-	if (h < 0 || h > src->h || h > dst->h)
-	{
-		h = (src->h > dst->h ? dst->h : src->h);
-		php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h);
-	}
-	if (sp != src->pitch)
-	{
-		sp = src->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp);
-	}
-	if (dp != dst->pitch)
-	{
-		dp = dst->pitch;
-		php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp);
-	}
-	RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp));
+
+	RETVAL_LONG(SDL_ConvertPixels(w, h, src_format, src->pixels, src_pitch, dst_format, dst->pixels, dst_pitch));
 }
 /* }}} */
 
@@ -1392,8 +1378,6 @@ zval *sdl_surface_read_property(zend_object *object, zend_string *member, int ty
 	else if (!strcmp(member_val, "pixels"))
 	{
 		SDL_Pixels pix;
-		pix.pitch = intern->surface->pitch;
-		pix.h = intern->surface->h;
 		pix.pixels = (Uint8 *)intern->surface->pixels;
 		sdl_pixels_to_zval(&pix, retval, SDL_DONTFREE);
 	}

From 655e403b8a9681c418702a74833c68c1a4ae1bd5 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sat, 31 Dec 2022 15:35:11 +0000
Subject: [PATCH 51/53] Use new parameter parsing method

---
 src/render.c | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/render.c b/src/render.c
index a48d5ae..9314a00 100644
--- a/src/render.c
+++ b/src/render.c
@@ -33,9 +33,13 @@ PHP_FUNCTION(SDL_SetRenderDrawColor)
 	zend_long r, g, b, a;
 	SDL_Renderer *renderer;
 
-	if( zend_parse_parameters(ZEND_NUM_ARGS(), "zllll", &z_renderer, &r, &g, &b, &a) == FAILURE ) {
-		WRONG_PARAM_COUNT;
-	}
+	ZEND_PARSE_PARAMETERS_START(5, 5)
+		Z_PARAM_ZVAL(z_renderer)
+		Z_PARAM_LONG(r)
+		Z_PARAM_LONG(g)
+		Z_PARAM_LONG(b)
+		Z_PARAM_LONG(a)
+	ZEND_PARSE_PARAMETERS_END();
 
     renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
 
@@ -144,9 +148,9 @@ PHP_FUNCTION(SDL_RenderPresent)
 	zval *z_renderer;
 	SDL_Renderer *renderer;
 
-	if( zend_parse_parameters(ZEND_NUM_ARGS(), "z", &z_renderer) == FAILURE ) {
-		WRONG_PARAM_COUNT;
-	}
+	ZEND_PARSE_PARAMETERS_START(1, 1)
+		Z_PARAM_ZVAL(z_renderer)
+	ZEND_PARSE_PARAMETERS_END();
 
     renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
 
@@ -221,9 +225,13 @@ PHP_FUNCTION(SDL_UpdateTexture)
 	SDL_Texture *texture = NULL;
 	SDL_Pixels *pixels;
 
-	if( zend_parse_parameters(ZEND_NUM_ARGS(), "zO!Ol", &z_texture, &z_rect, get_php_sdl_rect_ce(), &z_pixels, get_php_sdl_pixels_ce(), &pitch ) == FAILURE ) {
-		WRONG_PARAM_COUNT;
-	}
+	ZEND_PARSE_PARAMETERS_START(4, 4)
+	Z_PARAM_ZVAL(z_texture)
+	Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_rect, get_php_sdl_rect_ce())
+	Z_PARAM_OBJECT_OF_CLASS(z_pixels, get_php_sdl_pixels_ce())
+	Z_PARAM_LONG(pitch)
+	ZEND_PARSE_PARAMETERS_END();
+
 	if(z_rect != NULL && Z_TYPE_P(z_rect) != IS_NULL) {
 		rect = &def_rect;
 		zval_to_sdl_rect(z_rect, rect);
@@ -306,9 +314,12 @@ PHP_FUNCTION(SDL_RenderCopy)
 	SDL_Rect *srcrect = NULL, *dstrect = NULL;
 	SDL_Rect def_srcrect, def_dstrect;
 
-	if( zend_parse_parameters(ZEND_NUM_ARGS(), "zzO!O!", &z_renderer, &z_texture, &z_srcrect, get_php_sdl_rect_ce(), &z_dstrect, get_php_sdl_rect_ce()) == FAILURE ) {
-		WRONG_PARAM_COUNT;
-	}
+	ZEND_PARSE_PARAMETERS_START(4, 4)
+	Z_PARAM_ZVAL(z_renderer)
+	Z_PARAM_ZVAL(z_texture)
+	Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_srcrect, get_php_sdl_rect_ce())
+	Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_dstrect, get_php_sdl_rect_ce())
+	ZEND_PARSE_PARAMETERS_END();
 
     renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
     texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);

From 107999a668cff872b8cae58682ff47f4b18cebd9 Mon Sep 17 00:00:00 2001
From: Manuel Baldassarri <kea@keasoft.it>
Date: Sun, 6 Aug 2023 22:43:26 +0200
Subject: [PATCH 52/53] Remove invalid tests for SDL_Pixels array access (#73)

---
 tests/014-version.phpt    |  3 ++-
 tests/021-surface-oo.phpt | 16 ++--------------
 tests/022-pixels.phpt     | 38 ++------------------------------------
 3 files changed, 6 insertions(+), 51 deletions(-)

diff --git a/tests/014-version.phpt b/tests/014-version.phpt
index 05889fe..52d45fa 100644
--- a/tests/014-version.phpt
+++ b/tests/014-version.phpt
@@ -26,7 +26,8 @@ var_dump(12030 === SDL_VERSIONNUM(10,20,30));
 var_dump(SDL_VERSION_ATLEAST(2,0,0));
 var_dump(SDL_VERSION_ATLEAST(2,0,25));
 var_dump(is_string(SDL_GetRevision()));
-var_dump(is_integer(SDL_GetRevisionNumber()));
+SDL_GetVersion($linkedVersion);
+var_dump(array_key_exists('major', $linkedVersion) && array_key_exists('minor', $linkedVersion) && array_key_exists('patch', $linkedVersion));
 
 echo '= Done', PHP_EOL;
 ?>
diff --git a/tests/021-surface-oo.phpt b/tests/021-surface-oo.phpt
index f107820..f2b74e6 100644
--- a/tests/021-surface-oo.phpt
+++ b/tests/021-surface-oo.phpt
@@ -61,26 +61,14 @@ string(40) "SDL_Surface(%d,150,100,8,0x0,0x0,0x0,0x0)"
 int(150)
 int(100)
 int(256)
-object(SDL_Pixels)#%d (3) {
-  ["pitch"]=>
-  int(152)
-  ["h"]=>
-  int(100)
-  ["count"]=>
-  int(15200)
+object(SDL_Pixels)#%d (0) {
 }
 = Create True colors
 string(57) "SDL_Surface(%d,150,100,32,0xff000000,0xff0000,0xff00,0xff)"
 int(150)
 int(100)
 NULL
-object(SDL_Pixels)#%d (3) {
-  ["pitch"]=>
-  int(600)
-  ["h"]=>
-  int(100)
-  ["count"]=>
-  int(60000)
+object(SDL_Pixels)#%d (0) {
 }
 = Lock
 bool(false)
diff --git a/tests/022-pixels.phpt b/tests/022-pixels.phpt
index 25f0a88..fd0aa8e 100644
--- a/tests/022-pixels.phpt
+++ b/tests/022-pixels.phpt
@@ -14,19 +14,6 @@ try {
 	echo "Exception: " . $e->getMessage() . "\n";
 }
 var_dump($pix = new SDL_Pixels(10, 10), "$pix");
-echo "= Get/Set\n";
-var_dump($pix->GetByte(15,15));
-var_dump($pix->SetByte(0,0,1));
-var_dump($pix->GetByte(0,0));
-var_dump($pix->SetByte(1,1,255));
-var_dump($pix->GetByte(1,1));
-
-echo "= Array\n";
-var_dump($pix[20], isset($pix[20]), isset($pix[1000]));
-var_dump($pix[20]=127);
-var_dump($pix[20]);
-unset($pix[20]);
-var_dump($pix[20]);
 ?>
 = Done
 --EXPECTF--
@@ -34,28 +21,7 @@ var_dump($pix[20]);
 Exception: Invalid size
 
 Notice: SDL_Pixels::__construct(): Pitch set to 12 in %s%e022-pixels.php on line 8
-object(SDL_Pixels)#%d (3) {
-  ["pitch"]=>
-  int(12)
-  ["h"]=>
-  int(10)
-  ["count"]=>
-  int(120)
+object(SDL_Pixels)#%d (0) {
 }
-string(17) "SDL_Pixels(12,10)"
-= Get/Set
-
-Notice: SDL_Pixels::GetByte(): Invalid position (15,15) in SDL_Pixels (12,10) in %s%e022-pixels.php on line 10
-bool(false)
-int(0)
-int(1)
-int(0)
-int(255)
-= Array
-int(0)
-bool(true)
-bool(false)
-int(127)
-int(127)
-int(0)
+string(10) "SDL_Pixels"
 = Done

From 96a6c7f9a95d1ff8b868656dbc30e08c520541b4 Mon Sep 17 00:00:00 2001
From: Santiago Lizardo <santiagolizardo@users.noreply.github.com>
Date: Sun, 6 Aug 2023 22:14:12 +0100
Subject: [PATCH 53/53] Fix version test

---
 tests/014-version.phpt | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/014-version.phpt b/tests/014-version.phpt
index 52d45fa..31cc82b 100644
--- a/tests/014-version.phpt
+++ b/tests/014-version.phpt
@@ -23,7 +23,6 @@ echo '= Functions', PHP_EOL;
 SDL_VERSION($version);
 var_dump(array_key_exists('major', $version) && array_key_exists('minor', $version) && array_key_exists('patch', $version));
 var_dump(12030 === SDL_VERSIONNUM(10,20,30));
-var_dump(SDL_VERSION_ATLEAST(2,0,0));
 var_dump(SDL_VERSION_ATLEAST(2,0,25));
 var_dump(is_string(SDL_GetRevision()));
 SDL_GetVersion($linkedVersion);
@@ -47,7 +46,6 @@ bool(true)
 bool(true)
 bool(true)
 bool(true)
-bool(false)
 bool(true)
 bool(true)
 = Done
