Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
51c5ff88
Commit
51c5ff88
authored
Oct 26, 2016
by
Paul Yang
Committed by
GitHub
Oct 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pure php implementation for 32-bit machine. (#2282)
parent
58580da3
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
545 additions
and
392 deletions
+545
-392
Makefile.am
Makefile.am
+0
-1
composer.json
composer.json
+1
-2
pull_request_32.sh
jenkins/buildcmds/pull_request_32.sh
+1
-1
Dockerfile
jenkins/docker32/Dockerfile
+3
-1
GPBUtil.php
php/src/Google/Protobuf/Internal/GPBUtil.php
+38
-3
GPBWire.php
php/src/Google/Protobuf/Internal/GPBWire.php
+23
-24
InputStream.php
php/src/Google/Protobuf/Internal/InputStream.php
+58
-8
Message.php
php/src/Google/Protobuf/Internal/Message.php
+0
-5
OutputStream.php
php/src/Google/Protobuf/Internal/OutputStream.php
+36
-15
Type.php
php/src/Google/Protobuf/Internal/Type.php
+0
-175
array_test.php
php/tests/array_test.php
+76
-35
generated_class_test.php
php/tests/generated_class_test.php
+55
-10
map_field_test.php
php/tests/map_field_test.php
+44
-12
php_implementation_test.php
php/tests/php_implementation_test.php
+93
-55
test_base.php
php/tests/test_base.php
+13
-7
test_util.php
php/tests/test_util.php
+83
-38
tests.sh
tests.sh
+21
-0
No files found.
Makefile.am
View file @
51c5ff88
...
@@ -577,7 +577,6 @@ php_EXTRA_DIST= \
...
@@ -577,7 +577,6 @@ php_EXTRA_DIST= \
php/src/Google/Protobuf/Internal/DescriptorPool.php
\
php/src/Google/Protobuf/Internal/DescriptorPool.php
\
php/src/Google/Protobuf/Internal/OneofField.php
\
php/src/Google/Protobuf/Internal/OneofField.php
\
php/src/Google/Protobuf/Internal/MapEntry.php
\
php/src/Google/Protobuf/Internal/MapEntry.php
\
php/src/Google/Protobuf/Internal/Type.php
\
php/src/Google/Protobuf/Internal/InputStream.php
\
php/src/Google/Protobuf/Internal/InputStream.php
\
php/src/Google/Protobuf/Internal/OutputStream.php
\
php/src/Google/Protobuf/Internal/OutputStream.php
\
php/src/Google/Protobuf/Internal/MessageBuilderContext.php
\
php/src/Google/Protobuf/Internal/MessageBuilderContext.php
\
...
...
composer.json
View file @
51c5ff88
...
@@ -17,8 +17,7 @@
...
@@ -17,8 +17,7 @@
},
},
"files"
:
[
"files"
:
[
"php/src/Google/Protobuf/descriptor.php"
,
"php/src/Google/Protobuf/descriptor.php"
,
"php/src/Google/Protobuf/descriptor_internal.pb.php"
,
"php/src/Google/Protobuf/descriptor_internal.pb.php"
"php/src/Google/Protobuf/Internal/Type.php"
]
]
}
}
}
}
jenkins/buildcmds/pull_request_32.sh
View file @
51c5ff88
...
@@ -12,5 +12,5 @@
...
@@ -12,5 +12,5 @@
export
DOCKERFILE_DIR
=
jenkins/docker32
export
DOCKERFILE_DIR
=
jenkins/docker32
export
DOCKER_RUN_SCRIPT
=
jenkins/pull_request_in_docker.sh
export
DOCKER_RUN_SCRIPT
=
jenkins/pull_request_in_docker.sh
export
OUTPUT_DIR
=
testoutput
export
OUTPUT_DIR
=
testoutput
export
TEST_SET
=
"php_all"
export
TEST_SET
=
"php_all
_32
"
./jenkins/build_and_run_docker.sh
./jenkins/build_and_run_docker.sh
jenkins/docker32/Dockerfile
View file @
51c5ff88
...
@@ -83,7 +83,9 @@ RUN wget http://am1.php.net/get/php-5.5.38.tar.bz2/from/this/mirror
...
@@ -83,7 +83,9 @@ RUN wget http://am1.php.net/get/php-5.5.38.tar.bz2/from/this/mirror
RUN
mv
mirror php-5.5.38.tar.bz2
RUN
mv
mirror php-5.5.38.tar.bz2
RUN
tar
-xvf
php-5.5.38.tar.bz2
RUN
tar
-xvf
php-5.5.38.tar.bz2
RUN
cd
php-5.5.38
&&
./configure
--enable-maintainer-zts
--prefix
=
/usr/local/php-5.5-zts
&&
\
RUN
cd
php-5.5.38
&&
./configure
--enable-maintainer-zts
--prefix
=
/usr/local/php-5.5-zts
&&
\
make
&&
make
install
make
&&
make
install
&&
make clean
&&
cd
..
RUN
cd
php-5.5.38
&&
./configure
--enable-bcmath
--prefix
=
/usr/local/php-5.5-bc
&&
\
make
&&
make
install
&&
make clean
&&
cd
..
##################
##################
# Python dependencies
# Python dependencies
...
...
php/src/Google/Protobuf/Internal/GPBUtil.php
View file @
51c5ff88
...
@@ -37,6 +37,28 @@ use Google\Protobuf\Internal\RepeatedField;
...
@@ -37,6 +37,28 @@ use Google\Protobuf\Internal\RepeatedField;
class
GPBUtil
class
GPBUtil
{
{
public
function
divideInt64ToInt32
(
$value
,
&
$high
,
&
$low
,
$trim
=
false
)
{
$isNeg
=
(
bccomp
(
$value
,
0
)
<
0
);
if
(
$isNeg
)
{
$value
=
bcsub
(
0
,
$value
);
}
$high
=
(
int
)
bcdiv
(
bcadd
(
$value
,
1
),
4294967296
);
$low
=
(
int
)
bcmod
(
$value
,
4294967296
);
if
(
$isNeg
)
{
$high
=
~
$high
;
$low
=
~
$low
;
$low
++
;
if
(
!
$low
)
{
$high
++
;
}
}
if
(
$trim
)
{
$high
=
0
;
}
}
public
static
function
checkString
(
&
$var
,
$check_utf8
)
public
static
function
checkString
(
&
$var
,
$check_utf8
)
{
{
...
@@ -70,9 +92,14 @@ class GPBUtil
...
@@ -70,9 +92,14 @@ class GPBUtil
public
static
function
checkUint32
(
&
$var
)
public
static
function
checkUint32
(
&
$var
)
{
{
if
(
is_numeric
(
$var
))
{
if
(
is_numeric
(
$var
))
{
$var
=
intval
(
$var
);
if
(
PHP_INT_SIZE
===
8
)
{
if
(
PHP_INT_SIZE
===
8
)
{
$var
=
intval
(
$var
);
$var
|=
((
-
((
$var
>>
31
)
&
0x1
))
&
~
0xFFFFFFFF
);
$var
|=
((
-
((
$var
>>
31
)
&
0x1
))
&
~
0xFFFFFFFF
);
}
else
{
if
(
bccomp
(
$var
,
0x7FFFFFFF
)
>
0
)
{
$var
=
bcsub
(
$var
,
"4294967296"
);
}
$var
=
(
int
)
$var
;
}
}
}
else
{
}
else
{
trigger_error
(
"Expect integer."
,
E_USER_ERROR
);
trigger_error
(
"Expect integer."
,
E_USER_ERROR
);
...
@@ -82,7 +109,11 @@ class GPBUtil
...
@@ -82,7 +109,11 @@ class GPBUtil
public
static
function
checkInt64
(
&
$var
)
public
static
function
checkInt64
(
&
$var
)
{
{
if
(
is_numeric
(
$var
))
{
if
(
is_numeric
(
$var
))
{
$var
=
intval
(
$var
);
if
(
PHP_INT_SIZE
==
8
)
{
$var
=
intval
(
$var
);
}
else
{
$var
=
bcdiv
(
$var
,
1
,
0
);
}
}
else
{
}
else
{
trigger_error
(
"Expect integer."
,
E_USER_ERROR
);
trigger_error
(
"Expect integer."
,
E_USER_ERROR
);
}
}
...
@@ -91,7 +122,11 @@ class GPBUtil
...
@@ -91,7 +122,11 @@ class GPBUtil
public
static
function
checkUint64
(
&
$var
)
public
static
function
checkUint64
(
&
$var
)
{
{
if
(
is_numeric
(
$var
))
{
if
(
is_numeric
(
$var
))
{
$var
=
intval
(
$var
);
if
(
PHP_INT_SIZE
==
8
)
{
$var
=
intval
(
$var
);
}
else
{
$var
=
bcdiv
(
$var
,
1
,
0
);
}
}
else
{
}
else
{
trigger_error
(
"Expect integer."
,
E_USER_ERROR
);
trigger_error
(
"Expect integer."
,
E_USER_ERROR
);
}
}
...
...
php/src/Google/Protobuf/Internal/GPBWire.php
View file @
51c5ff88
...
@@ -32,10 +32,6 @@
...
@@ -32,10 +32,6 @@
namespace
Google\Protobuf\Internal
;
namespace
Google\Protobuf\Internal
;
use
Google\Protobuf\Internal\GPBUtil
;
use
Google\Protobuf\Internal\Int64
;
use
Google\Protobuf\Internal\Uint64
;
class
GPBWire
class
GPBWire
{
{
...
@@ -150,20 +146,28 @@ class GPBWire
...
@@ -150,20 +146,28 @@ class GPBWire
public
static
function
zigZagEncode64
(
$int64
)
public
static
function
zigZagEncode64
(
$int64
)
{
{
$a
=
$int64
->
copy
()
->
leftShift
(
1
);
if
(
PHP_INT_SIZE
==
4
)
{
$b
=
$int64
->
copy
()
->
rightShift
(
63
);
if
(
bccomp
(
$int64
,
0
)
>=
0
)
{
$result
=
$a
->
bitXor
(
$b
);
return
bcmul
(
$int64
,
2
);
$uint64
=
Uint64
::
newValue
(
$result
->
high
,
$result
->
low
);
}
else
{
return
$uint64
;
return
bcsub
(
bcmul
(
bcsub
(
0
,
$int64
),
2
),
1
);
}
}
else
{
return
(
$int64
<<
1
)
^
(
$int64
>>
63
);
}
}
}
public
static
function
zigZagDecode64
(
$uint64
)
public
static
function
zigZagDecode64
(
$uint64
)
{
{
$a
=
$uint64
->
copy
()
->
rightShift
(
1
);
if
(
PHP_INT_SIZE
==
4
)
{
$b
=
$uint64
->
oddMask
();
if
(
bcmod
(
$uint64
,
2
)
==
0
)
{
$result
=
$a
->
bitXor
(
$b
);
return
bcdiv
(
$uint64
,
2
,
0
);
$int64
=
Int64
::
newValue
(
$result
->
high
,
$result
->
low
);
}
else
{
return
$int64
;
return
bcsub
(
0
,
bcdiv
(
bcadd
(
$uint64
,
1
),
2
,
0
));
}
}
else
{
return
((
$uint64
>>
1
)
&
0x7FFFFFFFFFFFFFFF
)
^
(
-
(
$uint64
&
1
));
}
}
}
public
static
function
readInt32
(
&
$input
,
&
$value
)
public
static
function
readInt32
(
&
$input
,
&
$value
)
...
@@ -227,11 +231,7 @@ class GPBWire
...
@@ -227,11 +231,7 @@ class GPBWire
public
static
function
readSfixed64
(
&
$input
,
&
$value
)
public
static
function
readSfixed64
(
&
$input
,
&
$value
)
{
{
if
(
!
self
::
readFixed64
(
$input
,
$value
))
{
return
$input
->
readLittleEndian64
(
$value
);
return
false
;
}
$value
=
Int64
::
newValue
(
$value
->
high
,
$value
->
low
);
return
true
;
}
}
public
static
function
readFloat
(
&
$input
,
&
$value
)
public
static
function
readFloat
(
&
$input
,
&
$value
)
...
@@ -259,7 +259,7 @@ class GPBWire
...
@@ -259,7 +259,7 @@ class GPBWire
if
(
!
$input
->
readVarint64
(
$value
))
{
if
(
!
$input
->
readVarint64
(
$value
))
{
return
false
;
return
false
;
}
}
if
(
$value
->
high
===
0
&&
$value
->
low
=
==
0
)
{
if
(
$value
==
0
)
{
$value
=
false
;
$value
=
false
;
}
else
{
}
else
{
$value
=
true
;
$value
=
true
;
...
@@ -324,8 +324,8 @@ class GPBWire
...
@@ -324,8 +324,8 @@ class GPBWire
public
static
function
writeSint64
(
&
$output
,
$value
)
public
static
function
writeSint64
(
&
$output
,
$value
)
{
{
$value
=
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
$value
)
);
$value
=
GPBWire
::
zigZagEncode64
(
$value
);
return
$output
->
writeVarint64
(
$value
->
toInteger
()
);
return
$output
->
writeVarint64
(
$value
);
}
}
public
static
function
writeFixed32
(
&
$output
,
$value
)
public
static
function
writeFixed32
(
&
$output
,
$value
)
...
@@ -431,9 +431,8 @@ class GPBWire
...
@@ -431,9 +431,8 @@ class GPBWire
public
static
function
sint64Size
(
$value
)
public
static
function
sint64Size
(
$value
)
{
{
$value
=
GPBUtil
::
Int64
(
$value
);
$value
=
self
::
zigZagEncode64
(
$value
);
$value
=
self
::
zigZagEncode64
(
$value
);
return
self
::
varint64Size
(
$value
->
toInteger
()
);
return
self
::
varint64Size
(
$value
);
}
}
public
static
function
varint64Size
(
$value
)
public
static
function
varint64Size
(
$value
)
...
...
php/src/Google/Protobuf/Internal/InputStream.php
View file @
51c5ff88
...
@@ -34,6 +34,24 @@ namespace Google\Protobuf\Internal;
...
@@ -34,6 +34,24 @@ namespace Google\Protobuf\Internal;
use
Google\Protobuf\Internal\Uint64
;
use
Google\Protobuf\Internal\Uint64
;
function
combineInt32ToInt64
(
$high
,
$low
)
{
$isNeg
=
$high
<
0
;
if
(
$isNeg
)
{
$high
=
~
$high
;
$low
=
~
$low
;
$low
++
;
if
(
!
$low
)
{
$high
++
;
}
}
$result
=
bcadd
(
bcmul
(
$high
,
4294967296
),
$low
);
if
(
$isNeg
)
{
$result
=
bcsub
(
0
,
$result
);
}
return
$result
;
}
class
InputStream
class
InputStream
{
{
...
@@ -116,11 +134,23 @@ class InputStream
...
@@ -116,11 +134,23 @@ class InputStream
if
(
!
$this
->
readVarint64
(
$var
))
{
if
(
!
$this
->
readVarint64
(
$var
))
{
return
false
;
return
false
;
}
}
$var
=
$var
->
toInteger
()
&
0xFFFFFFFF
;
if
(
PHP_INT_SIZE
==
4
)
{
$var
=
bcmod
(
$var
,
4294967296
);
}
else
{
$var
&=
0xFFFFFFFF
;
}
// Convert large uint32 to int32.
// Convert large uint32 to int32.
if
(
PHP_INT_SIZE
===
8
&&
(
$var
>
0x7FFFFFFF
))
{
if
(
$var
>
0x7FFFFFFF
)
{
$var
=
$var
|
(
0xFFFFFFFF
<<
32
);
if
(
PHP_INT_SIZE
===
8
)
{
$var
=
$var
|
(
0xFFFFFFFF
<<
32
);
}
else
{
$var
=
bcsub
(
$var
,
4294967296
);
}
}
}
$var
=
intval
(
$var
);
return
true
;
return
true
;
}
}
...
@@ -130,7 +160,8 @@ class InputStream
...
@@ -130,7 +160,8 @@ class InputStream
*/
*/
public
function
readVarint64
(
&
$var
)
public
function
readVarint64
(
&
$var
)
{
{
$result
=
new
Uint64
(
0
);
$high
=
0
;
$low
=
0
;
$count
=
0
;
$count
=
0
;
$b
=
0
;
$b
=
0
;
...
@@ -142,12 +173,27 @@ class InputStream
...
@@ -142,12 +173,27 @@ class InputStream
return
false
;
return
false
;
}
}
$b
=
ord
(
$this
->
buffer
[
$this
->
current
]);
$b
=
ord
(
$this
->
buffer
[
$this
->
current
]);
$result
->
bitOr
((
new
Uint64
(
$b
&
0x7F
))
->
leftShift
(
7
*
$count
));
$bits
=
7
*
$count
;
if
(
$bits
>=
32
)
{
$high
|=
((
$b
&
0x7F
)
<<
(
$bits
-
32
));
}
else
if
(
$bits
>
25
){
$high_bits
=
$bits
-
25
;
$low
=
(
$low
|
((
$b
&
0x7F
)
<<
$bits
))
&
(
int
)
0xFFFFFFFF
;
$high
=
$b
&
((
0x1
<<
$high_bits
)
-
1
);
}
else
{
$low
|=
((
$b
&
0x7F
)
<<
$bits
);
}
$this
->
advance
(
1
);
$this
->
advance
(
1
);
$count
+=
1
;
$count
+=
1
;
}
while
(
$b
&
0x80
);
}
while
(
$b
&
0x80
);
$var
=
$result
;
if
(
PHP_INT_SIZE
==
4
)
{
$var
=
combineInt32ToInt64
(
$high
,
$low
);
}
else
{
$var
=
(
$high
&
0xFFFFFFFF
)
<<
32
|
(
$low
&
0xFFFFFFFF
);
}
return
true
;
return
true
;
}
}
...
@@ -161,7 +207,7 @@ class InputStream
...
@@ -161,7 +207,7 @@ class InputStream
if
(
!
$this
->
readVarint64
(
$var
))
{
if
(
!
$this
->
readVarint64
(
$var
))
{
return
false
;
return
false
;
}
}
$var
=
$var
->
toInteger
()
;
$var
=
(
int
)
$var
;
return
true
;
return
true
;
}
}
...
@@ -197,7 +243,11 @@ class InputStream
...
@@ -197,7 +243,11 @@ class InputStream
return
false
;
return
false
;
}
}
$high
=
unpack
(
'V'
,
$data
)[
1
];
$high
=
unpack
(
'V'
,
$data
)[
1
];
$var
=
Uint64
::
newValue
(
$high
,
$low
);
if
(
PHP_INT_SIZE
==
4
)
{
$var
=
combineInt32ToInt64
(
$high
,
$low
);
}
else
{
$var
=
(
$high
<<
32
)
|
$low
;
}
return
true
;
return
true
;
}
}
...
...
php/src/Google/Protobuf/Internal/Message.php
View file @
51c5ff88
...
@@ -210,13 +210,11 @@ class Message
...
@@ -210,13 +210,11 @@ class Message
if
(
!
GPBWire
::
readInt64
(
$input
,
$value
))
{
if
(
!
GPBWire
::
readInt64
(
$input
,
$value
))
{
return
false
;
return
false
;
}
}
$value
=
$value
->
toInteger
();
break
;
break
;
case
GPBType
::
UINT64
:
case
GPBType
::
UINT64
:
if
(
!
GPBWire
::
readUint64
(
$input
,
$value
))
{
if
(
!
GPBWire
::
readUint64
(
$input
,
$value
))
{
return
false
;
return
false
;
}
}
$value
=
$value
->
toInteger
();
break
;
break
;
case
GPBType
::
INT32
:
case
GPBType
::
INT32
:
if
(
!
GPBWire
::
readInt32
(
$input
,
$value
))
{
if
(
!
GPBWire
::
readInt32
(
$input
,
$value
))
{
...
@@ -227,7 +225,6 @@ class Message
...
@@ -227,7 +225,6 @@ class Message
if
(
!
GPBWire
::
readFixed64
(
$input
,
$value
))
{
if
(
!
GPBWire
::
readFixed64
(
$input
,
$value
))
{
return
false
;
return
false
;
}
}
$value
=
$value
->
toInteger
();
break
;
break
;
case
GPBType
::
FIXED32
:
case
GPBType
::
FIXED32
:
if
(
!
GPBWire
::
readFixed32
(
$input
,
$value
))
{
if
(
!
GPBWire
::
readFixed32
(
$input
,
$value
))
{
...
@@ -285,7 +282,6 @@ class Message
...
@@ -285,7 +282,6 @@ class Message
if
(
!
GPBWire
::
readSfixed64
(
$input
,
$value
))
{
if
(
!
GPBWire
::
readSfixed64
(
$input
,
$value
))
{
return
false
;
return
false
;
}
}
$value
=
$value
->
toInteger
();
break
;
break
;
case
GPBType
::
SINT32
:
case
GPBType
::
SINT32
:
if
(
!
GPBWire
::
readSint32
(
$input
,
$value
))
{
if
(
!
GPBWire
::
readSint32
(
$input
,
$value
))
{
...
@@ -296,7 +292,6 @@ class Message
...
@@ -296,7 +292,6 @@ class Message
if
(
!
GPBWire
::
readSint64
(
$input
,
$value
))
{
if
(
!
GPBWire
::
readSint64
(
$input
,
$value
))
{
return
false
;
return
false
;
}
}
$value
=
$value
->
toInteger
();
break
;
break
;
default
:
default
:
user_error
(
"Unsupported type."
);
user_error
(
"Unsupported type."
);
...
...
php/src/Google/Protobuf/Internal/OutputStream.php
View file @
51c5ff88
...
@@ -90,8 +90,6 @@ class OutputStream
...
@@ -90,8 +90,6 @@ class OutputStream
public
function
writeRaw
(
$data
,
$size
)
public
function
writeRaw
(
$data
,
$size
)
{
{
if
(
$this
->
buffer_size
<
$size
)
{
if
(
$this
->
buffer_size
<
$size
)
{
var_dump
(
$this
->
buffer_size
);
var_dump
(
$size
);
trigger_error
(
"Output stream doesn't have enough buffer."
);
trigger_error
(
"Output stream doesn't have enough buffer."
);
return
false
;
return
false
;
}
}
...
@@ -107,15 +105,28 @@ class OutputStream
...
@@ -107,15 +105,28 @@ class OutputStream
private
static
function
writeVarintToArray
(
$value
,
&
$buffer
,
$trim
=
false
)
private
static
function
writeVarintToArray
(
$value
,
&
$buffer
,
$trim
=
false
)
{
{
$current
=
0
;
$current
=
0
;
if
(
$trim
)
{
$value
&=
0xFFFFFFFF
;
$high
=
0
;
$low
=
0
;
if
(
PHP_INT_SIZE
==
4
)
{
GPBUtil
::
divideInt64ToInt32
(
$value
,
$high
,
$low
,
$trim
);
}
else
{
if
(
$trim
)
{
$low
=
$value
&
0xFFFFFFFF
;
}
else
{
$low
=
$value
;
}
}
}
while
(
$value
>=
0x80
||
$value
<
0
)
{
$buffer
[
$current
]
=
chr
(
$value
|
0x80
);
while
(
$low
>=
0x80
||
$low
<
0
)
{
$buffer
[
$current
]
=
chr
(
$low
|
0x80
);
$value
=
(
$value
>>
7
)
&
~
(
0x7F
<<
((
PHP_INT_SIZE
<<
3
)
-
7
));
$value
=
(
$value
>>
7
)
&
~
(
0x7F
<<
((
PHP_INT_SIZE
<<
3
)
-
7
));
$carry
=
(
$high
&
0x7F
)
<<
((
PHP_INT_SIZE
<<
3
)
-
7
);
$high
=
(
$high
>>
7
)
&
~
(
0x7F
<<
((
PHP_INT_SIZE
<<
3
)
-
7
));
$low
=
((
$low
>>
7
)
&
~
(
0x7F
<<
((
PHP_INT_SIZE
<<
3
)
-
7
))
|
$carry
);
$current
++
;
$current
++
;
}
}
$buffer
[
$current
]
=
chr
(
$
value
);
$buffer
[
$current
]
=
chr
(
$
low
);
return
$current
+
1
;
return
$current
+
1
;
}
}
...
@@ -130,14 +141,24 @@ class OutputStream
...
@@ -130,14 +141,24 @@ class OutputStream
private
static
function
writeLittleEndian64ToArray
(
$value
,
&
$buffer
)
private
static
function
writeLittleEndian64ToArray
(
$value
,
&
$buffer
)
{
{
$buffer
[
0
]
=
chr
(
$value
&
0x000000FF
);
$high
=
0
;
$buffer
[
1
]
=
chr
((
$value
>>
8
)
&
0x000000FF
);
$low
=
0
;
$buffer
[
2
]
=
chr
((
$value
>>
16
)
&
0x000000FF
);
if
(
PHP_INT_SIZE
==
4
)
{
$buffer
[
3
]
=
chr
((
$value
>>
24
)
&
0x000000FF
);
GPBUtil
::
divideInt64ToInt32
(
$value
,
$high
,
$low
);
$buffer
[
4
]
=
chr
((
$value
>>
32
)
&
0x000000FF
);
}
else
{
$buffer
[
5
]
=
chr
((
$value
>>
40
)
&
0x000000FF
);
$low
=
$value
&
0xFFFFFFFF
;
$buffer
[
6
]
=
chr
((
$value
>>
48
)
&
0x000000FF
);
$high
=
(
$value
>>
32
)
&
0xFFFFFFFF
;
$buffer
[
7
]
=
chr
((
$value
>>
56
)
&
0x000000FF
);
}
$buffer
[
0
]
=
chr
(
$low
&
0x000000FF
);
$buffer
[
1
]
=
chr
((
$low
>>
8
)
&
0x000000FF
);
$buffer
[
2
]
=
chr
((
$low
>>
16
)
&
0x000000FF
);
$buffer
[
3
]
=
chr
((
$low
>>
24
)
&
0x000000FF
);
$buffer
[
4
]
=
chr
(
$high
&
0x000000FF
);
$buffer
[
5
]
=
chr
((
$high
>>
8
)
&
0x000000FF
);
$buffer
[
6
]
=
chr
((
$high
>>
16
)
&
0x000000FF
);
$buffer
[
7
]
=
chr
((
$high
>>
24
)
&
0x000000FF
);
return
8
;
return
8
;
}
}
}
}
php/src/Google/Protobuf/Internal/Type.php
deleted
100644 → 0
View file @
58580da3
<?php
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS 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 COPYRIGHT
// OWNER OR 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.
namespace
Google\Protobuf\Internal
;
class
GPBInteger
{
public
$high
=
0
;
public
$low
=
0
;
public
function
__construct
(
$value
=
0
)
{
$this
->
low
=
$value
&
0xFFFFFFFF
;
if
(
PHP_INT_SIZE
===
8
)
{
$this
->
high
=
(
$value
>>
32
)
&
0xFFFFFFFF
;
}
}
// Return 0 for unsigned integers and 1 for signed integers.
protected
function
sign
()
{
trigger_error
(
"Not implemented"
,
E_ERROR
);
}
public
function
leftShift
(
$count
)
{
if
(
$count
>
63
)
{
$this
->
low
=
0
;
$this
->
high
=
0
;
return
;
}
if
(
$count
>
32
)
{
$this
->
high
=
$this
->
low
;
$this
->
low
=
0
;
$count
-=
32
;
}
$mask
=
(
1
<<
$count
)
-
1
;
$this
->
high
=
((
$this
->
high
<<
$count
)
&
0xFFFFFFFF
)
|
((
$this
->
low
>>
(
32
-
$count
))
&
$mask
);
$this
->
low
=
(
$this
->
low
<<
$count
)
&
0xFFFFFFFF
;
$this
->
high
&=
0xFFFFFFFF
;
$this
->
low
&=
0xFFFFFFFF
;
return
$this
;
}
public
function
rightShift
(
$count
)
{
$sign
=
((
$this
->
high
&
0x80000000
)
>>
31
)
&
$this
->
sign
();
if
(
$count
>
63
)
{
$this
->
low
=
-
$sign
;
$this
->
high
=
-
$sign
;
return
;
}
if
(
$count
>
32
)
{
$this
->
low
=
$this
->
high
;
$this
->
high
=
-
$sign
;
$count
-=
32
;
}
$this
->
low
=
((
$this
->
low
>>
$count
)
&
0xFFFFFFFF
)
|
((
$this
->
high
<<
(
32
-
$count
))
&
0xFFFFFFFF
);
$this
->
high
=
((
$this
->
high
>>
$count
)
|
(
-
$sign
<<
$count
));
$this
->
high
&=
0xFFFFFFFF
;
$this
->
low
&=
0xFFFFFFFF
;
return
$this
;
}
public
function
bitOr
(
$var
)
{
$this
->
high
|=
$var
->
high
;
$this
->
low
|=
$var
->
low
;
return
$this
;
}
public
function
bitXor
(
$var
)
{
$this
->
high
^=
$var
->
high
;
$this
->
low
^=
$var
->
low
;
return
$this
;
}
public
function
bitAnd
(
$var
)
{
$this
->
high
&=
$var
->
high
;
$this
->
low
&=
$var
->
low
;
return
$this
;
}
// Even: all zero; Odd: all one.
public
function
oddMask
()
{
$low
=
(
-
(
$this
->
low
&
1
))
&
0xFFFFFFFF
;
$high
=
$low
;
return
UInt64
::
newValue
(
$high
,
$low
);
}
public
function
toInteger
()
{
if
(
PHP_INT_SIZE
===
8
)
{
return
(
$this
->
high
<<
32
)
|
$this
->
low
;
}
else
{
return
$this
->
low
;
}
}
public
function
copy
()
{
return
static
::
newValue
(
$this
->
high
,
$this
->
low
);
}
}
class
Uint64
extends
GPBInteger
{
public
static
function
newValue
(
$high
,
$low
)
{
$uint64
=
new
Uint64
(
0
);
$uint64
->
high
=
$high
;
$uint64
->
low
=
$low
;
return
$uint64
;
}
protected
function
sign
()
{
return
0
;
}
}
class
Int64
extends
GPBInteger
{
public
static
function
newValue
(
$high
,
$low
)
{
$int64
=
new
Int64
(
0
);
$int64
->
high
=
$high
;
$int64
->
low
=
$low
;
return
$int64
;
}
protected
function
sign
()
{
return
1
;
}
}
php/tests/array_test.php
View file @
51c5ff88
...
@@ -225,46 +225,68 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase
...
@@ -225,46 +225,68 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase
// Test append.
// Test append.
$arr
[]
=
MAX_INT64
;
$arr
[]
=
MAX_INT64
;
$this
->
assertSame
(
MAX_INT64
,
$arr
[
0
]);
$arr
[]
=
MIN_INT64
;
$arr
[]
=
MIN_INT64
;
$this
->
assertEquals
(
MIN_INT64
,
$arr
[
1
]);
$arr
[]
=
1.1
;
$arr
[]
=
1.1
;
$this
->
assertSame
(
1
,
$arr
[
2
]);
$arr
[]
=
'2'
;
$arr
[]
=
'2'
;
$this
->
assertSame
(
2
,
$arr
[
3
]);
$arr
[]
=
'3.1'
;
$arr
[]
=
'3.1'
;
$this
->
assertSame
(
3
,
$arr
[
4
]);
$arr
[]
=
MAX_INT64_STRING
;
$arr
[]
=
MAX_INT64_STRING
;
$this
->
assertSame
(
MAX_INT64
,
$arr
[
5
]);
$arr
[]
=
MIN_INT64_STRING
;
$arr
[]
=
MIN_INT64_STRING
;
$this
->
assertEquals
(
MIN_INT64
,
$arr
[
6
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_INT64
,
$arr
[
0
]);
$this
->
assertSame
(
MIN_INT64
,
$arr
[
1
]);
$this
->
assertSame
(
'1'
,
$arr
[
2
]);
$this
->
assertSame
(
'2'
,
$arr
[
3
]);
$this
->
assertSame
(
'3'
,
$arr
[
4
]);
$this
->
assertSame
(
MAX_INT64_STRING
,
$arr
[
5
]);
$this
->
assertSame
(
MIN_INT64_STRING
,
$arr
[
6
]);
}
else
{
$this
->
assertSame
(
MAX_INT64
,
$arr
[
0
]);
$this
->
assertSame
(
MIN_INT64
,
$arr
[
1
]);
$this
->
assertSame
(
1
,
$arr
[
2
]);
$this
->
assertSame
(
2
,
$arr
[
3
]);
$this
->
assertSame
(
3
,
$arr
[
4
]);
$this
->
assertSame
(
MAX_INT64
,
$arr
[
5
]);
$this
->
assertSame
(
MIN_INT64
,
$arr
[
6
]);
}
$this
->
assertEquals
(
7
,
count
(
$arr
));
$this
->
assertEquals
(
7
,
count
(
$arr
));
for
(
$i
=
0
;
$i
<
count
(
$arr
);
$i
++
)
{
for
(
$i
=
0
;
$i
<
count
(
$arr
);
$i
++
)
{
$arr
[
$i
]
=
0
;
$arr
[
$i
]
=
0
;
$this
->
assertSame
(
0
,
$arr
[
$i
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'0'
,
$arr
[
$i
]);
}
else
{
$this
->
assertSame
(
0
,
$arr
[
$i
]);
}
}
}
// Test set.
// Test set.
$arr
[
0
]
=
MAX_INT64
;
$arr
[
0
]
=
MAX_INT64
;
$this
->
assertSame
(
MAX_INT64
,
$arr
[
0
]);
$arr
[
1
]
=
MIN_INT64
;
$arr
[
1
]
=
MIN_INT64
;
$this
->
assertEquals
(
MIN_INT64
,
$arr
[
1
]);
$arr
[
2
]
=
1.1
;
$arr
[
2
]
=
1.1
;
$this
->
assertSame
(
1
,
$arr
[
2
]);
$arr
[
3
]
=
'2'
;
$arr
[
3
]
=
'2'
;
$this
->
assertSame
(
2
,
$arr
[
3
]);
$arr
[
4
]
=
'3.1'
;
$arr
[
4
]
=
'3.1'
;
$this
->
assertSame
(
3
,
$arr
[
4
]);
$arr
[
5
]
=
MAX_INT64_STRING
;
$arr
[
5
]
=
MAX_INT64_STRING
;
$this
->
assertSame
(
MAX_INT64
,
$arr
[
5
]);
$arr
[
6
]
=
MIN_INT64_STRING
;
$arr
[
6
]
=
MIN_INT64_STRING
;
$this
->
assertEquals
(
MIN_INT64
,
$arr
[
6
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_INT64_STRING
,
$arr
[
0
]);
$this
->
assertSame
(
MIN_INT64_STRING
,
$arr
[
1
]);
$this
->
assertSame
(
'1'
,
$arr
[
2
]);
$this
->
assertSame
(
'2'
,
$arr
[
3
]);
$this
->
assertSame
(
'3'
,
$arr
[
4
]);
$this
->
assertSame
(
MAX_INT64_STRING
,
$arr
[
5
]);
$this
->
assertEquals
(
MIN_INT64_STRING
,
$arr
[
6
]);
}
else
{
$this
->
assertSame
(
MAX_INT64
,
$arr
[
0
]);
$this
->
assertSame
(
MIN_INT64
,
$arr
[
1
]);
$this
->
assertSame
(
1
,
$arr
[
2
]);
$this
->
assertSame
(
2
,
$arr
[
3
]);
$this
->
assertSame
(
3
,
$arr
[
4
]);
$this
->
assertSame
(
MAX_INT64
,
$arr
[
5
]);
$this
->
assertEquals
(
MIN_INT64
,
$arr
[
6
]);
}
}
}
/**
/**
...
@@ -315,38 +337,57 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase
...
@@ -315,38 +337,57 @@ class RepeatedFieldTest extends PHPUnit_Framework_TestCase
// Test append.
// Test append.
$arr
[]
=
MAX_UINT64
;
$arr
[]
=
MAX_UINT64
;
$this
->
assertEquals
(
MAX_UINT64
,
$arr
[
0
]);
$arr
[]
=
1.1
;
$arr
[]
=
1.1
;
$this
->
assertSame
(
1
,
$arr
[
1
]);
$arr
[]
=
'2'
;
$arr
[]
=
'2'
;
$this
->
assertSame
(
2
,
$arr
[
2
]);
$arr
[]
=
'3.1'
;
$arr
[]
=
'3.1'
;
$this
->
assertSame
(
3
,
$arr
[
3
]);
$arr
[]
=
MAX_UINT64_STRING
;
$arr
[]
=
MAX_UINT64_STRING
;
$this
->
assertEquals
(
MAX_UINT64
,
$arr
[
4
]);
$this
->
assertEquals
(
5
,
count
(
$arr
));
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_UINT64_STRING
,
$arr
[
0
]);
$this
->
assertSame
(
'1'
,
$arr
[
1
]);
$this
->
assertSame
(
'2'
,
$arr
[
2
]);
$this
->
assertSame
(
'3'
,
$arr
[
3
]);
$this
->
assertSame
(
MAX_UINT64_STRING
,
$arr
[
4
]);
}
else
{
$this
->
assertSame
(
MAX_UINT64
,
$arr
[
0
]);
$this
->
assertSame
(
1
,
$arr
[
1
]);
$this
->
assertSame
(
2
,
$arr
[
2
]);
$this
->
assertSame
(
3
,
$arr
[
3
]);
$this
->
assertSame
(
MAX_UINT64
,
$arr
[
4
]);
$this
->
assertSame
(
5
,
count
(
$arr
));
}
$this
->
assertSame
(
5
,
count
(
$arr
));
for
(
$i
=
0
;
$i
<
count
(
$arr
);
$i
++
)
{
for
(
$i
=
0
;
$i
<
count
(
$arr
);
$i
++
)
{
$arr
[
$i
]
=
0
;
$arr
[
$i
]
=
0
;
$this
->
assertSame
(
0
,
$arr
[
$i
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'0'
,
$arr
[
$i
]);
}
else
{
$this
->
assertSame
(
0
,
$arr
[
$i
]);
}
}
}
// Test set.
// Test set.
$arr
[
0
]
=
MAX_UINT64
;
$arr
[
0
]
=
MAX_UINT64
;
$this
->
assertEquals
(
MAX_UINT64
,
$arr
[
0
]);
$arr
[
1
]
=
1.1
;
$arr
[
1
]
=
1.1
;
$this
->
assertSame
(
1
,
$arr
[
1
]);
$arr
[
2
]
=
'2'
;
$arr
[
2
]
=
'2'
;
$this
->
assertSame
(
2
,
$arr
[
2
]);
$arr
[
3
]
=
'3.1'
;
$arr
[
3
]
=
'3.1'
;
$this
->
assertSame
(
3
,
$arr
[
3
]);
$arr
[
4
]
=
MAX_UINT64_STRING
;
$arr
[
4
]
=
MAX_UINT64_STRING
;
$this
->
assertEquals
(
MAX_UINT64
,
$arr
[
4
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_UINT64_STRING
,
$arr
[
0
]);
$this
->
assertSame
(
'1'
,
$arr
[
1
]);
$this
->
assertSame
(
'2'
,
$arr
[
2
]);
$this
->
assertSame
(
'3'
,
$arr
[
3
]);
$this
->
assertSame
(
MAX_UINT64_STRING
,
$arr
[
4
]);
}
else
{
$this
->
assertSame
(
MAX_UINT64
,
$arr
[
0
]);
$this
->
assertSame
(
1
,
$arr
[
1
]);
$this
->
assertSame
(
2
,
$arr
[
2
]);
$this
->
assertSame
(
3
,
$arr
[
3
]);
$this
->
assertSame
(
MAX_UINT64
,
$arr
[
4
]);
}
}
}
/**
/**
...
...
php/tests/generated_class_test.php
View file @
51c5ff88
...
@@ -148,17 +148,40 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase
...
@@ -148,17 +148,40 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase
// Set float.
// Set float.
$m
->
setOptionalInt64
(
1.1
);
$m
->
setOptionalInt64
(
1.1
);
$this
->
assertSame
(
1
,
$m
->
getOptionalInt64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'1'
,
$m
->
getOptionalInt64
());
}
else
{
$this
->
assertSame
(
1
,
$m
->
getOptionalInt64
());
}
// Set string.
// Set string.
$m
->
setOptionalInt64
(
'2'
);
$m
->
setOptionalInt64
(
'2'
);
$this
->
assertSame
(
2
,
$m
->
getOptionalInt64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'2'
,
$m
->
getOptionalInt64
());
}
else
{
$this
->
assertSame
(
2
,
$m
->
getOptionalInt64
());
}
$m
->
setOptionalInt64
(
'3.1'
);
$m
->
setOptionalInt64
(
'3.1'
);
$this
->
assertSame
(
3
,
$m
->
getOptionalInt64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'3'
,
$m
->
getOptionalInt64
());
}
else
{
$this
->
assertSame
(
3
,
$m
->
getOptionalInt64
());
}
$m
->
setOptionalInt64
(
MAX_INT64_STRING
);
$m
->
setOptionalInt64
(
MAX_INT64_STRING
);
$this
->
assertSame
(
MAX_INT64
,
$m
->
getOptionalInt64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_INT64_STRING
,
$m
->
getOptionalInt64
());
}
else
{
$this
->
assertSame
(
MAX_INT64
,
$m
->
getOptionalInt64
());
}
$m
->
setOptionalInt64
(
MIN_INT64_STRING
);
$m
->
setOptionalInt64
(
MIN_INT64_STRING
);
$this
->
assertEquals
(
MIN_INT64
,
$m
->
getOptionalInt64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MIN_INT64_STRING
,
$m
->
getOptionalInt64
());
}
else
{
$this
->
assertSame
(
MIN_INT64
,
$m
->
getOptionalInt64
());
}
}
}
/**
/**
...
@@ -189,19 +212,41 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase
...
@@ -189,19 +212,41 @@ class GeneratedClassTest extends PHPUnit_Framework_TestCase
// Set integer.
// Set integer.
$m
->
setOptionalUint64
(
MAX_UINT64
);
$m
->
setOptionalUint64
(
MAX_UINT64
);
$this
->
assertEquals
(
MAX_UINT64
,
$m
->
getOptionalUint64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_UINT64_STRING
,
$m
->
getOptionalUint64
());
}
else
{
$this
->
assertSame
(
MAX_UINT64
,
$m
->
getOptionalUint64
());
}
// Set float.
// Set float.
$m
->
setOptionalUint64
(
1.1
);
$m
->
setOptionalUint64
(
1.1
);
$this
->
assertSame
(
1
,
$m
->
getOptionalUint64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'1'
,
$m
->
getOptionalUint64
());
}
else
{
$this
->
assertSame
(
1
,
$m
->
getOptionalUint64
());
}
// Set string.
// Set string.
$m
->
setOptionalUint64
(
'2'
);
$m
->
setOptionalUint64
(
'2'
);
$this
->
assertSame
(
2
,
$m
->
getOptionalUint64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'2'
,
$m
->
getOptionalUint64
());
}
else
{
$this
->
assertSame
(
2
,
$m
->
getOptionalUint64
());
}
$m
->
setOptionalUint64
(
'3.1'
);
$m
->
setOptionalUint64
(
'3.1'
);
$this
->
assertSame
(
3
,
$m
->
getOptionalUint64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'3'
,
$m
->
getOptionalUint64
());
}
else
{
$this
->
assertSame
(
3
,
$m
->
getOptionalUint64
());
}
$m
->
setOptionalUint64
(
MAX_UINT64_STRING
);
$m
->
setOptionalUint64
(
MAX_UINT64_STRING
);
$this
->
assertEquals
(
MAX_UINT64
,
$m
->
getOptionalUint64
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_UINT64_STRING
,
$m
->
getOptionalUint64
());
}
else
{
$this
->
assertSame
(
MAX_UINT64
,
$m
->
getOptionalUint64
());
}
}
}
/**
/**
...
...
php/tests/map_field_test.php
View file @
51c5ff88
...
@@ -205,9 +205,14 @@ class MapFieldTest extends PHPUnit_Framework_TestCase {
...
@@ -205,9 +205,14 @@ class MapFieldTest extends PHPUnit_Framework_TestCase {
// Test integer argument.
// Test integer argument.
$arr
[
MAX_INT64
]
=
MAX_INT64
;
$arr
[
MAX_INT64
]
=
MAX_INT64
;
$this
->
assertSame
(
MAX_INT64
,
$arr
[
MAX_INT64
]);
$arr
[
MIN_INT64
]
=
MIN_INT64
;
$arr
[
MIN_INT64
]
=
MIN_INT64
;
$this
->
assertEquals
(
MIN_INT64
,
$arr
[
MIN_INT64
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_INT64_STRING
,
$arr
[
MAX_INT64_STRING
]);
$this
->
assertSame
(
MIN_INT64_STRING
,
$arr
[
MIN_INT64_STRING
]);
}
else
{
$this
->
assertSame
(
MAX_INT64
,
$arr
[
MAX_INT64
]);
$this
->
assertSame
(
MIN_INT64
,
$arr
[
MIN_INT64
]);
}
$this
->
assertEquals
(
2
,
count
(
$arr
));
$this
->
assertEquals
(
2
,
count
(
$arr
));
unset
(
$arr
[
MAX_INT64
]);
unset
(
$arr
[
MAX_INT64
]);
unset
(
$arr
[
MIN_INT64
]);
unset
(
$arr
[
MIN_INT64
]);
...
@@ -215,20 +220,31 @@ class MapFieldTest extends PHPUnit_Framework_TestCase {
...
@@ -215,20 +220,31 @@ class MapFieldTest extends PHPUnit_Framework_TestCase {
// Test float argument.
// Test float argument.
$arr
[
1.1
]
=
1.1
;
$arr
[
1.1
]
=
1.1
;
$this
->
assertSame
(
1
,
$arr
[
1
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'1'
,
$arr
[
'1'
]);
}
else
{
$this
->
assertSame
(
1
,
$arr
[
1
]);
}
$this
->
assertEquals
(
1
,
count
(
$arr
));
$this
->
assertEquals
(
1
,
count
(
$arr
));
unset
(
$arr
[
1.1
]);
unset
(
$arr
[
1.1
]);
$this
->
assertEquals
(
0
,
count
(
$arr
));
$this
->
assertEquals
(
0
,
count
(
$arr
));
// Test string argument.
// Test string argument.
$arr
[
'2'
]
=
'2'
;
$arr
[
'2'
]
=
'2'
;
$this
->
assertSame
(
2
,
$arr
[
2
]);
$arr
[
'3.1'
]
=
'3.1'
;
$arr
[
'3.1'
]
=
'3.1'
;
$this
->
assertSame
(
3
,
$arr
[
3
]);
$arr
[
MAX_INT64_STRING
]
=
MAX_INT64_STRING
;
$arr
[
MAX_INT64_STRING
]
=
MAX_INT64_STRING
;
$this
->
assertSame
(
MAX_INT64
,
$arr
[
MAX_INT64
]);
$arr
[
MIN_INT64_STRING
]
=
MIN_INT64_STRING
;
$arr
[
MIN_INT64_STRING
]
=
MIN_INT64_STRING
;
$this
->
assertEquals
(
MIN_INT64
,
$arr
[
MIN_INT64
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'2'
,
$arr
[
'2'
]);
$this
->
assertSame
(
'3'
,
$arr
[
'3'
]);
$this
->
assertSame
(
MAX_INT64_STRING
,
$arr
[
MAX_INT64_STRING
]);
$this
->
assertSame
(
MIN_INT64_STRING
,
$arr
[
MIN_INT64_STRING
]);
}
else
{
$this
->
assertSame
(
2
,
$arr
[
2
]);
$this
->
assertSame
(
3
,
$arr
[
3
]);
$this
->
assertSame
(
MAX_INT64
,
$arr
[
MAX_INT64
]);
$this
->
assertSame
(
MIN_INT64
,
$arr
[
MIN_INT64
]);
}
$this
->
assertEquals
(
4
,
count
(
$arr
));
$this
->
assertEquals
(
4
,
count
(
$arr
));
unset
(
$arr
[
'2'
]);
unset
(
$arr
[
'2'
]);
unset
(
$arr
[
'3.1'
]);
unset
(
$arr
[
'3.1'
]);
...
@@ -282,25 +298,41 @@ class MapFieldTest extends PHPUnit_Framework_TestCase {
...
@@ -282,25 +298,41 @@ class MapFieldTest extends PHPUnit_Framework_TestCase {
// Test integer argument.
// Test integer argument.
$arr
[
MAX_UINT64
]
=
MAX_UINT64
;
$arr
[
MAX_UINT64
]
=
MAX_UINT64
;
$this
->
assertEquals
(
MAX_UINT64
,
$arr
[
MAX_UINT64
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
MAX_UINT64_STRING
,
$arr
[
MAX_UINT64_STRING
]);
}
else
{
$this
->
assertSame
(
MAX_UINT64
,
$arr
[
MAX_UINT64
]);
}
$this
->
assertEquals
(
1
,
count
(
$arr
));
$this
->
assertEquals
(
1
,
count
(
$arr
));
unset
(
$arr
[
MAX_UINT64
]);
unset
(
$arr
[
MAX_UINT64
]);
$this
->
assertEquals
(
0
,
count
(
$arr
));
$this
->
assertEquals
(
0
,
count
(
$arr
));
// Test float argument.
// Test float argument.
$arr
[
1.1
]
=
1.1
;
$arr
[
1.1
]
=
1.1
;
$this
->
assertSame
(
1
,
$arr
[
1
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'1'
,
$arr
[
'1'
]);
}
else
{
$this
->
assertSame
(
1
,
$arr
[
1
]);
}
$this
->
assertEquals
(
1
,
count
(
$arr
));
$this
->
assertEquals
(
1
,
count
(
$arr
));
unset
(
$arr
[
1.1
]);
unset
(
$arr
[
1.1
]);
$this
->
assertEquals
(
0
,
count
(
$arr
));
$this
->
assertEquals
(
0
,
count
(
$arr
));
// Test string argument.
// Test string argument.
$arr
[
'2'
]
=
'2'
;
$arr
[
'2'
]
=
'2'
;
$this
->
assertSame
(
2
,
$arr
[
2
]);
$arr
[
'3.1'
]
=
'3.1'
;
$arr
[
'3.1'
]
=
'3.1'
;
$this
->
assertSame
(
3
,
$arr
[
3
]);
$arr
[
MAX_UINT64_STRING
]
=
MAX_UINT64_STRING
;
$arr
[
MAX_UINT64_STRING
]
=
MAX_UINT64_STRING
;
$this
->
assertEquals
(
MAX_UINT64
,
$arr
[
MAX_UINT64
]);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'2'
,
$arr
[
'2'
]);
$this
->
assertSame
(
'3'
,
$arr
[
'3'
]);
$this
->
assertSame
(
MAX_UINT64_STRING
,
$arr
[
MAX_UINT64_STRING
]);
}
else
{
$this
->
assertSame
(
2
,
$arr
[
2
]);
$this
->
assertSame
(
3
,
$arr
[
3
]);
$this
->
assertSame
(
MAX_UINT64
,
$arr
[
MAX_UINT64
]);
}
$this
->
assertEquals
(
3
,
count
(
$arr
));
$this
->
assertEquals
(
3
,
count
(
$arr
));
unset
(
$arr
[
'2'
]);
unset
(
$arr
[
'2'
]);
unset
(
$arr
[
'3.1'
]);
unset
(
$arr
[
'3.1'
]);
...
...
php/tests/php_implementation_test.php
View file @
51c5ff88
...
@@ -9,14 +9,10 @@ use Foo\TestMessage_Sub;
...
@@ -9,14 +9,10 @@ use Foo\TestMessage_Sub;
use
Foo\TestPackedMessage
;
use
Foo\TestPackedMessage
;
use
Google\Protobuf\Internal\InputStream
;
use
Google\Protobuf\Internal\InputStream
;
use
Google\Protobuf\Internal\FileDescriptorSet
;
use
Google\Protobuf\Internal\FileDescriptorSet
;
use
Google\Protobuf\Internal\GPBUtil
;
use
Google\Protobuf\Internal\Int64
;
use
Google\Protobuf\Internal\Uint64
;
use
Google\Protobuf\Internal\GPBLabel
;
use
Google\Protobuf\Internal\GPBLabel
;
use
Google\Protobuf\Internal\GPBType
;
use
Google\Protobuf\Internal\GPBType
;
use
Google\Protobuf\Internal\GPBWire
;
use
Google\Protobuf\Internal\GPBWire
;
use
Google\Protobuf\Internal\OutputStream
;
use
Google\Protobuf\Internal\OutputStream
;
use
Google\Protobuf\Internal\RepeatedField
;
class
ImplementationTest
extends
TestBase
class
ImplementationTest
extends
TestBase
{
{
...
@@ -68,17 +64,17 @@ class ImplementationTest extends TestBase
...
@@ -68,17 +64,17 @@ class ImplementationTest extends TestBase
// Positive number.
// Positive number.
$input
=
new
InputStream
(
hex2bin
(
"01"
));
$input
=
new
InputStream
(
hex2bin
(
"01"
));
GPBWire
::
readInt64
(
$input
,
$value
);
GPBWire
::
readInt64
(
$input
,
$value
);
$this
->
assert
Same
(
1
,
$value
->
toInteger
()
);
$this
->
assert
Equals
(
1
,
$value
);
// Negative number.
// Negative number.
$input
=
new
InputStream
(
hex2bin
(
"ffffffffffffffffff01"
));
$input
=
new
InputStream
(
hex2bin
(
"ffffffffffffffffff01"
));
GPBWire
::
readInt64
(
$input
,
$value
);
GPBWire
::
readInt64
(
$input
,
$value
);
$this
->
assert
Same
(
-
1
,
$value
->
toInteger
()
);
$this
->
assert
Equals
(
-
1
,
$value
);
// Discard overflow bits.
// Discard overflow bits.
$input
=
new
InputStream
(
hex2bin
(
"ffffffffffffffffff0f"
));
$input
=
new
InputStream
(
hex2bin
(
"ffffffffffffffffff0f"
));
GPBWire
::
readInt64
(
$input
,
$value
);
GPBWire
::
readInt64
(
$input
,
$value
);
$this
->
assert
Same
(
-
1
,
$value
->
toInteger
()
);
$this
->
assert
Equals
(
-
1
,
$value
);
}
}
public
function
testReadUint64
()
public
function
testReadUint64
()
...
@@ -88,17 +84,17 @@ class ImplementationTest extends TestBase
...
@@ -88,17 +84,17 @@ class ImplementationTest extends TestBase
// Positive number.
// Positive number.
$input
=
new
InputStream
(
hex2bin
(
"01"
));
$input
=
new
InputStream
(
hex2bin
(
"01"
));
GPBWire
::
readUint64
(
$input
,
$value
);
GPBWire
::
readUint64
(
$input
,
$value
);
$this
->
assert
Same
(
1
,
$value
->
toInteger
()
);
$this
->
assert
Equals
(
1
,
$value
);
// Negative number.
// Negative number.
$input
=
new
InputStream
(
hex2bin
(
"FFFFFFFFFFFFFFFFFF01"
));
$input
=
new
InputStream
(
hex2bin
(
"FFFFFFFFFFFFFFFFFF01"
));
GPBWire
::
readUint64
(
$input
,
$value
);
GPBWire
::
readUint64
(
$input
,
$value
);
$this
->
assert
Same
(
-
1
,
$value
->
toInteger
()
);
$this
->
assert
Equals
(
-
1
,
$value
);
// Discard overflow bits.
// Discard overflow bits.
$input
=
new
InputStream
(
hex2bin
(
"FFFFFFFFFFFFFFFFFF0F"
));
$input
=
new
InputStream
(
hex2bin
(
"FFFFFFFFFFFFFFFFFF0F"
));
GPBWire
::
readUint64
(
$input
,
$value
);
GPBWire
::
readUint64
(
$input
,
$value
);
$this
->
assert
Same
(
-
1
,
$value
->
toInteger
()
);
$this
->
assert
Equals
(
-
1
,
$value
);
}
}
public
function
testReadSint32
()
public
function
testReadSint32
()
...
@@ -124,15 +120,15 @@ class ImplementationTest extends TestBase
...
@@ -124,15 +120,15 @@ class ImplementationTest extends TestBase
$input
=
new
InputStream
(
hex2bin
(
"00"
));
$input
=
new
InputStream
(
hex2bin
(
"00"
));
GPBWire
::
readSint64
(
$input
,
$value
);
GPBWire
::
readSint64
(
$input
,
$value
);
$this
->
assertEquals
(
GPBUtil
::
Int64
(
0
)
,
$value
);
$this
->
assertEquals
(
0
,
$value
);
$input
=
new
InputStream
(
hex2bin
(
"01"
));
$input
=
new
InputStream
(
hex2bin
(
"01"
));
GPBWire
::
readSint64
(
$input
,
$value
);
GPBWire
::
readSint64
(
$input
,
$value
);
$this
->
assertEquals
(
GPBUtil
::
Int64
(
-
1
)
,
$value
);
$this
->
assertEquals
(
-
1
,
$value
);
$input
=
new
InputStream
(
hex2bin
(
"02"
));
$input
=
new
InputStream
(
hex2bin
(
"02"
));
GPBWire
::
readSint64
(
$input
,
$value
);
GPBWire
::
readSint64
(
$input
,
$value
);
$this
->
assertEquals
(
GPBUtil
::
Int64
(
1
)
,
$value
);
$this
->
assertEquals
(
1
,
$value
);
}
}
public
function
testReadFixed32
()
public
function
testReadFixed32
()
...
@@ -148,7 +144,11 @@ class ImplementationTest extends TestBase
...
@@ -148,7 +144,11 @@ class ImplementationTest extends TestBase
$value
=
null
;
$value
=
null
;
$input
=
new
InputStream
(
hex2bin
(
"1234567812345678"
));
$input
=
new
InputStream
(
hex2bin
(
"1234567812345678"
));
GPBWire
::
readFixed64
(
$input
,
$value
);
GPBWire
::
readFixed64
(
$input
,
$value
);
$this
->
assertEquals
(
Uint64
::
newValue
(
0x78563412
,
0x78563412
),
$value
);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
"8671175386481439762"
,
$value
);
}
else
{
$this
->
assertSame
(
0x7856341278563412
,
$value
);
}
}
}
public
function
testReadSfixed32
()
public
function
testReadSfixed32
()
...
@@ -193,7 +193,11 @@ class ImplementationTest extends TestBase
...
@@ -193,7 +193,11 @@ class ImplementationTest extends TestBase
$value
=
null
;
$value
=
null
;
$input
=
new
InputStream
(
hex2bin
(
"1234567812345678"
));
$input
=
new
InputStream
(
hex2bin
(
"1234567812345678"
));
GPBWire
::
readSfixed64
(
$input
,
$value
);
GPBWire
::
readSfixed64
(
$input
,
$value
);
$this
->
assertEquals
(
Int64
::
newValue
(
0x78563412
,
0x78563412
),
$value
);
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
"8671175386481439762"
,
$value
);
}
else
{
$this
->
assertSame
(
0x7856341278563412
,
$value
);
}
}
}
public
function
testZigZagEncodeDecode
()
public
function
testZigZagEncodeDecode
()
...
@@ -214,43 +218,65 @@ class ImplementationTest extends TestBase
...
@@ -214,43 +218,65 @@ class ImplementationTest extends TestBase
$this
->
assertSame
(
0x3FFFFFFF
,
GPBWire
::
zigZagDecode32
(
0x7FFFFFFE
));
$this
->
assertSame
(
0x3FFFFFFF
,
GPBWire
::
zigZagDecode32
(
0x7FFFFFFE
));
$this
->
assertSame
(
-
1073741824
,
GPBWire
::
zigZagDecode32
(
0x7FFFFFFF
));
$this
->
assertSame
(
-
1073741824
,
GPBWire
::
zigZagDecode32
(
0x7FFFFFFF
));
$this
->
assertSame
(
0x7FFFFFFF
,
GPBWire
::
zigZagDecode32
(
0xFFFFFFFE
));
$this
->
assertSame
(
0x7FFFFFFF
,
GPBWire
::
zigZagDecode32
(
0xFFFFFFFE
));
$this
->
assertSame
(
-
2147483648
,
GPBWire
::
zigZagDecode32
(
0xFFFFFFFF
));
$this
->
assertSame
((
int
)
-
2147483648
,
GPBWire
::
zigZagDecode32
(
0xFFFFFFFF
));
$this
->
assertEquals
(
GPBUtil
::
Uint64
(
0
),
if
(
PHP_INT_SIZE
==
4
)
{
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
0
)));
$this
->
assertSame
(
'0'
,
GPBWire
::
zigZagEncode64
(
0
));
$this
->
assertEquals
(
GPBUtil
::
Uint64
(
1
),
$this
->
assertSame
(
'1'
,
GPBWire
::
zigZagEncode64
(
-
1
));
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
-
1
)));
$this
->
assertSame
(
'2'
,
GPBWire
::
zigZagEncode64
(
1
));
$this
->
assertEquals
(
GPBUtil
::
Uint64
(
2
),
$this
->
assertSame
(
'3'
,
GPBWire
::
zigZagEncode64
(
-
2
));
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
1
)));
$this
->
assertSame
(
$this
->
assertEquals
(
GPBUtil
::
Uint64
(
3
),
'2147483646'
,
// 0x7FFFFFE
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
-
2
)));
GPBWire
::
zigZagEncode64
(
0x3FFFFFFF
));
$this
->
assertEquals
(
$this
->
assertSame
(
GPBUtil
::
Uint64
(
0x000000007FFFFFFE
),
'2147483647'
,
// 0x7FFFFFF
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
0x000000003FFFFFFF
)));
GPBWire
::
zigZagEncode64
(
-
1073741824
));
// 0xFFFFFFFFC0000000
$this
->
assertEquals
(
$this
->
assertSame
(
GPBUtil
::
Uint64
(
0x000000007FFFFFFF
),
'4294967294'
,
// 0xFFFFFFFE
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
0xFFFFFFFFC0000000
)));
GPBWire
::
zigZagEncode64
(
2147483647
));
// 0x7FFFFFFF
$this
->
assertEquals
(
$this
->
assertSame
(
GPBUtil
::
Uint64
(
0x00000000FFFFFFFE
),
'4294967295'
,
// 0xFFFFFFFF
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
0x000000007FFFFFFF
)));
GPBWire
::
zigZagEncode64
(
-
2147483648
));
// 0xFFFFFFFF80000000
$this
->
assertEquals
(
$this
->
assertSame
(
GPBUtil
::
Uint64
(
0x00000000FFFFFFFF
),
'18446744073709551614'
,
// 0xFFFFFFFFFFFFFFFE
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
0xFFFFFFFF80000000
)));
// 0x7FFFFFFFFFFFFFFF
$this
->
assertEquals
(
GPBWire
::
zigZagEncode64
(
"9223372036854775807"
));
Uint64
::
newValue
(
4294967295
,
4294967294
),
$this
->
assertSame
(
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
0x7FFFFFFFFFFFFFFF
)));
'18446744073709551615'
,
// 0xFFFFFFFFFFFFFFFF
$this
->
assertEquals
(
// 0x8000000000000000
Uint64
::
newValue
(
4294967295
,
4294967295
),
GPBWire
::
zigZagEncode64
(
"-9223372036854775808"
));
GPBWire
::
zigZagEncode64
(
GPBUtil
::
Int64
(
0x8000000000000000
)));
$this
->
assertSame
(
'0'
,
GPBWire
::
zigZagDecode64
(
0
));
$this
->
assertEquals
(
GPBUtil
::
Int64
(
0
),
$this
->
assertSame
(
'-1'
,
GPBWire
::
zigZagDecode64
(
1
));
GPBWire
::
zigZagDecode64
(
GPBUtil
::
Uint64
(
0
)));
$this
->
assertSame
(
'1'
,
GPBWire
::
zigZagDecode64
(
2
));
$this
->
assertEquals
(
GPBUtil
::
Int64
(
-
1
),
$this
->
assertSame
(
'-2'
,
GPBWire
::
zigZagDecode64
(
3
));
GPBWire
::
zigZagDecode64
(
GPBUtil
::
Uint64
(
1
)));
}
else
{
$this
->
assertEquals
(
GPBUtil
::
Int64
(
1
),
$this
->
assertSame
(
0
,
GPBWire
::
zigZagEncode64
(
0
));
GPBWire
::
zigZagDecode64
(
GPBUtil
::
Uint64
(
2
)));
$this
->
assertSame
(
1
,
GPBWire
::
zigZagEncode64
(
-
1
));
$this
->
assertEquals
(
GPBUtil
::
Int64
(
-
2
),
$this
->
assertSame
(
2
,
GPBWire
::
zigZagEncode64
(
1
));
GPBWire
::
zigZagDecode64
(
GPBUtil
::
Uint64
(
3
)));
$this
->
assertSame
(
3
,
GPBWire
::
zigZagEncode64
(
-
2
));
$this
->
assertSame
(
0x7FFFFFFE
,
GPBWire
::
zigZagEncode64
(
0x3FFFFFFF
));
$this
->
assertSame
(
0x7FFFFFFF
,
GPBWire
::
zigZagEncode64
(
0xFFFFFFFFC0000000
));
$this
->
assertSame
(
0xFFFFFFFE
,
GPBWire
::
zigZagEncode64
(
0x7FFFFFFF
));
$this
->
assertSame
(
0xFFFFFFFF
,
GPBWire
::
zigZagEncode64
(
0xFFFFFFFF80000000
));
$this
->
assertSame
(
-
2
,
// 0xFFFFFFFFFFFFFFFE
GPBWire
::
zigZagEncode64
(
0x7FFFFFFFFFFFFFFF
));
$this
->
assertSame
(
-
1
,
// 0xFFFFFFFFFFFFFFFF
GPBWire
::
zigZagEncode64
(
0x8000000000000000
));
$this
->
assertSame
(
0
,
GPBWire
::
zigZagDecode64
(
0
));
$this
->
assertSame
(
-
1
,
GPBWire
::
zigZagDecode64
(
1
));
$this
->
assertSame
(
1
,
GPBWire
::
zigZagDecode64
(
2
));
$this
->
assertSame
(
-
2
,
GPBWire
::
zigZagDecode64
(
3
));
}
// Round trip
// Round trip
$this
->
assertSame
(
0
,
GPBWire
::
zigZagDecode32
(
GPBWire
::
zigZagEncode32
(
0
)));
$this
->
assertSame
(
0
,
GPBWire
::
zigZagDecode32
(
GPBWire
::
zigZagEncode32
(
0
)));
...
@@ -319,15 +345,27 @@ class ImplementationTest extends TestBase
...
@@ -319,15 +345,27 @@ class ImplementationTest extends TestBase
// Normal case.
// Normal case.
$input
=
new
InputStream
(
hex2bin
(
'808001'
));
$input
=
new
InputStream
(
hex2bin
(
'808001'
));
$this
->
assertTrue
(
$input
->
readVarint64
(
$var
));
$this
->
assertTrue
(
$input
->
readVarint64
(
$var
));
$this
->
assertSame
(
16384
,
$var
->
toInteger
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'16384'
,
$var
);
}
else
{
$this
->
assertSame
(
16384
,
$var
);
}
$this
->
assertFalse
(
$input
->
readVarint64
(
$var
));
$this
->
assertFalse
(
$input
->
readVarint64
(
$var
));
// Read two varint.
// Read two varint.
$input
=
new
InputStream
(
hex2bin
(
'808001808002'
));
$input
=
new
InputStream
(
hex2bin
(
'808001808002'
));
$this
->
assertTrue
(
$input
->
readVarint64
(
$var
));
$this
->
assertTrue
(
$input
->
readVarint64
(
$var
));
$this
->
assertSame
(
16384
,
$var
->
toInteger
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'16384'
,
$var
);
}
else
{
$this
->
assertSame
(
16384
,
$var
);
}
$this
->
assertTrue
(
$input
->
readVarint64
(
$var
));
$this
->
assertTrue
(
$input
->
readVarint64
(
$var
));
$this
->
assertSame
(
32768
,
$var
->
toInteger
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'32768'
,
$var
);
}
else
{
$this
->
assertSame
(
32768
,
$var
);
}
$this
->
assertFalse
(
$input
->
readVarint64
(
$var
));
$this
->
assertFalse
(
$input
->
readVarint64
(
$var
));
}
}
...
...
php/tests/test_base.php
View file @
51c5ff88
...
@@ -13,22 +13,28 @@ class TestBase extends PHPUnit_Framework_TestCase
...
@@ -13,22 +13,28 @@ class TestBase extends PHPUnit_Framework_TestCase
public
function
expectFields
(
TestMessage
$m
)
public
function
expectFields
(
TestMessage
$m
)
{
{
$this
->
assertSame
(
-
42
,
$m
->
getOptionalInt32
());
$this
->
assertSame
(
42
,
$m
->
getOptionalUint32
());
$this
->
assertSame
(
-
43
,
$m
->
getOptionalInt64
());
$this
->
assertSame
(
43
,
$m
->
getOptionalUint64
());
$this
->
assertSame
(
-
44
,
$m
->
getOptionalSint32
());
$this
->
assertSame
(
-
44
,
$m
->
getOptionalSint32
());
$this
->
assertSame
(
-
45
,
$m
->
getOptionalSint64
());
$this
->
assertSame
(
46
,
$m
->
getOptionalFixed32
());
$this
->
assertSame
(
46
,
$m
->
getOptionalFixed32
());
$this
->
assertSame
(
47
,
$m
->
getOptionalFixed64
());
$this
->
assertSame
(
-
46
,
$m
->
getOptionalSfixed32
());
$this
->
assertSame
(
-
46
,
$m
->
getOptionalSfixed32
());
$this
->
assertSame
(
-
47
,
$m
->
getOptionalSfixed64
());
$this
->
assertSame
(
1.5
,
$m
->
getOptionalFloat
());
$this
->
assertSame
(
1.5
,
$m
->
getOptionalFloat
());
$this
->
assertSame
(
1.6
,
$m
->
getOptionalDouble
());
$this
->
assertSame
(
1.6
,
$m
->
getOptionalDouble
());
$this
->
assertSame
(
true
,
$m
->
getOptionalBool
());
$this
->
assertSame
(
true
,
$m
->
getOptionalBool
());
$this
->
assertSame
(
'a'
,
$m
->
getOptionalString
());
$this
->
assertSame
(
'a'
,
$m
->
getOptionalString
());
$this
->
assertSame
(
'b'
,
$m
->
getOptionalBytes
());
$this
->
assertSame
(
'b'
,
$m
->
getOptionalBytes
());
$this
->
assertSame
(
33
,
$m
->
getOptionalMessage
()
->
getA
());
$this
->
assertSame
(
33
,
$m
->
getOptionalMessage
()
->
getA
());
if
(
PHP_INT_SIZE
==
4
)
{
$this
->
assertSame
(
'-43'
,
$m
->
getOptionalInt64
());
$this
->
assertSame
(
'43'
,
$m
->
getOptionalUint64
());
$this
->
assertSame
(
'-45'
,
$m
->
getOptionalSint64
());
$this
->
assertSame
(
'47'
,
$m
->
getOptionalFixed64
());
$this
->
assertSame
(
'-47'
,
$m
->
getOptionalSfixed64
());
}
else
{
$this
->
assertSame
(
-
43
,
$m
->
getOptionalInt64
());
$this
->
assertSame
(
43
,
$m
->
getOptionalUint64
());
$this
->
assertSame
(
-
45
,
$m
->
getOptionalSint64
());
$this
->
assertSame
(
47
,
$m
->
getOptionalFixed64
());
$this
->
assertSame
(
-
47
,
$m
->
getOptionalSfixed64
());
}
$this
->
assertEquals
(
-
42
,
$m
->
getRepeatedInt32
()[
0
]);
$this
->
assertEquals
(
-
42
,
$m
->
getRepeatedInt32
()[
0
]);
$this
->
assertEquals
(
42
,
$m
->
getRepeatedUint32
()[
0
]);
$this
->
assertEquals
(
42
,
$m
->
getRepeatedUint32
()[
0
]);
...
...
php/tests/test_util.php
View file @
51c5ff88
...
@@ -20,7 +20,7 @@ define('MAX_INT32', 2147483647);
...
@@ -20,7 +20,7 @@ define('MAX_INT32', 2147483647);
define
(
'MAX_INT32_FLOAT'
,
2147483647.0
);
define
(
'MAX_INT32_FLOAT'
,
2147483647.0
);
define
(
'MAX_INT32_STRING'
,
'2147483647'
);
define
(
'MAX_INT32_STRING'
,
'2147483647'
);
define
(
'MIN_INT32'
,
-
2147483648
);
define
(
'MIN_INT32'
,
(
int
)
-
2147483648
);
define
(
'MIN_INT32_FLOAT'
,
-
2147483648.0
);
define
(
'MIN_INT32_FLOAT'
,
-
2147483648.0
);
define
(
'MIN_INT32_STRING'
,
'-2147483648'
);
define
(
'MIN_INT32_STRING'
,
'-2147483648'
);
...
@@ -28,23 +28,24 @@ define('MAX_UINT32', 4294967295);
...
@@ -28,23 +28,24 @@ define('MAX_UINT32', 4294967295);
define
(
'MAX_UINT32_FLOAT'
,
4294967295.0
);
define
(
'MAX_UINT32_FLOAT'
,
4294967295.0
);
define
(
'MAX_UINT32_STRING'
,
'4294967295'
);
define
(
'MAX_UINT32_STRING'
,
'4294967295'
);
define
(
'MIN_UINT32'
,
-
2147483648
);
define
(
'MIN_UINT32'
,
(
int
)
-
2147483648
);
define
(
'MIN_UINT32_FLOAT'
,
-
2147483648.0
);
define
(
'MIN_UINT32_FLOAT'
,
-
2147483648.0
);
define
(
'MIN_UINT32_STRING'
,
'-2147483648'
);
define
(
'MIN_UINT32_STRING'
,
'-2147483648'
);
define
(
'MAX_INT64'
,
9223372036854775807
);
define
(
'MAX_INT64_STRING'
,
'9223372036854775807'
);
define
(
'MAX_INT64_STRING'
,
'9223372036854775807'
);
define
(
'MIN_INT64_STRING'
,
'-9223372036854775808'
);
define
(
'MAX_UINT64_STRING'
,
'-9223372036854775808'
);
define
(
'MIN_INT64_STRING'
,
'-9223372036854775808'
);
if
(
PHP_INT_SIZE
===
8
)
{
if
(
PHP_INT_SIZE
===
8
)
{
define
(
'MIN_INT64'
,
-
9223372036854775808
);
define
(
'MAX_INT64'
,
(
int
)
9223372036854775807
);
define
(
'MIN_INT64'
,
(
int
)
-
9223372036854775808
);
define
(
'MAX_UINT64'
,
(
int
)
-
9223372036854775808
);
}
else
{
}
else
{
define
(
'MAX_INT64'
,
MAX_INT64_STRING
);
define
(
'MIN_INT64'
,
MIN_INT64_STRING
);
define
(
'MIN_INT64'
,
MIN_INT64_STRING
);
define
(
'MAX_UINT64'
,
MAX_UINT64_STRING
);
}
}
define
(
'MAX_UINT64_STRING'
,
'-9223372036854775808'
);
define
(
'MAX_UINT64'
,
MAX_UINT64_STRING
);
class
TestUtil
class
TestUtil
{
{
...
@@ -129,16 +130,24 @@ class TestUtil
...
@@ -129,16 +130,24 @@ class TestUtil
public
static
function
assertTestMessage
(
TestMessage
$m
)
public
static
function
assertTestMessage
(
TestMessage
$m
)
{
{
if
(
PHP_INT_SIZE
==
4
)
{
assert
(
'-43'
===
$m
->
getOptionalInt64
());
assert
(
'43'
===
$m
->
getOptionalUint64
());
assert
(
'-45'
===
$m
->
getOptionalSint64
());
assert
(
'47'
===
$m
->
getOptionalFixed64
());
assert
(
'-47'
===
$m
->
getOptionalSfixed64
());
}
else
{
assert
(
-
43
===
$m
->
getOptionalInt64
());
assert
(
43
===
$m
->
getOptionalUint64
());
assert
(
-
45
===
$m
->
getOptionalSint64
());
assert
(
47
===
$m
->
getOptionalFixed64
());
assert
(
-
47
===
$m
->
getOptionalSfixed64
());
}
assert
(
-
42
===
$m
->
getOptionalInt32
());
assert
(
-
42
===
$m
->
getOptionalInt32
());
assert
(
42
===
$m
->
getOptionalUint32
());
assert
(
42
===
$m
->
getOptionalUint32
());
assert
(
-
43
===
$m
->
getOptionalInt64
());
assert
(
43
===
$m
->
getOptionalUint64
());
assert
(
-
44
===
$m
->
getOptionalSint32
());
assert
(
-
44
===
$m
->
getOptionalSint32
());
assert
(
-
45
===
$m
->
getOptionalSint64
());
assert
(
46
===
$m
->
getOptionalFixed32
());
assert
(
46
===
$m
->
getOptionalFixed32
());
assert
(
47
===
$m
->
getOptionalFixed64
());
assert
(
-
46
===
$m
->
getOptionalSfixed32
());
assert
(
-
46
===
$m
->
getOptionalSfixed32
());
assert
(
-
47
===
$m
->
getOptionalSfixed64
());
assert
(
1.5
===
$m
->
getOptionalFloat
());
assert
(
1.5
===
$m
->
getOptionalFloat
());
assert
(
1.6
===
$m
->
getOptionalDouble
());
assert
(
1.6
===
$m
->
getOptionalDouble
());
assert
(
true
===
$m
->
getOptionalBool
());
assert
(
true
===
$m
->
getOptionalBool
());
...
@@ -147,16 +156,24 @@ class TestUtil
...
@@ -147,16 +156,24 @@ class TestUtil
assert
(
TestEnum
::
ONE
===
$m
->
getOptionalEnum
());
assert
(
TestEnum
::
ONE
===
$m
->
getOptionalEnum
());
assert
(
33
===
$m
->
getOptionalMessage
()
->
getA
());
assert
(
33
===
$m
->
getOptionalMessage
()
->
getA
());
if
(
PHP_INT_SIZE
==
4
)
{
assert
(
'-43'
===
$m
->
getRepeatedInt64
()[
0
]);
assert
(
'43'
===
$m
->
getRepeatedUint64
()[
0
]);
assert
(
'-45'
===
$m
->
getRepeatedSint64
()[
0
]);
assert
(
'47'
===
$m
->
getRepeatedFixed64
()[
0
]);
assert
(
'-47'
===
$m
->
getRepeatedSfixed64
()[
0
]);
}
else
{
assert
(
-
43
===
$m
->
getRepeatedInt64
()[
0
]);
assert
(
43
===
$m
->
getRepeatedUint64
()[
0
]);
assert
(
-
45
===
$m
->
getRepeatedSint64
()[
0
]);
assert
(
47
===
$m
->
getRepeatedFixed64
()[
0
]);
assert
(
-
47
===
$m
->
getRepeatedSfixed64
()[
0
]);
}
assert
(
-
42
===
$m
->
getRepeatedInt32
()[
0
]);
assert
(
-
42
===
$m
->
getRepeatedInt32
()[
0
]);
assert
(
42
===
$m
->
getRepeatedUint32
()[
0
]);
assert
(
42
===
$m
->
getRepeatedUint32
()[
0
]);
assert
(
-
43
===
$m
->
getRepeatedInt64
()[
0
]);
assert
(
43
===
$m
->
getRepeatedUint64
()[
0
]);
assert
(
-
44
===
$m
->
getRepeatedSint32
()[
0
]);
assert
(
-
44
===
$m
->
getRepeatedSint32
()[
0
]);
assert
(
-
45
===
$m
->
getRepeatedSint64
()[
0
]);
assert
(
46
===
$m
->
getRepeatedFixed32
()[
0
]);
assert
(
46
===
$m
->
getRepeatedFixed32
()[
0
]);
assert
(
47
===
$m
->
getRepeatedFixed64
()[
0
]);
assert
(
-
46
===
$m
->
getRepeatedSfixed32
()[
0
]);
assert
(
-
46
===
$m
->
getRepeatedSfixed32
()[
0
]);
assert
(
-
47
===
$m
->
getRepeatedSfixed64
()[
0
]);
assert
(
1.5
===
$m
->
getRepeatedFloat
()[
0
]);
assert
(
1.5
===
$m
->
getRepeatedFloat
()[
0
]);
assert
(
1.6
===
$m
->
getRepeatedDouble
()[
0
]);
assert
(
1.6
===
$m
->
getRepeatedDouble
()[
0
]);
assert
(
true
===
$m
->
getRepeatedBool
()[
0
]);
assert
(
true
===
$m
->
getRepeatedBool
()[
0
]);
...
@@ -165,16 +182,24 @@ class TestUtil
...
@@ -165,16 +182,24 @@ class TestUtil
assert
(
TestEnum
::
ZERO
===
$m
->
getRepeatedEnum
()[
0
]);
assert
(
TestEnum
::
ZERO
===
$m
->
getRepeatedEnum
()[
0
]);
assert
(
34
===
$m
->
getRepeatedMessage
()[
0
]
->
getA
());
assert
(
34
===
$m
->
getRepeatedMessage
()[
0
]
->
getA
());
if
(
PHP_INT_SIZE
==
4
)
{
assert
(
'-53'
===
$m
->
getRepeatedInt64
()[
1
]);
assert
(
'53'
===
$m
->
getRepeatedUint64
()[
1
]);
assert
(
'-55'
===
$m
->
getRepeatedSint64
()[
1
]);
assert
(
'57'
===
$m
->
getRepeatedFixed64
()[
1
]);
assert
(
'-57'
===
$m
->
getRepeatedSfixed64
()[
1
]);
}
else
{
assert
(
-
53
===
$m
->
getRepeatedInt64
()[
1
]);
assert
(
53
===
$m
->
getRepeatedUint64
()[
1
]);
assert
(
-
55
===
$m
->
getRepeatedSint64
()[
1
]);
assert
(
57
===
$m
->
getRepeatedFixed64
()[
1
]);
assert
(
-
57
===
$m
->
getRepeatedSfixed64
()[
1
]);
}
assert
(
-
52
===
$m
->
getRepeatedInt32
()[
1
]);
assert
(
-
52
===
$m
->
getRepeatedInt32
()[
1
]);
assert
(
52
===
$m
->
getRepeatedUint32
()[
1
]);
assert
(
52
===
$m
->
getRepeatedUint32
()[
1
]);
assert
(
-
53
===
$m
->
getRepeatedInt64
()[
1
]);
assert
(
53
===
$m
->
getRepeatedUint64
()[
1
]);
assert
(
-
54
===
$m
->
getRepeatedSint32
()[
1
]);
assert
(
-
54
===
$m
->
getRepeatedSint32
()[
1
]);
assert
(
-
55
===
$m
->
getRepeatedSint64
()[
1
]);
assert
(
56
===
$m
->
getRepeatedFixed32
()[
1
]);
assert
(
56
===
$m
->
getRepeatedFixed32
()[
1
]);
assert
(
57
===
$m
->
getRepeatedFixed64
()[
1
]);
assert
(
-
56
===
$m
->
getRepeatedSfixed32
()[
1
]);
assert
(
-
56
===
$m
->
getRepeatedSfixed32
()[
1
]);
assert
(
-
57
===
$m
->
getRepeatedSfixed64
()[
1
]);
assert
(
2.5
===
$m
->
getRepeatedFloat
()[
1
]);
assert
(
2.5
===
$m
->
getRepeatedFloat
()[
1
]);
assert
(
2.6
===
$m
->
getRepeatedDouble
()[
1
]);
assert
(
2.6
===
$m
->
getRepeatedDouble
()[
1
]);
assert
(
false
===
$m
->
getRepeatedBool
()[
1
]);
assert
(
false
===
$m
->
getRepeatedBool
()[
1
]);
...
@@ -183,14 +208,21 @@ class TestUtil
...
@@ -183,14 +208,21 @@ class TestUtil
assert
(
TestEnum
::
ONE
===
$m
->
getRepeatedEnum
()[
1
]);
assert
(
TestEnum
::
ONE
===
$m
->
getRepeatedEnum
()[
1
]);
assert
(
35
===
$m
->
getRepeatedMessage
()[
1
]
->
getA
());
assert
(
35
===
$m
->
getRepeatedMessage
()[
1
]
->
getA
());
if
(
PHP_INT_SIZE
==
4
)
{
assert
(
'-63'
===
$m
->
getMapInt64Int64
()[
'-63'
]);
assert
(
'63'
===
$m
->
getMapUint64Uint64
()[
'63'
]);
assert
(
'-65'
===
$m
->
getMapSint64Sint64
()[
'-65'
]);
assert
(
'67'
===
$m
->
getMapFixed64Fixed64
()[
'67'
]);
}
else
{
assert
(
-
63
===
$m
->
getMapInt64Int64
()[
-
63
]);
assert
(
63
===
$m
->
getMapUint64Uint64
()[
63
]);
assert
(
-
65
===
$m
->
getMapSint64Sint64
()[
-
65
]);
assert
(
67
===
$m
->
getMapFixed64Fixed64
()[
67
]);
}
assert
(
-
62
===
$m
->
getMapInt32Int32
()[
-
62
]);
assert
(
-
62
===
$m
->
getMapInt32Int32
()[
-
62
]);
assert
(
-
63
===
$m
->
getMapInt64Int64
()[
-
63
]);
assert
(
62
===
$m
->
getMapUint32Uint32
()[
62
]);
assert
(
62
===
$m
->
getMapUint32Uint32
()[
62
]);
assert
(
63
===
$m
->
getMapUint64Uint64
()[
63
]);
assert
(
-
64
===
$m
->
getMapSint32Sint32
()[
-
64
]);
assert
(
-
64
===
$m
->
getMapSint32Sint32
()[
-
64
]);
assert
(
-
65
===
$m
->
getMapSint64Sint64
()[
-
65
]);
assert
(
66
===
$m
->
getMapFixed32Fixed32
()[
66
]);
assert
(
66
===
$m
->
getMapFixed32Fixed32
()[
66
]);
assert
(
67
===
$m
->
getMapFixed64Fixed64
()[
67
]);
assert
(
3.5
===
$m
->
getMapInt32Float
()[
1
]);
assert
(
3.5
===
$m
->
getMapInt32Float
()[
1
]);
assert
(
3.6
===
$m
->
getMapInt32Double
()[
1
]);
assert
(
3.6
===
$m
->
getMapInt32Double
()[
1
]);
assert
(
true
===
$m
->
getMapBoolBool
()[
true
]);
assert
(
true
===
$m
->
getMapBoolBool
()[
true
]);
...
@@ -325,24 +357,14 @@ class TestUtil
...
@@ -325,24 +357,14 @@ class TestUtil
assert
(
-
42
===
$m
->
getRepeatedInt32
()[
0
]);
assert
(
-
42
===
$m
->
getRepeatedInt32
()[
0
]);
assert
(
-
52
===
$m
->
getRepeatedInt32
()[
1
]);
assert
(
-
52
===
$m
->
getRepeatedInt32
()[
1
]);
assert
(
-
43
===
$m
->
getRepeatedInt64
()[
0
]);
assert
(
-
53
===
$m
->
getRepeatedInt64
()[
1
]);
assert
(
42
===
$m
->
getRepeatedUint32
()[
0
]);
assert
(
42
===
$m
->
getRepeatedUint32
()[
0
]);
assert
(
52
===
$m
->
getRepeatedUint32
()[
1
]);
assert
(
52
===
$m
->
getRepeatedUint32
()[
1
]);
assert
(
43
===
$m
->
getRepeatedUint64
()[
0
]);
assert
(
53
===
$m
->
getRepeatedUint64
()[
1
]);
assert
(
-
44
===
$m
->
getRepeatedSint32
()[
0
]);
assert
(
-
44
===
$m
->
getRepeatedSint32
()[
0
]);
assert
(
-
54
===
$m
->
getRepeatedSint32
()[
1
]);
assert
(
-
54
===
$m
->
getRepeatedSint32
()[
1
]);
assert
(
-
45
===
$m
->
getRepeatedSint64
()[
0
]);
assert
(
-
55
===
$m
->
getRepeatedSint64
()[
1
]);
assert
(
46
===
$m
->
getRepeatedFixed32
()[
0
]);
assert
(
46
===
$m
->
getRepeatedFixed32
()[
0
]);
assert
(
56
===
$m
->
getRepeatedFixed32
()[
1
]);
assert
(
56
===
$m
->
getRepeatedFixed32
()[
1
]);
assert
(
47
===
$m
->
getRepeatedFixed64
()[
0
]);
assert
(
57
===
$m
->
getRepeatedFixed64
()[
1
]);
assert
(
-
46
===
$m
->
getRepeatedSfixed32
()[
0
]);
assert
(
-
46
===
$m
->
getRepeatedSfixed32
()[
0
]);
assert
(
-
56
===
$m
->
getRepeatedSfixed32
()[
1
]);
assert
(
-
56
===
$m
->
getRepeatedSfixed32
()[
1
]);
assert
(
-
47
===
$m
->
getRepeatedSfixed64
()[
0
]);
assert
(
-
57
===
$m
->
getRepeatedSfixed64
()[
1
]);
assert
(
1.5
===
$m
->
getRepeatedFloat
()[
0
]);
assert
(
1.5
===
$m
->
getRepeatedFloat
()[
0
]);
assert
(
2.5
===
$m
->
getRepeatedFloat
()[
1
]);
assert
(
2.5
===
$m
->
getRepeatedFloat
()[
1
]);
assert
(
1.6
===
$m
->
getRepeatedDouble
()[
0
]);
assert
(
1.6
===
$m
->
getRepeatedDouble
()[
0
]);
...
@@ -351,6 +373,29 @@ class TestUtil
...
@@ -351,6 +373,29 @@ class TestUtil
assert
(
false
===
$m
->
getRepeatedBool
()[
1
]);
assert
(
false
===
$m
->
getRepeatedBool
()[
1
]);
assert
(
TestEnum
::
ONE
===
$m
->
getRepeatedEnum
()[
0
]);
assert
(
TestEnum
::
ONE
===
$m
->
getRepeatedEnum
()[
0
]);
assert
(
TestEnum
::
ZERO
===
$m
->
getRepeatedEnum
()[
1
]);
assert
(
TestEnum
::
ZERO
===
$m
->
getRepeatedEnum
()[
1
]);
if
(
PHP_INT_SIZE
==
4
)
{
assert
(
'-43'
===
$m
->
getRepeatedInt64
()[
0
]);
assert
(
'-53'
===
$m
->
getRepeatedInt64
()[
1
]);
assert
(
'43'
===
$m
->
getRepeatedUint64
()[
0
]);
assert
(
'53'
===
$m
->
getRepeatedUint64
()[
1
]);
assert
(
'-45'
===
$m
->
getRepeatedSint64
()[
0
]);
assert
(
'-55'
===
$m
->
getRepeatedSint64
()[
1
]);
assert
(
'47'
===
$m
->
getRepeatedFixed64
()[
0
]);
assert
(
'57'
===
$m
->
getRepeatedFixed64
()[
1
]);
assert
(
'-47'
===
$m
->
getRepeatedSfixed64
()[
0
]);
assert
(
'-57'
===
$m
->
getRepeatedSfixed64
()[
1
]);
}
else
{
assert
(
-
43
===
$m
->
getRepeatedInt64
()[
0
]);
assert
(
-
53
===
$m
->
getRepeatedInt64
()[
1
]);
assert
(
43
===
$m
->
getRepeatedUint64
()[
0
]);
assert
(
53
===
$m
->
getRepeatedUint64
()[
1
]);
assert
(
-
45
===
$m
->
getRepeatedSint64
()[
0
]);
assert
(
-
55
===
$m
->
getRepeatedSint64
()[
1
]);
assert
(
47
===
$m
->
getRepeatedFixed64
()[
0
]);
assert
(
57
===
$m
->
getRepeatedFixed64
()[
1
]);
assert
(
-
47
===
$m
->
getRepeatedSfixed64
()[
0
]);
assert
(
-
57
===
$m
->
getRepeatedSfixed64
()[
1
]);
}
}
}
public
static
function
getGoldenTestPackedMessage
()
public
static
function
getGoldenTestPackedMessage
()
...
...
tests.sh
View file @
51c5ff88
...
@@ -358,6 +358,16 @@ use_php_zts() {
...
@@ -358,6 +358,16 @@ use_php_zts() {
ln
-sfn
"/usr/local/php-
${
VERSION
}
-zts/bin/phpize"
$PHPIZE
ln
-sfn
"/usr/local/php-
${
VERSION
}
-zts/bin/phpize"
$PHPIZE
}
}
use_php_bc
()
{
VERSION
=
$1
PHP
=
`
which php
`
PHP_CONFIG
=
`
which php-config
`
PHPIZE
=
`
which phpize
`
ln
-sfn
"/usr/local/php-
${
VERSION
}
-bc/bin/php"
$PHP
ln
-sfn
"/usr/local/php-
${
VERSION
}
-bc/bin/php-config"
$PHP_CONFIG
ln
-sfn
"/usr/local/php-
${
VERSION
}
-bc/bin/phpize"
$PHPIZE
}
build_php5.5
()
{
build_php5.5
()
{
use_php 5.5
use_php 5.5
rm
-rf
vendor
rm
-rf
vendor
...
@@ -376,6 +386,13 @@ build_php5.5_zts_c() {
...
@@ -376,6 +386,13 @@ build_php5.5_zts_c() {
cd
php/tests
&&
/bin/bash ./test.sh
&&
cd
../..
cd
php/tests
&&
/bin/bash ./test.sh
&&
cd
../..
}
}
build_php5.5_32
()
{
use_php_bc 5.5
rm
-rf
vendor
cp
-r
/usr/local/vendor-5.5 vendor
./vendor/bin/phpunit
}
build_php5.6
()
{
build_php5.6
()
{
use_php 5.6
use_php 5.6
rm
-rf
vendor
rm
-rf
vendor
...
@@ -429,6 +446,10 @@ build_php_all() {
...
@@ -429,6 +446,10 @@ build_php_all() {
build_php5.5_zts_c
build_php5.5_zts_c
}
}
build_php_all_32
()
{
build_php5.5_32
}
# Note: travis currently does not support testing more than one language so the
# Note: travis currently does not support testing more than one language so the
# .travis.yml cheats and claims to only be cpp. If they add multiple language
# .travis.yml cheats and claims to only be cpp. If they add multiple language
# support, this should probably get updated to install steps and/or
# support, this should probably get updated to install steps and/or
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment