Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
56 changes: 56 additions & 0 deletions build/fix-strict-types.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env php
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

include __DIR__ . '/../build/integration/vendor/autoload.php';

use PhpParser\Node\DeclareItem;
use PhpParser\Node\Stmt\Declare_;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\CloningVisitor;
use PhpParser\NodeVisitor\NameResolver;
use PhpParser\ParserFactory;
use PhpParser\PrettyPrinter;

$parser = (new ParserFactory())->createForHostVersion();

$nodeTraverser = new NodeTraverser();
$nodeTraverser->addVisitor(new CloningVisitor());
$nodeTraverser->addVisitor(new NameResolver());

$prettyPrinter = new PrettyPrinter\Standard();

$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('lib'));

/** @var SplFileInfo $info */
foreach ($iterator as $info) {
if ($info->getType() !== 'file' || $info->getExtension() !== 'php') {
continue;
}

error_log($info->getRealPath());

$code = file_get_contents($info->getRealPath());
$oldStmts = $parser->parse($code);
$oldTokens = $parser->getTokens();
$newStmts = $nodeTraverser->traverse($oldStmts);

$hasStrictTypes = false;
foreach ($newStmts as $stmt) {
if ($stmt instanceof Declare_) {
$hasStrictTypes = true;
break;
}
}

if (!$hasStrictTypes) {
array_unshift($newStmts, new Declare_([new DeclareItem('strict_types', new PhpParser\Node\Scalar\Int_(1))]));
file_put_contents($info->getRealPath(), $prettyPrinter->printFormatPreserving($newStmts, $oldStmts, $oldTokens));
}
}
1 change: 1 addition & 0 deletions lib/composer/autoload.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
// autoload.php @generated by Composer

if (PHP_VERSION_ID < 50600) {
Expand Down
4 changes: 2 additions & 2 deletions lib/composer/composer/ClassLoader.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
/*
* This file is part of Composer.
*
Expand All @@ -9,7 +10,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Composer\Autoload;

/**
Expand Down Expand Up @@ -576,4 +576,4 @@ private static function initializeIncludeClosure()
include $file;
}, null, null);
}
}
}
4 changes: 2 additions & 2 deletions lib/composer/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
/*
* This file is part of Composer.
*
Expand All @@ -9,7 +10,6 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Composer;

use Composer\Autoload\ClassLoader;
Expand Down Expand Up @@ -356,4 +356,4 @@ private static function getInstalled()

return $installed;
}
}
}
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
// autoload_classmap.php @generated by Composer

$vendorDir = dirname(__DIR__);
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_files.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
// autoload_files.php @generated by Composer

$vendorDir = dirname(__DIR__);
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_namespaces.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(__DIR__);
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
// autoload_psr4.php @generated by Composer

$vendorDir = dirname(__DIR__);
Expand Down
4 changes: 2 additions & 2 deletions lib/composer/composer/autoload_real.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

declare (strict_types=1);
// autoload_real.php @generated by Composer

class ComposerAutoloaderInit749170dad3f5e7f9ca158f5a9f04f6a2
{
private static $loader;
Expand Down Expand Up @@ -47,4 +47,4 @@ public static function getLoader()

return $loader;
}
}
}
4 changes: 2 additions & 2 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

declare (strict_types=1);
// autoload_static.php @generated by Composer

namespace Composer\Autoload;

class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
Expand Down Expand Up @@ -2058,4 +2058,4 @@ public static function getInitializer(ClassLoader $loader)

}, null, ClassLoader::class);
}
}
}
7 changes: 5 additions & 2 deletions lib/composer/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php return array(
<?php

declare (strict_types=1);
return array(
'root' => array(
'name' => '__root__',
'pretty_version' => 'dev-master',
Expand All @@ -20,4 +23,4 @@
'dev_requirement' => false,
),
),
);
);
1 change: 1 addition & 0 deletions lib/composer/composer/platform_check.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
// platform_check.php @generated by Composer

$issues = array();
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Accounts/AccountManager.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace OC\Accounts;

use Exception;
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Accounts/Hooks.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Activity/EventMerger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/Activity/Manager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
2 changes: 2 additions & 0 deletions lib/private/AllConfig.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Bundles/Bundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Bundles/BundleFetcher.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Bundles/EducationBundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Bundles/EnterpriseBundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Bundles/GroupwareBundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Bundles/PublicSectorBundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Bundles/SocialSharingBundle.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
3 changes: 2 additions & 1 deletion lib/private/App/AppStore/Fetcher/AppDiscoverFetcher.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OC\App\AppStore\Fetcher;

use DateTimeImmutable;
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Fetcher/AppFetcher.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Fetcher/CategoryFetcher.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Fetcher/Fetcher.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Version/Version.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/AppStore/Version/VersionParser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/DependencyAnalyzer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/InfoParser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/Platform.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
2 changes: 2 additions & 0 deletions lib/private/App/PlatformRepository.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
1 change: 1 addition & 0 deletions lib/private/AppFramework/Http.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
1 change: 1 addition & 0 deletions lib/private/AppFramework/Http/Output.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
2 changes: 2 additions & 0 deletions lib/private/AppFramework/Middleware/OCSMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare (strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
Loading