Skip to content

Commit

Permalink
Merge pull request #812 from nextcloud/coposer-install-22
Browse files Browse the repository at this point in the history
[stable22] composer install
  • Loading branch information
LukasReschke committed Sep 22, 2021
2 parents 6966f16 + 28d4c74 commit 40760a4
Show file tree
Hide file tree
Showing 16 changed files with 351 additions and 34 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/composer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ jobs:
coverage: none
- name: Update composer
run: sudo composer self-update && composer --version
- name: Vendor dependencies
run: composer run vendor
- name: Delete dependencies
run: rm -rf ./*/
- name: Download dependencies
run: composer install --no-dev
- name: Dump Autoload
run: composer dump-autoload
- name: Check vendor changes
run: |
bash -c "[[ ! \"`git status --porcelain . :!composer/installed.json :!composer/installed.php :!composer/package-versions-deprecated/src/PackageVersions/Versions.php `\" ]] || ( echo 'Uncommited vendor changes' && git status && git diff && exit 1 )"
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,3 @@ Some 3rd party libraries that are necessary to run Nextcloud.

[![Dependency Status](https://www.versioneye.com/user/projects/576c043fcd6d510048bab256/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/576c043fcd6d510048bab256)

## Updating composer dependencies

To check in all required changes for a new, updated or deleted dependency, you just run

```bash
composer run vendor
```

to update the files. Then you can commit all changes.
40 changes: 40 additions & 0 deletions brick/math/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="3.8.5@e6ec5fa22a7b9e61670a24d07b3119aff80dcd89">
<file src="src/Internal/Calculator/BcMathCalculator.php">
<InvalidNullableReturnType occurrences="3">
<code>string</code>
<code>string</code>
<code>string</code>
</InvalidNullableReturnType>
<InvalidReturnStatement occurrences="1">
<code>[$q, $r]</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>array</code>
</InvalidReturnType>
<NullableReturnStatement occurrences="3">
<code>\bcdiv($a, $b, 0)</code>
<code>\bcmod($a, $b)</code>
<code>\bcpowmod($base, $exp, $mod, 0)</code>
</NullableReturnStatement>
</file>
<file src="src/Internal/Calculator/NativeCalculator.php">
<InvalidOperand occurrences="6">
<code>$a</code>
<code>$a</code>
<code>$a</code>
<code>$b</code>
<code>$blockA</code>
<code>$blockA</code>
</InvalidOperand>
<LoopInvalidation occurrences="4">
<code>$i</code>
<code>$i</code>
<code>$i</code>
<code>$j</code>
</LoopInvalidation>
<PossiblyInvalidArgument occurrences="1">
<code>$e / 2</code>
</PossiblyInvalidArgument>
</file>
</files>
56 changes: 56 additions & 0 deletions brick/math/psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<InternalMethod errorLevel="info" />
<InternalProperty errorLevel="info" />
<InternalClass errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />

<InvalidStringClass errorLevel="info" />
</issueHandlers>
</psalm>
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,5 @@
"symfony/routing": "4.4.25",
"symfony/translation": "4.4.25",
"web-auth/webauthn-lib": "^3.1"
},
"scripts": {
"vendor": "composer install --no-dev && git clean -xdf && composer dump-autoload"
}
}
113 changes: 102 additions & 11 deletions composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,75 @@
*/
class ClassLoader
{
/** @var ?string */
private $vendorDir;

// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr4 = array();

// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
*/
private $fallbackDirsPsr0 = array();

/** @var bool */
private $useIncludePath = false;

/**
* @var string[]
* @psalm-var array<string, string>
*/
private $classMap = array();

/** @var bool */
private $classMapAuthoritative = false;

/**
* @var bool[]
* @psalm-var array<string, bool>
*/
private $missingClasses = array();

/** @var ?string */
private $apcuPrefix;

/**
* @var self[]
*/
private static $registeredLoaders = array();

/**
* @param ?string $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}

/**
* @return string[]
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
Expand All @@ -75,28 +120,47 @@ public function getPrefixes()
return array();
}

/**
* @return array[]
* @psalm-return array<string, array<int, string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}

/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}

/**
* @return array[]
* @psalm-return array<string, string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}

/**
* @return string[] Array of classname => path
* @psalm-var array<string, string>
*/
public function getClassMap()
{
return $this->classMap;
}

/**
* @param array $classMap Class to filename map
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
*
* @return void
*/
public function addClassMap(array $classMap)
{
Expand All @@ -111,9 +175,11 @@ public function addClassMap(array $classMap)
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
Expand Down Expand Up @@ -156,11 +222,13 @@ public function add($prefix, $paths, $prepend = false)
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
Expand Down Expand Up @@ -204,8 +272,10 @@ public function addPsr4($prefix, $paths, $prepend = false)
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
Expand All @@ -220,10 +290,12 @@ public function set($prefix, $paths)
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
Expand All @@ -243,6 +315,8 @@ public function setPsr4($prefix, $paths)
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
Expand All @@ -265,6 +339,8 @@ public function getUseIncludePath()
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
Expand All @@ -285,6 +361,8 @@ public function isClassMapAuthoritative()
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
Expand All @@ -305,6 +383,8 @@ public function getApcuPrefix()
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
Expand All @@ -324,6 +404,8 @@ public function register($prepend = false)

/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
Expand Down Expand Up @@ -403,6 +485,11 @@ public static function getRegisteredLoaders()
return self::$registeredLoaders;
}

/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
Expand Down Expand Up @@ -474,6 +561,10 @@ private function findFileWithExtension($class, $ext)
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{
Expand Down

0 comments on commit 40760a4

Please sign in to comment.