From 64889a6db05b57fc3cc75ba57d56b0f7eafed487 Mon Sep 17 00:00:00 2001 From: jnels Date: Tue, 13 Sep 2016 19:21:41 -0400 Subject: [PATCH 01/11] initial commit --- src/data_types.php | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/data_types.php diff --git a/src/data_types.php b/src/data_types.php new file mode 100644 index 0000000..5e74322 --- /dev/null +++ b/src/data_types.php @@ -0,0 +1,50 @@ + From 137f37bc1341593a9e55af5c7b88d8f1523540b3 Mon Sep 17 00:00:00 2001 From: jnels Date: Tue, 13 Sep 2016 19:25:57 -0400 Subject: [PATCH 02/11] Took var_dumps out --- src/data_types.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/data_types.php b/src/data_types.php index 5e74322..075aba9 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -37,14 +37,11 @@ function convert_to_null($input) { } } -$test = null; +convert_to_int($test); +convert_to_float($test); +convert_to_string($test); +convert_to_bool($test); +convert_to_array($test); +convert_to_null($test); -$int = convert_to_int($test); -$float = convert_to_float($test); -$string = convert_to_string($test); -$bool = convert_to_bool($test); -$array = convert_to_array($test); -$null = convert_to_null($test); - -var_dump($array); ?> From 9c4139efef14cd804cacabd59f893fca548db232 Mon Sep 17 00:00:00 2001 From: jnels Date: Tue, 13 Sep 2016 19:33:20 -0400 Subject: [PATCH 03/11] Removed function call --- src/data_types.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/data_types.php b/src/data_types.php index 075aba9..c12381d 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -37,11 +37,4 @@ function convert_to_null($input) { } } -convert_to_int($test); -convert_to_float($test); -convert_to_string($test); -convert_to_bool($test); -convert_to_array($test); -convert_to_null($test); - ?> From d9847068de3a39c185cf4fd5c9fc029db127c1cf Mon Sep 17 00:00:00 2001 From: jnels Date: Tue, 13 Sep 2016 19:42:27 -0400 Subject: [PATCH 04/11] Here goes nothing --- src/data_types.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/data_types.php b/src/data_types.php index c12381d..bcdbc83 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -13,7 +13,6 @@ function convert_to_string($input) { } else { $input = strval($input); } - return $input; } @@ -30,7 +29,7 @@ function convert_to_array($input) { } function convert_to_null($input) { - if ($input == null) { + if ($input === null) { return null; } else { return $input; From 1fcf091c4fa7998e4f2af81f16f21eda156f8566 Mon Sep 17 00:00:00 2001 From: jnels Date: Tue, 13 Sep 2016 19:58:09 -0400 Subject: [PATCH 05/11] another try --- src/data_types.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/data_types.php b/src/data_types.php index bcdbc83..dec2b91 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -25,7 +25,11 @@ function convert_to_bool($input) { } function convert_to_array($input) { - return array($input); + if (is_array($input)) { + return $input; + } else { + return array($input); + } } function convert_to_null($input) { @@ -36,4 +40,8 @@ function convert_to_null($input) { } } +$test = [2,3]; + +var_dump( convert_to_array($test) ); + ?> From 639fcb2e16303e59d6651d2449ed4212b1f22136 Mon Sep 17 00:00:00 2001 From: jnels Date: Wed, 14 Sep 2016 06:50:44 -0400 Subject: [PATCH 06/11] Je Suis PHP --- src/data_types.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/data_types.php b/src/data_types.php index dec2b91..51fed2a 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -33,15 +33,13 @@ function convert_to_array($input) { } function convert_to_null($input) { - if ($input === null) { + if (!$input) { return null; } else { return $input; } } -$test = [2,3]; - -var_dump( convert_to_array($test) ); +var_dump(convert_to_array([1, 1, "poop"])); ?> From fcff9b1fe6b8eecad0c709e3ba582b026af866cf Mon Sep 17 00:00:00 2001 From: jnels Date: Wed, 14 Sep 2016 07:00:47 -0400 Subject: [PATCH 07/11] Je ne c'est pas PHP --- src/data_types.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/data_types.php b/src/data_types.php index 51fed2a..0410bec 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -25,7 +25,9 @@ function convert_to_bool($input) { } function convert_to_array($input) { - if (is_array($input)) { + if ($input === null) { + return array(); + } else if (is_array($input)) { return $input; } else { return array($input); @@ -33,13 +35,10 @@ function convert_to_array($input) { } function convert_to_null($input) { - if (!$input) { + if (!$input || $input == null) { return null; } else { return $input; } } - -var_dump(convert_to_array([1, 1, "poop"])); - ?> From ef6280f50f9b59f62a23d9225ead7174aa8450eb Mon Sep 17 00:00:00 2001 From: jnels Date: Wed, 14 Sep 2016 07:03:41 -0400 Subject: [PATCH 08/11] Things are gonna change. I can feel it. --- src/data_types.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/data_types.php b/src/data_types.php index 0410bec..fcdeb0f 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -35,10 +35,11 @@ function convert_to_array($input) { } function convert_to_null($input) { - if (!$input || $input == null) { + if (!$input || $input === null || $input = "null") { return null; } else { return $input; } } + ?> From 8687fb9152253e64f16c9efc206364218cb55a6a Mon Sep 17 00:00:00 2001 From: jnels Date: Wed, 14 Sep 2016 14:10:29 -0400 Subject: [PATCH 09/11] New and improved: Now with more beef! --- src/data_types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data_types.php b/src/data_types.php index fcdeb0f..5ecab13 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -35,7 +35,7 @@ function convert_to_array($input) { } function convert_to_null($input) { - if (!$input || $input === null || $input = "null") { + if (!$input) { return null; } else { return $input; From 2dabe1767052b47e1018a4cbdd5e8b4ad1df1b14 Mon Sep 17 00:00:00 2001 From: jnels Date: Wed, 14 Sep 2016 14:16:14 -0400 Subject: [PATCH 10/11] Jedi Mind Trick: 'All checks have passed.' --- src/data_types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data_types.php b/src/data_types.php index 5ecab13..cda1d51 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -35,7 +35,7 @@ function convert_to_array($input) { } function convert_to_null($input) { - if (!$input) { + if (!$input || $input = "null") { return null; } else { return $input; From 61a34e9cadb0861d9817d18422c36139600863f2 Mon Sep 17 00:00:00 2001 From: jnels Date: Wed, 14 Sep 2016 14:24:34 -0400 Subject: [PATCH 11/11] OK. Stupid mistake. For real this time... --- src/data_types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data_types.php b/src/data_types.php index cda1d51..f1261fc 100644 --- a/src/data_types.php +++ b/src/data_types.php @@ -35,7 +35,7 @@ function convert_to_array($input) { } function convert_to_null($input) { - if (!$input || $input = "null") { + if (!$input || $input === "null") { return null; } else { return $input;