PHP-Serialization-0.34/0000755000076500000240000000000011350524012013256 5ustar t0mstaffPHP-Serialization-0.34/Changes0000644000076500000240000000341011350523755014564 0ustar t0mstaffRevision history for Perl extension PHP::Serialization 0.34 2010-03-18 - Fix keys and values like '010' being serialized as strings as expected rather than being turned into ints. (RT#48594) 0.33 2009-07-14 - Added ability to store the order of the keys on decoding PHP assoc array (Alexander Bassilov) - Added ability to sort the keys on encoding HASHes (Alexander Bassilov) 0.32 2009-06-20 - Making finite state machine - Fixed bug in arrays RT21218 - RT24441 is not a bug - Croaks on incomplete strings. RT44700 - Fixed bug with float as index. RT42029 - Removed warning from POD - Changed todo in POD - BOLAV@cpan.org 0.31 2009-04-14 - Add warning note to POD - Take patch from RT#45024 to fix boolean deserialization bug. 0.30 2009-01-11 - Significantly cleanup the code to be much prettier. - Fix RT#42279, output sizes a bytes, not characters so that serializing multibyte data works correctly. 0.29 2008-09-17 - Fix bug with negative numbers, RT#6402, patch from - Add TODO test for RT21218 - Add TODO test for RT24441 0.28 - Serializing long integers comes out as -1 on the PHP end as noted in RT#6112 patch from . - Add test for the issue above (t0m). - Fix POD as noted in RT#6113 by MCMAHON. - Only require perl 5.6 in Makefile.PL as noted in RT#17034 by 0.27 - Fixed versioning (internal lib version was .26, was reporting as .25 in previous version) - Fixed array serialization/unserialization issues due to incorrect element counts - Fixed overly restrictive perl version requirement - Fixed formatting issues in the documentation 0.25 Tue Dec 16 05:44:04 2003 - Original public version - Change text formatted to zap tabs in docs. PHP-Serialization-0.34/lib/0000755000076500000240000000000011350524012014024 5ustar t0mstaffPHP-Serialization-0.34/lib/PHP/0000755000076500000240000000000011350524012014453 5ustar t0mstaffPHP-Serialization-0.34/lib/PHP/Serialization.pm0000644000076500000240000003134511350523755017651 0ustar t0mstaffpackage PHP::Serialization; use strict; use warnings; use Exporter (); use Scalar::Util qw/blessed/; use Carp qw(croak confess carp); use bytes; use vars qw/$VERSION @ISA @EXPORT_OK/; $VERSION = '0.34'; @ISA = qw(Exporter); @EXPORT_OK = qw(unserialize serialize); =head1 NAME PHP::Serialization - simple flexible means of converting the output of PHP's serialize() into the equivalent Perl memory structure, and vice versa. =head1 SYNOPSIS use PHP::Serialization qw(serialize unserialize); my $encoded = serialize({ a => 1, b => 2}); my $hashref = unserialize($encoded); =cut =head1 DESCRIPTION Provides a simple, quick means of serializing perl memory structures (including object data!) into a format that PHP can deserialize() and access, and vice versa. NOTE: Converts PHP arrays into Perl Arrays when the PHP array used exclusively numeric indexes, and into Perl Hashes then the PHP array did not. =cut sub new { my ($class) = shift; my $self = bless {}, blessed($class) ? blessed($class) : $class; return $self; } =head1 FUNCTIONS Exportable functions.. =cut =head2 serialize($var,[optional $asString,[optional $sortHashes]]) Serializes the memory structure pointed to by $var, and returns a scalar value of encoded data. If the optional $asString is true, $var will be encoded as string if it is double or float. If the optional $sortHashes is true, all hashes will be sorted before serialization. NOTE: Will recursively encode objects, hashes, arrays, etc. SEE ALSO: ->encode() =cut sub serialize { return __PACKAGE__->new->encode(@_); } =head2 unserialize($encoded,[optional CLASS]) Deserializes the encoded data in $encoded, and returns a value (be it a hashref, arrayref, scalar, etc) representing the data structure serialized in $encoded_string. If the optional CLASS is specified, any objects are blessed into CLASS::$serialized_class. Otherwise, O bjects are blessed into PHP::Serialization::Object::$serialized_class. (which has no methods) SEE ALSO: ->decode() =cut sub unserialize { return __PACKAGE__->new->decode(@_); } =head1 METHODS Functionality available if using the object interface.. =cut =head2 decode($encoded_string,[optional CLASS]) Deserializes the encoded data in $encoded, and returns a value (be it a hashref, arrayref, scalar, etc) representing the data structure serialized in $encoded_string. If the optional CLASS is specified, any objects are blessed into CLASS::$serialized_class. Otherwise, Objects are blessed into PHP::Serialization::Object::$serialized_class. (which has no methods) SEE ALSO: unserialize() =cut my $sorthash; sub decode { my ($self, $string, $class, $shash) = @_; $sorthash=$shash if defined($shash); my $cursor = 0; $self->{string} = \$string; $self->{cursor} = \$cursor; $self->{strlen} = length($string); if ( defined $class ) { $self->{class} = $class; } else { $self->{class} = 'PHP::Serialization::Object'; } # Ok, start parsing... my @values = $self->_parse(); # Ok, we SHOULD only have one value.. if ( $#values == -1 ) { # Oops, none... return; } elsif ( $#values == 0 ) { # Ok, return our one value.. return $values[0]; } else { # Ok, return a reference to the list. return \@values; } } # End of decode sub. my %type_table = ( O => 'object', s => 'scalar', a => 'array', i => 'integer', d => 'float', b => 'boolean', N => 'undef', ); sub _parse_array { my $self = shift; my $elemcount = shift; my $cursor = $self->{cursor}; my $string = $self->{string}; my $strlen = $self->{strlen}; confess("No cursor") unless $cursor; confess("No string") unless $string; confess("No strlen") unless $strlen; my @elems = (); my @shash_arr = ('some') if (($sorthash) and (ref($sorthash) eq 'HASH')); $self->_skipchar('{'); foreach my $i (1..$elemcount*2) { push(@elems,$self->_parse_elem); if (($i % 2) and (@shash_arr)) { $shash_arr[0]= ((($i-1)/2) eq $elems[$#elems])? 'array' : 'hash' unless ($shash_arr[0] eq 'hash'); push(@shash_arr,$elems[$#elems]); } } $self->_skipchar('}'); push(@elems,\@shash_arr) if (@shash_arr); return @elems; } sub _parse_elem { my $self = shift; my $cursor = $self->{cursor}; my $string = $self->{string}; my $strlen = $self->{strlen}; my @elems; my $type_c = $self->_readchar(); my $type = $type_table{$type_c}; if (!defined $type) { croak("ERROR: Unknown type $type_c."); } if ( $type eq 'object' ) { $self->_skipchar(':'); # Ok, get our name count... my $namelen = $self->_readnum(); $self->_skipchar(':'); # Ok, get our object name... $self->_skipchar('"'); my $name = $self->_readstr($namelen); $self->_skipchar('"'); # Ok, our sub elements... $self->_skipchar(':'); my $elemcount = $self->_readnum(); $self->_skipchar(':'); my %value = $self->_parse_array($elemcount); # TODO: Call wakeup # TODO: Support for objecttypes return bless(\%value, $self->{class} . '::' . $name); } elsif ( $type eq 'array' ) { $self->_skipchar(':'); # Ok, our sub elements... my $elemcount = $self->_readnum(); $self->_skipchar(':'); my @values = $self->_parse_array($elemcount); # If every other key is not numeric, map to a hash.. my $subtype = 'array'; my @newlist; my @shash_arr=@{pop(@values)} if (ref($sorthash) eq 'HASH'); foreach ( 0..$#values ) { if ( ($_ % 2) ) { push(@newlist, $values[$_]); next; } elsif (($_ / 2) ne $values[$_]) { $subtype = 'hash'; last; } if ( $values[$_] !~ /^\d+$/ ) { $subtype = 'hash'; last; } } if ( $subtype eq 'array' ) { # Ok, remap... return \@newlist; } else { # Ok, force into hash.. my %hash = @values; ${$sorthash}{\%hash}=@shash_arr if ((ref($sorthash) eq 'HASH') and @shash_arr and (shift(@shash_arr) ne 'array')); return \%hash; } } elsif ( $type eq 'scalar' ) { $self->_skipchar(':'); # Ok, get our string size count... my $strlen = $self->_readnum; $self->_skipchar(':'); $self->_skipchar('"'); my $string = $self->_readstr($strlen); $self->_skipchar('"'); $self->_skipchar(';'); return $string; } elsif ( $type eq 'integer' || $type eq 'float' ) { $self->_skipchar(':'); # Ok, read the value.. my $val = $self->_readnum; if ( $type eq 'integer' ) { $val = int($val); } $self->_skipchar(';'); return $val; } elsif ( $type eq 'boolean' ) { $self->_skipchar(':'); # Ok, read our boolen value.. my $bool = $self->_readchar; $self->_skipchar; if ($bool eq '0') { $bool = undef; } return $bool; } elsif ( $type eq 'undef' ) { $self->_skipchar(';'); return undef; } else { confess "Unknown element type '$type' found! (cursor $$cursor)"; } } sub _parse { my ($self) = @_; my $cursor = $self->{cursor}; my $string = $self->{string}; my $strlen = $self->{strlen}; confess("No cursor") unless $cursor; confess("No string") unless $string; confess("No strlen") unless $strlen; my @elems; push(@elems,$self->_parse_elem); # warn if we have unused chars if ($$cursor != $strlen) { carp("WARN: Unused characters in string after $$cursor."); } return @elems; } # End of decode. sub _readstr { my ($self, $length) = @_; my $string = $self->{string}; my $cursor = $self->{cursor}; if ($$cursor + $length > length($$string)) { croak("ERROR: Read past end of string. Want $length after $$cursor. (".$$string.")"); } my $str = substr($$string, $$cursor, $length); $$cursor += $length; return $str; } sub _readchar { my ($self) = @_; return $self->_readstr(1); } sub _readnum { # Reads in a character at a time until we run out of numbers to read... my ($self) = @_; my $cursor = $self->{cursor}; my $string; while ( 1 ) { my $char = $self->_readchar; if ( $char !~ /^[\d\.-]+$/ ) { $$cursor--; last; } $string .= $char; } # End of while. return $string; } # End of readnum sub _skipchar { my $self = shift; my $want = shift; my $c = $self->_readchar(); if (($want)&&($c ne $want)) { my $cursor = $self->{cursor}; my $str = $self->{string}; croak("ERROR: Wrong char $c, expected $want at position ".$$cursor." (".$$str.")"); } print "_skipchar: WRONG char $c ($want)\n" if (($want)&&($c ne $want)); # ${$$self{cursor}}++; } # Move our cursor one bytes ahead... =head2 encode($reference,[optional $asString,[optional $sortHashes]]) Serializes the memory structure pointed to by $reference, and returns a scalar value of encoded data. If the optional $asString is true, $reference will be encoded as string if it is double or float. If the optional $sortHashes is true, all hashes will be sorted before serialization. NOTE: Will recursively encode objects, hashes, arrays, etc. SEE ALSO: serialize() =cut sub encode { my ($self, $val, $iskey, $shash) = @_; $iskey=0 unless defined $iskey; $sorthash=$shash if defined $shash; if ( ! defined $val ) { return $self->_encode('null', $val); } elsif ( blessed $val ) { return $self->_encode('obj', $val); } elsif ( ! ref($val) ) { if ( $val =~ /^-?(?:[0-9]|[1-9]\d{1,10})$/ && abs($val) < 2**31 ) { return $self->_encode('int', $val); } elsif ( $val =~ /^-?\d+\.\d*$/ && !$iskey) { return $self->_encode('float', $val); } else { return $self->_encode('string', $val); } } else { my $type = ref($val); if ($type eq 'HASH' || $type eq 'ARRAY' ) { return $self->_sort_hash_encode($val) if (($sorthash) and ($type eq 'HASH')); return $self->_encode('array', $val); } else { confess "I can't serialize data of type '$type'!"; } } } sub _sort_hash_encode { my ($self, $val) = @_; my $buffer = ''; my @hsort = ((ref($sorthash) eq 'HASH') and (ref(${$sorthash}{$val}) eq 'ARRAY')) ? ${$sorthash}{$val} : sort keys %{$val}; $buffer .= sprintf('a:%d:',scalar(@hsort)) . '{'; for (@hsort) { $buffer .= $self->encode($_,1); $buffer .= $self->encode($$val{$_}); } $buffer .= '}'; return $buffer; } sub _encode { my ($self, $type, $val) = @_; my $buffer = ''; if ( $type eq 'null' ) { $buffer .= 'N;'; } elsif ( $type eq 'int' ) { $buffer .= sprintf('i:%d;', $val); } elsif ( $type eq 'float' ) { $buffer .= sprintf('d:%s;', $val); } elsif ( $type eq 'string' ) { $buffer .= sprintf('s:%d:"%s";', length($val), $val); } elsif ( $type eq 'array' ) { if ( ref($val) eq 'ARRAY' ) { $buffer .= sprintf('a:%d:',($#{$val}+1)) . '{'; map { # Ewww $buffer .= $self->encode($_); $buffer .= $self->encode($$val[$_]); } 0..$#{$val}; $buffer .= '}'; } else { $buffer .= sprintf('a:%d:',scalar(keys(%{$val}))) . '{'; while ( my ($key, $value) = each(%{$val}) ) { $buffer .= $self->encode($key,1); $buffer .= $self->encode($value); } $buffer .= '}'; } } elsif ( $type eq 'obj' ) { my $class = ref($val); $class =~ /(\w+)$/; my $subclass = $1; $buffer .= sprintf('O:%d:"%s":%d:', length($subclass), $subclass, scalar(keys %{$val})) . '{'; foreach ( %{$val} ) { $buffer .= $self->encode($_); } $buffer .= '}'; } else { confess "Unknown encode type!"; } return $buffer; } =head1 TODO Support diffrent object types =head1 AUTHOR INFORMATION Copyright (c) 2003 Jesse Brown . All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Various patches contributed by assorted authors on rt.cpan.org (as detailed in Changes file). Currently maintained by Tomas Doran . Rewritten to solve all known bugs by Bjørn-Olav Strand =cut package PHP::Serialization::Object; 1; PHP-Serialization-0.34/Makefile.PL0000644000076500000240000000103211233534330015230 0ustar t0mstaffuse 5.006; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'PHP::Serialization', 'VERSION_FROM' => 'lib/PHP/Serialization.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/PHP/Serialization.pm', # retrieve abstract from module AUTHOR => 'Jesse Brown ') : ()), ); PHP-Serialization-0.34/MANIFEST0000644000076500000240000000053211350524012014407 0ustar t0mstaffChanges lib/PHP/Serialization.pm Makefile.PL MANIFEST This list of files README t/01use.t t/02basic.t t/03largeints.t t/04arraysRT21218.t t/05RT24441.t t/06bool_deserializeRT45024.t t/07croak.t t/08incompletestringRT44700.t t/09floatindexRT42029.t t/10intRT48594.t META.yml Module meta-data (added by MakeMaker) PHP-Serialization-0.34/META.yml0000644000076500000240000000117011350524012014526 0ustar t0mstaff--- #YAML:1.0 name: PHP-Serialization version: 0.34 abstract: simple flexible means of converting the output of PHP's serialize() into the equivalent Perl memory structure, and vice versa. author: - Jesse Brown license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: {} no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.54 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 PHP-Serialization-0.34/README0000644000076500000240000000606511233534330014151 0ustar t0mstaffNAME PHP::Serialization - simple flexible means of converting the output of PHP's serialize() into the equivalent Perl memory structure, and vice versa. SYNOPSIS use PHP::Serialization qw(serialize unserialize); my $encoded = serialize({ a => 1, b => 2}); my $hashref = unserialize($encoded); DESCRIPTION Provides a simple, quick means of serializing perl memory structures (including object data!) into a format that PHP can deserialize() and access, and vice versa. NOTE: Converts PHP arrays into Perl Arrays when the PHP array used exclusively numeric indexes, and into Perl Hashes then the PHP array did not. FUNCTIONS Exportable functions.. serialize($var,[optional $asString,[optional $sortHashes]]) Serializes the memory structure pointed to by $var, and returns a scalar value of encoded data. If the optional $asString is true, $var will be encoded as string if it is double or float. If the optional $sortHashes is true, all hashes will be sorted before serialization. NOTE: Will recursively encode objects, hashes, arrays, etc. SEE ALSO: ->encode() unserialize($encoded,[optional CLASS]) Deserializes the encoded data in $encoded, and returns a value (be it a hashref, arrayref, scalar, etc) representing the data structure serialized in $encoded_string. If the optional CLASS is specified, any objects are blessed into CLASS::$serialized_class. Otherwise, O bjects are blessed into PHP::Serialization::Object::$serialized_class. (which has no methods) SEE ALSO: ->decode() METHODS Functionality available if using the object interface.. decode($encoded_string,[optional CLASS]) Deserializes the encoded data in $encoded, and returns a value (be it a hashref, arrayref, scalar, etc) representing the data structure serialized in $encoded_string. If the optional CLASS is specified, any objects are blessed into CLASS::$serialized_class. Otherwise, Objects are blessed into PHP::Serialization::Object::$serialized_class. (which has no methods) SEE ALSO: unserialize() encode($reference,[optional $asString,[optional $sortHashes]]) Serializes the memory structure pointed to by $reference, and returns a scalar value of encoded data. If the optional $asString is true, $reference will be encoded as string if it is double or float. If the optional $sortHashes is true, all hashes will be sorted before serialization. NOTE: Will recursively encode objects, hashes, arrays, etc. SEE ALSO: serialize() TODO Support diffrent object types AUTHOR INFORMATION Copyright (c) 2003 Jesse Brown . All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Various patches contributed by assorted authors on rt.cpan.org (as detailed in Changes file). Currently maintained by Tomas Doran . Rewritten to solve all known bugs by Bjørn-Olav Strand PHP-Serialization-0.34/t/0000755000076500000240000000000011350524012013521 5ustar t0mstaffPHP-Serialization-0.34/t/01use.t0000644000076500000240000000010411233534330014642 0ustar t0mstaffuse Test::More tests => 1; BEGIN { use_ok('PHP::Serialization') }; PHP-Serialization-0.34/t/02basic.t0000755000076500000240000000037511233534330015145 0ustar t0mstaff#!/usr/bin/perl use Test::More tests => 1; use PHP::Serialization qw(unserialize serialize); my $data = { this_is_a_test => 1.23, second_test => [1,2,3], third_test => -2, }; my $encoded = serialize($data); is_deeply($data, unserialize($encoded)); PHP-Serialization-0.34/t/03largeints.t0000644000076500000240000000052311233534330016045 0ustar t0mstaffuse strict; use warnings; use Test::More tests => 3; BEGIN { use_ok('PHP::Serialization') }; my $text = PHP::Serialization::serialize(744763740179); is($text, 's:12:"744763740179";', 'Large integers serialize correctly'); $text = PHP::Serialization::serialize([1, 2]); is($text, 'a:2:{i:0;i:1;i:1;i:2;}', 'Array serializes correctly'); PHP-Serialization-0.34/t/04arraysRT21218.t0000644000076500000240000000153511233534330016227 0ustar t0mstaffuse strict; use warnings; use Data::Dumper; use Test::More tests => 3; BEGIN { use_ok('PHP::Serialization') }; my $data = PHP::Serialization::unserialize( q{a:1:{s:3:"lll";a:2:{i:195;a:1:{i:111;s:3:"bbb";}i:194;a:1:{i:222;s:3:"ccc";}}}} ); is_deeply($data, { 'lll' => { '195' => {111 => 'bbb'}, '194' => {222 => 'ccc'}, } }, 'Only numbers as hashindexes works' ) or warn Dumper($data); $data = PHP::Serialization::unserialize( q{a:1:{s:3:"lll";a:2:{i:195;a:2:{i:0;i:111;i:1;s:3:"bbb";}i:194;a:2:{i:0;i:222;i:1;s:3:"ccc";}}}} ); is_deeply($data, { 'lll' => { '195' => [111, 'bbb'], '194' => [222, 'ccc'], } }, 'Only numbers as hashindexes works with arrays' ) or warn Dumper($data); PHP-Serialization-0.34/t/05RT24441.t0000644000076500000240000000115111233534330015001 0ustar t0mstaff#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 2; BEGIN { use_ok('PHP::Serialization') }; my $str = ; eval { PHP::Serialization::unserialize $str }; { ok($@, 'Illegal string'); } __END__ rand_code|s:32:"13680074cb023d44014946df7c1d7819";ban|a:5:{s:12:"last_checked";i:1165345329;s:9:"ID_MEMBER";i:0;s:2:"ip";s:15:"68.75.16.72";s:3:"ip2";s:15:"195.174.114.197";s:5:"email";s:0:"";}log_time|i:1165345329;timeOnlineUpdated|i:1165344980;old_url|s:64:"http://www.site.com/";USER_AGENT|s:34:"Opera/9.02 (Windows NT 5.1; U; tr)";visual_verification_code|s:5:"WZAPE";just_registered|i:1;PHP-Serialization-0.34/t/06bool_deserializeRT45024.t0000644000076500000240000000056011233534330020241 0ustar t0mstaff#!/usr/bin/env perl use strict; use warnings; use PHP::Serialization; use Test::More tests => 2; my $s = 'b:0;'; my $u = PHP::Serialization::unserialize($s); is($u, undef, 'b:0 equals undef'); $s = 'a:4:{i:0;s:3:"ABC";i:1;s:3:"OPQ";i:2;s:3:"XYZ";i:3;b:0;}'; $u = PHP::Serialization::unserialize($s); is_deeply $u, [ 'ABC', 'OPQ', 'XYZ', undef, ]; PHP-Serialization-0.34/t/07croak.t0000644000076500000240000000031711233534330015161 0ustar t0mstaff#!/usr/bin/env perl use strict; use warnings; use PHP::Serialization; use Test::More tests => 1; my $s = 's:3;"ABC";'; eval q{ my $u = PHP::Serialization::unserialize($s); }; like($@, qr/ERROR/, 'dies'); PHP-Serialization-0.34/t/08incompletestringRT44700.t0000644000076500000240000000157011233534330020320 0ustar t0mstaff#!/usr/bin/env perl use strict; use warnings; use PHP::Serialization; use Test::More tests => 1; my $encoded_php = 'a:2:{s:15:"info_buyRequest";a:5:{s:4:"uenc";s:72:"aHR0cDovL3N0YWdpbmcucGNkaXJlY3QuY29tL21vbml0b3JzL2Jsc2FzeTIwMjB3aS5odG1s";s:7:"product";s:3:"663";s:15:"related_product";s:0:"";s:7:"options";a:3:{i:3980;s:5:"12553";i:3981;s:5:"12554";i:3982;s:5:"12555";}s:3:"qty";s:6:"1.0000";}s:7:"options";a:3:{i:0;a:8:{s:5:"label";s:27:"Dead Pixel Checking Service";s:5:"value";s:155:"I understand LCD technology might have slight imperfections. Even a high quality A Grade panel might have up to five dead pixels. Ship without pre-checking";s:9:"option_id";s:4:"3980";s:3:"sku";s:0:"";s:5:"price";N;s:10:"price_type";N;s:3:"raw";O:33:"Mage_Catalog_Model_Product_Option":15:{s:11:"'; eval q{ my $u = PHP::Serialization::unserialize($encoded_php); }; like($@, qr/ERROR/, 'dies'); PHP-Serialization-0.34/t/09floatindexRT42029.t0000644000076500000240000000047411233534330017074 0ustar t0mstaff#!/usr/bin/env perl use strict; use warnings; use PHP::Serialization; use Test::More tests => 1; my $hash = { 'Volkswagen' => { 'Touareg' => { '2.5' => 1 } }, }; my $str = PHP::Serialization::serialize($hash); is($str,'a:1:{s:10:"Volkswagen";a:1:{s:7:"Touareg";a:1:{s:3:"2.5";i:1;}}}','Keys are string or int'); PHP-Serialization-0.34/t/10intRT48594.t0000644000076500000240000000060511350523020015524 0ustar t0mstaff#!/usr/bin/env perl use strict; use warnings; use PHP::Serialization; use Test::More tests => 2; my $a = {'020' => '001'}; my $str = PHP::Serialization::serialize( $a ); is($str,'a:1:{s:3:"020";s:3:"001";}', 'Keys and vals are string for 0 prefixed numbers'); my $b = {'0' => '0'}; $str = PHP::Serialization::serialize( $b ); is($str,'a:1:{i:0;i:0;}', 'Keys and vals are ints for 0');