You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by rs...@apache.org on 2020/11/16 09:11:08 UTC
[avro] branch master updated: AVRO-2975: Enable PHP linting and fix
its errors (#984)
This is an automated email from the ASF dual-hosted git repository.
rskraba pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new edddf44 AVRO-2975: Enable PHP linting and fix its errors (#984)
edddf44 is described below
commit edddf440521d253aecbd0f95a65c6b0063fe654f
Author: Kengo Seki <se...@apache.org>
AuthorDate: Mon Nov 16 18:00:06 2020 +0900
AVRO-2975: Enable PHP linting and fix its errors (#984)
* AVRO-2975: Enable PHP linting and fix its errors
* Fix lang/php/build.sh to install dependencies before running phpcs
---
build.sh | 2 +-
lang/php/build.sh | 1 +
lang/php/lib/AvroDebug.php | 6 ++--
lang/php/lib/AvroIO.php | 10 +++---
lang/php/lib/DataFile/AvroDataIO.php | 22 ++++++------
lang/php/lib/IO/AvroFile.php | 4 +--
lang/php/lib/Schema/AvroField.php | 12 +++----
lang/php/lib/Schema/AvroName.php | 4 +--
lang/php/lib/Schema/AvroSchema.php | 66 ++++++++++++++++++------------------
pom.xml | 1 +
10 files changed, 65 insertions(+), 63 deletions(-)
diff --git a/build.sh b/build.sh
index 93c9272..352aa4f 100755
--- a/build.sh
+++ b/build.sh
@@ -92,7 +92,7 @@ do
(cd lang/csharp; ./build.sh test)
(cd lang/js; ./build.sh lint test)
(cd lang/ruby; ./build.sh lint test)
- (cd lang/php; ./build.sh test)
+ (cd lang/php; ./build.sh lint test)
(cd lang/perl; ./build.sh lint test)
(cd lang/py; ./build.sh interop-data-generate)
diff --git a/lang/php/build.sh b/lang/php/build.sh
index f302d30..3d1002e 100755
--- a/lang/php/build.sh
+++ b/lang/php/build.sh
@@ -57,6 +57,7 @@ do
;;
lint)
+ composer install -d "../.."
find . -name "*.php" -print0 | xargs -0 -n1 -P8 php -l
vendor/bin/phpcs --standard=PSR12 lib
;;
diff --git a/lang/php/lib/AvroDebug.php b/lang/php/lib/AvroDebug.php
index 508c0c6..777dcd9 100644
--- a/lang/php/lib/AvroDebug.php
+++ b/lang/php/lib/AvroDebug.php
@@ -29,15 +29,15 @@ class AvroDebug
/**
* @var int high debug level
*/
- const DEBUG5 = 5;
+ public const DEBUG5 = 5;
/**
* @var int low debug level
*/
- const DEBUG1 = 1;
+ public const DEBUG1 = 1;
/**
* @var int current debug level
*/
- const DEBUG_LEVEL = self::DEBUG1;
+ public const DEBUG_LEVEL = self::DEBUG1;
/**
* @param string $format format string for the given arguments. Passed as is
diff --git a/lang/php/lib/AvroIO.php b/lang/php/lib/AvroIO.php
index 3474318..30cd94e 100644
--- a/lang/php/lib/AvroIO.php
+++ b/lang/php/lib/AvroIO.php
@@ -31,24 +31,24 @@ class AvroIO
/**
* @var string general read mode
*/
- const READ_MODE = 'r';
+ public const READ_MODE = 'r';
/**
* @var string general write mode.
*/
- const WRITE_MODE = 'w';
+ public const WRITE_MODE = 'w';
/**
* @var int set position to current index + $offset bytes
*/
- const SEEK_CUR = SEEK_CUR;
+ public const SEEK_CUR = SEEK_CUR;
/**
* @var int set position equal to $offset bytes
*/
- const SEEK_SET = SEEK_SET;
+ public const SEEK_SET = SEEK_SET;
/**
* @var int set position to end of file + $offset bytes
*/
- const SEEK_END = SEEK_END;
+ public const SEEK_END = SEEK_END;
/**
* Read $len bytes from AvroIO instance
diff --git a/lang/php/lib/DataFile/AvroDataIO.php b/lang/php/lib/DataFile/AvroDataIO.php
index bc78a68..aaea5bd 100644
--- a/lang/php/lib/DataFile/AvroDataIO.php
+++ b/lang/php/lib/DataFile/AvroDataIO.php
@@ -34,48 +34,48 @@ class AvroDataIO
/**
* @var int used in file header
*/
- const VERSION = 1;
+ public const VERSION = 1;
/**
* @var int count of bytes in synchronization marker
*/
- const SYNC_SIZE = 16;
+ public const SYNC_SIZE = 16;
/**
* @var int count of items per block, arbitrarily set to 4000 * SYNC_SIZE
* @todo make this value configurable
*/
- const SYNC_INTERVAL = 64000;
+ public const SYNC_INTERVAL = 64000;
/**
* @var string map key for datafile metadata codec value
*/
- const METADATA_CODEC_ATTR = 'avro.codec';
+ public const METADATA_CODEC_ATTR = 'avro.codec';
/**
* @var string map key for datafile metadata schema value
*/
- const METADATA_SCHEMA_ATTR = 'avro.schema';
+ public const METADATA_SCHEMA_ATTR = 'avro.schema';
/**
* @var string JSON for datafile metadata schema
*/
- const METADATA_SCHEMA_JSON = '{"type":"map","values":"bytes"}';
+ public const METADATA_SCHEMA_JSON = '{"type":"map","values":"bytes"}';
/**
* @var string codec value for NULL codec
*/
- const NULL_CODEC = 'null';
+ public const NULL_CODEC = 'null';
/**
* @var string codec value for deflate codec
*/
- const DEFLATE_CODEC = 'deflate';
+ public const DEFLATE_CODEC = 'deflate';
- const SNAPPY_CODEC = 'snappy';
+ public const SNAPPY_CODEC = 'snappy';
- const ZSTANDARD_CODEC = 'zstandard';
+ public const ZSTANDARD_CODEC = 'zstandard';
- const BZIP2_CODEC = 'bzip2';
+ public const BZIP2_CODEC = 'bzip2';
/**
* @var array array of valid codec names
diff --git a/lang/php/lib/IO/AvroFile.php b/lang/php/lib/IO/AvroFile.php
index ace97a7..b68de63 100644
--- a/lang/php/lib/IO/AvroFile.php
+++ b/lang/php/lib/IO/AvroFile.php
@@ -31,12 +31,12 @@ class AvroFile extends AvroIO
/**
* @var string fopen read mode value. Used internally.
*/
- const FOPEN_READ_MODE = 'rb';
+ public const FOPEN_READ_MODE = 'rb';
/**
* @var string fopen write mode value. Used internally.
*/
- const FOPEN_WRITE_MODE = 'wb';
+ public const FOPEN_WRITE_MODE = 'wb';
/**
* @var string
diff --git a/lang/php/lib/Schema/AvroField.php b/lang/php/lib/Schema/AvroField.php
index f30070c..eeb50bc 100644
--- a/lang/php/lib/Schema/AvroField.php
+++ b/lang/php/lib/Schema/AvroField.php
@@ -29,32 +29,32 @@ class AvroField extends AvroSchema
/**
* @var string fields name attribute name
*/
- const FIELD_NAME_ATTR = 'name';
+ public const FIELD_NAME_ATTR = 'name';
/**
* @var string
*/
- const DEFAULT_ATTR = 'default';
+ public const DEFAULT_ATTR = 'default';
/**
* @var string
*/
- const ORDER_ATTR = 'order';
+ public const ORDER_ATTR = 'order';
/**
* @var string
*/
- const ASC_SORT_ORDER = 'ascending';
+ public const ASC_SORT_ORDER = 'ascending';
/**
* @var string
*/
- const DESC_SORT_ORDER = 'descending';
+ public const DESC_SORT_ORDER = 'descending';
/**
* @var string
*/
- const IGNORE_SORT_ORDER = 'ignore';
+ public const IGNORE_SORT_ORDER = 'ignore';
/**
* @var array list of valid field sort order values
diff --git a/lang/php/lib/Schema/AvroName.php b/lang/php/lib/Schema/AvroName.php
index 9dd38f0..19ddd06 100644
--- a/lang/php/lib/Schema/AvroName.php
+++ b/lang/php/lib/Schema/AvroName.php
@@ -28,12 +28,12 @@ class AvroName
/**
* @var string character used to separate names comprising the fullname
*/
- const NAME_SEPARATOR = '.';
+ public const NAME_SEPARATOR = '.';
/**
* @var string regular expression to validate name values
*/
- const NAME_REGEXP = '/^[A-Za-z_][A-Za-z0-9_]*$/';
+ public const NAME_REGEXP = '/^[A-Za-z_][A-Za-z0-9_]*$/';
/**
* @var string valid names are matched by self::NAME_REGEXP
*/
diff --git a/lang/php/lib/Schema/AvroSchema.php b/lang/php/lib/Schema/AvroSchema.php
index 10dc2a9..dc4bb8e 100644
--- a/lang/php/lib/Schema/AvroSchema.php
+++ b/lang/php/lib/Schema/AvroSchema.php
@@ -56,174 +56,174 @@ class AvroSchema
/**
* @var int lower bound of integer values: -(1 << 31)
*/
- const INT_MIN_VALUE = -2147483648;
+ public const INT_MIN_VALUE = -2147483648;
/**
* @var int upper bound of integer values: (1 << 31) - 1
*/
- const INT_MAX_VALUE = 2147483647;
+ public const INT_MAX_VALUE = 2147483647;
/**
* @var long lower bound of long values: -(1 << 63)
*/
- const LONG_MIN_VALUE = -9223372036854775808;
+ public const LONG_MIN_VALUE = -9223372036854775808;
/**
* @var long upper bound of long values: (1 << 63) - 1
*/
- const LONG_MAX_VALUE = 9223372036854775807;
+ public const LONG_MAX_VALUE = 9223372036854775807;
/**
* @var string null schema type name
*/
- const NULL_TYPE = 'null';
+ public const NULL_TYPE = 'null';
/**
* @var string boolean schema type name
*/
- const BOOLEAN_TYPE = 'boolean';
+ public const BOOLEAN_TYPE = 'boolean';
/**
* int schema type value is a 32-bit signed int
* @var string int schema type name.
*/
- const INT_TYPE = 'int';
+ public const INT_TYPE = 'int';
/**
* long schema type value is a 64-bit signed int
* @var string long schema type name
*/
- const LONG_TYPE = 'long';
+ public const LONG_TYPE = 'long';
/**
* float schema type value is a 32-bit IEEE 754 floating-point number
* @var string float schema type name
*/
- const FLOAT_TYPE = 'float';
+ public const FLOAT_TYPE = 'float';
/**
* double schema type value is a 64-bit IEEE 754 floating-point number
* @var string double schema type name
*/
- const DOUBLE_TYPE = 'double';
+ public const DOUBLE_TYPE = 'double';
/**
* string schema type value is a Unicode character sequence
* @var string string schema type name
*/
- const STRING_TYPE = 'string';
+ public const STRING_TYPE = 'string';
/**
* bytes schema type value is a sequence of 8-bit unsigned bytes
* @var string bytes schema type name
*/
- const BYTES_TYPE = 'bytes';
+ public const BYTES_TYPE = 'bytes';
// Complex Types
// Unnamed Schema
/**
* @var string array schema type name
*/
- const ARRAY_SCHEMA = 'array';
+ public const ARRAY_SCHEMA = 'array';
/**
* @var string map schema type name
*/
- const MAP_SCHEMA = 'map';
+ public const MAP_SCHEMA = 'map';
/**
* @var string union schema type name
*/
- const UNION_SCHEMA = 'union';
+ public const UNION_SCHEMA = 'union';
/**
* Unions of error schemas are used by Avro messages
* @var string error_union schema type name
*/
- const ERROR_UNION_SCHEMA = 'error_union';
+ public const ERROR_UNION_SCHEMA = 'error_union';
// Named Schema
/**
* @var string enum schema type name
*/
- const ENUM_SCHEMA = 'enum';
+ public const ENUM_SCHEMA = 'enum';
/**
* @var string fixed schema type name
*/
- const FIXED_SCHEMA = 'fixed';
+ public const FIXED_SCHEMA = 'fixed';
/**
* @var string record schema type name
*/
- const RECORD_SCHEMA = 'record';
+ public const RECORD_SCHEMA = 'record';
// Other Schema
/**
* @var string error schema type name
*/
- const ERROR_SCHEMA = 'error';
+ public const ERROR_SCHEMA = 'error';
/**
* @var string request schema type name
*/
- const REQUEST_SCHEMA = 'request';
+ public const REQUEST_SCHEMA = 'request';
// Schema attribute names
/**
* @var string schema type name attribute name
*/
- const TYPE_ATTR = 'type';
+ public const TYPE_ATTR = 'type';
/**
* @var string named schema name attribute name
*/
- const NAME_ATTR = 'name';
+ public const NAME_ATTR = 'name';
/**
* @var string named schema namespace attribute name
*/
- const NAMESPACE_ATTR = 'namespace';
+ public const NAMESPACE_ATTR = 'namespace';
/**
* @var string derived attribute: doesn't appear in schema
*/
- const FULLNAME_ATTR = 'fullname';
+ public const FULLNAME_ATTR = 'fullname';
/**
* @var string array schema size attribute name
*/
- const SIZE_ATTR = 'size';
+ public const SIZE_ATTR = 'size';
/**
* @var string record fields attribute name
*/
- const FIELDS_ATTR = 'fields';
+ public const FIELDS_ATTR = 'fields';
/**
* @var string array schema items attribute name
*/
- const ITEMS_ATTR = 'items';
+ public const ITEMS_ATTR = 'items';
/**
* @var string enum schema symbols attribute name
*/
- const SYMBOLS_ATTR = 'symbols';
+ public const SYMBOLS_ATTR = 'symbols';
/**
* @var string map schema values attribute name
*/
- const VALUES_ATTR = 'values';
+ public const VALUES_ATTR = 'values';
/**
* @var string document string attribute name
*/
- const DOC_ATTR = 'doc';
-
+ public const DOC_ATTR = 'doc';
+
/** @var string aliases string attribute name */
- const ALIASES_ATTR = 'aliases';
+ public const ALIASES_ATTR = 'aliases';
/**
* @var array list of primitive schema type names
diff --git a/pom.xml b/pom.xml
index d3366a1..adb8e49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -314,6 +314,7 @@
<exclude>lang/perl/blib/**/.exists</exclude>
<exclude>vendor/**</exclude>
<exclude>lang/php/vendor/**</exclude>
+ <exclude>lang/php/.phpunit.result.cache</exclude>
<exclude>lang/ruby/Gemfile.lock</exclude>
<exclude>lang/ruby/avro.gemspec</exclude>
<exclude>lang/ruby/.gem/**</exclude>