Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/joomla/joomla-platform.git

Conflicts:
	tests/suites/legacy/request/JRequestGetMethodTest.php
  • Loading branch information...
commit 12bf28c954abbe8b4c7b6dcbb09b75897da52644 2 parents cb555dc + 65d3fa6
@kaviththiranga authored
Showing with 3,681 additions and 20,070 deletions.
  1. +3 −0  .gitmodules
  2. +24 −0 CONTRIBUTING.markdown
  3. +381 −0 bin/keychain.php
  4. +30 −11 build.xml
  5. +1 −0  build/.gitignore
  6. +91 −0 build/bootstrap.stub.php
  7. +10 −7 build/changelog.php
  8. +68 −0 build/import.stub.php
  9. +0 −24 build/phpcs/Joomla/Docs/Files/IncludingFileStandard.xml
  10. +0 −7 build/phpcs/Joomla/Docs/Files/LineLengthStandard.xml
  11. +0 −19 build/phpcs/Joomla/Docs/Functions/FunctionCallArgumentSpacingStandard.xml
  12. +0 −19 build/phpcs/Joomla/Docs/Functions/FunctionCallSignatureStandard.xml
  13. +0 −25 build/phpcs/Joomla/Docs/Functions/ValidDefaultValueStandard.xml
  14. +0 −23 build/phpcs/Joomla/Docs/NamingConventions/ValidClassNameStandard.xml
  15. +0 −23 build/phpcs/Joomla/Docs/NamingConventions/ValidFunctionNameStandard.xml
  16. +0 −106 build/phpcs/Joomla/Sniffs/Classes/InstantiateNewClassesSniff.php
  17. +0 −93 build/phpcs/Joomla/Sniffs/Classes/MemberVarScopeSniff.php
  18. +0 −87 build/phpcs/Joomla/Sniffs/Classes/MethodScopeSniff.php
  19. +0 −94 build/phpcs/Joomla/Sniffs/Classes/StaticThisUsageSniff.php
  20. +0 −299 build/phpcs/Joomla/Sniffs/Commenting/ClassCommentSniff.php
  21. +0 −793 build/phpcs/Joomla/Sniffs/Commenting/FileCommentSniff.php
  22. +0 −508 build/phpcs/Joomla/Sniffs/Commenting/FunctionCommentSniff.php
  23. +0 −147 build/phpcs/Joomla/Sniffs/Commenting/SingleCommentSniff.php
  24. +0 −106 build/phpcs/Joomla/Sniffs/ControlStructures/ControlSignatureSniff.php
  25. +0 −79 build/phpcs/Joomla/Sniffs/ControlStructures/ElseIfDeclarationSniff.php
  26. +0 −121 build/phpcs/Joomla/Sniffs/ControlStructures/InlineControlStructureSniff.php
  27. +0 −133 build/phpcs/Joomla/Sniffs/ControlStructures/MultiLineConditionSniff.php
  28. +0 −146 build/phpcs/Joomla/Sniffs/Files/IncludingFileSniff.php
  29. +0 −257 build/phpcs/Joomla/Sniffs/Functions/FunctionCallSignatureSniff.php
  30. +0 −228 build/phpcs/Joomla/Sniffs/Functions/FunctionDeclarationSniff.php
  31. +0 −318 build/phpcs/Joomla/Sniffs/NamingConventions/ValidFunctionNameSniff.php
  32. +0 −148 build/phpcs/Joomla/Sniffs/NamingConventions/ValidVariableNameSniff.php
  33. +0 −90 build/phpcs/Joomla/Sniffs/PHP/LowerCaseConstantSniff.php
  34. +0 −78 build/phpcs/Joomla/Sniffs/WhiteSpace/CastSpacingSniff.php
  35. +0 −99 build/phpcs/Joomla/Sniffs/WhiteSpace/ConcatenationSpacingSniff.php
  36. +0 −87 build/phpcs/Joomla/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php
  37. +0 −151 build/phpcs/Joomla/Sniffs/WhiteSpace/MemberVarSpacingSniff.php
  38. +0 −169 build/phpcs/Joomla/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php
  39. +0 −258 build/phpcs/Joomla/Sniffs/WhiteSpace/OperatorSpacingSniff.php
  40. +0 −145 build/phpcs/Joomla/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php
  41. +0 −82 build/phpcs/Joomla/Sniffs/WhiteSpace/SemicolonSpacingSniff.php
  42. +0 −86 build/phpcs/Joomla/Sniffs/WhiteSpace/SpaceAfterCastSniff.php
  43. +0 −258 build/phpcs/Joomla/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php
  44. +0 −33 build/phpcs/Joomla/notes.txt
  45. +0 −75 build/phpcs/Joomla/ruleset.xml
  46. +0 −233 build/phpcs/eclipse_pdt3_formatter.xml
  47. +0 −174 build/phpcs/zend_studio_formatter.xml
  48. +11 −0 composer.json
  49. +0 −13 docs/build.xml
  50. +0 −8 docs/coding-standards/en-US/Author_Group.xml
  51. +0 −28 docs/coding-standards/en-US/Book_Info.xml
  52. +0 −4 docs/coding-standards/en-US/Coding_Standards.ent
  53. +0 −14 docs/coding-standards/en-US/Coding_Standards.xml
  54. +0 −25 docs/coding-standards/en-US/Preface.xml
  55. +0 −26 docs/coding-standards/en-US/appendices/Revision_History.xml
  56. +0 −51 docs/coding-standards/en-US/chapters/basic-guidelines.xml
  57. +0 −108 docs/coding-standards/en-US/chapters/comments.xml
  58. +0 −809 docs/coding-standards/en-US/chapters/php.xml
  59. +0 −38 docs/coding-standards/en-US/chapters/source-code-management.xml
  60. +0 −19 docs/coding-standards/en-US/images/icon.svg
  61. +0 −9 docs/manual/en-US/Author_Group.xml
  62. +0 −28 docs/manual/en-US/Book_Info.xml
  63. +0 −4 docs/manual/en-US/Developer_Manual.ent
  64. +0 −16 docs/manual/en-US/Developer_Manual.xml
  65. +100 −0 docs/manual/en-US/appendices/analysis.md
  66. +0 −121 docs/manual/en-US/appendices/analysis.xml
  67. +36 −0 docs/manual/en-US/appendices/history.md
  68. +0 −34 docs/manual/en-US/appendices/history.xml
  69. +0 −70 docs/manual/en-US/chapters/classes/jcontrollerbase.xml
  70. +0 −162 docs/manual/en-US/chapters/classes/jhttp.xml
  71. +0 −21 docs/manual/en-US/chapters/classes/jhttpfactory.xml
  72. +0 −11 docs/manual/en-US/chapters/classes/jhttpresponse.xml
  73. +0 −11 docs/manual/en-US/chapters/classes/jhttptransportcurl.xml
  74. +0 −11 docs/manual/en-US/chapters/classes/jhttptransportsocket.xml
  75. +0 −11 docs/manual/en-US/chapters/classes/jhttptransportstream.xml
  76. +0 −158 docs/manual/en-US/chapters/classes/jinput.xml
  77. +0 −76 docs/manual/en-US/chapters/classes/jinputcli.xml
  78. +0 −11 docs/manual/en-US/chapters/classes/jinputcookie.xml
  79. +0 −11 docs/manual/en-US/chapters/classes/jinputfiles.xml
  80. +0 −92 docs/manual/en-US/chapters/classes/jloader.xml
  81. +0 −51 docs/manual/en-US/chapters/classes/jmodelbase.xml
  82. +0 −73 docs/manual/en-US/chapters/classes/jmodeldatabase.xml
  83. +0 −69 docs/manual/en-US/chapters/classes/jplatform.xml
  84. +0 −75 docs/manual/en-US/chapters/classes/jviewbase.xml
  85. +0 −93 docs/manual/en-US/chapters/classes/jviewhtml.xml
  86. +0 −13 docs/manual/en-US/chapters/interfaces/jcontroller.xml
  87. +0 −11 docs/manual/en-US/chapters/interfaces/jhttptransport.xml
  88. +0 −12 docs/manual/en-US/chapters/interfaces/jmodel.xml
  89. +0 −12 docs/manual/en-US/chapters/interfaces/jview.xml
  90. +361 −0 docs/manual/en-US/chapters/introduction.md
  91. +0 −128 docs/manual/en-US/chapters/introduction.xml
  92. +0 −24 docs/manual/en-US/chapters/packages.xml
  93. +46 −0 docs/manual/en-US/chapters/packages/crypt.md
  94. +180 −0 docs/manual/en-US/chapters/packages/data.md
  95. +72 −0 docs/manual/en-US/chapters/packages/database.md
  96. +0 −30 docs/manual/en-US/chapters/packages/database.xml
  97. +84 −0 docs/manual/en-US/chapters/packages/github.md
  98. +0 −91 docs/manual/en-US/chapters/packages/github.xml
  99. +79 −0 docs/manual/en-US/chapters/packages/google.md
  100. +182 −0 docs/manual/en-US/chapters/packages/http.md
  101. +0 −28 docs/manual/en-US/chapters/packages/http.xml
  102. +284 −0 docs/manual/en-US/chapters/packages/input.md
  103. +0 −26 docs/manual/en-US/chapters/packages/input.xml
  104. +186 −0 docs/manual/en-US/chapters/packages/keychain.md
  105. +307 −0 docs/manual/en-US/chapters/packages/log.md
  106. +0 −369 docs/manual/en-US/chapters/packages/log.xml
  107. +356 −0 docs/manual/en-US/chapters/packages/mvc.md
  108. +0 −57 docs/manual/en-US/chapters/packages/mvc.xml
  109. +21 −0 docs/manual/en-US/chapters/packages/object.md
  110. +47 −0 docs/manual/en-US/chapters/packages/profiler.md
  111. +0 −12 docs/manual/en-US/chapters/preface.xml
  112. +72 −0 docs/manual/en-US/chapters/testing.md
  113. +0 −83 docs/manual/en-US/chapters/testing.xml
  114. +23 −0 docs/manual/en-US/coding-standards/chapters/basic-guidelines.md
  115. +97 −0 docs/manual/en-US/coding-standards/chapters/comments.md
  116. +479 −0 docs/manual/en-US/coding-standards/chapters/php.md
  117. +17 −0 docs/manual/en-US/coding-standards/chapters/source-code-management.md
  118. +7 −0 docs/manual/en-US/coding-standards/preface.md
  119. +0 −19 docs/manual/en-US/images/icon.svg
  120. +26 −0 docs/manual/en-US/menu.md
  121. +0 −115 docs/xsl/VERSION
  122. +0 −1,229 docs/xsl/common/af.xml
  123. +0 −1,229 docs/xsl/common/am.xml
  124. +0 −1,229 docs/xsl/common/ar.xml
  125. +0 −660 docs/xsl/common/as.xml
  126. +0 −660 docs/xsl/common/ast.xml
  127. +0 −44 docs/xsl/common/autoidx-kimber.xsl
  128. +0 −154 docs/xsl/common/autoidx-kosek.xsl
  129. +0 −672 docs/xsl/common/az.xml
  130. +0 −724 docs/xsl/common/bg.xml
  131. +0 −1,229 docs/xsl/common/bn.xml
  132. +0 −660 docs/xsl/common/bn_in.xml
  133. +0 −662 docs/xsl/common/bs.xml
  134. +0 −660 docs/xsl/common/ca.xml
  135. +0 −185 docs/xsl/common/charmap.xml
  136. +0 −221 docs/xsl/common/charmap.xsl
  137. +0 −622 docs/xsl/common/common.xml
