THRIFT-2712 PHP: add "json" option to create JsonSerializable code

This patch adds a "json" option to PHP code generation that will
make generated classes implement JsonSerializable, so thrift
objects may be converted to json using json_encode() easily.
If the "validate" option is enabled, the object's write validator
will be called, beyond that the jsonSerialize() method only outputs
non-null fields in the JSON object (JSON parsers get grumpy if you
send them null where they expect to see a number).

Patch: Stig Bakken

Github Pull Request: This closes #219
diff --git a/lib/php/test/Makefile.am b/lib/php/test/Makefile.am
index a529d8c..869c544 100755
--- a/lib/php/test/Makefile.am
+++ b/lib/php/test/Makefile.am
@@ -24,25 +24,34 @@
 	$(THRIFT) --gen php -r --out ./packages ../../../test/ThriftTest.thrift
 	mkdir -p ./packages/phpv
 	mkdir -p ./packages/phpvo
-	$(THRIFT) --gen php:validate     -r --out ./packages/phpv   TestValidators.thrift 
-	$(THRIFT) --gen php:validate,oop -r --out ./packages/phpvo  TestValidators.thrift 
-	
+	mkdir -p ./packages/phpjs
+	$(THRIFT) --gen php:validate     -r --out ./packages/phpv   TestValidators.thrift
+	$(THRIFT) --gen php:validate,oop -r --out ./packages/phpvo  TestValidators.thrift
+	$(THRIFT) --gen php:json         -r --out ./packages/phpjs  TestValidators.thrift
+
+check-json-serializer: stubs
+if HAVE_PHPUNIT
+	$(PHPUNIT) --log-junit=TEST-json-serializer.xml Test/Thrift/JsonSerialize/
+endif
+
 check-validator: stubs 
 	php Test/Thrift/TestValidators.php 
 	php Test/Thrift/TestValidators.php -oop 
 
 check-protocol:	stubs
 if HAVE_PHPUNIT
-	$(PHPUNIT) --log-junit=phpunit.xml Test/Thrift/Protocol/TestTJSONProtocol.php
-	$(PHPUNIT) --log-junit=phpunit.xml Test/Thrift/Protocol/TestBinarySerializer.php
+	$(PHPUNIT) --log-junit=TEST-log-json-protocol.xml Test/Thrift/Protocol/TestTJSONProtocol.php
+	$(PHPUNIT) --log-junit=TEST-binary-serializer.xml Test/Thrift/Protocol/TestBinarySerializer.php
 endif
-	
+
 check: stubs \
   check-protocol \
-  check-validator
+  check-validator \
+  check-json-serializer
 
 clean-local:
 	$(RM) -r ./packages
+	$(RM) TEST-*.xml
 
 EXTRA_DIST = Test