Skip to content

Commit

Permalink
Revert "xdebug and phpunit upgrade"
Browse files Browse the repository at this point in the history
This reverts commit 01fe626.
  • Loading branch information
k-samuel committed Nov 21, 2024
1 parent 01fe626 commit 23d5b82
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 54 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
}
},
"require-dev": {
"phpunit/phpunit": "^11",
"phpstan/phpstan": "^2",
"phpunit/phpunit": "^9",
"phpstan/phpstan": "^1",
"codacy/coverage": "dev-master",
"phpbench/phpbench": "^1.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/ExcludeFilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface ExcludeFilterInterface extends FilterInterface
/**
* Add records into exclude list
* @param array<int|string,array<int>|\SplFixedArray<int>> $facetedData
* @param array<int,bool|int> &$excludeRecords - RecordId passed into keys of an array (performance issue)
* @param array<int,bool|int> & $excludeRecords - RecordId passed into keys of an array (performance issue)
* @return void
*/
public function addExcluded(array $facetedData, array &$excludeRecords): void;
Expand Down
5 changes: 1 addition & 4 deletions src/Filter/ExcludeRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
class ExcludeRangeFilter extends RangeFilter implements ExcludeFilterInterface
{
/**
* @inheritdoc
* @inheritDoc
*/
public function addExcluded(array $facetedData, array &$excludeRecords): void
{
Expand All @@ -61,9 +61,6 @@ public function addExcluded(array $facetedData, array &$excludeRecords): void
continue;
}
foreach ($records as $item) {
/**
* @var int $item
*/
$excludeRecords[$item] = true;
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/Filter/ExcludeValueFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ public function addExcluded(array $facetedData, array &$excludeRecords): void
}

foreach ($facetedData[$item] as $recId) {
/**
* @var int $recId
*/
$excludeRecords[$recId] = true;
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/Filter/RangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ public function filterInput(array $facetedData, array &$inputIdKeys, array $exc

if (empty($inputIdKeys)) {
foreach ($limit as $v) {
/**
* @var int $v
*/
$inputIdKeys[$v] = true;
}
return;
Expand All @@ -116,9 +113,6 @@ public function filterInput(array $facetedData, array &$inputIdKeys, array $exc
// Reuse of input data. Set mark "2" for the data that needs to be in result.
foreach ($limit as $index) {
if (isset($inputIdKeys[$index])) {
/**
* @var int $index
*/
$inputIdKeys[$index] = 2;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/ValueFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
class ValueFilter extends AbstractFilter
{
/**
* @var array<int|mixed,mixed>
* @var array<int,mixed>
*/
protected $value;

Expand Down
3 changes: 3 additions & 0 deletions src/Index/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ final class Factory

public function create(string $storage): IndexInterface
{
/**
* @var StorageInterface $store
*/
$store = new $storage;

if (!$store instanceof StorageInterface) {
Expand Down
20 changes: 7 additions & 13 deletions src/Index/Storage/ArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ class ArrayStorage implements StorageInterface
{
/**
* Index data
* @var array<int|string,array<int|string,array<int,int>>>
* @var array<int|string,array<int|string,array<int>>>
*/
protected array $data = [];
/**
* @var array<int|string, IndexerInterface>
* @var array<int|string,IndexerInterface>
*/
protected array $indexers = [];

/**
* Add record to index
* @param int $recordId
* @param array<int|string,mixed|array<int,mixed>> $recordValues - ['fieldName'=>'fieldValue','fieldName2'=>['val1','val2']]
* @param array<int|string,array<int,mixed>> $recordValues - ['fieldName'=>'fieldValue','fieldName2'=>['val1','val2']]
* @return bool
*/
public function addRecord(int $recordId, array $recordValues): bool
Expand All @@ -68,10 +68,6 @@ public function addRecord(int $recordId, array $recordValues): bool
if (!isset($this->data[$fieldName])) {
$this->data[$fieldName] = [];
}

/**
* @phpstan-ignore-next-line
*/
if (!$this->indexers[$fieldName]->add($this->data[$fieldName], $recordId, $values)) {
return false;
}
Expand All @@ -92,21 +88,20 @@ public function addRecord(int $recordId, array $recordValues): bool

/**
* Get facet data.
* @return array<int|string,array<int|string,array<int,int>|\SplFixedArray<int>>>
* @return array<int|string,array<int|string,array<int>|\SplFixedArray<int>>>
*/
public function getData(): array
{
return $this->data;
}

/**
* Get facet data.
* @return array<int|string,array<int|string,array<int,int>>>
* Get facet data.
* @return array<int|string,array<int|string,array<int>>>
*/
public function export(): array
{
foreach ($this->indexers as $fieldName => $item) {
// @phpstan-ignore-next-line
$item->optimize($this->data[$fieldName]);
}

Expand All @@ -115,7 +110,7 @@ public function export(): array

/**
* Set index data. Can be used for restoring from DB
* @param array<int|string,array<int|string,array<int,int>>> $data
* @param array<int|string,array<int|string,array<int>>> $data
*/
public function setData(array $data): void
{
Expand Down Expand Up @@ -195,7 +190,6 @@ protected function getValuesCount(): array
public function optimize(): void
{
foreach ($this->indexers as $fieldName => $item) {
// @phpstan-ignore-next-line
$item->optimize($this->data[$fieldName]);
}

Expand Down
9 changes: 4 additions & 5 deletions src/Index/Storage/FixedArrayStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FixedArrayStorage extends ArrayStorage

/**
* Get index data. Can be used for storing it to DB
* @return array<int|string,array<int|string,array<int,int>>>
* @return array<int|string,array<int|string,array<int>>>
*/
public function export(): array
{
Expand All @@ -54,11 +54,10 @@ public function export(): array
}

foreach ($this->indexers as $fieldName => $item) {
// @phpstan-ignore-next-line
$item->optimize($this->data[$fieldName]);
}
/**
* @var array<int|string,array<int|string,array<int,int>>>
* @var array<int|string,array<int|string,array<int>>>
*/
return $this->data;
}
Expand All @@ -70,7 +69,7 @@ public function writeMode(): void
{
foreach ($this->data as &$value) {
/**
* @var array<int,int>|\SplFixedArray<int> $recordList
* @var \SplFixedArray<int> $recordList
*/
foreach ($value as &$recordList) {
if ($recordList instanceof \SplFixedArray) {
Expand All @@ -90,7 +89,7 @@ public function convert(): void
{
foreach ($this->data as &$value) {
/**
* @var array<int,int>|\SplFixedArray<int> $recordList
* @var array<int>|\SplFixedArray<int> $recordList
*/
foreach ($value as &$recordList) {
if (is_array($recordList)) {
Expand Down
10 changes: 5 additions & 5 deletions src/Index/Storage/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function findRecordsMap(StorageInterface $storage, array $filters, array
return [];
}
}
// @phpstan-ignore return.type

return $inputRecords;
}

Expand All @@ -87,7 +87,6 @@ public function findExcludeRecordsMap(StorageInterface $storage, array $filters,
foreach ($filters as $filter) {
$fieldName = $filter->getFieldName();
if (isset($data[$fieldName])) {
// @phpstan-ignore-next-line
$filter->addExcluded($data[$fieldName], $excludeRecords);
}
}
Expand Down Expand Up @@ -140,9 +139,6 @@ private function findInput(StorageInterface $storage, array $inputRecords, array
*/
public function getAllRecordIdMap(StorageInterface $storage): array
{
/**
* @var array<int,bool> $result
*/
$result = [];
/**
* @var array<int|string,array<int>>$values
Expand All @@ -154,6 +150,10 @@ public function getAllRecordIdMap(StorageInterface $storage): array
}
}
}
/**
* @var array<int,bool> $result
*/

return $result;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion src/Indexer/IndexerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function add(array &$indexContainer, int $recordId, array $values): bool;

/**
* Optimize data structures
* @param array<int|string,array<int|string,array<int,int>>> &$indexContainer
* @param array<int|string,array<int|string,array<int>>> &$indexContainer
* @return void
*/
public function optimize(array &$indexContainer): void;
Expand Down
14 changes: 7 additions & 7 deletions src/Indexer/Number/RangeIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@

class RangeIndexer implements IndexerInterface
{

/**
* @var int
*/
protected int $step;

protected bool $hasUnsorted = false;
/**
* New values for sorting
* @var array<int|string,array<int|string,array<int,int>>>
* @var array<int|string,array<int|string,array<int>>>
*/
protected array $unsortedBuf = [];

Expand All @@ -53,7 +55,7 @@ public function __construct(int $step)
}

/**
* @param array<int|string,array<int,int>> $indexContainer
* @param array<int|string,array<int>> $indexContainer
* @param int $recordId
* @param array<int,int|float> $values
* @return bool
Expand All @@ -76,7 +78,7 @@ public function add(&$indexContainer, int $recordId, array $values): bool
/**
* Prepare values for export
*
* @param array<int|string,array<int|string,array<int,int>>> &$indexContainer
* @param array<int|string,array<int|string,array<int>>> &$indexContainer
* @return void
*/
public function optimize(array &$indexContainer): void
Expand All @@ -87,12 +89,10 @@ public function optimize(array &$indexContainer): void

foreach ($this->unsortedBuf as $position => &$values) {
ksort($values);
foreach ($values as $ids) {
foreach ($values as $value => $ids) {
foreach ($ids as $id) {
// @phpstan-ignore-next-line
$this->addSorterId($indexContainer[$position], $id);
}
// @phpstan-ignore parameterByRef.type
$indexContainer[$position] = array_values($indexContainer[$position]);
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/Indexer/Number/RangeListIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function detectRangeKey($value): int
/**
* Prepare values for export
*
* @param array<int|string,array<int|string,array<int,int>>> &$indexContainer
* @param array<int|string,array<int|string,array<int>>> &$indexContainer
* @return void
*/
public function optimize(array &$indexContainer): void
Expand All @@ -107,12 +107,10 @@ public function optimize(array &$indexContainer): void

foreach ($this->unsortedBuf as $position => &$values) {
ksort($values);
foreach ($values as $ids) {
foreach ($values as $value => $ids) {
foreach ($ids as $id) {
// @phpstan-ignore-next-line
$this->addSorterId($indexContainer[$position], $id);
}
// @phpstan-ignore-next-line
$indexContainer[$position] = array_values($indexContainer[$position]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Index/Storage/StorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class StorageTest extends TestCase
{
static public function storeProvider(): array
public function storeProvider(): array
{
return [
[(new Factory)->create(Factory::ARRAY_STORAGE)],
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testAggregate(): void
);
}

static public function storeProvider(): array
public function storeProvider(): array
{
return [
[(new Factory)->create(Factory::ARRAY_STORAGE)],
Expand Down

0 comments on commit 23d5b82

Please sign in to comment.