Skip to content

Enhancement: Enable braces_position fixer #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'array_syntax' => true,
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'braces_position' => true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, this fixer could also be configured with a range of options.

'class_attributes_separation' => true,
'class_definition' => true,
'concat_space' => [
Expand Down
28 changes: 21 additions & 7 deletions cal.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@
}

// Give defaults for the month and day values if they were invalid
if (empty($cm)) { $cm = date("m"); }
if (empty($cy)) { $cy = date("Y"); }
if (empty($cm)) {
$cm = date("m");
}
if (empty($cy)) {
$cy = date("Y");
}

// Start of the month date
$date = mktime(0, 0, 1, $cm, 1, $cy);
Expand Down Expand Up @@ -257,7 +261,9 @@ function load_event($id)
{
// Open events CSV file, return on error
$fp = @fopen("backend/events.csv",'r');
if (!$fp) { return false; }
if (!$fp) {
return false;
}

// Read as we can, event by event
while (!feof($fp)) {
Expand Down Expand Up @@ -292,7 +298,9 @@ function load_events($from, $whole_month = false)

// Try to open the events file for reading, return if unable to
$fp = @fopen("backend/events.csv",'r');
if (!$fp) { return false; }
if (!$fp) {
return false;
}

// For all events, read in the event and check it if fits our scope
while (!feof($fp)) {
Expand All @@ -305,8 +313,12 @@ function load_events($from, $whole_month = false)

// Keep event's seen list up to date
// (for repeating events with the same ID)
if (!isset($seen[$event['id']])) { $seen[$event['id']] = 1; }
else { continue; }
if (!isset($seen[$event['id']])) {
$seen[$event['id']] = 1;
}
else {
continue;
}

// Check if event is in our scope, depending on type
switch ($event['type']) {
Expand Down Expand Up @@ -350,7 +362,9 @@ function read_event($fp)
}

// Corrupt line in CSV file
if (count($linearr) < 13) { return false; }
if (count($linearr) < 13) {
return false;
}

// Get components
[
Expand Down
8 changes: 6 additions & 2 deletions docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@
}

// Make preferred language bold
if ($langcode == $LANG) { echo "<strong>"; }
if ($langcode == $LANG) {
echo "<strong>";
}

echo '<a href="/manual/' . $langcode . '/">' . $langname . '</a>';
echo ($lastlang != $langname) ? ",\n" : "\n";

if ($langcode == $LANG) { echo "</strong>"; }
if ($langcode == $LANG) {
echo "</strong>";
}
}

?>
Expand Down
16 changes: 12 additions & 4 deletions download-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@

// Print out the name of the formats
foreach ($formats as $formatname => $extension) {
if (!isset($found_formats[$formatname])) { continue; }
if (!isset($found_formats[$formatname])) {
continue;
}
echo " <th valign=\"bottom\">$formatname</th>\n";
}

Expand All @@ -170,8 +172,12 @@
foreach ($files as $langcode => $lang_files) {

// See if current language is the preferred one
if ($langcode == $LANG) { $preflang = true; }
else { $preflang = false; }
if ($langcode == $LANG) {
$preflang = true;
}
else {
$preflang = false;
}

// Highlight manual in preferred language
if ($preflang) {
Expand All @@ -185,7 +191,9 @@
foreach ($formats as $formatname => $extension) {

// Skip if no file found
if (!isset($found_formats[$formatname])) { continue; }
if (!isset($found_formats[$formatname])) {
continue;
}

echo "<td align=\"center\"$cellclass>";
if (!isset($lang_files[$formatname])) {
Expand Down
9 changes: 6 additions & 3 deletions images/logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
}
}

function imgheader($filename) {
function imgheader($filename)
{
Comment on lines +22 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this. Also, I think this fixer should be applied together with indentation fixer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe #886 helps, @kamil-tekiela?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I would hold off with applying either of them. It creates too many changes and I don't know if this project is ready for this yet. I'd rather take small steps here.

$ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
switch ($ext) {
case 'gif':
Expand All @@ -41,7 +42,8 @@ function imgheader($filename) {
header("Content-Type: $hdr");
}

function get_accepted_encodings() {
function get_accepted_encodings()
{
if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
$encodings = explode(',', $_SERVER['HTTP_ACCEPT_ENCODING']);
return array_map(function ($x) {
Expand All @@ -51,7 +53,8 @@ function get_accepted_encodings() {
return [];
}

function serve_compressed_if_available($logo): void {
function serve_compressed_if_available($logo): void
{
$encodings = get_accepted_encodings();
if (!empty($encodings)) {
foreach ($encodings as $encoding) {
Expand Down
6 changes: 4 additions & 2 deletions images/supported-versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
$branch_height = 30;
$footer_height = 24;

function branches_to_show() {
function branches_to_show()
{
// Basically: show all 5.3+ branches with EOL dates > min_date().
$branches = [];

Expand Down Expand Up @@ -39,7 +40,8 @@ function max_date(): DateTime
return $now->add(new DateInterval('P5Y'));
}

function date_horiz_coord(DateTime $date) {
function date_horiz_coord(DateTime $date)
{
$diff = $date->diff(min_date());
if (!$diff->invert) {
return $GLOBALS['margin_left'];
Expand Down
27 changes: 18 additions & 9 deletions include/branches.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ $BRANCHES = [
* page. (Currently 28 days.) */
$KEEP_EOL = new DateInterval('P28D');

function format_interval($from, DateTime $to) {
function format_interval($from, DateTime $to)
{
try {
$from_obj = $from instanceof DateTime ? $from : new DateTime($from);
$diff = $to->diff($from_obj);
Expand Down Expand Up @@ -85,7 +86,8 @@ function format_interval($from, DateTime $to) {
return $eolPeriod;
}

function version_number_to_branch(string $version): ?string {
function version_number_to_branch(string $version): ?string
{
$parts = explode('.', $version);
if (count($parts) > 1) {
return "$parts[0].$parts[1]";
Expand All @@ -94,7 +96,8 @@ function version_number_to_branch(string $version): ?string {
return null;
}

function get_all_branches() {
function get_all_branches()
{
$branches = [];

foreach ($GLOBALS['OLDRELEASES'] as $major => $releases) {
Expand Down Expand Up @@ -131,7 +134,8 @@ function get_all_branches() {
return $branches;
}

function get_active_branches($include_recent_eols = true) {
function get_active_branches($include_recent_eols = true)
{
$branches = [];
$now = new DateTime();

Expand Down Expand Up @@ -166,7 +170,8 @@ function get_active_branches($include_recent_eols = true) {
/* If you provide an array to $always_include, note that the version numbers
* must be in $RELEASES _and_ must be the full version number, not the branch:
* ie provide array('5.3.29'), not array('5.3'). */
function get_eol_branches($always_include = null) {
function get_eol_branches($always_include = null)
{
$always_include = $always_include ?: [];
$branches = [];
$now = new DateTime();
Expand Down Expand Up @@ -242,7 +247,8 @@ function get_eol_branches($always_include = null) {
* MAJOR.MINOR.REVISION (the REVISION will be ignored if provided). This will
* return either null (if no release exists on the given branch), or the usual
* version metadata from $RELEASES for a single release. */
function get_initial_release($branch) {
function get_initial_release($branch)
{
$branch = version_number_to_branch($branch);
if (!$branch) {
return null;
Expand All @@ -266,7 +272,8 @@ function get_initial_release($branch) {
return null;
}

function get_final_release($branch) {
function get_final_release($branch)
{
$branch = version_number_to_branch($branch);
if (!$branch) {
return null;
Expand Down Expand Up @@ -333,7 +340,8 @@ function get_branch_release_date($branch): ?DateTime
return $initial ? new DateTime($initial['date']) : null;
}

function get_branch_support_state($branch) {
function get_branch_support_state($branch)
{
$initial = get_branch_release_date($branch);
$bug = get_branch_bug_eol_date($branch);
$security = get_branch_security_eol_date($branch);
Expand Down Expand Up @@ -394,7 +402,8 @@ function version_array(string $version, ?int $length = null)
return $versionArray;
}

function get_current_release_for_branch(int $major, ?int $minor): ?string {
function get_current_release_for_branch(int $major, ?int $minor): ?string
{
global $RELEASES, $OLDRELEASES;

$prefix = "{$major}.";
Expand Down
33 changes: 22 additions & 11 deletions include/changelogs.inc
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
<?php
function bugfix($number): void {
function bugfix($number): void
{
echo "Fixed bug "; bugl($number);
}

function bugl($number): void {
function bugl($number): void
{
echo "<a href=\"http://bugs.php.net/$number\">#$number</a>";
}

function implemented($number): void {
function implemented($number): void
{
echo "Implemented FR "; bugl($number);
}

function peclbugfix($number): void {
function peclbugfix($number): void
{
echo "Fixed PECL bug "; bugl($number);
}

function peclbugl($number): void {
function peclbugl($number): void
{
echo "<a href=\"http://pecl.php.net/bugs/bug.php?id=$number\">#$number</a>";
}

function githubissue($repo, $number): void {
function githubissue($repo, $number): void
{
echo "Fixed issue "; githubissuel($repo, $number);
}

function githubissuel($repo, $number): void {
function githubissuel($repo, $number): void
{
echo "<a href=\"https://github.com/$repo/issues/$number\">GH-$number</a>";
}

function release_date($in): void {
function release_date($in): void
{
$time = strtotime($in);
$human_readable = date('d M Y', $time);
$for_tools = date('Y-m-d', $time);
echo "<time class='releasedate' datetime='{$for_tools}'>{$human_readable}</time>";
}

function changelog_makelink(string $branch): string {
function changelog_makelink(string $branch): string
{
return '<a href="#PHP_' . urlencode(strtr($branch, '.', '_')) . '">' . htmlentities($branch) . '</a>';
}

function changelog_header(int $major_version, array $minor_versions): void {
function changelog_header(int $major_version, array $minor_versions): void
{
site_header("PHP {$major_version} ChangeLog", [
'current' => 'docs',
'css' => ['changelog.css'],
Expand All @@ -53,7 +63,8 @@ function changelog_header(int $major_version, array $minor_versions): void {
echo "\n";
}

function changelog_footer(int $current_major, array $minor_versions): void {
function changelog_footer(int $current_major, array $minor_versions): void
{
$sidebar = "<div class=\"panel\">ChangeLogs<div class=\"body\"><ul>\n";
foreach ([8, 7, 5, 4] as $major) {
if ($major === $current_major) {
Expand Down
3 changes: 2 additions & 1 deletion include/email-validation.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ function is_emailable_address($email)
* .... will match:
* [email protected]
*/
function blacklisted($email) {
function blacklisted($email)
{
$mosquitoes = [
'[email protected]',
'[email protected]',
Expand Down
Loading