diff --git a/.gitignore b/.gitignore index 1f14d26aa2..f56a35f176 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ vendor/* composer.lock bin/dbunit bin/phpunit +.php_cs.cache diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 0000000000..d593c1b9e8 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,14 @@ +notPath('tests/Zend/Loader/_files/ParseError.php') + ->in('.'); + +return PhpCsFixer\Config::create() + ->setFinder($finder) + ->setRules([ + 'array_syntax' => ['syntax' => 'long'], + 'list_syntax' => ['syntax' => 'long'], + 'modernize_types_casting' => true, + 'logical_operators' => true, + ]); diff --git a/ISSUE_TEMPLATE b/ISSUE_TEMPLATE deleted file mode 100644 index f0289361e5..0000000000 --- a/ISSUE_TEMPLATE +++ /dev/null @@ -1,4 +0,0 @@ -Zend Framework 1 reaches its End of Life (EOL) and is no longer maintained. -No Pull Requests will be accepted. - -https://framework.zend.com/blog/2016-06-28-zf1-eol.html diff --git a/PULL_REQUEST_TEMPLATE b/PULL_REQUEST_TEMPLATE deleted file mode 100644 index f0289361e5..0000000000 --- a/PULL_REQUEST_TEMPLATE +++ /dev/null @@ -1,4 +0,0 @@ -Zend Framework 1 reaches its End of Life (EOL) and is no longer maintained. -No Pull Requests will be accepted. - -https://framework.zend.com/blog/2016-06-28-zf1-eol.html diff --git a/README.md b/README.md index 1b04849b84..00c2e641f0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ -Post end of life changes for zf1 to allow compatibility with PHP 7.3, and potentially future versions +# Post end of life changes for zf1 to allow compatibility with the latest PHP versions. If you have any requests for tags, releases, or anything else. Feel free to raise an issue and I'll get it sorted. + + +## Installation + +Installable through git clone or through +`composer require shardj/zf1-future` https://packagist.org/packages/shardj/zf1-future + +Minimum PHP Version is 7.0 + + +## Extras + +Recently https://github.com/Shardj/zf1-extras-future has been created for those who need it. + + +## Known issues and solutions + +* ``Bootstrap error: Unable to resolve plugin "useragent"; no corresponding plugin with that name`` + See comments in: https://github.com/Shardj/zf1-future/issues/92 diff --git a/bin/classmap_generator.php b/bin/classmap_generator.php index 90fadb18e1..a282e9c9fc 100644 --- a/bin/classmap_generator.php +++ b/bin/classmap_generator.php @@ -52,18 +52,18 @@ $libraryPath = getcwd(); // Setup autoloading -$loader = new Zend_Loader_StandardAutoloader(array('autoregister_zf' => true)); +$loader = new Zend_Loader_StandardAutoloader(['autoregister_zf' => true]); $loader->setFallbackAutoloader(true); $loader->register(); -$rules = array( +$rules = [ 'help|h' => 'Get usage message', 'library|l-s' => 'Library to parse; if none provided, assumes current directory', 'output|o-s' => 'Where to write autoload file; if not provided, assumes "autoload_classmap.php" in library directory', 'append|a' => 'Append to autoload file if it exists', 'overwrite|w' => 'Whether or not to overwrite existing autoload file', 'ignore|i-s' => 'Comma-separated namespaces to ignore', -); +]; try { $opts = new Zend_Console_Getopt($rules); @@ -78,7 +78,7 @@ exit(0); } -$ignoreNamespaces = array(); +$ignoreNamespaces = []; if (isset($opts->i)) { $ignoreNamespaces = explode(',', $opts->i); } diff --git a/bin/zf.php b/bin/zf.php index 0d8d43f77c..2d9c39c978 100755 --- a/bin/zf.php +++ b/bin/zf.php @@ -45,7 +45,7 @@ class ZF /** * @var array of messages */ - protected $_messages = array(); + protected $_messages = []; /** * @var string @@ -585,7 +585,7 @@ protected function _runSetupMoreInfo() protected function _runTool() { - $configOptions = array(); + $configOptions = []; if (isset($this->_configFile) && $this->_configFile) { $configOptions['configOptions']['configFilepath'] = $this->_configFile; } diff --git a/composer.json b/composer.json index 15a5198258..3e4372628b 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "shardj/zf1-future", - "description": "Zend Framework 1 PHP 7.2 and 7.3 compatible", + "description": "Zend Framework 1. The aim is to keep ZF1 working with the latest PHP versions", "type": "library", "keywords": [ "framework", @@ -9,7 +9,7 @@ "homepage": "http://framework.zend.com/", "license": "BSD-3-Clause", "require": { - "php": ">=5.2.11" + "php": ">=7.0" }, "autoload": { "psr-0": { @@ -35,6 +35,6 @@ "exclude": ["/demos", "/documentation", "/tests"] }, "replace": { - "zendframework/zendframework1": "1.*" + "zendframework/zendframework1": ">=1.12.20" } } diff --git a/demos/Zend/Cloud/cloudexp/application/controllers/DocumentController.php b/demos/Zend/Cloud/cloudexp/application/controllers/DocumentController.php index e2c7798c0c..8a73bdb72f 100644 --- a/demos/Zend/Cloud/cloudexp/application/controllers/DocumentController.php +++ b/demos/Zend/Cloud/cloudexp/application/controllers/DocumentController.php @@ -29,7 +29,7 @@ class DocumentController extends Zend_Controller_Action { - public $dependencies = array('config'); + public $dependencies = ['config']; /** * @var Zend_Cloud_DocumentService_Adapter @@ -55,9 +55,9 @@ public function showAction() return; } $q = $this->_doc->select("*"); - $this->view->data = $this->_doc->query($name, $q, array( + $this->view->data = $this->_doc->query($name, $q, [ Zend_Cloud_DocumentService_Adapter_SimpleDB::RETURN_DOCUMENTS => true - )); + ]); } public function createAction() @@ -87,8 +87,8 @@ public function addDocumentAction() if (!$id = $this->_getParam('id', false)) { return; } - $fields = array(); - foreach ($this->_getParam('field', array()) as $field) { + $fields = []; + foreach ($this->_getParam('field', []) as $field) { if (!$field["name"]) { continue; } @@ -99,7 +99,7 @@ public function addDocumentAction() } $document = new Zend_Cloud_DocumentService_Document($id, $fields); $this->_doc->insertDocument($name, $document); - return $this->_helper->redirector('show', null, null, array("collection" => $name)); + return $this->_helper->redirector('show', null, null, ["collection" => $name]); } public function deleteDocumentAction() @@ -115,6 +115,6 @@ public function deleteDocumentAction() return; } $this->_doc->deleteDocument($name, $id); - return $this->_helper->redirector('show', null, null, array("collection" => $name)); + return $this->_helper->redirector('show', null, null, ["collection" => $name]); } } diff --git a/demos/Zend/Cloud/cloudexp/application/controllers/QueueController.php b/demos/Zend/Cloud/cloudexp/application/controllers/QueueController.php index fdeddc0cbe..0fc3da62bb 100755 --- a/demos/Zend/Cloud/cloudexp/application/controllers/QueueController.php +++ b/demos/Zend/Cloud/cloudexp/application/controllers/QueueController.php @@ -29,7 +29,7 @@ class QueueController extends Zend_Controller_Action { - public $dependencies = array('config'); + public $dependencies = ['config']; /** * @var Zend_Cloud_QueueService_Adapter diff --git a/demos/Zend/Cloud/cloudexp/application/controllers/StorageController.php b/demos/Zend/Cloud/cloudexp/application/controllers/StorageController.php index 6d04c85e29..9c6f1b802a 100755 --- a/demos/Zend/Cloud/cloudexp/application/controllers/StorageController.php +++ b/demos/Zend/Cloud/cloudexp/application/controllers/StorageController.php @@ -29,7 +29,7 @@ class StorageController extends Zend_Controller_Action { - public $dependencies = array('config'); + public $dependencies = ['config']; /** * @var Zend_Cloud_StorageService_Adapter @@ -52,10 +52,10 @@ public function getAction() return $this->_helper->redirector('index'); } - $item = $this->_storage->fetchItem($name, array( + $item = $this->_storage->fetchItem($name, [ Zend_Cloud_StorageService_Adapter_S3::FETCH_STREAM => true, Zend_Cloud_StorageService_Adapter_WindowsAzure::RETURN_TYPE => Zend_Cloud_StorageService_Adapter_WindowsAzure::RETURN_STREAM - )); + ]); if (!$item) { $this->getResponse()->setHttpResponseCode(404); @@ -103,11 +103,11 @@ public function uploadAction() $name = $upload->getFileName(null, false); } - $this->_storage->storeItem($name, $fp, array( - Zend_Cloud_StorageService_Adapter_S3::METADATA => array("type" => $mime) - )); + $this->_storage->storeItem($name, $fp, [ + Zend_Cloud_StorageService_Adapter_S3::METADATA => ["type" => $mime] + ]); try { - $this->_storage->storeMetadata($name, array("type" => $mime)); + $this->_storage->storeMetadata($name, ["type" => $mime]); } catch(Zend_Cloud_OperationNotAvailableException $e) { // ignore it } diff --git a/demos/Zend/Cloud/cloudexp/public/index.php b/demos/Zend/Cloud/cloudexp/public/index.php index a4b28ed9fd..789b974dec 100755 --- a/demos/Zend/Cloud/cloudexp/public/index.php +++ b/demos/Zend/Cloud/cloudexp/public/index.php @@ -9,10 +9,10 @@ || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development')); // Ensure library/ is on include_path -set_include_path(implode(PATH_SEPARATOR, array( +set_include_path(implode(PATH_SEPARATOR, [ realpath(APPLICATION_PATH . '/../library'), get_include_path(), -))); +])); /** Zend_Application */ require_once 'Zend/Application.php'; diff --git a/demos/Zend/Gdata/3LeggedOAuth/Gdata_OAuth_Helper.php b/demos/Zend/Gdata/3LeggedOAuth/Gdata_OAuth_Helper.php index 12f7ab9d81..352ba4999e 100755 --- a/demos/Zend/Gdata/3LeggedOAuth/Gdata_OAuth_Helper.php +++ b/demos/Zend/Gdata/3LeggedOAuth/Gdata_OAuth_Helper.php @@ -16,13 +16,13 @@ class Gdata_OAuth_Helper extends Zend_Oauth_Consumer { // Google's default oauth parameters/constants. - private $_defaultOptions = array( + private $_defaultOptions = [ 'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER, 'version' => '1.0', 'requestTokenUrl' => 'https://www.google.com/accounts/OAuthGetRequestToken', 'userAuthorizationUrl' => 'https://www.google.com/accounts/OAuthAuthorizeToken', 'accessTokenUrl' => 'https://www.google.com/accounts/OAuthGetAccessToken' - ); + ]; /** * Create Gdata_OAuth_Helper object @@ -70,7 +70,7 @@ public function fetchRequestToken($scope, $callback) { $this->_defaultOptions['callbackUrl'] = $uri; $this->_config->setCallbackUrl($uri); if (!isset($_SESSION['ACCESS_TOKEN'])) { - return parent::getRequestToken(array('scope' => $scope)); + return parent::getRequestToken(['scope' => $scope]); } return null; } @@ -85,9 +85,9 @@ public function fetchRequestToken($scope, $callback) { * @return void */ public function authorizeRequestToken($domain=null) { - $params = array(); + $params = []; if ($domain != null) { - $params = array('hd' => $domain); + $params = ['hd' => $domain]; } $this->redirect($params); } diff --git a/demos/Zend/Gdata/3LeggedOAuth/index.php b/demos/Zend/Gdata/3LeggedOAuth/index.php index 839806e098..526435caf4 100755 --- a/demos/Zend/Gdata/3LeggedOAuth/index.php +++ b/demos/Zend/Gdata/3LeggedOAuth/index.php @@ -38,10 +38,10 @@ // Application constants. Replace these values with your own. $APP_NAME = 'google-ZendGData3LOSample-1.0'; $APP_URL = getAppURL(); -$scopes = array( +$scopes = [ 'https://docs.google.com/feeds/', 'http://spreadsheets.google.com/feeds/' -); +]; // Setup OAuth consumer. Thes values should be replaced with your registered // app's consumer key/secret. @@ -78,7 +78,7 @@ $spreadsheetFeed = $spreadsheetsService->getSpreadsheetFeed( 'http://spreadsheets.google.com/feeds/spreadsheets/private/full?max-results=100'); - renderHTML($accessToken, array($docsFeed, $spreadsheetFeed)); + renderHTML($accessToken, [$docsFeed, $spreadsheetFeed]); } else { renderHTML(); } diff --git a/demos/Zend/Gdata/Calendar.php b/demos/Zend/Gdata/Calendar.php index 399558e884..8bf3ac6e55 100644 --- a/demos/Zend/Gdata/Calendar.php +++ b/demos/Zend/Gdata/Calendar.php @@ -396,7 +396,7 @@ function createEvent ($client, $title = 'Tennis with Beth', $gc = new Zend_Gdata_Calendar($client); $newEntry = $gc->newEventEntry(); $newEntry->title = $gc->newTitle(trim($title)); - $newEntry->where = array($gc->newWhere($where)); + $newEntry->where = [$gc->newWhere($where)]; $newEntry->content = $gc->newContent($desc); $newEntry->content->type = 'text'; @@ -404,7 +404,7 @@ function createEvent ($client, $title = 'Tennis with Beth', $when = $gc->newWhen(); $when->startTime = "{$startDate}T{$startTime}:00.000{$tzOffset}:00"; $when->endTime = "{$endDate}T{$endTime}:00.000{$tzOffset}:00"; - $newEntry->when = array($when); + $newEntry->when = [$when]; $createdEntry = $gc->insertEvent($newEntry); return $createdEntry->id->text; @@ -458,7 +458,7 @@ function createWebContentEvent ($client, $title = 'World Cup 2006', $when = $gc->newWhen(); $when->startTime = $startDate; $when->endTime = $endDate; - $newEntry->when = array($when); + $newEntry->when = [$when]; $wc = $gc->newWebContent(); $wc->url = $url; @@ -472,7 +472,7 @@ function createWebContentEvent ($client, $title = 'World Cup 2006', $wcLink->href = $icon; $wcLink->webContent = $wc; - $newEntry->link = array($wcLink); + $newEntry->link = [$wcLink]; $createdEntry = $gc->insertEvent($newEntry); return $createdEntry->id->text; @@ -496,7 +496,7 @@ function createRecurringEvent ($client, $title = 'Tennis with Beth', $gc = new Zend_Gdata_Calendar($client); $newEntry = $gc->newEventEntry(); $newEntry->title = $gc->newTitle(trim($title)); - $newEntry->where = array($gc->newWhere($where)); + $newEntry->where = [$gc->newWhere($where)]; $newEntry->content = $gc->newContent($desc); $newEntry->content->type = 'text'; @@ -590,7 +590,7 @@ function addExtendedProperty ($client, $eventId, $gc = new Zend_Gdata_Calendar($client); if ($event = getEvent($client, $eventId)) { $extProp = $gc->newExtendedProperty($name, $value); - $extProps = array_merge($event->extendedProperty, array($extProp)); + $extProps = array_merge($event->extendedProperty, [$extProp]); $event->extendedProperty = $extProps; $eventNew = $event->save(); return $eventNew; @@ -618,7 +618,7 @@ function setReminder($client, $eventId, $minutes=15) $reminder = $gc->newReminder(); $reminder->setMinutes($minutes); $reminder->setMethod($method); - $when->reminders = array($reminder); + $when->reminders = [$reminder]; } $eventNew = $event->save(); return $eventNew; diff --git a/demos/Zend/Gdata/InstallationChecker.php b/demos/Zend/Gdata/InstallationChecker.php index b3e21d80aa..c3fce80755 100644 --- a/demos/Zend/Gdata/InstallationChecker.php +++ b/demos/Zend/Gdata/InstallationChecker.php @@ -36,19 +36,19 @@ class InstallationChecker { const ZEND_GDATA_INSTALL_ERRORS = 'Zend Framework Installation Errors'; const ZEND_SUBVERSION_URI = 'http://framework.zend.com/download/subversion'; - private static $REQUIRED_EXTENSIONS = array( - 'ctype', 'dom', 'libxml', 'spl', 'standard', 'openssl'); + private static $REQUIRED_EXTENSIONS = [ + 'ctype', 'dom', 'libxml', 'spl', 'standard', 'openssl']; - private $_allErrors = array( - self::PHP_EXTENSION_ERRORS => array( - 'tested' => false, 'errors' => null), - self::ZEND_GDATA_INSTALL_ERRORS => array( - 'tested' => false, 'errors' => null), - self::SSL_CAPABILITIES_ERRORS => array( - 'tested' => false, 'errors' => null), - self::YOUTUBE_API_CONNECTIVITY_ERRORS => array( - 'tested' => false, 'errors' => null) - ); + private $_allErrors = [ + self::PHP_EXTENSION_ERRORS => [ + 'tested' => false, 'errors' => null], + self::ZEND_GDATA_INSTALL_ERRORS => [ + 'tested' => false, 'errors' => null], + self::SSL_CAPABILITIES_ERRORS => [ + 'tested' => false, 'errors' => null], + self::YOUTUBE_API_CONNECTIVITY_ERRORS => [ + 'tested' => false, 'errors' => null] + ]; private $_sapiModeCLI = null; @@ -117,7 +117,7 @@ public function runAllVerifications() */ private function validatePHPExtensions() { - $phpExtensionErrors = array(); + $phpExtensionErrors = []; foreach (self::$REQUIRED_EXTENSIONS as $requiredExtension) { if (!extension_loaded($requiredExtension)) { $requiredExtensionError = $requiredExtension . @@ -159,7 +159,7 @@ private function validatePHPExtensions() */ private function validateZendFrameworkInstallation() { - $zendFrameworkInstallationErrors = array(); + $zendFrameworkInstallationErrors = []; $zendLoaderPresent = false; try { $zendLoaderPresent = @fopen('Zend/Loader.php', 'r', true); @@ -241,7 +241,7 @@ private function makeHTMLLink($inputString) */ private function testSSLCapabilities() { - $sslCapabilitiesErrors = array(); + $sslCapabilitiesErrors = []; require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Http_Client'); @@ -271,7 +271,7 @@ private function testSSLCapabilities() */ private function validateYouTubeAPIConnectivity() { - $connectivityErrors = array(); + $connectivityErrors = []; require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata_YouTube'); $yt = new Zend_Gdata_YouTube(); diff --git a/demos/Zend/Gdata/Spreadsheet-ClientLogin.php b/demos/Zend/Gdata/Spreadsheet-ClientLogin.php index 5394d53d89..7dccfc78e2 100644 --- a/demos/Zend/Gdata/Spreadsheet-ClientLogin.php +++ b/demos/Zend/Gdata/Spreadsheet-ClientLogin.php @@ -326,7 +326,7 @@ public function listDeleteAction($index) */ public function stringToArray($rowData) { - $arr = array(); + $arr = []; foreach ($rowData as $row) { $temp = explode('=', $row); $arr[$temp[0]] = $temp[1]; diff --git a/demos/Zend/Mail/SimpleMailer.php b/demos/Zend/Mail/SimpleMailer.php index e9c0af7b77..cdd0d7cd56 100644 --- a/demos/Zend/Mail/SimpleMailer.php +++ b/demos/Zend/Mail/SimpleMailer.php @@ -113,26 +113,26 @@ function __construct() switch ($this->type) { case 'mbox': - $this->mail = new Zend_Mail_Storage_Mbox(array('filename' => $this->param)); + $this->mail = new Zend_Mail_Storage_Mbox(['filename' => $this->param]); break; case 'mbox-folder': - $this->mail = new Zend_Mail_Storage_Folder_Mbox(array('dirname' => $this->param)); + $this->mail = new Zend_Mail_Storage_Folder_Mbox(['dirname' => $this->param]); break; case 'maildir': - $this->mail = new Zend_Mail_Storage_Maildir(array('dirname' => $this->param)); + $this->mail = new Zend_Mail_Storage_Maildir(['dirname' => $this->param]); break; case 'maildir-folder': - $this->mail = new Zend_Mail_Storage_Folder_Maildir(array('dirname' => $this->param)); + $this->mail = new Zend_Mail_Storage_Folder_Maildir(['dirname' => $this->param]); break; case 'pop3': - $this->mail = new Zend_Mail_Storage_Pop3(array('host' => $this->param, + $this->mail = new Zend_Mail_Storage_Pop3(['host' => $this->param, 'user' => $_SERVER['PHP_AUTH_USER'], - 'password' => $_SERVER['PHP_AUTH_PW'])); + 'password' => $_SERVER['PHP_AUTH_PW']]); break; case 'imap': - $this->mail = new Zend_Mail_Storage_Imap(array('host' => $this->param, + $this->mail = new Zend_Mail_Storage_Imap(['host' => $this->param, 'user' => $_SERVER['PHP_AUTH_USER'], - 'password' => $_SERVER['PHP_AUTH_PW'])); + 'password' => $_SERVER['PHP_AUTH_PW']]); break; default: $this->mail = null; @@ -147,14 +147,14 @@ function __construct() */ function whitelistParam() { - $whitelist = array('mbox' => array('mbox/INBOX', 'mbox/subfolder/test'), - 'mbox-folder' => array('mbox'), - 'maildir' => array('maildir', 'maildir/.subfolder', 'maildir/.subfolder.test'), - 'maildir-folder' => array('maildir', 'maildir/.subfolder', 'maildir/.subfolder.test'), - 'pop3' => array(), - 'imap' => array()); - - if ($this->type === null || @$whitelist[$this->type] === array() || @in_array($this->param, $whitelist[$this->type])) { + $whitelist = ['mbox' => ['mbox/INBOX', 'mbox/subfolder/test'], + 'mbox-folder' => ['mbox'], + 'maildir' => ['maildir', 'maildir/.subfolder', 'maildir/.subfolder.test'], + 'maildir-folder' => ['maildir', 'maildir/.subfolder', 'maildir/.subfolder.test'], + 'pop3' => [], + 'imap' => []]; + + if ($this->type === null || @$whitelist[$this->type] === [] || @in_array($this->param, $whitelist[$this->type])) { return; } @@ -168,12 +168,12 @@ function whitelistParam() */ function loadClasses() { - $classname = array('mbox' => 'Zend_Mail_Storage_Mbox', + $classname = ['mbox' => 'Zend_Mail_Storage_Mbox', 'mbox-folder' => 'Zend_Mail_Storage_Folder_Mbox', 'maildir' => 'Zend_Mail_Storage_Maildir', 'maildir-folder' => 'Zend_Mail_Storage_Folder_Maildir', 'pop3' => 'Zend_Mail_Storage_Pop3', - 'imap' => 'Zend_Mail_Storage_Imap'); + 'imap' => 'Zend_Mail_Storage_Imap']; if (isset($classname[$this->type])) { Zend_Loader::loadClass($classname[$this->type]); @@ -193,9 +193,9 @@ function initVars() $this->param = isset($_GET['param']) ? $_GET['param'] : null; $this->folder = isset($_GET['folder']) ? $_GET['folder'] : null; $this->messageNum = isset($_GET['message']) && is_numeric($_GET['message']) ? $_GET['message'] : null; - $this->queryString = http_build_query(array('type' => $this->type, + $this->queryString = http_build_query(['type' => $this->type, 'param' => $this->param, - 'folder' => $this->folder)); + 'folder' => $this->folder]); } /** @@ -379,7 +379,7 @@ function showList() foreach ($this->mail as $num => $message) { if ($this->mail->hasFlags) { - $class = array(); + $class = []; if ($message->hasFlag(Zend_Mail_Storage::FLAG_RECENT)) { $class['unread'] = 'unread'; diff --git a/demos/Zend/Mobile/Push/GcmServer.php b/demos/Zend/Mobile/Push/GcmServer.php index 22794324b7..bf2fb92db7 100644 --- a/demos/Zend/Mobile/Push/GcmServer.php +++ b/demos/Zend/Mobile/Push/GcmServer.php @@ -4,10 +4,10 @@ $message = new Zend_Mobile_Push_Message_Gcm(); $message->addToken('ABCDEF0123456789'); -$message->setData(array( +$message->setData([ 'foo' => 'bar', 'bar' => 'foo', -)); +]); $gcm = new Zend_Mobile_Push_Gcm(); $gcm->setApiKey('YOUR_API_KEY'); diff --git a/demos/Zend/Mobile/Push/MpnsServer.php b/demos/Zend/Mobile/Push/MpnsServer.php index a076068fde..23e871eafb 100644 --- a/demos/Zend/Mobile/Push/MpnsServer.php +++ b/demos/Zend/Mobile/Push/MpnsServer.php @@ -5,7 +5,7 @@ require_once 'Zend/Mobile/Push/Message/Mpns/Toast.php'; $mpns = new Zend_Mobile_Push_Mpns(); -$messages = array(); +$messages = []; // raw notification $message = new Zend_Mobile_Push_Message_Mpns_Raw(); diff --git a/demos/Zend/OpenId/test_consumer.php b/demos/Zend/OpenId/test_consumer.php index 96cf7a5bf0..b681efcbe1 100644 --- a/demos/Zend/OpenId/test_consumer.php +++ b/demos/Zend/OpenId/test_consumer.php @@ -34,13 +34,13 @@ $id = ""; $status = ""; -$data = array(); +$data = []; if (isset($_POST['openid_action']) && $_POST['openid_action'] == "login" && !empty($_POST['openid_identifier'])) { $consumer = new Zend_OpenId_Consumer(); - $props = array(); + $props = []; foreach (Zend_OpenId_Extension_Sreg::getSregProperties() as $prop) { if (isset($_POST[$prop])) { if ($_POST[$prop] === "required") { diff --git a/demos/Zend/OpenId/test_server.php b/demos/Zend/OpenId/test_server.php index d5aa16bbd0..b638c08c0e 100644 --- a/demos/Zend/OpenId/test_server.php +++ b/demos/Zend/OpenId/test_server.php @@ -242,7 +242,7 @@ function sreg_form(Zend_OpenId_Extension_Sreg $sreg) if (isset($_POST['forever'])) { $server->denySite($server->getSiteRoot($_GET)); } - Zend_OpenId::redirect($_GET['openid_return_to'], array('openid.mode'=>'cancel')); + Zend_OpenId::redirect($_GET['openid_return_to'], ['openid.mode'=>'cancel']); } } else if (isset($_POST['allow'])) { $server->allowSite($_POST['site']); diff --git a/demos/Zend/Pdf/demo.php b/demos/Zend/Pdf/demo.php index 6a306b07e0..e2e19120f7 100644 --- a/demos/Zend/Pdf/demo.php +++ b/demos/Zend/Pdf/demo.php @@ -64,7 +64,7 @@ $style->setFillColor(new Zend_Pdf_Color_Rgb(0, 0, 0.9)); $style->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)); $style->setLineWidth(3); -$style->setLineDashingPattern(array(3, 2, 3, 4), 1.6); +$style->setLineDashingPattern([3, 2, 3, 4], 1.6); $style->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD), 32); try { @@ -123,7 +123,7 @@ // Draw rectangle $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8)) ->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)) - ->setLineDashingPattern(array(3, 2, 3, 4), 1.6) + ->setLineDashingPattern([3, 2, 3, 4], 1.6) ->drawRectangle(60, 400, 400, 350); // Draw circle @@ -148,8 +148,8 @@ // Draw and fill polygon $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1)); -$x = array(); -$y = array(); +$x = []; +$y = []; for ($count = 0; $count < 8; $count++) { $x[] = 140 + 25*cos(3*M_PI_4*$count); $y[] = 375 + 25*sin(3*M_PI_4*$count); @@ -167,7 +167,7 @@ // Draw rectangle $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8)) ->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)) - ->setLineDashingPattern(array(3, 2, 3, 4), 1.6) + ->setLineDashingPattern([3, 2, 3, 4], 1.6) ->drawRectangle(0, 50, 340, 0); // Draw circle @@ -192,8 +192,8 @@ // Draw and fill polygon $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1)); -$x = array(); -$y = array(); +$x = []; +$y = []; for ($count = 0; $count < 8; $count++) { $x[] = 80 + 25*cos(3*M_PI_4*$count); $y[] = 25 + 25*sin(3*M_PI_4*$count); @@ -218,7 +218,7 @@ // Draw rectangle $page2->setFillColor(new Zend_Pdf_Color_GrayScale(0.8)) ->setLineColor(new Zend_Pdf_Color_GrayScale(0.2)) - ->setLineDashingPattern(array(3, 2, 3, 4), 1.6) + ->setLineDashingPattern([3, 2, 3, 4], 1.6) ->drawRectangle(0, 50, 340, 0); // Draw circle @@ -243,8 +243,8 @@ // Draw and fill polygon $page2->setFillColor(new Zend_Pdf_Color_Rgb(1, 0, 1)); -$x = array(); -$y = array(); +$x = []; +$y = []; for ($count = 0; $count < 8; $count++) { $x[] = 80 + 25*cos(3*M_PI_4*$count); $y[] = 25 + 25*sin(3*M_PI_4*$count); diff --git a/demos/Zend/ProgressBar/JsPush.php b/demos/Zend/ProgressBar/JsPush.php index ea0b52c5ba..6f930edcb6 100644 --- a/demos/Zend/ProgressBar/JsPush.php +++ b/demos/Zend/ProgressBar/JsPush.php @@ -30,8 +30,8 @@ require_once 'Zend/ProgressBar.php'; require_once 'Zend/ProgressBar/Adapter/JsPush.php'; - $adapter = new Zend_ProgressBar_Adapter_JsPush(array('updateMethodName' => 'Zend_ProgressBar_Update', - 'finishMethodName' => 'Zend_ProgressBar_Finish')); + $adapter = new Zend_ProgressBar_Adapter_JsPush(['updateMethodName' => 'Zend_ProgressBar_Update', + 'finishMethodName' => 'Zend_ProgressBar_Finish']); $progressBar = new Zend_ProgressBar($adapter, 0, 100); for ($i = 1; $i <= 100; $i++) { diff --git a/demos/Zend/ProgressBar/ZendForm.php b/demos/Zend/ProgressBar/ZendForm.php index 5ea49c56fd..dff31c7337 100644 --- a/demos/Zend/ProgressBar/ZendForm.php +++ b/demos/Zend/ProgressBar/ZendForm.php @@ -33,7 +33,7 @@ require_once 'Zend/ProgressBar/Adapter/JsPull.php'; $adapter = new Zend_ProgressBar_Adapter_JsPull(); - Zend_File_Transfer_Adapter_Http::getProgress(array('progress' => $adapter)); + Zend_File_Transfer_Adapter_Http::getProgress(['progress' => $adapter]); die; } ?> @@ -193,16 +193,16 @@ function finish() require_once 'Zend/View.php'; require_once 'Zend/Form.php'; - $form = new Zend_Form(array( + $form = new Zend_Form([ 'enctype' => 'multipart/form-data', 'action' => 'ZendForm.php', 'target' => 'uploadTarget', 'onsubmit' => 'observeProgress();', - 'elements' => array( - 'file' => array('file', array('label' => 'File')), - 'submit' => array('submit', array('label' => 'Upload!')) - ) - )); + 'elements' => [ + 'file' => ['file', ['label' => 'File']], + 'submit' => ['submit', ['label' => 'Upload!']] + ] + ]); $form->setView(new Zend_View()); diff --git a/demos/Zend/Service/LiveDocx/MailMerge/constructors/public.php b/demos/Zend/Service/LiveDocx/MailMerge/constructors/public.php index a5973cad84..760bc22c68 100755 --- a/demos/Zend/Service/LiveDocx/MailMerge/constructors/public.php +++ b/demos/Zend/Service/LiveDocx/MailMerge/constructors/public.php @@ -37,10 +37,10 @@ // Alternatively, you can pass username and password in the constructor. $mailMerge = new Zend_Service_LiveDocx_MailMerge( - array ( + [ 'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD, - ) + ] ); $mailMerge->getTemplateFormats(); // then call methods as usual diff --git a/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php b/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php index 5f33ba2152..b90b7d9e7e 100755 --- a/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php +++ b/demos/Zend/Service/LiveDocx/MailMerge/license-agreement/generate-document-concat.php @@ -87,7 +87,7 @@ // Generate temporary documents -$tempFilenames = array(); +$tempFilenames = []; $mailMerge = new Zend_Service_LiveDocx_MailMerge(); @@ -162,7 +162,7 @@ function randomString() for ($i = 0; $i < $stringLen; $i ++) { $pos = (rand() % $poolLen); - $ret .= $pool{$pos}; + $ret .= $pool[$pos]; } return $ret; @@ -220,6 +220,7 @@ function concatenatePdfFilenames($inputFilenames, $outputFilename, $processor = case PROCESSOR_PDFTK : $format = '%s %s cat output %s'; + trigger_error(sprintf("%s (%s::%s)", "PHP 7.4 Compatibility Alert WARNING: Passing the \$glue and \$pieces parameters in reverse order to implode has been deprecated since PHP 7.4; \$glue should be the first parameter and \$pieces the second", __FILE__, __LINE__) . "\n\t" . implode("\n\t", array_map(function ($item) { return call_user_func_array('sprintf', array_values(array_merge(array('format' => '%s::%s %s%s%s'), array_fill_keys(array('file', 'line', 'class', 'type', 'function'), null), $item))); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING); $command = sprintf($format, EXEC_PDFTK, implode($inputFilenames, ' '), $outputFilename); break; @@ -229,6 +230,7 @@ function concatenatePdfFilenames($inputFilenames, $outputFilename, $processor = $format .= '-dColorImageFilter=/FlateEncode -dCompatibilityLevel=1.3 -dEmbedAllFonts=true '; $format .= '-dGrayImageFilter=/FlateEncode -dMaxSubsetPct=100 -dMonoImageFilter=/CCITTFaxEncode '; $format .= '-dSubsetFonts=true -sOUTPUTFILE=%s %s'; + trigger_error(sprintf("%s (%s::%s)", "PHP 7.4 Compatibility Alert WARNING: Passing the \$glue and \$pieces parameters in reverse order to implode has been deprecated since PHP 7.4; \$glue should be the first parameter and \$pieces the second", __FILE__, __LINE__) . "\n\t" . implode("\n\t", array_map(function ($item) { return call_user_func_array('sprintf', array_values(array_merge(array('format' => '%s::%s %s%s%s'), array_fill_keys(array('file', 'line', 'class', 'type', 'function'), null), $item))); }, debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS))), E_USER_WARNING); $command = sprintf($format, EXEC_GHOSTSCRIPT, $outputFilename, implode($inputFilenames, ' ')); break; diff --git a/demos/Zend/Service/LiveDocx/MailMerge/pdf-security/generate-document.php b/demos/Zend/Service/LiveDocx/MailMerge/pdf-security/generate-document.php index 8855e95566..4be8b54c50 100755 --- a/demos/Zend/Service/LiveDocx/MailMerge/pdf-security/generate-document.php +++ b/demos/Zend/Service/LiveDocx/MailMerge/pdf-security/generate-document.php @@ -26,10 +26,10 @@ // Available on premium service only $mailMerge->setDocumentAccessPermissions( - array( + [ 'AllowHighLevelPrinting' , // getDocumentAccessOptions() returns 'AllowExtractContents' // array of permitted values - ), + ], 'myDocumentAccessPassword' ); diff --git a/demos/Zend/Service/LiveDocx/MailMerge/supported-fonts/show-supported-fonts-cached.php b/demos/Zend/Service/LiveDocx/MailMerge/supported-fonts/show-supported-fonts-cached.php index f197a28429..c296e8d84e 100755 --- a/demos/Zend/Service/LiveDocx/MailMerge/supported-fonts/show-supported-fonts-cached.php +++ b/demos/Zend/Service/LiveDocx/MailMerge/supported-fonts/show-supported-fonts-cached.php @@ -7,14 +7,14 @@ $cacheId = md5(__FILE__); -$cacheFrontendOptions = array( +$cacheFrontendOptions = [ 'lifetime' => 2592000, // 30 days 'automatic_serialization' => true -); +]; -$cacheBackendOptions = array( +$cacheBackendOptions = [ 'cache_dir' => dirname(__FILE__) . '/cache' -); +]; $cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions); diff --git a/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php b/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php index 5780c2af38..5bd64e284e 100755 --- a/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php +++ b/demos/Zend/Service/LiveDocx/MailMerge/supported-formats/show-supported-formats-cached.php @@ -17,14 +17,14 @@ $cacheId = md5(__FILE__); -$cacheFrontendOptions = array( +$cacheFrontendOptions = [ 'lifetime' => 2592000, // 30 days 'automatic_serialization' => true -); +]; -$cacheBackendOptions = array( +$cacheBackendOptions = [ 'cache_dir' => dirname(__FILE__) . '/cache' -); +]; $cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions); diff --git a/demos/Zend/Service/LiveDocx/MailMerge/telephone-bill/generate-document.php b/demos/Zend/Service/LiveDocx/MailMerge/telephone-bill/generate-document.php index 29fe389441..f389f577c4 100755 --- a/demos/Zend/Service/LiveDocx/MailMerge/telephone-bill/generate-document.php +++ b/demos/Zend/Service/LiveDocx/MailMerge/telephone-bill/generate-document.php @@ -29,7 +29,7 @@ ->assign('account_number', sprintf("#%'10s", rand(0,1000000000))); -$billData = array ( +$billData = [ 'phone' => '+22 (0)333 444 555', 'date' => Zend_Date::now()->toString(Zend_Date::DATE_LONG), 'name' => 'James Henry Brown', @@ -42,33 +42,33 @@ 'tax' => '19.00', 'tax_value' => '3.72', 'total' => '23.32' -); +]; $mailMerge->assign($billData); -$billConnections = array( - array( +$billConnections = [ + [ 'connection_number' => '+11 (0)222 333 441', 'connection_duration' => '00:01:01', 'fee' => '1.15' - ), - array( + ], + [ 'connection_number' => '+11 (0)222 333 442', 'connection_duration' => '00:01:02', 'fee' => '1.15' - ), - array( + ], + [ 'connection_number' => '+11 (0)222 333 443', 'connection_duration' => '00:01:03', 'fee' => '1.15' - ), - array( + ], + [ 'connection_number' => '+11 (0)222 333 444', 'connection_duration' => '00:01:04', 'fee' => '1.15' - ) -); + ] +]; $mailMerge->assign('connection', $billConnections); diff --git a/demos/Zend/Service/LiveDocx/check-environment.php b/demos/Zend/Service/LiveDocx/check-environment.php index f12862e57d..7d0e6c4152 100755 --- a/demos/Zend/Service/LiveDocx/check-environment.php +++ b/demos/Zend/Service/LiveDocx/check-environment.php @@ -165,12 +165,12 @@ $geoData = @file_get_contents('http://api.ipinfodb.com/v2/ip_query.php?key=332bde528d94fe578455e18ad225a01cba8dd359ee915ee46b70ca5e67137252'); -$keys = array ( +$keys = [ 'Ip' => 'IP address', 'City' => 'city', 'RegionName' => 'region', 'CountryName' => 'country' -); +]; if (false !== $geoData) { $simplexml = new SimpleXMLElement($geoData); @@ -221,10 +221,10 @@ try { $microtime = microtime(true); $mailMerge = new Zend_Service_LiveDocx_MailMerge( - array ( + [ 'username' => DEMOS_ZEND_SERVICE_LIVEDOCX_USERNAME, 'password' => DEMOS_ZEND_SERVICE_LIVEDOCX_PASSWORD - ) + ] ); $mailMerge->logIn(); $duration = microtime(true) - $microtime; diff --git a/demos/Zend/WebServices/Amazon/amazon-search.php b/demos/Zend/WebServices/Amazon/amazon-search.php index 66418fa285..011b6d52b9 100644 --- a/demos/Zend/WebServices/Amazon/amazon-search.php +++ b/demos/Zend/WebServices/Amazon/amazon-search.php @@ -111,7 +111,7 @@ in ', $html); } } diff --git a/tests/Zend/View/Helper/BaseUrlTest.php b/tests/Zend/View/Helper/BaseUrlTest.php index 9586dd7dd5..437297c170 100644 --- a/tests/Zend/View/Helper/BaseUrlTest.php +++ b/tests/Zend/View/Helper/BaseUrlTest.php @@ -95,7 +95,7 @@ protected function tearDown() */ public function testBaseUrlIsSameAsFrontController() { - $baseUrls = array('', '/subdir', '/subdir/', '/sub/sub/dir'); + $baseUrls = ['', '/subdir', '/subdir/', '/sub/sub/dir']; foreach ($baseUrls as $baseUrl) { Zend_Controller_Front::getInstance()->setBaseUrl($baseUrl); $helper = new Zend_View_Helper_BaseUrl(); @@ -110,11 +110,11 @@ public function testBaseUrlIsSameAsFrontController() */ public function testBaseUrlIsCorrectingFilePath() { - $baseUrls = array( + $baseUrls = [ '' => '/file.js', '/subdir' => '/subdir/file.js', '/sub/sub/dir' => '/sub/sub/dir/file.js', - ); + ]; foreach ($baseUrls as $baseUrl => $val) { Zend_Controller_Front::getInstance()->setBaseUrl($baseUrl); @@ -130,11 +130,11 @@ public function testBaseUrlIsCorrectingFilePath() */ public function testBaseUrlIsAppendedWithFile() { - $baseUrls = array( + $baseUrls = [ '' => '/file.js', '/subdir' => '/subdir/file.js', '/sub/sub/dir' => '/sub/sub/dir/file.js', - ); + ]; foreach ($baseUrls as $baseUrl => $val) { Zend_Controller_Front::getInstance()->setBaseUrl($baseUrl); @@ -150,11 +150,11 @@ public function testBaseUrlIsAppendedWithFile() */ public function testBaseUrlIsAppendedWithPath() { - $baseUrls = array( + $baseUrls = [ '' => '/path/bar', '/subdir' => '/subdir/path/bar', '/sub/sub/dir' => '/sub/sub/dir/path/bar', - ); + ]; foreach ($baseUrls as $baseUrl => $val) { Zend_Controller_Front::getInstance()->setBaseUrl($baseUrl); @@ -170,10 +170,10 @@ public function testBaseUrlIsAppendedWithPath() */ public function testBaseUrlIsAppendedWithRootPath() { - $baseUrls = array( + $baseUrls = [ '' => '/', '/foo' => '/foo/' - ); + ]; foreach ($baseUrls as $baseUrl => $val) { Zend_Controller_Front::getInstance()->setBaseUrl($baseUrl); diff --git a/tests/Zend/View/Helper/CurrencyTest.php b/tests/Zend/View/Helper/CurrencyTest.php index 8535721775..de55534eff 100644 --- a/tests/Zend/View/Helper/CurrencyTest.php +++ b/tests/Zend/View/Helper/CurrencyTest.php @@ -84,8 +84,8 @@ public function setUp() $this->clearRegistry(); require_once 'Zend/Cache.php'; $this->_cache = Zend_Cache::factory('Core', 'File', - array('lifetime' => 120, 'automatic_serialization' => true), - array('cache_dir' => dirname(__FILE__) . '/../../_files/')); + ['lifetime' => 120, 'automatic_serialization' => true], + ['cache_dir' => dirname(__FILE__) . '/../../_files/']); Zend_Currency::setCache($this->_cache); $this->helper = new Zend_View_Helper_Currency('de_AT'); diff --git a/tests/Zend/View/Helper/CycleTest.php b/tests/Zend/View/Helper/CycleTest.php index 030642abf3..ce6bfb275a 100644 --- a/tests/Zend/View/Helper/CycleTest.php +++ b/tests/Zend/View/Helper/CycleTest.php @@ -87,25 +87,25 @@ public function testCycleMethodReturnsObjectInstance() public function testAssignAndGetValues() { - $this->helper->assign(array('a', 1, 'asd')); - $this->assertEquals(array('a', 1, 'asd'), $this->helper->getAll()); + $this->helper->assign(['a', 1, 'asd']); + $this->assertEquals(['a', 1, 'asd'], $this->helper->getAll()); } public function testCycleMethod() { - $this->helper->cycle(array('a', 1, 'asd')); - $this->assertEquals(array('a', 1, 'asd'), $this->helper->getAll()); + $this->helper->cycle(['a', 1, 'asd']); + $this->assertEquals(['a', 1, 'asd'], $this->helper->getAll()); } public function testToString() { - $this->helper->cycle(array('a', 1, 'asd')); + $this->helper->cycle(['a', 1, 'asd']); $this->assertEquals('a', (string) $this->helper->toString()); } public function testNextValue() { - $this->helper->assign(array('a', 1, 3)); + $this->helper->assign(['a', 1, 3]); $this->assertEquals('a', (string) $this->helper->next()); $this->assertEquals(1, (string) $this->helper->next()); $this->assertEquals(3, (string) $this->helper->next()); @@ -115,7 +115,7 @@ public function testNextValue() public function testPrevValue() { - $this->helper->assign(array(4, 1, 3)); + $this->helper->assign([4, 1, 3]); $this->assertEquals(3, (string) $this->helper->prev()); $this->assertEquals(1, (string) $this->helper->prev()); $this->assertEquals(4, (string) $this->helper->prev()); @@ -125,7 +125,7 @@ public function testPrevValue() public function testRewind() { - $this->helper->assign(array(5, 8, 3)); + $this->helper->assign([5, 8, 3]); $this->assertEquals(5, (string) $this->helper->next()); $this->assertEquals(8, (string) $this->helper->next()); $this->helper->rewind(); @@ -135,7 +135,7 @@ public function testRewind() public function testMixedMethods() { - $this->helper->assign(array(5, 8, 3)); + $this->helper->assign([5, 8, 3]); $this->assertEquals(5, (string) $this->helper->next()); $this->assertEquals(5, (string) $this->helper->current()); $this->assertEquals(8, (string) $this->helper->next()); @@ -144,17 +144,17 @@ public function testMixedMethods() public function testTwoCycles() { - $this->helper->assign(array(5, 8, 3)); + $this->helper->assign([5, 8, 3]); $this->assertEquals(5, (string) $this->helper->next()); - $this->assertEquals(2, (string) $this->helper->cycle(array(2,38,1),'cycle2')->next()); + $this->assertEquals(2, (string) $this->helper->cycle([2,38,1],'cycle2')->next()); $this->assertEquals(8, (string) $this->helper->cycle()->next()); $this->assertEquals(38, (string) $this->helper->setName('cycle2')->next()); } public function testTwoCyclesInLoop() { - $expected = array(5,4,2,3); - $expected2 = array(7,34,8,6); + $expected = [5,4,2,3]; + $expected2 = [7,34,8,6]; for($i=0;$i<4;$i++) { $this->assertEquals($expected[$i], (string) $this->helper->cycle($expected)->next()); $this->assertEquals($expected2[$i], (string) $this->helper->cycle($expected2,'cycle2')->next()); diff --git a/tests/Zend/View/Helper/DeclareVarsTest.php b/tests/Zend/View/Helper/DeclareVarsTest.php index f5b4237724..e5f6d07e99 100644 --- a/tests/Zend/View/Helper/DeclareVarsTest.php +++ b/tests/Zend/View/Helper/DeclareVarsTest.php @@ -71,10 +71,10 @@ protected function _declareVars() $this->view->declareVars( 'varName1', 'varName2', - array( + [ 'varName3' => 'defaultValue', - 'varName4' => array() - ) + 'varName4' => [] + ] ); } @@ -88,7 +88,7 @@ public function testDeclareUndeclaredVars() $this->assertTrue(isset($this->view->varName4)); $this->assertEquals('defaultValue', $this->view->varName3); - $this->assertEquals(array(), $this->view->varName4); + $this->assertEquals([], $this->view->varName4); } public function testDeclareDeclaredVars() diff --git a/tests/Zend/View/Helper/DoctypeTest.php b/tests/Zend/View/Helper/DoctypeTest.php index ea52eb10c5..b122ff17a0 100644 --- a/tests/Zend/View/Helper/DoctypeTest.php +++ b/tests/Zend/View/Helper/DoctypeTest.php @@ -117,14 +117,14 @@ public function testPassingDoctypeSetsDoctype() public function testIsXhtmlReturnsTrueForXhtmlDoctypes() { - $types = array( + $types = [ 'XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET', 'XHTML1_RDFA', 'XHTML1_RDFA11', 'XHTML5', - ); + ]; foreach ($types as $type) { $doctype = $this->helper->doctype($type); @@ -139,7 +139,7 @@ public function testIsXhtmlReturnsTrueForXhtmlDoctypes() public function testIsXhtmlReturnsFalseForNonXhtmlDoctypes() { - foreach (array('HTML4_STRICT', 'HTML4_LOOSE', 'HTML4_FRAMESET') as $type) { + foreach (['HTML4_STRICT', 'HTML4_LOOSE', 'HTML4_FRAMESET'] as $type) { $doctype = $this->helper->doctype($type); $this->assertEquals($type, $doctype->getDoctype()); $this->assertFalse($doctype->isXhtml()); @@ -151,13 +151,13 @@ public function testIsXhtmlReturnsFalseForNonXhtmlDoctypes() } public function testIsHtml5() { - foreach (array('HTML5', 'XHTML5') as $type) { + foreach (['HTML5', 'XHTML5'] as $type) { $doctype = $this->helper->doctype($type); $this->assertEquals($type, $doctype->getDoctype()); $this->assertTrue($doctype->isHtml5()); } - foreach (array('HTML4_STRICT', 'HTML4_LOOSE', 'HTML4_FRAMESET', 'XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET') as $type) { + foreach (['HTML4_STRICT', 'HTML4_LOOSE', 'HTML4_FRAMESET', 'XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET'] as $type) { $doctype = $this->helper->doctype($type); $this->assertEquals($type, $doctype->getDoctype()); $this->assertFalse($doctype->isHtml5()); @@ -170,7 +170,7 @@ public function testIsRdfa() $this->assertTrue($this->helper->doctype('XHTML1_RDFA11')->isRdfa()); // built-in doctypes - foreach (array('HTML4_STRICT', 'HTML4_LOOSE', 'HTML4_FRAMESET', 'XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET') as $type) { + foreach (['HTML4_STRICT', 'HTML4_LOOSE', 'HTML4_FRAMESET', 'XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET'] as $type) { $doctype = $this->helper->doctype($type); $this->assertFalse($doctype->isRdfa()); } diff --git a/tests/Zend/View/Helper/FieldsetTest.php b/tests/Zend/View/Helper/FieldsetTest.php index 6be3475e37..af9fd3fc09 100644 --- a/tests/Zend/View/Helper/FieldsetTest.php +++ b/tests/Zend/View/Helper/FieldsetTest.php @@ -88,7 +88,7 @@ public function testFieldsetHelperCreatesFieldsetWithProvidedContent() public function testProvidingLegendOptionToFieldsetCreatesLegendTag() { - $html = $this->helper->fieldset('foo', 'foobar', array('legend' => 'Great Scott!')); + $html = $this->helper->fieldset('foo', 'foobar', ['legend' => 'Great Scott!']); $this->assertRegexp('#Great Scott!#', $html); } @@ -97,8 +97,8 @@ public function testProvidingLegendOptionToFieldsetCreatesLegendTag() */ public function testEmptyLegendShouldNotRenderLegendTag() { - foreach (array(null, '', ' ', false) as $legend) { - $html = $this->helper->fieldset('foo', 'foobar', array('legend' => $legend)); + foreach ([null, '', ' ', false] as $legend) { + $html = $this->helper->fieldset('foo', 'foobar', ['legend' => $legend]); $this->assertNotContains('', $html, 'Failed with value ' . var_export($legend, 1) . ': ' . $html); } } @@ -108,7 +108,7 @@ public function testEmptyLegendShouldNotRenderLegendTag() */ public function testHelperShouldAllowDisablingEscapingOfLegend() { - $html = $this->helper->fieldset('foo', 'foobar', array('legend' => 'Great Scott!', 'escape' => false)); + $html = $this->helper->fieldset('foo', 'foobar', ['legend' => 'Great Scott!', 'escape' => false]); $this->assertRegexp('#Great Scott!#', $html, $html); } } diff --git a/tests/Zend/View/Helper/FormButtonTest.php b/tests/Zend/View/Helper/FormButtonTest.php index 54be7659ef..7e6c0e4a0d 100644 --- a/tests/Zend/View/Helper/FormButtonTest.php +++ b/tests/Zend/View/Helper/FormButtonTest.php @@ -88,7 +88,7 @@ public function testFormButtonRendersButtonXhtml() public function testCanPassContentViaContentAttribKey() { - $button = $this->helper->formButton('foo', 'bar', array('content' => 'Display this')); + $button = $this->helper->formButton('foo', 'bar', ['content' => 'Display this']); $this->assertContains('>Display this<', $button); $this->assertContains('assertContains('', $button); @@ -96,13 +96,13 @@ public function testCanPassContentViaContentAttribKey() public function testCanDisableContentEscaping() { - $button = $this->helper->formButton('foo', 'bar', array('content' => 'Display this', 'escape' => false)); + $button = $this->helper->formButton('foo', 'bar', ['content' => 'Display this', 'escape' => false]); $this->assertContains('>Display this<', $button); - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('content' => 'Display this', 'escape' => false))); + $button = $this->helper->formButton(['name' => 'foo', 'value' => 'bar', 'attribs' => ['content' => 'Display this', 'escape' => false]]); $this->assertContains('>Display this<', $button); - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'escape' => false, 'attribs' => array('content' => 'Display this'))); + $button = $this->helper->formButton(['name' => 'foo', 'value' => 'bar', 'escape' => false, 'attribs' => ['content' => 'Display this']]); $this->assertContains('>Display this<', $button); $this->assertContains('assertContains('', $button); @@ -110,25 +110,25 @@ public function testCanDisableContentEscaping() public function testValueUsedForContentWhenNoContentProvided() { - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar')); + $button = $this->helper->formButton(['name' => 'foo', 'value' => 'bar']); $this->assertRegexp('#]*?value="bar"[^>]*>bar#', $button); } public function testButtonTypeIsButtonByDefault() { - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar')); + $button = $this->helper->formButton(['name' => 'foo', 'value' => 'bar']); $this->assertContains('type="button"', $button); } public function testButtonTypeMayOnlyBeValidXhtmlButtonType() { - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('type' => 'submit'))); + $button = $this->helper->formButton(['name' => 'foo', 'value' => 'bar', 'attribs' => ['type' => 'submit']]); $this->assertContains('type="submit"', $button); - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('type' => 'reset'))); + $button = $this->helper->formButton(['name' => 'foo', 'value' => 'bar', 'attribs' => ['type' => 'reset']]); $this->assertContains('type="reset"', $button); - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('type' => 'button'))); + $button = $this->helper->formButton(['name' => 'foo', 'value' => 'bar', 'attribs' => ['type' => 'button']]); $this->assertContains('type="button"', $button); - $button = $this->helper->formButton(array('name' => 'foo', 'value' => 'bar', 'attribs' => array('type' => 'bogus'))); + $button = $this->helper->formButton(['name' => 'foo', 'value' => 'bar', 'attribs' => ['type' => 'bogus']]); $this->assertContains('type="button"', $button); } } diff --git a/tests/Zend/View/Helper/FormCheckboxTest.php b/tests/Zend/View/Helper/FormCheckboxTest.php index b762870abb..31e1870ba9 100644 --- a/tests/Zend/View/Helper/FormCheckboxTest.php +++ b/tests/Zend/View/Helper/FormCheckboxTest.php @@ -76,7 +76,7 @@ public function testIdSetFromName() public function testSetIdFromAttribs() { - $element = $this->helper->formCheckbox('foo', null, array('id' => 'bar')); + $element = $this->helper->formCheckbox('foo', null, ['id' => 'bar']); $this->assertContains('name="foo"', $element); $this->assertContains('id="bar"', $element); } @@ -86,11 +86,11 @@ public function testSetIdFromAttribs() */ public function testCanDisableCheckbox() { - $html = $this->helper->formCheckbox(array( + $html = $this->helper->formCheckbox([ 'name' => 'foo', 'value' => 'bar', - 'attribs'=> array('disable' => true) - )); + 'attribs'=> ['disable' => true] + ]); $this->assertRegexp('/]*?(disabled="disabled")/', $html); } @@ -99,21 +99,21 @@ public function testCanDisableCheckbox() */ public function testCheckboxNotDisabled() { - $html = $this->helper->formCheckbox(array( + $html = $this->helper->formCheckbox([ 'name' => 'foo', 'value' => 'bar', - 'attribs'=> array('disable' => false) - )); + 'attribs'=> ['disable' => false] + ]); $this->assertNotContains('disabled="disabled"', $html); } public function testCanSelectCheckbox() { - $html = $this->helper->formCheckbox(array( + $html = $this->helper->formCheckbox([ 'name' => 'foo', 'value' => 'bar', - 'attribs'=> array('checked' => true) - )); + 'attribs'=> ['checked' => true] + ]); $this->assertRegexp('/]*?(checked="checked")/', $html); $count = substr_count($html, 'checked'); $this->assertEquals(2, $count); @@ -124,22 +124,22 @@ public function testCanSelectCheckbox() */ public function testNameBracketsStrippedWhenCreatingId() { - $html = $this->helper->formCheckbox(array( + $html = $this->helper->formCheckbox([ 'name' => 'foo[]', 'value' => 'bar' - )); + ]); $this->assertRegexp('/]*?(id="foo")/', $html); - $html = $this->helper->formCheckbox(array( + $html = $this->helper->formCheckbox([ 'name' => 'foo[bar]', 'value' => 'bar' - )); + ]); $this->assertRegexp('/]*?(id="foo-bar")/', $html); - $html = $this->helper->formCheckbox(array( + $html = $this->helper->formCheckbox([ 'name' => 'foo[bar][baz]', 'value' => 'bar' - )); + ]); $this->assertRegexp('/]*?(id="foo-bar-baz")/', $html); } @@ -148,10 +148,10 @@ public function testNameBracketsStrippedWhenCreatingId() */ public function testDoesNotRenderHiddenElementsForCheckboxArray() { - $html = $this->helper->formCheckbox(array( + $html = $this->helper->formCheckbox([ 'name' => 'foo[]', 'value' => 'bar' - )); + ]); $this->assertNotRegexp('/]*?(type="hidden")/', $html); } @@ -163,40 +163,40 @@ public function testShouldRenderHiddenElementShowingUncheckedOptionForNonArrayNa $html1 = $this->helper->formCheckbox( 'foo', 'bar', - array('checked' => true), - array( + ['checked' => true], + [ 'checked' => 'bar', 'unChecked' => 'baz' - ) + ] ); $html2 = $this->helper->formCheckbox( 'foo', 'bar', - array('checked' => true), - array( + ['checked' => true], + [ 'bar', 'baz' - ) + ] ); $html3 = $this->helper->formCheckbox( 'foo', 'bar', - array('checked' => false), - array( + ['checked' => false], + [ 'checked' => 'bar', 'unChecked' => 'baz' - ) + ] ); $html4 = $this->helper->formCheckbox( 'foo', 'bar', - array('checked' => false), - array( + ['checked' => false], + [ 'bar', 'baz' - ) + ] ); - foreach (array('html1', 'html2', 'html3', 'html4') as $html) { + foreach (['html1', 'html2', 'html3', 'html4'] as $html) { if (!preg_match_all('/(]+>)/', $$html, $matches)) { $this->fail('Unexpected output generated by helper'); } @@ -217,7 +217,7 @@ public function testShouldRenderHiddenElementShowingUncheckedOptionForNonArrayNa */ public function testCheckedAttributeNotRenderedIfItEvaluatesToFalse() { - $test = $this->helper->formCheckbox('foo', 'value', array('checked' => false)); + $test = $this->helper->formCheckbox('foo', 'value', ['checked' => false]); $this->assertNotContains('checked', $test); } @@ -232,11 +232,11 @@ public function testCanSpecifyValue() */ public function testShouldCheckValueIfValueMatchesCheckedOption() { - $test = $this->helper->formCheckbox('foo', 'bar', array(), array('bar', 'baz')); + $test = $this->helper->formCheckbox('foo', 'bar', [], ['bar', 'baz']); $this->assertContains('value="bar"', $test); $this->assertContains('checked', $test); - $test = $this->helper->formCheckbox('foo', 'bar', array(), array('checked' => 'bar', 'unChecked' => 'baz')); + $test = $this->helper->formCheckbox('foo', 'bar', [], ['checked' => 'bar', 'unChecked' => 'baz']); $this->assertContains('value="bar"', $test); $this->assertContains('checked', $test); } @@ -246,7 +246,7 @@ public function testShouldCheckValueIfValueMatchesCheckedOption() */ public function testShouldOnlySetValueIfValueMatchesCheckedOption() { - $test = $this->helper->formCheckbox('foo', 'baz', array(), array('bar', 'baz')); + $test = $this->helper->formCheckbox('foo', 'baz', [], ['bar', 'baz']); $this->assertContains('value="bar"', $test); } @@ -255,7 +255,7 @@ public function testShouldOnlySetValueIfValueMatchesCheckedOption() */ public function testShouldNotCheckValueIfValueDoesNotMatchCheckedOption() { - $test = $this->helper->formCheckbox('foo', 'baz', array(), array('bar', 'baz')); + $test = $this->helper->formCheckbox('foo', 'baz', [], ['bar', 'baz']); $this->assertContains('value="bar"', $test); $this->assertNotContains('checked', $test); } @@ -278,28 +278,28 @@ public function testCanRendersAsXHtml() */ public function testShouldNotShowHiddenFieldIfDisableIsTrue() { - $test = $this->helper->formCheckbox('foo', 'bar', array('disable' => true)); + $test = $this->helper->formCheckbox('foo', 'bar', ['disable' => true]); $this->assertNotContains('type="hidden"', $test); } public function testIntValueIsChecked() { - $test = $this->helper->formCheckbox('foo', '1', array(), array('checked'=>1, 'unchecked'=>0)); + $test = $this->helper->formCheckbox('foo', '1', [], ['checked'=>1, 'unchecked'=>0]); $this->assertContains('checked="checked"', $test); - $test = $this->helper->formCheckbox('foo', '1', array(), array(1,0)); + $test = $this->helper->formCheckbox('foo', '1', [], [1,0]); $this->assertContains('checked="checked"', $test); - $test = $this->helper->formCheckbox('foo', 1, array(), array('checked'=>1, 'unchecked'=>0)); + $test = $this->helper->formCheckbox('foo', 1, [], ['checked'=>1, 'unchecked'=>0]); $this->assertContains('checked="checked"', $test); - $test = $this->helper->formCheckbox('foo', 1, array(), array(1,0)); + $test = $this->helper->formCheckbox('foo', 1, [], [1,0]); $this->assertContains('checked="checked"', $test); - $test = $this->helper->formCheckbox('foo', 0, array(), array('checked'=>1, 'unchecked'=>0)); + $test = $this->helper->formCheckbox('foo', 0, [], ['checked'=>1, 'unchecked'=>0]); $this->assertNotContains('checked="checked"', $test); - $test = $this->helper->formCheckbox('foo', 0, array(), array(1,0)); + $test = $this->helper->formCheckbox('foo', 0, [], [1,0]); $this->assertNotContains('checked="checked"', $test); } @@ -311,9 +311,9 @@ public function testRenderingWithoutHiddenElement() $html = $this->helper->formCheckbox( 'foo', 'bar', - array( + [ 'disableHidden' => true, - ) + ] ); $this->assertSame( '', @@ -332,9 +332,9 @@ public function testRenderingWithoutHiddenElement() $html = $this->helper->formCheckbox( 'foo', 'bar', - array( + [ 'disableHidden' => false, - ) + ] ); $this->assertSame( diff --git a/tests/Zend/View/Helper/FormErrorsTest.php b/tests/Zend/View/Helper/FormErrorsTest.php index 1ec64f26fb..94a0c8b912 100644 --- a/tests/Zend/View/Helper/FormErrorsTest.php +++ b/tests/Zend/View/Helper/FormErrorsTest.php @@ -116,7 +116,7 @@ public function testCanSetElementStartString() public function testFormErrorsRendersUnorderedListByDefault() { - $errors = array('foo', 'bar', 'baz'); + $errors = ['foo', 'bar', 'baz']; $html = $this->helper->formErrors($errors); $this->assertContains('helper->setElementStart('
') ->setElementSeparator('
') ->setElementEnd('
'); - $errors = array('foo', 'bar', 'baz'); + $errors = ['foo', 'bar', 'baz']; $html = $this->helper->formErrors($errors); $this->assertContains('
', $html); foreach ($errors as $error) { @@ -141,9 +141,9 @@ public function testFormErrorsRendersWithSpecifiedStrings() public function testFormErrorsPreventsXssAttacks() { - $errors = array( + $errors = [ 'bad' => '\">', - ); + ]; $html = $this->helper->formErrors($errors); $this->assertNotContains($errors['bad'], $html); $this->assertContains('&', $html); @@ -151,11 +151,11 @@ public function testFormErrorsPreventsXssAttacks() public function testCanDisableEscapingErrorMessages() { - $errors = array( + $errors = [ 'foo' => 'Field is required', 'bar' => 'Please click here for more information' - ); - $html = $this->helper->formErrors($errors, array('escape' => false)); + ]; + $html = $this->helper->formErrors($errors, ['escape' => false]); $this->assertContains($errors['foo'], $html); $this->assertContains($errors['bar'], $html); } @@ -166,8 +166,8 @@ public function testCanDisableEscapingErrorMessages() */ public function testCanSetClassAttribute() { - $options = array('class' => 'custom-class'); - $actualHtml = $this->helper->formErrors(array(), $options); + $options = ['class' => 'custom-class']; + $actualHtml = $this->helper->formErrors([], $options); $this->assertEquals( '
', $actualHtml @@ -180,12 +180,12 @@ public function testCanSetClassAttribute() public function testCanSetElementStringsPerOptions() { $actual = $this->helper->formErrors( - array('foo', 'bar', 'baz'), - array( + ['foo', 'bar', 'baz'], + [ 'elementStart' => '

', 'elementEnd' => '

', 'elementSeparator' => '
', - ) + ] ); $this->assertEquals('

foo
bar
baz

', $actual); diff --git a/tests/Zend/View/Helper/FormFileTest.php b/tests/Zend/View/Helper/FormFileTest.php index d937656f30..875347bbe3 100644 --- a/tests/Zend/View/Helper/FormFileTest.php +++ b/tests/Zend/View/Helper/FormFileTest.php @@ -88,10 +88,10 @@ protected function setUp() */ public function testCanDisableElement() { - $html = $this->helper->formFile(array( + $html = $this->helper->formFile([ 'name' => 'foo', - 'attribs' => array('disable' => true) - )); + 'attribs' => ['disable' => true] + ]); $this->assertRegexp('/]*?(disabled="disabled")/', $html); } @@ -101,10 +101,10 @@ public function testCanDisableElement() */ public function testDisablingElementDoesNotRenderHiddenElements() { - $html = $this->helper->formFile(array( + $html = $this->helper->formFile([ 'name' => 'foo', - 'attribs' => array('disable' => true) - )); + 'attribs' => ['disable' => true] + ]); $this->assertNotRegexp('/]*?(type="hidden")/', $html); } @@ -112,18 +112,18 @@ public function testDisablingElementDoesNotRenderHiddenElements() public function testRendersAsHtmlByDefault() { - $test = $this->helper->formFile(array( + $test = $this->helper->formFile([ 'name' => 'foo', - )); + ]); $this->assertNotContains(' />', $test); } public function testCanRendersAsXHtml() { $this->view->doctype('XHTML1_STRICT'); - $test = $this->helper->formFile(array( + $test = $this->helper->formFile([ 'name' => 'foo', - )); + ]); $this->assertContains(' />', $test); } @@ -134,10 +134,10 @@ public function testRendersCustomAttributes() { $test = $this->helper->formFile( 'foo', - array( + [ 'data-image-old' => 100, 'data-image-new' => 200, - ) + ] ); $this->assertEquals( '', diff --git a/tests/Zend/View/Helper/FormImageTest.php b/tests/Zend/View/Helper/FormImageTest.php index ea9c503b6e..320819fd04 100644 --- a/tests/Zend/View/Helper/FormImageTest.php +++ b/tests/Zend/View/Helper/FormImageTest.php @@ -88,7 +88,7 @@ public function testFormImageRendersFormImageXhtml() public function testDisablingFormImageRendersImageInputWithDisableAttribute() { - $button = $this->helper->formImage('foo', 'bar', array('disable' => true)); + $button = $this->helper->formImage('foo', 'bar', ['disable' => true]); $this->assertRegexp('/]*?disabled="disabled"/', $button); $this->assertRegexp('/]*?src="bar"/', $button); $this->assertRegexp('/]*?name="foo"/', $button); @@ -100,9 +100,9 @@ public function testDisablingFormImageRendersImageInputWithDisableAttribute() */ public function testRendersAsHtmlByDefault() { - $test = $this->helper->formImage(array( + $test = $this->helper->formImage([ 'name' => 'foo', - )); + ]); $this->assertNotContains(' />', $test); } @@ -112,9 +112,9 @@ public function testRendersAsHtmlByDefault() public function testCanRendersAsXHtml() { $this->view->doctype('XHTML1_STRICT'); - $test = $this->helper->formImage(array( + $test = $this->helper->formImage([ 'name' => 'foo', - )); + ]); $this->assertContains(' />', $test); } } diff --git a/tests/Zend/View/Helper/FormLabelTest.php b/tests/Zend/View/Helper/FormLabelTest.php index cba07313be..e5057a5618 100644 --- a/tests/Zend/View/Helper/FormLabelTest.php +++ b/tests/Zend/View/Helper/FormLabelTest.php @@ -100,13 +100,13 @@ public function testViewIsSetAndSameAsCallingViewObject() public function testAttribsAreSet() { - $label = $this->helper->formLabel('foo', 'bar', array('class' => 'baz')); + $label = $this->helper->formLabel('foo', 'bar', ['class' => 'baz']); $this->assertEquals('', $label); } public function testNameAndIdForZF2154() { - $label = $this->helper->formLabel('name', 'value', array('id' => 'id')); + $label = $this->helper->formLabel('name', 'value', ['id' => 'id']); $this->assertEquals('', $label); } @@ -115,11 +115,11 @@ public function testNameAndIdForZF2154() */ public function testCanDisableEscapingLabelValue() { - $label = $this->helper->formLabel('foo', 'Label This!', array('escape' => false)); + $label = $this->helper->formLabel('foo', 'Label This!', ['escape' => false]); $this->assertContains('Label This!', $label); - $label = $this->helper->formLabel(array('name' => 'foo', 'value' => 'Label This!', 'escape' => false)); + $label = $this->helper->formLabel(['name' => 'foo', 'value' => 'Label This!', 'escape' => false]); $this->assertContains('Label This!', $label); - $label = $this->helper->formLabel(array('name' => 'foo', 'value' => 'Label This!', 'attribs' => array('escape' => false))); + $label = $this->helper->formLabel(['name' => 'foo', 'value' => 'Label This!', 'attribs' => ['escape' => false]]); $this->assertContains('Label This!', $label); } @@ -128,7 +128,7 @@ public function testCanDisableEscapingLabelValue() */ public function testHelperShouldAllowSuppressionOfForAttribute() { - $label = $this->helper->formLabel('foo', 'bar', array('disableFor' => true)); + $label = $this->helper->formLabel('foo', 'bar', ['disableFor' => true]); $this->assertNotContains('for="foo"', $label); } @@ -137,7 +137,7 @@ public function testHelperShouldAllowSuppressionOfForAttribute() */ public function testShouldNotRenderDisableForAttributeIfForIsSuppressed() { - $label = $this->helper->formLabel('foo', 'bar', array('disableFor' => true)); + $label = $this->helper->formLabel('foo', 'bar', ['disableFor' => true]); $this->assertNotContains('disableFor=', $label, 'Output contains disableFor attribute!'); } } diff --git a/tests/Zend/View/Helper/FormMultiCheckboxTest.php b/tests/Zend/View/Helper/FormMultiCheckboxTest.php index 68631a6480..656599a366 100644 --- a/tests/Zend/View/Helper/FormMultiCheckboxTest.php +++ b/tests/Zend/View/Helper/FormMultiCheckboxTest.php @@ -84,16 +84,16 @@ public function tearDown() public function testMultiCheckboxHelperRendersLabelledCheckboxesForEachOption() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formMultiCheckbox(array( + ]; + $html = $this->helper->formMultiCheckbox([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - )); + ]); foreach ($options as $key => $value) { $pattern = '#((]*>.*?)(]*?("' . $key . '").*?>)(.*?))#'; if (!preg_match($pattern, $html, $matches)) { @@ -108,16 +108,16 @@ public function testMultiCheckboxHelperRendersLabelledCheckboxesForEachOption() public function testRendersAsHtmlByDefault() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formMultiCheckbox(array( + ]; + $html = $this->helper->formMultiCheckbox([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - )); + ]); foreach ($options as $key => $value) { $pattern = '#(]*?("' . $key . '").*?>)#'; if (!preg_match($pattern, $html, $matches)) { @@ -130,16 +130,16 @@ public function testRendersAsHtmlByDefault() public function testCanRendersAsXHtml() { $this->view->doctype('XHTML1_STRICT'); - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formMultiCheckbox(array( + ]; + $html = $this->helper->formMultiCheckbox([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - )); + ]); foreach ($options as $key => $value) { $pattern = '#(]*?("' . $key . '").*?>)#'; if (!preg_match($pattern, $html, $matches)) { diff --git a/tests/Zend/View/Helper/FormPasswordTest.php b/tests/Zend/View/Helper/FormPasswordTest.php index 1197087d4f..3b237e86d4 100644 --- a/tests/Zend/View/Helper/FormPasswordTest.php +++ b/tests/Zend/View/Helper/FormPasswordTest.php @@ -78,11 +78,11 @@ protected function setUp() */ public function testCanDisableElement() { - $html = $this->helper->formPassword(array( + $html = $this->helper->formPassword([ 'name' => 'foo', 'value' => 'bar', - 'attribs' => array('disable' => true) - )); + 'attribs' => ['disable' => true] + ]); $this->assertRegexp('/]*?(disabled="disabled")/', $html); } @@ -92,11 +92,11 @@ public function testCanDisableElement() */ public function testDisablingElementDoesNotRenderHiddenElements() { - $html = $this->helper->formPassword(array( + $html = $this->helper->formPassword([ 'name' => 'foo', 'value' => 'bar', - 'attribs' => array('disable' => true) - )); + 'attribs' => ['disable' => true] + ]); $this->assertNotRegexp('/]*?(type="hidden")/', $html); } @@ -125,7 +125,7 @@ public function testShouldNotRenderValueByDefault() */ public function testShouldRenderValueWhenRenderPasswordFlagPresentAndTrue() { - $test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => true)); + $test = $this->helper->formPassword('foo', 'bar', ['renderPassword' => true]); $this->assertContains('value="bar"', $test); } @@ -134,9 +134,9 @@ public function testShouldRenderValueWhenRenderPasswordFlagPresentAndTrue() */ public function testRenderPasswordAttribShouldNeverBeRendered() { - $test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => true)); + $test = $this->helper->formPassword('foo', 'bar', ['renderPassword' => true]); $this->assertNotContains('renderPassword', $test); - $test = $this->helper->formPassword('foo', 'bar', array('renderPassword' => false)); + $test = $this->helper->formPassword('foo', 'bar', ['renderPassword' => false]); $this->assertNotContains('renderPassword', $test); } } diff --git a/tests/Zend/View/Helper/FormRadioTest.php b/tests/Zend/View/Helper/FormRadioTest.php index 9ce69f7ee7..f44e65be73 100644 --- a/tests/Zend/View/Helper/FormRadioTest.php +++ b/tests/Zend/View/Helper/FormRadioTest.php @@ -66,16 +66,16 @@ public function setUp() public function testRendersRadioLabelsWhenRenderingMultipleOptions() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - )); + ]); foreach ($options as $key => $value) { $this->assertRegexp('#.*?' . $value . '.*?#', $html, $html); $this->assertRegexp('#.*?#', $html, $html); @@ -84,27 +84,27 @@ public function testRendersRadioLabelsWhenRenderingMultipleOptions() public function testCanSpecifyRadioLabelPlacement() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - 'attribs' => array('labelPlacement' => 'append') - )); + 'attribs' => ['labelPlacement' => 'append'] + ]); foreach ($options as $key => $value) { $this->assertRegexp('#.*?#', $html, $html); } - $html = $this->helper->formRadio(array( + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - 'attribs' => array('labelPlacement' => 'prepend') - )); + 'attribs' => ['labelPlacement' => 'prepend'] + ]); foreach ($options as $key => $value) { $this->assertRegexp('#' . $value . '#', $html, $html); } @@ -115,33 +115,33 @@ public function testCanSpecifyRadioLabelPlacement() */ public function testSpecifyingLabelPlacementShouldNotOverwriteValue() { - $options = array( + $options = [ 'bar' => 'Bar', - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - 'attribs' => array( + 'attribs' => [ 'labelPlacement' => 'append', - ) - )); + ] + ]); $this->assertRegexp('#]*(checked="checked")#', $html, $html); } public function testCanSpecifyRadioLabelAttribs() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - 'attribs' => array('labelClass' => 'testclass', 'label_id' => 'testid') - )); + 'attribs' => ['labelClass' => 'testclass', 'label_id' => 'testid'] + ]); foreach ($options as $key => $value) { $this->assertRegexp('#]*?class="testclass"[^>]*>.*?' . $value . '#', $html, $html); @@ -151,17 +151,17 @@ public function testCanSpecifyRadioLabelAttribs() public function testCanSpecifyRadioSeparator() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, 'listsep' => '--FunkySep--', - )); + ]); $this->assertContains('--FunkySep--', $html); $count = substr_count($html, '--FunkySep--'); @@ -173,17 +173,17 @@ public function testCanSpecifyRadioSeparator() */ public function testCanDisableAllRadios() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - 'attribs' => array('disable' => true) - )); + 'attribs' => ['disable' => true] + ]); $this->assertRegexp('/]*?(disabled="disabled")/', $html, $html); $count = substr_count($html, 'disabled="disabled"'); @@ -195,17 +195,17 @@ public function testCanDisableAllRadios() */ public function testCanDisableIndividualRadios() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - 'attribs' => array('disable' => array('bar')) - )); + 'attribs' => ['disable' => ['bar']] + ]); $this->assertRegexp('/]*?(value="bar")[^>]*(disabled="disabled")/', $html, $html); $count = substr_count($html, 'disabled="disabled"'); @@ -217,19 +217,19 @@ public function testCanDisableIndividualRadios() */ public function testCanDisableMultipleRadios() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - 'attribs' => array('disable' => array('foo', 'baz')) - )); + 'attribs' => ['disable' => ['foo', 'baz']] + ]); - foreach (array('foo', 'baz') as $test) { + foreach (['foo', 'baz'] as $test) { $this->assertRegexp('/]*?(value="' . $test . '")[^>]*?(disabled="disabled")/', $html, $html); } $this->assertNotRegexp('/]*?(value="bar")[^>]*?(disabled="disabled")/', $html, $html); @@ -239,13 +239,13 @@ public function testCanDisableMultipleRadios() public function testLabelsAreEscapedByDefault() { - $options = array( + $options = [ 'bar' => 'Bar', - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'options' => $options, - )); + ]); $this->assertNotContains($options['bar'], $html); $this->assertContains('<b>Bar</b>', $html); @@ -253,14 +253,14 @@ public function testLabelsAreEscapedByDefault() public function testXhtmlLabelsAreAllowed() { - $options = array( + $options = [ 'bar' => 'Bar', - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'options' => $options, - 'attribs' => array('escape' => false) - )); + 'attribs' => ['escape' => false] + ]); $this->assertContains($options['bar'], $html); } @@ -270,31 +270,31 @@ public function testXhtmlLabelsAreAllowed() */ public function testDoesNotRenderHiddenElements() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'options' => $options, - )); + ]); $this->assertNotRegexp('/]*?(type="hidden")/', $html); } public function testSpecifyingAValueThatMatchesAnOptionChecksIt() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - )); + ]); if (!preg_match('/(]*?(value="bar")[^>]*>)/', $html, $matches)) { $this->fail('Radio for a given option was not found?'); @@ -304,18 +304,18 @@ public function testSpecifyingAValueThatMatchesAnOptionChecksIt() public function testOptionsWithMatchesInAnArrayOfValuesAreChecked() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', - 'value' => array('foo', 'baz'), + 'value' => ['foo', 'baz'], 'options' => $options, - )); + ]); - foreach (array('foo', 'baz') as $value) { + foreach (['foo', 'baz'] as $value) { if (!preg_match('/(]*?(value="' . $value . '")[^>]*>)/', $html, $matches)) { $this->fail('Radio for a given option was not found?'); } @@ -325,16 +325,16 @@ public function testOptionsWithMatchesInAnArrayOfValuesAreChecked() public function testEachRadioShouldHaveIdCreatedByAppendingFilteredValue() { - $options = array( + $options = [ 'foo bar' => 'Foo', 'bar baz' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo[]', 'value' => 'bar', 'options' => $options, - )); + ]); require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); @@ -346,17 +346,17 @@ public function testEachRadioShouldHaveIdCreatedByAppendingFilteredValue() public function testEachRadioShouldUseAttributeIdWhenSpecified() { - $options = array( + $options = [ 'foo bar' => 'Foo', 'bar baz' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo[bar]', 'value' => 'bar', - 'attribs' => array('id' => 'foo-bar'), + 'attribs' => ['id' => 'foo-bar'], 'options' => $options, - )); + ]); require_once 'Zend/Filter/Alnum.php'; $filter = new Zend_Filter_Alnum(); @@ -371,16 +371,16 @@ public function testEachRadioShouldUseAttributeIdWhenSpecified() */ public function testRadioLabelDoesNotContainHardCodedStyle() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - )); + ]); $this->assertNotContains('style="white-space: nowrap;"', $html); } @@ -390,13 +390,13 @@ public function testRadioLabelDoesNotContainHardCodedStyle() public function testRadioLabelContainsNotForAttributeTag() { $actual = $this->helper->formRadio( - array( + [ 'name' => 'foo', - 'options' => array( + 'options' => [ 'bar' => 'Bar', 'baz' => 'Baz' - ), - ) + ], + ] ); $expected = '
' @@ -412,11 +412,11 @@ public function testRadioLabelContainsNotForAttributeTag() public function testDashesShouldNotBeFilteredFromId() { $name = "Foo"; - $options = array( + $options = [ -1 => 'Test -1', 0 => 'Test 0', 1 => 'Test 1' - ); + ]; $formRadio = new Zend_View_Helper_FormRadio(); $formRadio->setView(new Zend_View()); @@ -435,15 +435,15 @@ public function testDashesShouldNotBeFilteredFromId() */ public function testRendersAsHtmlByDefault() { - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'options' => $options, - )); + ]); $this->assertContains('value="foo">', $html); $this->assertContains('value="bar">', $html); @@ -456,15 +456,15 @@ public function testRendersAsHtmlByDefault() public function testCanRendersAsXHtml() { $this->view->doctype('XHTML1_STRICT'); - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'options' => $options, - )); + ]); $this->assertContains('value="foo" />', $html); $this->assertContains('value="bar" />', $html); $this->assertContains('value="baz" />', $html); @@ -476,16 +476,16 @@ public function testCanRendersAsXHtml() public function testSeparatorCanRendersAsXhtmlByDefault() { $this->view->doctype('XHTML1_STRICT'); - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - )); + ]); $this->assertContains('
', $html); $count = substr_count($html, '
'); @@ -498,16 +498,16 @@ public function testSeparatorCanRendersAsXhtmlByDefault() public function testeparatorCanRendersAsHtml() { $this->view->doctype('HTML4_STRICT'); - $options = array( + $options = [ 'foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz' - ); - $html = $this->helper->formRadio(array( + ]; + $html = $this->helper->formRadio([ 'name' => 'foo', 'value' => 'bar', 'options' => $options, - )); + ]); $this->assertContains('
', $html); $count = substr_count($html, '
'); diff --git a/tests/Zend/View/Helper/FormResetTest.php b/tests/Zend/View/Helper/FormResetTest.php index ad2208612a..84d6f36a1b 100644 --- a/tests/Zend/View/Helper/FormResetTest.php +++ b/tests/Zend/View/Helper/FormResetTest.php @@ -83,10 +83,10 @@ public function tearDown() public function testShouldRenderResetInput() { - $html = $this->helper->formReset(array( + $html = $this->helper->formReset([ 'name' => 'foo', 'value' => 'Reset', - )); + ]); $this->assertRegexp('/]*?(type="reset")/', $html); } @@ -95,11 +95,11 @@ public function testShouldRenderResetInput() */ public function testShouldAllowDisabling() { - $html = $this->helper->formReset(array( + $html = $this->helper->formReset([ 'name' => 'foo', 'value' => 'Reset', - 'attribs' => array('disable' => true) - )); + 'attribs' => ['disable' => true] + ]); $this->assertRegexp('/]*?(disabled="disabled")/', $html); } diff --git a/tests/Zend/View/Helper/FormSelectTest.php b/tests/Zend/View/Helper/FormSelectTest.php index 7b32134321..7b9047506f 100644 --- a/tests/Zend/View/Helper/FormSelectTest.php +++ b/tests/Zend/View/Helper/FormSelectTest.php @@ -85,10 +85,10 @@ public function testRenderingWithOptions() 'foo', null, null, - array( + [ 'bar' => 'Bar', 'baz' => 'Baz', - ) + ] ); $expected = '', $html); $this->assertRegExp('#]+value="foo".*?>Foobar#', $html); @@ -122,20 +122,20 @@ public function testFormSelectWithOptionsCreatesPopulatedSelect() public function testFormSelectWithOptionsAndValueSelectsAppropriateValue() { - $html = $this->helper->formSelect('foo', 'baz', null, array('foo' => 'Foobar', 'baz' => 'Bazbat')); + $html = $this->helper->formSelect('foo', 'baz', null, ['foo' => 'Foobar', 'baz' => 'Bazbat']); $this->assertRegExp('#]+value="baz"[^>]*selected.*?>Bazbat#', $html); } public function testFormSelectWithMultipleAttributeCreatesMultiSelect() { - $html = $this->helper->formSelect('foo', null, array('multiple' => true), array('foo' => 'Foobar', 'baz' => 'Bazbat')); + $html = $this->helper->formSelect('foo', null, ['multiple' => true], ['foo' => 'Foobar', 'baz' => 'Bazbat']); $this->assertRegExp('#]+name="foo\[\]"#', $html); $this->assertRegExp('#]+multiple="multiple"#', $html); } public function testFormSelectWithMultipleAttributeAndValuesCreatesMultiSelectWithSelectedValues() { - $html = $this->helper->formSelect('foo', array('foo', 'baz'), array('multiple' => true), array('foo' => 'Foobar', 'baz' => 'Bazbat')); + $html = $this->helper->formSelect('foo', ['foo', 'baz'], ['multiple' => true], ['foo' => 'Foobar', 'baz' => 'Bazbat']); $this->assertRegExp('#]+value="foo"[^>]*selected.*?>Foobar#', $html); $this->assertRegExp('#]+value="baz"[^>]*selected.*?>Bazbat#', $html); } @@ -146,7 +146,7 @@ public function testFormSelectWithMultipleAttributeAndValuesCreatesMultiSelectWi */ public function testFormSelectWithZeroValueSelectsValue() { - $html = $this->helper->formSelect('foo', 0, null, array('foo' => 'Foobar', 0 => 'Bazbat')); + $html = $this->helper->formSelect('foo', 0, null, ['foo' => 'Foobar', 0 => 'Bazbat']); $this->assertRegExp('#]+value="0"[^>]*selected.*?>Bazbat#', $html); } @@ -155,16 +155,16 @@ public function testFormSelectWithZeroValueSelectsValue() */ public function testCanDisableEntireSelect() { - $html = $this->helper->formSelect(array( + $html = $this->helper->formSelect([ 'name' => 'baz', - 'options' => array( + 'options' => [ 'foo' => 'Foo', 'bar' => 'Bar' - ), - 'attribs' => array( + ], + 'attribs' => [ 'disable' => true - ), - )); + ], + ]); $this->assertRegexp('/]*?disabled/', $html, $html); $this->assertNotRegexp('/]*?disabled="disabled"/', $html, $html); } @@ -174,29 +174,29 @@ public function testCanDisableEntireSelect() */ public function testCanDisableIndividualSelectOptionsOnly() { - $html = $this->helper->formSelect(array( + $html = $this->helper->formSelect([ 'name' => 'baz', - 'options' => array( + 'options' => [ 'foo' => 'Foo', 'bar' => 'Bar' - ), - 'attribs' => array( - 'disable' => array('bar') - ), - )); + ], + 'attribs' => [ + 'disable' => ['bar'] + ], + ]); $this->assertNotRegexp('/]*?disabled/', $html, $html); $this->assertRegexp('/