Sorry, we could not display the entire diff because too many files (1,132) changed.
View
3  .gitmodules
@@ -0,0 +1,3 @@
+[submodule "build/phpcs/Joomla"]
+ path = build/phpcs/Joomla
+ url = https://github.com/joomla/coding-standards.git
View
24 CONTRIBUTING.markdown
@@ -0,0 +1,24 @@
+Contributing to the Joomla! Platform
+===============
+All contributions are welcome to be submitted for review for inclusion in the Joomla! Platform, but before they will be accepted, we ask that you follow these simple steps:
+
+1) Submitted code must follow the Joomla! Code Standards
+* Please use the resources at http://docs.joomla.org/Coding_style_and_standards for more information about the code standards.
+
+2) Submitted code must not cause existing unit tests to fail
+* If a change in a method causes a change in the expected behavior, the unit test should also be updated to match the change.
+
+3) Unit tests are *highly* encouraged for all pull requests
+* The Joomla Platform uses PHPUnit for its unit testing. Please review the PHPUnit manual at http://www.phpunit.de/manual/current/en/index.html.
+* Whether your pull request is a bug fix or introduces new classes or methods to the Platform, we ask that you include unit tests for your changes
+* We understand that not all users submitting pull requests will be proficient with PHPUnit. The maintainers and community as a whole are a helpful group and can help you with writing tests.
+* Although bug fixes may be accepted without unit tests (so long as existing tests do not fail with your change), new classes will not be accepted without tests to validate its functionality.
+
+4) Documentation is *highly* encouraged
+* The Platform Manual is contained in the docs directory of this repo and is written in Markdown format.
+* When submitting new packages, documentation will be required with your pull request. Please use the existing documentation for examples.
+* We understand that not all code is documented at this time. Feel free to expand on the existing documentation by adding to existing chapters or submitting new chapters.
+
+Please be patient as not all items will be tested or reviewed immediately by a Platform maintainer. There is an automated pull request tester online at http://developer.joomla.org/pulls/ which runs the unit tests and checks the code style of every request; please use this resource to ensure your pull does not cause test failures and follows the coding standard.
+
+Lastly, please be receptive to feedback about your change. The maintainers and other community members may make suggestions or ask questions about your change. This is part of the review process, and helps everyone to understand what is happening, why it is happening, and potentially optimize your code.
View
381 bin/keychain.php
@@ -0,0 +1,381 @@
+#!/usr/bin/env php
+<?php
+/**
+ * @package Joomla.Platform
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+define('_JEXEC', 1);
+define('JPATH_BASE', dirname(__FILE__));
+
+// Load the Joomla! Platform
+require_once realpath('../libraries/import.php');
+
+/**
+ * Keychain Manager
+ *
+ * @package Joomla.Platform
+ * @since 12.3
+ */
+class KeychainManager extends JApplicationCli
+{
+ /**
+ * @var boolean A flag if the keychain has been updated to trigger saving the keychain
+ * @since 12.3
+ */
+ protected $updated = false;
+
+ /**
+ * @var JKeychain The keychain object being manipulated.
+ * @since 12.3
+ */
+ protected $keychain = null;
+
+ /**
+ * Execute the application
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ public function execute( )
+ {
+ if (!count($this->input->args))
+ {
+ // Check if they passed --help in otherwise display short usage summary
+ if ($this->input->get('help', false) === false)
+ {
+ $this->out("usage: {$this->input->executable} [options] [command] [<args>]");
+ exit(1);
+ }
+ else
+ {
+ $this->displayHelp();
+ exit(0);
+ }
+ }
+
+ // For all tasks but help and init we use the keychain
+ if (!in_array($this->input->args[0], array('help', 'init')))
+ {
+ $this->loadKeychain();
+ }
+
+ switch ($this->input->args[0])
+ {
+ case 'init':
+ $this->initPassphraseFile();
+ break;
+ case 'list':
+ $this->listEntries();
+ break;
+ case 'create':
+ $this->create();
+ break;
+ case 'change':
+ $this->change();
+ case 'delete':
+ $this->delete();
+ break;
+ case 'read':
+ $this->read();
+ break;
+ case 'help':
+ $this->displayHelp();
+ break;
+ default:
+ $this->out('Invalid command.');
+ break;
+ }
+
+ if ($this->updated)
+ {
+ $this->saveKeychain();
+ }
+ exit(0);
+ }
+
+ /**
+ * Load the keychain from a file.
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function loadKeychain()
+ {
+ $keychain = $this->input->get('keychain', '', 'raw');
+ $publicKeyFile = $this->input->get('public-key', '', 'raw');
+ $passphraseFile = $this->input->get('passphrase', '', 'raw');
+
+ $this->keychain = new JKeychain;
+
+ if (file_exists($keychain))
+ {
+ if (file_exists($publicKeyFile))
+ {
+ $this->keychain->loadKeychain($keychain, $passphraseFile, $publicKeyFile);
+ }
+ else
+ {
+ $this->out('Public key not specified or missing!');
+ exit(1);
+ }
+ }
+ }
+
+ /**
+ * Save this keychain to a file.
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function saveKeychain()
+ {
+ $keychain = $this->input->get('keychain', '', 'raw');
+ $publicKeyFile = $this->input->get('public-key', '', 'raw');
+ $passphraseFile = $this->input->get('passphrase', '', 'raw');
+
+ if (!file_exists($publicKeyFile))
+ {
+ $this->out("Public key file specified doesn't exist: $publicKeyFile");
+ exit(1);
+ }
+
+ $this->keychain->saveKeychain($keychain, $passphraseFile, $publicKeyFile);
+ }
+
+ /**
+ * Initialise a new passphrase file.
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function initPassphraseFile()
+ {
+ $keychain = new JKeychain;
+
+ $passphraseFile = $this->input->get('passphrase', '', 'raw');
+ $privateKeyFile = $this->input->get('private-key', '', 'raw');
+
+ if (!strlen($passphraseFile))
+ {
+ $this->out('A passphrase file must be specified with --passphrase');
+ exit(1);
+ }
+
+ if (!file_exists($privateKeyFile))
+ {
+ $this->out("protected key file specified doesn't exist: $privateKeyFile");
+ exit(1);
+ }
+
+ $this->out('Please enter the new passphrase:');
+ $passphrase = $this->in();
+
+ $this->out('Please enter the passphrase for the protected key:');
+ $privateKeyPassphrase = $this->in();
+
+ $keychain->createPassphraseFile($passphrase, $passphraseFile, $privateKeyFile, $privateKeyPassphrase);
+ }
+
+ /**
+ * Create a new entry
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function create()
+ {
+ if (count($this->input->args) != 3)
+ {
+ $this->out("usage: {$this->input->executable} [options] create entry_name entry_value");
+ exit(1);
+ }
+
+ if ($this->keychain->exists($this->input->args[1]))
+ {
+ $this->out('error: entry already exists. To change this entry, use "change"');
+ exit(1);
+ }
+ $this->change();
+ }
+
+ /**
+ * Change an existing entry to a new value or create an entry if missing.
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function change()
+ {
+ if (count($this->input->args) != 3)
+ {
+ $this->out("usage: {$this->input->executable} [options] change entry_name entry_value");
+ exit(1);
+ }
+ $this->updated = true;
+ $this->keychain->setValue($this->input->args[1], $this->input->args[2]);
+ }
+
+ /**
+ * Read an entry from the keychain
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function read()
+ {
+ if (count($this->input->args) != 2)
+ {
+ $this->out("usage: {$this->input->executable} [options] read entry_name");
+ exit(1);
+ }
+
+ $key = $this->input->args[1];
+ $this->out($key . ': ' . $this->dumpVar($this->keychain->get($key)));
+ }
+
+ /**
+ * Get the string from var_dump
+ *
+ * @param mixed $var The variable you want to have dumped.
+ *
+ * @return string The result of var_dump
+ *
+ * @since 12.3
+ */
+ private function dumpVar($var)
+ {
+ ob_start();
+ var_dump($var);
+ $result = trim(ob_get_contents());
+ ob_end_clean();
+ return $result;
+ }
+
+ /**
+ * Delete an entry from the keychain
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function delete()
+ {
+ if (count($this->input->args) != 2)
+ {
+ $this->out("usage: {$this->input->executable} [options] delete entry_name");
+ exit(1);
+ }
+
+ $this->updated = true;
+ $this->keychain->deleteValue($this->input->args[1], null);
+ }
+
+ /**
+ * List entries in the keychain
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function listEntries()
+ {
+ foreach ($this->keychain->toArray() as $key => $value)
+ {
+ $line = $key;
+ if ($this->input->get('print-values'))
+ {
+ $line .= ': ' . $this->dumpVar($value);
+ }
+ $this->out($line);
+ }
+ }
+
+ /**
+ * Display the help information
+ *
+ * @return void
+ *
+ * @since 12.3
+ */
+ protected function displayHelp()
+ {
+/*
+COMMANDS
+
+ - list
+ - create entry_name entry_value
+ - change entry_name entry_value
+ - delete entry_name
+ - read entry_name
+*/
+
+ $help = <<<HELP
+Keychain Management Utility
+
+usage: {$this->input->executable} [--keychain=/path/to/keychain]
+ [--passphrase=/path/to/passphrase.dat] [--public-key=/path/to/public.pem]
+ [command] [<args>]
+
+OPTIONS
+
+ --keychain=/path/to/keychain
+ Path to a keychain file to manipulate.
+
+ --passphrase=/path/to/passphrase.dat
+ Path to a passphrase file containing the encryption/decryption key.
+
+ --public-key=/path/to/public.pem
+ Path to a public key file to decrypt the passphrase file.
+
+
+COMMANDS
+
+ list:
+ Usage: list [--print-values]
+ Lists all entries in the keychain. Optionally pass --print-values to print the values as well.
+
+ create:
+ Usage: create entry_name entry_value
+ Creates a new entry in the keychain called "entry_name" with the plaintext value "entry_value".
+ NOTE: This is an alias for change.
+
+ change:
+ Usage: change entry_name entry_value
+ Updates the keychain entry called "entry_name" with the value "entry_value".
+
+ delete:
+ Usage: delete entry_name
+ Removes an entry called "entry_name" from the keychain.
+
+ read:
+ Usage: read entry_name
+ Outputs the plaintext value of "entry_name" from the keychain.
+
+ init:
+ Usage: init
+ Creates a new passphrase file and prompts for a new passphrase.
+
+HELP;
+ $this->out($help);
+ }
+}
+
+try
+{
+ JApplicationCli::getInstance('KeychainManager')->execute();
+}
+catch (Exception $e)
+{
+ echo $e->getMessage() . "\n";
+ exit(1);
+}
View
41 build.xml
@@ -2,7 +2,15 @@
<project name="joomla-platform" default="build" basedir=".">
<property name="source" value="libraries" />
- <property name="joomlasource" value="libraries/joomla,libraries/platform.php,libraries/loader.php,libraries/import.php" />
+ <property name="joomlasource" value="libraries/joomla,libraries/legacy,libraries/compat,libraries/platform.php,libraries/loader.php,libraries/import.php" />
+
+ <condition property="script-suffix" value=".bat" else="">
+ <os family="windows" />
+ </condition>
+
+ <condition property="script-null" value="NUL" else="/dev/null">
+ <os family="windows" />
+ </condition>
<target name="clean" description="Clean up and create artifact directories">
<delete dir="${basedir}/build/api" />
@@ -19,11 +27,11 @@
</target>
<target name="phpunit" description="Run unit tests using PHPUnit and generates junit.xml and clover.xml">
- <exec executable="phpunit" />
+ <exec executable="phpunit${script-suffix}" />
</target>
<target name="phpunit-legacy" description="Run legacy tests using PHPUnit and generates junit.legacy.xml and clover.legacy.xml">
- <exec executable="phpunit">
+ <exec executable="phpunit${script-suffix}">
<arg value="-c" />
<arg value="legacy.xml.dist" />
</exec>
@@ -43,7 +51,7 @@
</target>
<target name="pdepend" description="Generate jdepend.xml and software metrics charts using PHP_Depend">
- <exec executable="pdepend">
+ <exec executable="pdepend${script-suffix}">
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
@@ -52,7 +60,7 @@
</target>
<target name="phpmd" description="Generate pmd.xml using PHPMD">
- <exec executable="phpmd">
+ <exec executable="phpmd${script-suffix}">
<arg path="${joomlasource}" />
<arg value="xml" />
<arg value="${basedir}/build/phpmd.xml" />
@@ -62,7 +70,7 @@
</target>
<target name="phpcpd" description="Generate pmd-cpd.xml using PHPCPD">
- <exec executable="phpcpd">
+ <exec executable="phpcpd${script-suffix}">
<arg value="--log-pmd" />
<arg value="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${source}/joomla" />
@@ -70,7 +78,7 @@
</target>
<target name="phploc" description="Generate phploc.csv">
- <exec executable="phploc">
+ <exec executable="phploc${script-suffix}">
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
<arg path="${source}/joomla" />
@@ -78,17 +86,17 @@
</target>
<target name="phpcs" description="Generate checkstyle.xml using PHP_CodeSniffer">
- <exec executable="phpcs">
+ <exec executable="phpcs${script-suffix}">
<arg value="--report=checkstyle" />
+ <arg value="--extensions=php,css" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=${basedir}/build/phpcs/Joomla" />
- <arg value="--ignore=${source}/phpmailer,${source}/phputf8,${source}/simplepie/,${source}/config.example.php" />
<arg path="${source}" />
</exec>
</target>
<target name="phpdoc" description="Generate API documentation using PHPDocumentor">
- <exec executable="phpdox">
+ <exec executable="phpdox${script-suffix}">
<arg value="-c" />
<arg path="${source}" />
<arg value="-d" />
@@ -101,7 +109,7 @@
</target>
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
- <exec executable="phpcb">
+ <exec executable="phpcb${script-suffix}">
<arg value="--log" />
<arg path="${basedir}/build/logs" />
<arg value="--source" />
@@ -111,5 +119,16 @@
</exec>
</target>
+ <target name="lint" description="Perform syntax check of sourcecode files">
+ <apply executable="php" failonerror="true">
+ <arg value="-l" />
+
+ <fileset dir="${source}">
+ <include name="**/*.php" />
+ <modified />
+ </fileset>
+ </apply>
+ </target>
+
<target name="build" depends="clean,phpunit,phpunit-legacy,parallelTasks,phpcb" />
</project>
View
1  build/.gitignore
@@ -1,4 +1,5 @@
/coverage
+/coverage-legacy
/logs
/pdepend
/code-browser
View
91 build/bootstrap.stub.php
@@ -0,0 +1,91 @@
+<?php
+/**
+ * Unit test runner bootstrap file for the Joomla Platform. This file becomes the PHAR stub
+ * when the platform and unit test classes are built into a single deployable archive to be
+ * used in testing Joomla applications.
+ *
+ * @package Joomla.UnitTest
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ * @link http://www.phpunit.de/manual/current/en/installation.html
+ */
+
+// Setup the Pharsanity!
+Phar::interceptFileFuncs();
+
+// Fix magic quotes.
+@ini_set('magic_quotes_runtime', 0);
+
+// Maximise error reporting.
+error_reporting(E_ALL & ~E_STRICT);
+ini_set('display_errors', 1);
+
+/*
+ * Ensure that required path constants are defined. These can be overridden within the phpunit.xml file
+ * if you chose to create a custom version of that file.
+ */
+if (!defined('JPATH_TESTS'))
+{
+ define('JPATH_TESTS', __DIR__);
+}
+if (!defined('JPATH_PLATFORM'))
+{
+ define('JPATH_PLATFORM', 'phar://' . __FILE__ . '/lib');
+}
+if (!defined('JPATH_BASE'))
+{
+ define('JPATH_BASE', JPATH_TESTS . '/tmp');
+}
+if (!defined('JPATH_ROOT'))
+{
+ define('JPATH_ROOT', JPATH_BASE);
+}
+if (!defined('JPATH_CACHE'))
+{
+ define('JPATH_CACHE', JPATH_BASE . '/cache');
+}
+if (!defined('JPATH_CONFIGURATION'))
+{
+ define('JPATH_CONFIGURATION', JPATH_BASE);
+}
+if (!defined('JPATH_MANIFESTS'))
+{
+ define('JPATH_MANIFESTS', JPATH_BASE . '/manifests');
+}
+if (!defined('JPATH_PLUGINS'))
+{
+ define('JPATH_PLUGINS', JPATH_BASE . '/plugins');
+}
+if (!defined('JPATH_THEMES'))
+{
+ define('JPATH_THEMES', JPATH_BASE . '/themes');
+}
+
+// Import the platform.
+require_once JPATH_PLATFORM . '/import.php';
+
+// Register the core Joomla test classes.
+JLoader::registerPrefix('Test', 'phar://' . __FILE__ . '/core');
+
+/*
+ * The following classes still depend on `JVersion` so we must load it until they are dealt with.
+ *
+ * JInstallerHelper
+ * JUpdaterCollection
+ * JUpdaterExtension
+ * JUpdate
+ * JFactory
+ */
+require_once 'phar://' . __FILE__ . '/version.php';
+
+/*
+ * The PHP garbage collector can be too aggressive in closing circular references before they are no longer needed. This can cause
+ * segfaults during long, memory-intensive processes such as testing large test suites and collecting coverage data. We explicitly
+ * disable garbage collection during the execution of PHPUnit processes so that we (hopefully) don't run into these issues going
+ * forwards. This is only a problem PHP 5.3+.
+ */
+gc_disable();
+
+// End of the Phar Stub.
+__HALT_COMPILER();?>
View
17 build/changelog.php
@@ -10,14 +10,11 @@
*
* php -f run.php
*
- * @package Joomla.Examples
- * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
- * @license GNU General Public License version 2 or later; see LICENSE
+ * @package Joomla.Examples
+ * @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
*/
-// We are a valid Joomla entry point.
-define('_JEXEC', 1);
-
// Setup the path related constants.
define('JPATH_BASE', dirname(__FILE__));
@@ -311,6 +308,8 @@ protected function getIssues($page)
/**
* Get information about a specific pull request.
*
+ * @param integer $id The GitHub pull request number.
+ *
* @return object
*
* @since 12.1
@@ -348,6 +347,7 @@ protected function render(array $versions)
// Print out the labelled version of the changelog first.
$labelled = $this->getBuffer("$version.labelled");
+
if ($labelled)
{
foreach ($labelled as $label => $links)
@@ -368,6 +368,7 @@ protected function render(array $versions)
$log = $this->getBuffer("$version.log");
$html .= PHP_EOL . '<h2>The following pull requests made by community contributors were merged:</h2>';
$html .= PHP_EOL . '<ol>';
+
foreach ($log as $issue)
{
$html .= PHP_EOL . "<li>$issue</li>";
@@ -381,6 +382,7 @@ protected function render(array $versions)
$html .= PHP_EOL . sprintf('<h4>%d pull requests.</h4>', $pullCount);
$html .= PHP_EOL . '<ol>';
+
foreach ($userCount as $user => $count)
{
$html .= PHP_EOL . sprintf('<li><a href="https://github.com/%1$s">%1$s</a>: %2$d</li>', $user, $count);
@@ -393,6 +395,7 @@ protected function render(array $versions)
$html .= PHP_EOL . '<h4>Merged by:</h4>';
$html .= PHP_EOL . '<ol>';
+
foreach ($mergedBy as $user => $count)
{
$html .= PHP_EOL . sprintf('<li><a href="https://github.com/%1$s">%1$s</a>: %2$d</li>', $user, $count);
@@ -438,7 +441,7 @@ protected function setBuffer($name, $text, $append = true)
// Catch any exceptions thrown.
try
{
- JCli::getInstance('Changelog')->execute();
+ JApplicationCli::getInstance('Changelog')->execute();
}
catch (Exception $e)
{
View
68 build/import.stub.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Bootstrap file for the Joomla Platform. This file becomes the PHAR stub when the platform is built
+ * into a single deployable archive to be used in Joomla applications.
+ *
+ * @package Joomla.Platform
+ *
+ * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE
+ */
+
+// Setup the Pharsanity!
+Phar::interceptFileFuncs();
+
+// Set the platform root path as a constant if necessary.
+if (!defined('JPATH_PLATFORM'))
+{
+ define('JPATH_PLATFORM', 'phar://' . __FILE__);
+}
+
+// Detect the native operating system type.
+$os = strtoupper(substr(PHP_OS, 0, 3));
+
+if (!defined('IS_WIN'))
+{
+ define('IS_WIN', ($os === 'WIN') ? true : false);
+}
+if (!defined('IS_UNIX'))
+{
+ define('IS_UNIX', (IS_WIN === false) ? true : false);
+}
+
+// Import the platform version library if necessary.
+if (!class_exists('JPlatform'))
+{
+ require_once JPATH_PLATFORM . '/platform.php';
+}
+
+// Import the library loader if necessary.
+if (!class_exists('JLoader'))
+{
+ require_once JPATH_PLATFORM . '/loader.php';
+}
+
+// Make sure that the Joomla Platform has been successfully loaded.
+if (!class_exists('JLoader'))
+{
+ throw new RuntimeException('Joomla Platform not loaded.');
+}
+
+// Setup the autoloaders.
+JLoader::setup();
+
+// Import the base Joomla Platform libraries.
+JLoader::import('joomla.factory');
+
+// Register classes for compatability with PHP 5.3
+if (version_compare(PHP_VERSION, '5.4.0', '<'))
+{
+ JLoader::register('JsonSerializable', JPATH_PLATFORM . '/compat/jsonserializable.php');
+}
+
+// Register classes that don't follow one file per class naming conventions.
+JLoader::register('JText', JPATH_PLATFORM . '/joomla/language/text.php');
+JLoader::register('JRoute', JPATH_PLATFORM . '/joomla/application/route.php');
+
+// End of the Phar Stub.
+__HALT_COMPILER();?>
View
24 build/phpcs/Joomla/Docs/Files/IncludingFileStandard.xml
@@ -1,24 +0,0 @@
-<documentation title="Including Code">
- <standard>
- <![CDATA[
- Anywhere you are unconditionally including a class file, use <em>require_once</em>. Anywhere you are conditionally including a class file (for example, factory methods), use <em>include_once</em>. Either of these will ensure that class files are included only once. They share the same file list, so you don't need to worry about mixing them - a file included with <em>require_once</em> will not be included again by <em>include_once</em>.
- ]]>
- </standard>
- <standard>
- <![CDATA[
- Note that <em>include_once</em> and <em>require_once</em> are statements, not functions. Parentheses should not surround the subject filename.
- ]]>
- </standard>
- <code_comparison>
- <code title="Valid: used as statement">
- <![CDATA[
-require_once 'PHP/CodeSniffer.php';
- ]]>
- </code>
- <code title="Invalid: used as function">
- <![CDATA[
-require_once<em>(</em>'PHP/CodeSniffer.php'<em>)</em>;
- ]]>
- </code>
- </code_comparison>
-</documentation>
View
7 build/phpcs/Joomla/Docs/Files/LineLengthStandard.xml
@@ -1,7 +0,0 @@
-<documentation title="Line Length">
- <standard>
- <![CDATA[
- It is recommended to keep lines at approximately 130 characters long for better code readability.
- ]]>
- </standard>
-</documentation>
View
19 build/phpcs/Joomla/Docs/Functions/FunctionCallArgumentSpacingStandard.xml
@@ -1,19 +0,0 @@
-<documentation title="Parameter Spacing in Function Calls">
- <standard>
- <![CDATA[
- There must be one space between a comma and a parameter in a function call.
- ]]>
- </standard>
- <code_comparison>
- <code title="Valid: spaces between parameters">
- <![CDATA[
-$var = foo($bar<em>, </em>$baz<em>, </em>$quux);
- ]]>
- </code>
- <code title="Invalid: no space between commas and parameters">
- <![CDATA[
-$var = foo($bar<em>,</em>$baz<em>,</em>$quux);
- ]]>
- </code>
- </code_comparison>
-</documentation>
View
19 build/phpcs/Joomla/Docs/Functions/FunctionCallSignatureStandard.xml
@@ -1,19 +0,0 @@
-<documentation title="Function Calls">
- <standard>
- <![CDATA[
- Functions should be called with no spaces between the function name, the opening parenthesis, and the first parameter; and no space between the last parameter, the closing parenthesis, and the semicolon.
- ]]>
- </standard>
- <code_comparison>
- <code title="Valid: spaces between parameters">
- <![CDATA[
-$var = foo($bar, $baz, $quux);
- ]]>
- </code>
- <code title="Invalid: additional spaces used">
- <![CDATA[
-$var = foo<em> </em>(<em> </em>$bar, $baz, $quux<em> </em>)<em> </em>;
- ]]>
- </code>
- </code_comparison>
-</documentation>
View
25 build/phpcs/Joomla/Docs/Functions/ValidDefaultValueStandard.xml
@@ -1,25 +0,0 @@
-<documentation title="Default Values in Function Declarations">
- <standard>
- <![CDATA[
- Arguments with default values go at the end of the argument list.
- ]]>
- </standard>
- <code_comparison>
- <code title="Valid: argument with default value at end of declaration">
- <![CDATA[
-function connect($dsn, <em>$persistent = false</em>)
-{
- ...
-}
- ]]>
- </code>
- <code title="Invalid: argument with default value at start of declaration">
- <![CDATA[
-function connect(<em>$persistent = false</em>, $dsn)
-{
- ...
-}
- ]]>
- </code>
- </code_comparison>
-</documentation>
View
23 build/phpcs/Joomla/Docs/NamingConventions/ValidClassNameStandard.xml
@@ -1,23 +0,0 @@
-<documentation title="Class Names">
- <standard>
- <![CDATA[
- Classes should be given descriptive names. Avoid using abbreviations where possible. Class names should always begin with an uppercase letter. The PEAR class hierarchy is also reflected in the class name, each level of the hierarchy separated with a single underscore.
- ]]>
- </standard>
- <code_comparison>
- <code title="Examples of valid class names">
- <![CDATA[
-Log
-Net_Finger
-HTML_Upload_Error
- ]]>
- </code>
- <code title="Examples of invalid class names">
- <![CDATA[
-log
-NetFinger
-HTML-Upload-Error
- ]]>
- </code>
- </code_comparison>
-</documentation>
View
23 build/phpcs/Joomla/Docs/NamingConventions/ValidFunctionNameStandard.xml
@@ -1,23 +0,0 @@
-<documentation title="Function and Method Names">
- <standard>
- <![CDATA[
- Functions and methods should be named using the "studly caps" style (also referred to as "bumpy case" or "camel caps"). Functions should in addition have the package name as a prefix, to avoid name collisions between packages. The initial letter of the name (after the prefix) is lowercase, and each letter that starts a new "word" is capitalized.
- ]]>
- </standard>
- <code_comparison>
- <code title="Examples of valid function names">
- <![CDATA[
-connect()
-getData()
-buildSomeWidget()
-XML_RPC_serializeData()
- ]]>
- </code>
- <code title="Examples of invalid function names">
- <![CDATA[
-Connect()
-get_data()
- ]]>
- </code>
- </code_comparison>
-</documentation>
View
106 build/phpcs/Joomla/Sniffs/Classes/InstantiateNewClassesSniff.php
@@ -1,106 +0,0 @@
-<?php
-/**
- * Ensures that new classes are instantiated without brackets if they do not
- * have any parameters.
- *
- * @category Classes
- * @package Joomla.CodeSniffer
- * @author Nikolai Plath
- * @version CVS: $Id: InstantiateNewClassesSniff.php 508 2011-08-29 08:53:08Z elkuku $
- */
-
-/**
- * Ensures that new classes are instantiated without brackets if they do not
- * have any parameters.
- *
- * @category Classes
- * @package Joomla.CodeSniffer
- */
-class Joomla_Sniffs_Classes_InstantiateNewClassesSniff implements PHP_CodeSniffer_Sniff
-{
- /**
- * Registers the token types that this sniff wishes to listen to.
- *
- * @return array
- */
- public function register()
- {
- return array(T_NEW);
- }//end register()
-
- /**
- * Process the tokens that this sniff is listening for.
- *
- * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
- * @param int $stackPtr The position in the stack where
- * the token was found.
- *
- * @return void
- */
- public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
- {
- $tokens = $phpcsFile->getTokens();
-
- $running = true;
- $valid = false;
- $started = false;
-
- $cnt = $stackPtr + 1;
-
- do
- {
- if( ! isset($tokens[$cnt]))
- {
- $running = false;
- }
- else
- {
- switch ($tokens[$cnt]['code'])
- {
- case T_SEMICOLON:
- $valid = true;
- $running = false;
- break;
-
- case T_OPEN_PARENTHESIS :
- $started = true;
- break;
-
- case T_VARIABLE :
- case T_STRING :
- case T_LNUMBER :
- case T_CONSTANT_ENCAPSED_STRING :
- case T_DOUBLE_QUOTED_STRING :
- if($started)
- {
- $valid = true;
- $running = false;
- }
-
- break;
-
- case T_CLOSE_PARENTHESIS :
- if( ! $started)
- {
- $valid = true;
- }
-
- $running = false;
- break;
-
- case T_WHITESPACE :
- break;
- }//switch
-
- $cnt ++;
- }
- }
- while ($running == true);
-
- if( ! $valid)
- {
- $error = 'Instanciating new classes without parameters does not require brackets.';
- $phpcsFile->addError($error, $stackPtr, 'New class');
- }
- }//function
-}//class
View
93 build/phpcs/Joomla/Sniffs/Classes/MemberVarScopeSniff.php
@@ -1,93 +0,0 @@
-<?php
-/**
- * Verifies that class members have scope modifiers.
- *
- * PHP version 5
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version CVS: $Id: MemberVarScopeSniff.php 8 2010-11-06 00:40:23Z elkuku $
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-
-if(class_exists('PHP_CodeSniffer_Standards_AbstractVariableSniff', true) === false)
-{
- throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractVariableSniff not found');
-}
-
-/**
- * Verifies that class members have scope modifiers.
- *
- * Example:
- * class Foo
- * {
- * <b class="good">private $foo</b>
- * <b class="bad">var $foo</b>
- * }
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version Release: 1.3.0RC1
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-class Joomla_Sniffs_Classes_MemberVarScopeSniff extends PHP_CodeSniffer_Standards_AbstractVariableSniff
-{
- /**
- * Processes the function tokens within the class.
- *
- * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
- * @param integer $stackPtr The position where the token was found.
- *
- * @return void
- */
- protected function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
- {
- $tokens = $phpcsFile->getTokens();
-
- $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr);
-
- if(($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line']))
- {
- $error = sprintf('Scope modifier not specified for member variable "%s"'
- , $tokens[$stackPtr]['content']);
-
- $phpcsFile->addWarning($error, $stackPtr, 'Missing');
- }
- }//function
-
- /**
- * Processes normal variables.
- *
- * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
- * @param integer $stackPtr The position where the token was found.
- *
- * @return void
- */
- protected function processVariable(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
- {
- // We don't care about normal variables.
- return;
- }//function
-
- /**
- * Processes variables in double quoted strings.
- *
- * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
- * @param integer $stackPtr The position where the token was found.
- *
- * @return void
- */
- protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
- {
- // We don't care about normal variables.
- return;
- }//function
-}//class
View
87 build/phpcs/Joomla/Sniffs/Classes/MethodScopeSniff.php
@@ -1,87 +0,0 @@
-<?php
-/**
- * Verifies that class members have scope modifiers.
- *
- * PHP version 5
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version CVS: $Id: MethodScopeSniff.php 8 2010-11-06 00:40:23Z elkuku $
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-
-if(class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false)
-{
- throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
-}
-
-/**
- * Verifies that class members have scope modifiers.
- *
- * Example:
- * class Foo
- * {
- * <b class="good">public function foo()</b>
- * {
- * }
- *
- * <b class="bad">function foo()</b>
- * {
- * }
- * }
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version Release: 1.3.0RC1
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-class Joomla_Sniffs_Classes_MethodScopeSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
-{
- /**
- * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.
- */
- public function __construct()
- {
- parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION));
- }//function
-
- /**
- * Processes the function tokens within the class.
- *
- * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
- * @param integer $stackPtr The position where the token was found.
- * @param integer $currScope The current scope opener token.
- *
- * @return void
- */
- protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
- {
- $tokens = $phpcsFile->getTokens();
-
- $methodName = $phpcsFile->getDeclarationName($stackPtr);
-
- if($methodName === null)
- {
- // Ignore closures.
- return;
- }
-
- $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr);
-
- if(($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line']))
- {
- $error = sprintf('No scope modifier specified for function "%s"'
- , $methodName);
-
- $phpcsFile->addWarning($error, $stackPtr, 'Missing');
- }
- }//function
-}//class
View
94 build/phpcs/Joomla/Sniffs/Classes/StaticThisUsageSniff.php
@@ -1,94 +0,0 @@
-<?php
-/**
- * Squiz_Sniffs_Classes_StaticThisUsageSniff.
- *
- * PHP version 5
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version CVS: $Id: StaticThisUsageSniff.php 8 2010-11-06 00:40:23Z elkuku $
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-
-if(class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false)
-{
- throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
-}
-
-/**
- * Checks for usage of "$this" in static methods, which will cause runtime errors.
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version Release: 1.3.0RC1
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-class Joomla_Sniffs_Classes_StaticThisUsageSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
-{
- /**
- * Constructs the test with the tokens it wishes to listen for.
- */
- public function __construct()
- {
- parent::__construct(array(T_CLASS), array(T_FUNCTION));
- }//function
-
- /**
- * Processes this test, when one of its tokens is encountered.
- *
- * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned.
- * @param integer $stackPtr The position of the current token in the
- * stack passed in $tokens.
- * @param integer $currScope A pointer to the start of the scope.
- *
- * @return void
- */
- public function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
- {
- $tokens = $phpcsFile->getTokens();
- $function = $tokens[($stackPtr + 2)];
-
- if($function['code'] !== T_STRING)
- {
- return;
- }
-
- $functionName = $function['content'];
- $classOpener = $tokens[$currScope]['scope_condition'];
- $className = $tokens[($classOpener + 2)]['content'];
-
- $methodProps = $phpcsFile->getMethodProperties($stackPtr);
-
- if($methodProps['is_static'] === true)
- {
- if(isset($tokens[$stackPtr]['scope_closer']) === false)
- {
- // There is no scope opener or closer, so the function
- // must be abstract.
- return;
- }
-
- $thisUsage = $stackPtr;
-
- while(($thisUsage = $phpcsFile->findNext(array(T_VARIABLE)
- , ($thisUsage + 1), $tokens[$stackPtr]['scope_closer'], false, '$this')) !== false)
- {
- if($thisUsage === false)
- {
- return;
- }
-
- $error = 'Usage of "$this" in static methods will cause runtime errors';
- $phpcsFile->addError($error, $thisUsage, 'Found');
- }//while
- }
- }//function
-}//class
View
299 build/phpcs/Joomla/Sniffs/Commenting/ClassCommentSniff.php
@@ -1,299 +0,0 @@
-<?php
-/**
- * Parses and verifies the doc comments for classes.
- *
- * PHP version 5
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version CVS: $Id: ClassCommentSniff.php 301632 2010-07-28 01:57:56Z squiz $
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-
-if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) {
- $error = 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found';
- throw new PHP_CodeSniffer_Exception($error);
-}
-
-require_once 'FileCommentSniff.php';
-
-if (class_exists('Joomla_Sniffs_Commenting_FileCommentSniff', true) === false) {
- $error = 'Class Joomla_Sniffs_Commenting_FileCommentSniff not found';
- throw new PHP_CodeSniffer_Exception($error);
-}
-
-/**
- * Parses and verifies the doc comments for classes.
- *
- * Verifies that :
- * <ul>
- * <li>A doc comment exists.</li>
- * <li>There is a blank newline after the short description.</li>
- * <li>There is a blank newline between the long and short description.</li>
- * <li>There is a blank newline between the long description and tags.</li>
- * <li>Check the order of the tags.</li>
- * <li>Check the indentation of each tag.</li>
- * <li>Check required and optional tags and the format of their content.</li>
- * </ul>
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version Release: 1.3.0RC2
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-class Joomla_Sniffs_Commenting_ClassCommentSniff extends Joomla_Sniffs_Commenting_FileCommentSniff
-{
-
-
- /**
- * Tags in correct order and related info.
- *
- * @var array
- */
- protected $tags = array(
- 'version' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'is first',
- ),
- 'category' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @version (if used)',
- ),
- 'package' => array(
- 'required' => true,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @category (if used)',
- ),
- 'subpackage' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @package',
- ),
- 'author' => array(
- 'required' => false,
- 'allow_multiple' => true,
- 'order_text' => 'is first',
- ),
- 'copyright' => array(
- 'required' => false,
- 'allow_multiple' => true,
- 'order_text' => 'must follow @author (if used) or @subpackage (if used) or @package',
- ),
- 'license' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @copyright (if used)',
- ),
- 'link' => array(
- 'required' => false,
- 'allow_multiple' => true,
- 'order_text' => 'must follow @version (if used)',
- ),
- 'see' => array(
- 'required' => false,
- 'allow_multiple' => true,
- 'order_text' => 'must follow @link (if used)',
- ),
- 'since' => array(
- 'required' => true,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @see (if used) or @link (if used)',
- ),
- 'deprecated' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @since (if used) or @see (if used) or @link (if used)',
- ),
- );
-
- /**
- * Returns an array of tokens this test wants to listen for.
- *
- * @return array
- */
- public function register()
- {
- return array(
- T_CLASS,
- T_INTERFACE,
- );
-
- }//end register()
-
-
- /**
- * Processes this test, when one of its tokens is encountered.
- *
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
- * @param int $stackPtr The position of the current token
- * in the stack passed in $tokens.
- *
- * @return void
- */
- public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
- {
- $this->currentFile = $phpcsFile;
-
- $tokens = $phpcsFile->getTokens();
- $type = strtolower($tokens[$stackPtr]['content']);
- $errorData = array($type);
- $find = array(
- T_ABSTRACT,
- T_WHITESPACE,
- T_FINAL,
- );
-
- // Extract the class comment docblock.
- $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
-
- if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) {
- $error = 'You must use "/**" style comments for a %s comment';
- $phpcsFile->addError($error, $stackPtr, 'WrongStyle', $errorData);
- return;
- } else if ($commentEnd === false
- || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT
- ) {
- $phpcsFile->addError('Missing %s doc comment', $stackPtr, 'Missing', $errorData);
- return;
- }
-
- $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1);
- $commentNext = $phpcsFile->findPrevious(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar);
-
- // Distinguish file and class comment.
- $prevClassToken = $phpcsFile->findPrevious(T_CLASS, ($stackPtr - 1));
- if ($prevClassToken === false) {
- // This is the first class token in this file, need extra checks.
- $prevNonComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($commentStart - 1), null, true);
- if ($prevNonComment !== false) {
- $prevComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($prevNonComment - 1));
- if ($prevComment === false) {
- // There is only 1 doc comment between open tag and class token.
- $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar);
- if ($newlineToken !== false) {
- $newlineToken = $phpcsFile->findNext(
- T_WHITESPACE,
- ($newlineToken + 1),
- $stackPtr,
- false,
- $phpcsFile->eolChar
- );
-
- if ($newlineToken !== false) {
- // Blank line between the class and the doc block.
- // The doc block is most likely a file comment.
- $error = 'Missing %s doc comment';
- $phpcsFile->addError($error, ($stackPtr + 1), 'Missing', $errorData);
- return;
- }
- }//end if
- }//end if
- }//end if
- }//end if
-
- $comment = $phpcsFile->getTokensAsString(
- $commentStart,
- ($commentEnd - $commentStart + 1)
- );
-
- // Parse the class comment.docblock.
- try {
- $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile);
- $this->commentParser->parse();
- } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
- $line = ($e->getLineWithinComment() + $commentStart);
- $phpcsFile->addError($e->getMessage(), $line, 'FailedParse');
- return;
- }
-
- $comment = $this->commentParser->getComment();
- if (is_null($comment) === true) {
- $error = 'Doc comment is empty for %s';
- $phpcsFile->addError($error, $commentStart, 'Empty', $errorData);
- return;
- }
-
- // No extra newline before short description.
- $short = $comment->getShortComment();
- $newlineCount = 0;
- $newlineSpan = strspn($short, $phpcsFile->eolChar);
- if ($short !== '' && $newlineSpan > 0) {
- $error = 'Extra newline(s) found before %s comment short description';
- $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort', $errorData);
- }
-
- $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1);
-
- // Exactly one blank line between short and long description.
- $long = $comment->getLongComment();
- if (empty($long) === false) {
- $between = $comment->getWhiteSpaceBetween();
- $newlineBetween = substr_count($between, $phpcsFile->eolChar);
- if ($newlineBetween !== 2) {
- $error = 'There must be exactly one blank line between descriptions in %s comments';
- $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingAfterShort', $errorData);
- }
-
- $newlineCount += $newlineBetween;
- }
-
- // Exactly one blank line before tags.
- $tags = $this->commentParser->getTagOrders();
- if (count($tags) > 1) {
- $newlineSpan = $comment->getNewlineAfter();
- if ($newlineSpan !== 2) {
- $error = 'There must be exactly one blank line before the tags in %s comments';
- if ($long !== '') {
- $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1);
- }
-
- $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags', $errorData);
- $short = rtrim($short, $phpcsFile->eolChar.' ');
- }
- }
-
- // Check each tag.
- $this->processTags($commentStart, $commentEnd);
-
- }//end process()
-
-
- /**
- * Process the version tag.
- *
- * @param int $errorPos The line number where the error occurs.
- *
- * @return void
- */
- protected function processVersion($errorPos)
- {
- $version = $this->commentParser->getVersion();
- if ($version !== null) {
- $content = $version->getContent();
- $matches = array();
- if (empty($content) === true) {
- $error = 'Content missing for @version tag in doc comment';
- $this->currentFile->addError($error, $errorPos, 'EmptyVersion');
- } else if ((strstr($content, 'Release:') === false)) {
- $error = 'Invalid version "%s" in doc comment; consider "Release: <package_version>" instead';
- $data = array($content);
- $this->currentFile->addWarning($error, $errorPos, 'InvalidVersion', $data);
- }
- }
-
- }//end processVersion()
-
-
-}//end class
-
-?>
View
793 build/phpcs/Joomla/Sniffs/Commenting/FileCommentSniff.php
@@ -1,793 +0,0 @@
-<?php
-/**
- * Parses and verifies the doc comments for files.
- *
- * PHP version 5
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version CVS: $Id: FileCommentSniff.php 301632 2010-07-28 01:57:56Z squiz $
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-
-if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) {
- throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found');
-}
-
-/**
- * Parses and verifies the doc comments for files.
- *
- * Verifies that :
- * <ul>
- * <li>A doc comment exists.</li>
- * <li>There is a blank newline after the short description.</li>
- * <li>There is a blank newline between the long and short description.</li>
- * <li>There is a blank newline between the long description and tags.</li>
- * <li>A PHP version is specified.</li>
- * <li>Check the order of the tags.</li>
- * <li>Check the indentation of each tag.</li>
- * <li>Check required and optional tags and the format of their content.</li>
- * </ul>
- *
- * @category PHP
- * @package PHP_CodeSniffer
- * @author Greg Sherwood <gsherwood@squiz.net>
- * @author Marc McIntyre <mmcintyre@squiz.net>
- * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
- * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
- * @version Release: 1.3.0RC2
- * @link http://pear.php.net/package/PHP_CodeSniffer
- */
-
-class Joomla_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
-{
-
- /**
- * The header comment parser for the current file.
- *
- * @var PHP_CodeSniffer_Comment_Parser_ClassCommentParser
- */
- protected $commentParser = null;
-
- /**
- * The current PHP_CodeSniffer_File object we are processing.
- *
- * @var PHP_CodeSniffer_File
- */
- protected $currentFile = null;
-
- /**
- * Tags in correct order and related info.
- *
- * @var array
- */
- protected $tags = array(
- 'version' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'must be first',
- ),
- 'category' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'precedes @package',
- ),
- 'package' => array(
- 'required' => true,
- 'allow_multiple' => false,
- 'order_text' => 'must follows @category (if used)',
- ),
- 'subpackage' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @package',
- ),
- 'author' => array(
- 'required' => false,
- 'allow_multiple' => true,
- 'order_text' => 'must follow @subpackage (if used) or @package',
- ),
- 'copyright' => array(
- 'required' => true,
- 'allow_multiple' => true,
- 'order_text' => 'must follow @author (if used), @subpackage (if used) or @package',
- ),
- 'license' => array(
- 'required' => true,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @copyright',
- ),
- 'link' => array(
- 'required' => false,
- 'allow_multiple' => true,
- 'order_text' => 'must follow @license',
- ),
- 'see' => array(
- 'required' => false,
- 'allow_multiple' => true,
- 'order_text' => 'must follow @link (if used) or @license',
- ),
- 'since' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'must follows @see (if used), @link (if used) or @license',
- ),
- 'deprecated' => array(
- 'required' => false,
- 'allow_multiple' => false,
- 'order_text' => 'must follow @since (if used), @see (if used), @link (if used) or @license',
- ),
- );
-
-
- /**
- * Returns an array of tokens this test wants to listen for.
- *
- * @return array
- */
- public function register()
- {
- return array(T_OPEN_TAG);
-
- }//end register()
-
-
- /**
- * Processes this test, when one of its tokens is encountered.
- *
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
- * @param int $stackPtr The position of the current token
- * in the stack passed in $tokens.
- *
- * @return void
- */
- public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
- {
- $this->currentFile = $phpcsFile;
-
- // We are only interested if this is the first open tag.
- if ($stackPtr !== 0) {
- if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
- return;
- }
- }
-
- $tokens = $phpcsFile->getTokens();
-
- // Find the next non whitespace token.
- $commentStart
- = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
-
- // Allow declare() statements at the top of the file.
- if ($tokens[$commentStart]['code'] === T_DECLARE) {
- $semicolon = $phpcsFile->findNext(T_SEMICOLON, ($commentStart + 1));
- $commentStart
- = $phpcsFile->findNext(T_WHITESPACE, ($semicolon + 1), null, true);
- }
-
- // Ignore vim header.
- if ($tokens[$commentStart]['code'] === T_COMMENT) {
- if (strstr($tokens[$commentStart]['content'], 'vim:') !== false) {
- $commentStart = $phpcsFile->findNext(
- T_WHITESPACE,
- ($commentStart + 1),
- null,
- true
- );
- }
- }
-
- $errorToken = ($stackPtr + 1);
- if (isset($tokens[$errorToken]) === false) {
- $errorToken--;
- }
-
- if ($tokens[$commentStart]['code'] === T_CLOSE_TAG) {
- // We are only interested if this is the first open tag.
- return;
- } else if ($tokens[$commentStart]['code'] === T_COMMENT) {
- $error = 'You must use "/**" style comments for a file comment';
- $phpcsFile->addError($error, $errorToken, 'WrongStyle');
- return;
- } else if ($commentStart === false
- || $tokens[$commentStart]['code'] !== T_DOC_COMMENT
- ) {
- $phpcsFile->addError('Missing file doc comment', $errorToken, 'Missing');
- return;
- } else {
-
- // Extract the header comment docblock.
- $commentEnd = $phpcsFile->findNext(
- T_DOC_COMMENT,
- ($commentStart + 1),
- null,
- true
- );
-
- $commentEnd--;
-
- // Check if there is only 1 doc comment between the
- // open tag and class token.
- $nextToken = array(
- T_ABSTRACT,
- T_CLASS,
- T_FUNCTION,
- T_DOC_COMMENT,
- );
-
- $commentNext = $phpcsFile->findNext($nextToken, ($commentEnd + 1));
- if ($commentNext !== false
- && $tokens[$commentNext]['code'] !== T_DOC_COMMENT
- ) {
- // Found a class token right after comment doc block.
- $newlineToken = $phpcsFile->findNext(
- T_WHITESPACE,
- ($commentEnd + 1),
- $commentNext,
- false,
- $phpcsFile->eolChar
- );
-
- if ($newlineToken !== false) {
- $newlineToken = $phpcsFile->findNext(
- T_WHITESPACE,
- ($newlineToken + 1),
- $commentNext,
- false,
- $phpcsFile->eolChar
- );
-
- if ($newlineToken === false) {
- // No blank line between the class token and the doc block.
- // The doc block is most likely a class comment.
- $error = 'Missing file doc comment';
- $phpcsFile->addError($error, $errorToken, 'Missing');
- return;
- }
- }
- }//end if
-
- $comment = $phpcsFile->getTokensAsString(
- $commentStart,
- ($commentEnd - $commentStart + 1)
- );
-
- // Parse the header comment docblock.
- try {
- $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile);
- $this->commentParser->parse();
- } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
- $line = ($e->getLineWithinComment() + $commentStart);
- $phpcsFile->addError($e->getMessage(), $line, 'FailedParse');
- return;
- }
-
- $comment = $this->commentParser->getComment();
- if (is_null($comment) === true) {
- $error = 'File doc comment is empty';
- $phpcsFile->addError($error, $commentStart, 'Empty');
- return;
- }
-
- // No extra newline before short description.
- $short = $comment->getShortComment();
- $newlineCount = 0;
- $newlineSpan = strspn($short, $phpcsFile->eolChar);
- if ($short !== '' && $newlineSpan > 0) {
- $error = 'Extra newline(s) found before file comment short description';
- $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBefore');
- }
-
- $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1);
-
- // Exactly one blank line between short and long description.
- $long = $comment->getLongComment();
- if (empty($long) === false) {
- $between = $comment->getWhiteSpaceBetween();
- $newlineBetween = substr_count($between, $phpcsFile->eolChar);
- if ($newlineBetween !== 2) {
- $error = 'There must be exactly one blank line between descriptions in file comment';
- $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'DescriptionSpacing');
- }
-
- $newlineCount += $newlineBetween;
- }
-
- // Exactly one blank line before tags if short description is present.
-