Fix the following errors from PHP_CodeSniffer with the help og phpcbf:
FILE: /home/ao2/Proj/Tweeper/tweeper/tweeper.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
54 | ERROR | [x] Short array syntax must be used to define arrays
65 | ERROR | [x] Short array syntax must be used to define arrays
124 | ERROR | [x] Short array syntax must be used to define arrays
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: /home/ao2/Proj/Tweeper/tweeper/src/Tweeper.php
----------------------------------------------------------------------
FOUND 15 ERRORS AFFECTING 12 LINES
----------------------------------------------------------------------
162 | ERROR | [x] Short array syntax must be used to define arrays
169 | ERROR | [x] Short array syntax must be used to define arrays
183 | ERROR | [x] Short array syntax must be used to define arrays
212 | ERROR | [x] Short array syntax must be used to define arrays
313 | ERROR | [x] Short array syntax must be used to define arrays
313 | ERROR | [x] Short array syntax must be used to define arrays
315 | ERROR | [x] Short array syntax must be used to define arrays
378 | ERROR | [x] Short array syntax must be used to define arrays
378 | ERROR | [x] Short array syntax must be used to define arrays
437 | ERROR | [x] Short array syntax must be used to define arrays
466 | ERROR | [x] Short array syntax must be used to define arrays
466 | ERROR | [x] Short array syntax must be used to define arrays
----------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 273ms; Memory: 10MB
*/
private static function getUrlContents($url) {
$ch = curl_init($url);
*/
private static function getUrlContents($url) {
$ch = curl_init($url);
- curl_setopt_array($ch, array(
+ curl_setopt_array($ch, [
CURLOPT_HEADER => FALSE,
CURLOPT_CONNECTTIMEOUT => Tweeper::$maxConnectionTimeout,
// Follow http redirects to get the real URL.
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_COOKIEFILE => "",
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HEADER => FALSE,
CURLOPT_CONNECTTIMEOUT => Tweeper::$maxConnectionTimeout,
// Follow http redirects to get the real URL.
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_COOKIEFILE => "",
CURLOPT_RETURNTRANSFER => TRUE,
- CURLOPT_HTTPHEADER => array('Accept-language: en'),
+ CURLOPT_HTTPHEADER => ['Accept-language: en'],
CURLOPT_USERAGENT => Tweeper::$userAgent,
CURLOPT_USERAGENT => Tweeper::$userAgent,
$contents = Tweeper::curlExec($ch);
curl_close($ch);
$contents = Tweeper::curlExec($ch);
curl_close($ch);
*/
private static function getUrlInfo($url) {
$ch = curl_init($url);
*/
private static function getUrlInfo($url) {
$ch = curl_init($url);
- curl_setopt_array($ch, array(
+ curl_setopt_array($ch, [
CURLOPT_HEADER => TRUE,
CURLOPT_NOBODY => TRUE,
CURLOPT_CONNECTTIMEOUT => Tweeper::$maxConnectionTimeout,
CURLOPT_HEADER => TRUE,
CURLOPT_NOBODY => TRUE,
CURLOPT_CONNECTTIMEOUT => Tweeper::$maxConnectionTimeout,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_USERAGENT => Tweeper::$userAgent,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_USERAGENT => Tweeper::$userAgent,
$ret = Tweeper::curlExec($ch);
if (FALSE === $ret) {
$ret = Tweeper::curlExec($ch);
if (FALSE === $ret) {
* Generate an RSS <enclosure/> element.
*/
public static function generateEnclosure($url) {
* Generate an RSS <enclosure/> element.
*/
public static function generateEnclosure($url) {
- $supported_content_types = array(
+ $supported_content_types = [
"application/octet-stream",
"application/ogg",
"application/pdf",
"application/octet-stream",
"application/ogg",
"application/pdf",
"video/mp4",
"video/mpeg",
"video/ogg",
"video/mp4",
"video/mpeg",
"video/ogg",
$url_info = Tweeper::getUrlInfo($url);
if (FALSE === $url_info) {
$url_info = Tweeper::getUrlInfo($url);
if (FALSE === $url_info) {
$encoder = new XmlEncoder();
$normalizer = new ObjectNormalizer();
$encoder = new XmlEncoder();
$normalizer = new ObjectNormalizer();
- $serializer = new Serializer(array($normalizer), array($encoder));
+ $serializer = new Serializer([$normalizer], [$encoder]);
- $serializer_options = array(
+ $serializer_options = [
'xml_encoding' => "UTF-8",
'xml_format_output' => TRUE,
'xml_root_node_name' => $root_node_name,
'xml_encoding' => "UTF-8",
'xml_format_output' => TRUE,
'xml_root_node_name' => $root_node_name,
$xml_data = $serializer->serialize($data, 'xml', $serializer_options);
if (!$xml_data) {
$xml_data = $serializer->serialize($data, 'xml', $serializer_options);
if (!$xml_data) {
// If there is a host-specific method to get the XML data, use it!
$get_xml_host_method = 'getXml' . Tweeper::toUpperCamelCase($host, '.');
if (method_exists($this, $get_xml_host_method)) {
// If there is a host-specific method to get the XML data, use it!
$get_xml_host_method = 'getXml' . Tweeper::toUpperCamelCase($host, '.');
if (method_exists($this, $get_xml_host_method)) {
- $xml_data = call_user_func_array(array($this, $get_xml_host_method), array($html));
+ $xml_data = call_user_func_array([$this, $get_xml_host_method], [$html]);
$xmlDoc->loadXML($xml_data);
}
else {
$xmlDoc->loadXML($xml_data);
}
else {
if (TRUE === $validate_scheme) {
$scheme = $url["scheme"];
if (TRUE === $validate_scheme) {
$scheme = $url["scheme"];
- if (!in_array($scheme, array("http", "https"))) {
+ if (!in_array($scheme, ["http", "https"])) {
trigger_error("unsupported scheme: $scheme", E_USER_WARNING);
return NULL;
}
trigger_error("unsupported scheme: $scheme", E_USER_WARNING);
return NULL;
}
$preprocess_html_host_method = 'preprocessHtml' . Tweeper::toUpperCamelCase($host, '.');
if (method_exists($this, $preprocess_html_host_method)) {
$preprocess_html_host_method = 'preprocessHtml' . Tweeper::toUpperCamelCase($host, '.');
if (method_exists($this, $preprocess_html_host_method)) {
- $html = call_user_func_array(array($this, $preprocess_html_host_method), array($html));
+ $html = call_user_func_array([$this, $preprocess_html_host_method], [$html]);
}
$xmlDoc = $this->htmlToXml($html, $host);
}
$xmlDoc = $this->htmlToXml($html, $host);
* Parse command line options.
*/
function parse_options_cli($argv, $argc) {
* Parse command line options.
*/
function parse_options_cli($argv, $argc) {
'generate_enclosure' => FALSE,
'show_usernames' => TRUE,
'show_multimedia' => TRUE,
'verbose_output' => TRUE,
'generate_enclosure' => FALSE,
'show_usernames' => TRUE,
'show_multimedia' => TRUE,
'verbose_output' => TRUE,
if ($argc < 2) {
return $options;
}
if ($argc < 2) {
return $options;
}
- $cli_options = getopt("em:u:v:h", array("help"));
+ $cli_options = getopt("em:u:v:h", ["help"]);
foreach ($cli_options as $opt => $val) {
switch ($opt) {
case 'e':
foreach ($cli_options as $opt => $val) {
switch ($opt) {
case 'e':
* Parse options passed from a query string.
*/
function parse_options_query_string() {
* Parse options passed from a query string.
*/
function parse_options_query_string() {
'generate_enclosure' => FALSE,
'show_usernames' => TRUE,
'show_multimedia' => TRUE,
'verbose_output' => TRUE,
'generate_enclosure' => FALSE,
'show_usernames' => TRUE,
'show_multimedia' => TRUE,
'verbose_output' => TRUE,
if (isset($_GET['src_url'])) {
$options['src_url'] = $_GET['src_url'];
if (isset($_GET['src_url'])) {
$options['src_url'] = $_GET['src_url'];