Skip to content
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

[Psalm] Introduce Psaml Tests for Components #1727

Merged
merged 18 commits into from
Sep 27, 2021
Merged
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
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ jobs:
cp -f config/packages/stan/config.yaml config/packages/dev/config.yaml
bin/console cache:clear --env=dev
vendor/bin/phpstan analyse -c phpstan.neon src -l 3

- name: PSALM
run: |
vendor/bin/psalm
24 changes: 13 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,20 @@
"require": {
"ext-json": "*",
"dachcom-digital/emailizr": "^2.0.0",
"doctrine/data-fixtures": "^1.0",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/data-fixtures": "^1.5",
"doctrine/orm": "^2.9",
"fzaninotto/faker": "^1.6",
"gedmo/doctrine-extensions": "^3.0.0",
"jms/serializer-bundle": "^3.7",
"knplabs/knp-menu-bundle": "^3.0.0",
"laminas/laminas-stdlib": "^3.3.1",
"sylius/theme-bundle": "^2.1",
"gedmo/doctrine-extensions": "^3.1.0",
"jms/serializer-bundle": "^3.10",
"knplabs/knp-menu-bundle": "^3.1",
"laminas/laminas-stdlib": "^3.6",
"sylius/theme-bundle": "^2.2",
"php-http/guzzle7-adapter": "^0.1",
"pimcore/pimcore": "^10.1",
"rinvex/countries": "^7.0",
"stof/doctrine-extensions-bundle": "^1.5",
"webmozart/assert": "^1.2",
"rinvex/countries": "^7.3",
"stof/doctrine-extensions-bundle": "^1.6",
"webmozart/assert": "^1.10",
"payum/payum": "dev-master",
"payum/payum-bundle": "dev-master"
},
Expand All @@ -116,7 +117,8 @@
"phpunit/phpunit": "^9.5",
"robertfausk/behat-panther-extension": "^1.0",
"symfony/panther": "^1.0",
"dbrekelmans/bdi": "^0.3.0"
"dbrekelmans/bdi": "^0.3.0",
"vimeo/psalm": "^4.10"
},
"suggest": {
"dpfaffenbauer/process-manager": "Allows to start Processes from within Pimcore UI and also tracks the status."
Expand Down
1 change: 0 additions & 1 deletion config/system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pimcore:
general:
timezone: Europe/Berlin
path_variable: ''
domain: pimcore-test.dev
redirect_to_maindomain: false
language: en
valid_languages: 'en,de'
Expand Down
25 changes: 0 additions & 25 deletions docs/02_Components/Pimcore_Component.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,31 +154,6 @@ use CoreShop\Component\Pimcore\Migration\SharedTranslation;
SharedTranslation::add('key', 'en', 'value');
```

### Routing Features

#### Link Generator
The CoreShop Link Generator is a wrapper arounds Symfony Routing Component, and helps you to easier generate routes for Pimcore Objects and Symfony Routes with one function.

```php
//Generate a route for a Pimcore Object with a Link Generator

$this->get('coreshop.link_generator')->generate($product, 'route_product', ['foo' => 'bar']);

//Generate a route for a Symfony Route or Pimcore Static Routes Route

$this->get('coreshop.link_generator')->generate(null, 'overview', ['foo' => 'bar']);
```

CoreShop also provides your with twig helpers for that:

```twig
{{ coreshop_path(product, 'coreshop_product_detail') }}

{{ coreshop_path('coreshop_cart_remove_price_rule', {'code' : priceRule.voucherCode }) }}

coreshop_path('coreshop_index')
```

### Twig Features
CoreShop adds a lot of additional twig functions to make a developers live even more enjoyable :)

Expand Down
125 changes: 125 additions & 0 deletions etc/psalm/LaminasPriorityQueueStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

// This stub is created to support Psalm generics.

/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Laminas\Stdlib;

use Countable;
use IteratorAggregate;
use Serializable;

/**
* @psalm-template T
* @template-extends IteratorAggregate<int, T>
* @template-extends ArrayAccess<int|null, T>
*/
class PriorityQueue implements Countable, IteratorAggregate, Serializable
{
const EXTR_DATA = 0x00000001;
const EXTR_PRIORITY = 0x00000002;
const EXTR_BOTH = 0x00000003;

/**
* @param mixed $data
* @param int $priority
*
* @return PriorityQueue
*
* @psalm-param T $data
* @psalm-return PriorityQueue<T>
*/
public function insert($data, $priority = 1) { }

/**
* @param mixed $datum
*
* @return bool False if the item was not found, true otherwise.
*
* @psalm-param T $datum
*/
public function remove($datum) { }

/**
* @return bool
*/
public function isEmpty() { }

/**
* @return int
*/
public function count() { }

/**
* @return mixed
*/
public function top() { }

/**
* @return mixed
*/
public function extract() { }

/**
* @return SplPriorityQueue
*
* @psalm-return SplPriorityQueue<T>
*/
public function getIterator() { }

/**
* @return string
*/
public function serialize() { }

/**
* @param string $data
*
* @return void
*/
public function unserialize($data) { }

/**
* @param int $flag
*
* @return array
*/
public function toArray($flag = self::EXTR_DATA) { }

/**
* @param string $class
*
* @return PriorityQueue
*
* @psalm-return PriorityQueue<T>
*/
public function setInternalQueueClass($class) { }

/**
* @param mixed $datum
*
* @return bool
*
* @psalm-param T $datum
*/
public function contains($datum) { }

/**
* @param int $priority
*
* @return bool
*/
public function hasPriority($priority) { }

/**
* @return void
*/
public function __clone() { }
}
1 change: 1 addition & 0 deletions phpstan-package.neon
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ parameters:
- '/unknown class LuceneSearchBundle/'
- '/typehint type LuceneSearchBundle/'
- '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)/'
- '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface/'
- '/Call to an undefined method Pimcore\\Model\\(.*)::save\(\)./'
- '/Call to an undefined method Pimcore\\Model\\(.*)::delete\(\)./'
- '/Method Pimcore\\Model\\DataObject\\Concrete::getLatestVersion\(\)\(.*\)/'
Expand Down
4 changes: 1 addition & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ parameters:
- '/Constant PIMCORE_DEVMODE not found./'
- '/Class Zend_Paginator_Adapter_Interface not found and could not be autoloaded./'

- '/Class LuceneSearchBundle/'
- '/unknown class LuceneSearchBundle/'
- '/typehint type LuceneSearchBundle/'
- '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)/'
- '/Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface/'
- '/Call to an undefined method Pimcore\\Model\\\(.*\)::save\(\)./'
- '/Call to an undefined method Pimcore\\Model\\\(.*\)::delete\(\)./'
- '/Method Pimcore\\Model\\DataObject\\Concrete::getLatestVersion\(\)(.*)/'
Expand Down
Loading