shochdoerfer
Repos
54
Followers
124
Following
105

Magento specific extension for PHPStan

88
19

Force Customer Login Module for Magento 2

153
64

Simple Logging Facade for Loggers implementing PSR-3 logging interface.

3
2

PSR-11 compatible Dependency Injection Container for PHP.

137
17

Events

Generated class ProductExtension is passed on incorrectly to phpstan

Hi there! Just updated from v0.23.1 (and phpstan 1.7) to v0.24.0 (and phpstan 1.8). Since the update I'm getting the following error when running phpstan:

Child process error (exit code 255): PHP Fatal error:  Declaration of      
     Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array            
     $websiteIds) must be compatible with                                       
     Magento\Catalog\Api\Data\ProductExtensionInterface::setWebsiteIds($websit  
     eIds) in                                                                   
     /tmp/phpstan/cache/PHPStan/95/c3/95c3cd23c340083ec99b41a2ad173115a2e32d1c  
     .php on line 109                                                           
     Fatal error: Declaration of                                                
     Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array            
     $websiteIds) must be compatible with                                       
     Magento\Catalog\Api\Data\ProductExtensionInterface::setWebsiteIds($websit  
     eIds) in                                                                   
     /tmp/phpstan/cache/PHPStan/95/c3/95c3cd23c340083ec99b41a2ad173115a2e32d1c  
     .php on line 109             

Those are two generated classes from Magento: ProductExtensionInterface

<?php
namespace Magento\Catalog\Api\Data;

/**
 * ExtensionInterface class for @see \Magento\Catalog\Api\Data\ProductInterface
 */
interface ProductExtensionInterface extends \Magento\Framework\Api\ExtensionAttributesInterface
{
    /**
     * @return int[]|null
     */
    public function getWebsiteIds();

    /**
     * @param int[] $websiteIds
     * @return $this
     */
    public function setWebsiteIds($websiteIds);

ProductExtension

<?php
namespace Magento\Catalog\Api\Data;

/**
 * Extension class for @see \Magento\Catalog\Api\Data\ProductInterface
 */
class ProductExtension extends \Magento\Framework\Api\AbstractSimpleObject implements ProductExtensionInterface
{
    /**
     * @return int[]|null
     */
    public function getWebsiteIds()
    {
        return $this->_get('website_ids');
    }

    /**
     * @param int[] $websiteIds
     * @return $this
     */
    public function setWebsiteIds($websiteIds)
    {
        $this->setData('website_ids', $websiteIds);
        return $this;
    }

As we can see both classes are generated correctly. In the error message it says that Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array $websiteIds) must be compatible with its interface declaration but in the actual code there is no typed parameter ?array so it has to be somehow generated and passed to phpstan virtually.

FYI: I deleted the phpstan cache before running phpstan.

Created at 6 hours ago
Generated class ProductExtension is passed on incorrectly to phpstan

I've just published version 0.25.0 of the extension.

Created at 6 hours ago
shochdoerfer create tag v0.25.0
Created at 6 hours ago
shochdoerfer create branch release/r0.25.0
Created at 6 hours ago

Make code compatible with PHP 7.2

Merge pull request #273 from shochdoerfer/fix/php72_compatibility

Make code compatible with PHP 7.2

Don't use ?array type hint in ext attributes

Remove param type hints from generated classes

Merge pull request #274 from shochdoerfer/fix/ext_attr_array

Don't use ?array type hint in ext attributes

Restructure the docs

Merge pull request #275 from shochdoerfer/fix/optimize_docs

Restructure the docs

Update Changelog file

Created at 6 hours ago

Update Changelog file

Created at 6 hours ago
pull request closed
Restructure the docs
Created at 6 hours ago

Restructure the docs

Merge pull request #275 from shochdoerfer/fix/optimize_docs

Restructure the docs

Created at 6 hours ago
pull request opened
Restructure the docs
Created at 6 hours ago
shochdoerfer create branch fix/optimize_docs
Created at 6 hours ago
Created at 1 day ago
Generated class ProductExtension is passed on incorrectly to phpstan

@oneserv-heuser @norgeindian I found the source of the issue. I went a bit far when adding type hints to the generated classes. The PR reverted this. To simplify your testing effort, I merged the changes already in dev-master. Could you guys please check if things are working for you again?

@torhoehn could you also check if your issue in regards of the array handling still does work with dev-master?

Created at 1 day ago
reopened issue
Generated class ProductExtension is passed on incorrectly to phpstan

Hi there! Just updated from v0.23.1 (and phpstan 1.7) to v0.24.0 (and phpstan 1.8). Since the update I'm getting the following error when running phpstan:

Child process error (exit code 255): PHP Fatal error:  Declaration of      
     Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array            
     $websiteIds) must be compatible with                                       
     Magento\Catalog\Api\Data\ProductExtensionInterface::setWebsiteIds($websit  
     eIds) in                                                                   
     /tmp/phpstan/cache/PHPStan/95/c3/95c3cd23c340083ec99b41a2ad173115a2e32d1c  
     .php on line 109                                                           
     Fatal error: Declaration of                                                
     Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array            
     $websiteIds) must be compatible with                                       
     Magento\Catalog\Api\Data\ProductExtensionInterface::setWebsiteIds($websit  
     eIds) in                                                                   
     /tmp/phpstan/cache/PHPStan/95/c3/95c3cd23c340083ec99b41a2ad173115a2e32d1c  
     .php on line 109             

Those are two generated classes from Magento: ProductExtensionInterface

<?php
namespace Magento\Catalog\Api\Data;

/**
 * ExtensionInterface class for @see \Magento\Catalog\Api\Data\ProductInterface
 */
interface ProductExtensionInterface extends \Magento\Framework\Api\ExtensionAttributesInterface
{
    /**
     * @return int[]|null
     */
    public function getWebsiteIds();

    /**
     * @param int[] $websiteIds
     * @return $this
     */
    public function setWebsiteIds($websiteIds);

ProductExtension

<?php
namespace Magento\Catalog\Api\Data;

/**
 * Extension class for @see \Magento\Catalog\Api\Data\ProductInterface
 */
class ProductExtension extends \Magento\Framework\Api\AbstractSimpleObject implements ProductExtensionInterface
{
    /**
     * @return int[]|null
     */
    public function getWebsiteIds()
    {
        return $this->_get('website_ids');
    }

    /**
     * @param int[] $websiteIds
     * @return $this
     */
    public function setWebsiteIds($websiteIds)
    {
        $this->setData('website_ids', $websiteIds);
        return $this;
    }

As we can see both classes are generated correctly. In the error message it says that Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array $websiteIds) must be compatible with its interface declaration but in the actual code there is no typed parameter ?array so it has to be somehow generated and passed to phpstan virtually.

FYI: I deleted the phpstan cache before running phpstan.

Created at 1 day ago
Generated class ProductExtension is passed on incorrectly to phpstan

Hi there! Just updated from v0.23.1 (and phpstan 1.7) to v0.24.0 (and phpstan 1.8). Since the update I'm getting the following error when running phpstan:

Child process error (exit code 255): PHP Fatal error:  Declaration of      
     Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array            
     $websiteIds) must be compatible with                                       
     Magento\Catalog\Api\Data\ProductExtensionInterface::setWebsiteIds($websit  
     eIds) in                                                                   
     /tmp/phpstan/cache/PHPStan/95/c3/95c3cd23c340083ec99b41a2ad173115a2e32d1c  
     .php on line 109                                                           
     Fatal error: Declaration of                                                
     Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array            
     $websiteIds) must be compatible with                                       
     Magento\Catalog\Api\Data\ProductExtensionInterface::setWebsiteIds($websit  
     eIds) in                                                                   
     /tmp/phpstan/cache/PHPStan/95/c3/95c3cd23c340083ec99b41a2ad173115a2e32d1c  
     .php on line 109             

Those are two generated classes from Magento: ProductExtensionInterface

<?php
namespace Magento\Catalog\Api\Data;

/**
 * ExtensionInterface class for @see \Magento\Catalog\Api\Data\ProductInterface
 */
interface ProductExtensionInterface extends \Magento\Framework\Api\ExtensionAttributesInterface
{
    /**
     * @return int[]|null
     */
    public function getWebsiteIds();

    /**
     * @param int[] $websiteIds
     * @return $this
     */
    public function setWebsiteIds($websiteIds);

ProductExtension

<?php
namespace Magento\Catalog\Api\Data;

/**
 * Extension class for @see \Magento\Catalog\Api\Data\ProductInterface
 */
class ProductExtension extends \Magento\Framework\Api\AbstractSimpleObject implements ProductExtensionInterface
{
    /**
     * @return int[]|null
     */
    public function getWebsiteIds()
    {
        return $this->_get('website_ids');
    }

    /**
     * @param int[] $websiteIds
     * @return $this
     */
    public function setWebsiteIds($websiteIds)
    {
        $this->setData('website_ids', $websiteIds);
        return $this;
    }

As we can see both classes are generated correctly. In the error message it says that Magento\Catalog\Api\Data\ProductExtension::setWebsiteIds(?array $websiteIds) must be compatible with its interface declaration but in the actual code there is no typed parameter ?array so it has to be somehow generated and passed to phpstan virtually.

FYI: I deleted the phpstan cache before running phpstan.

Created at 1 day ago

Don't use ?array type hint in ext attributes

Remove param type hints from generated classes

Merge pull request #274 from shochdoerfer/fix/ext_attr_array

Don't use ?array type hint in ext attributes

Created at 1 day ago
pull request closed
Don't use ?array type hint in ext attributes

Should fix #272

Created at 1 day ago

Remove param type hints from generated classes

Created at 1 day ago
Created at 2 days ago
issue comment
PHP 8 and attributes

Does not look like anyone wants to drive this forward anymore ;(

There's a new kid on the block that might be interesting for those of you looking for a PHP8 version of Disco that makes use of attributes: https://github.com/giuseppe998e/syringe

Created at 2 days ago
Created at 2 days ago
Generated class ProductExtension is passed on incorrectly to phpstan

Getting closer to the real issue. Looks like with #248 I went a bit too far with adding the type hints. Will do some more tests and hopefully come up with a fix soonish.

Created at 4 days ago
Generated class ProductExtension is passed on incorrectly to phpstan

@oneserv-heuser sorry man, not exactly sure what is going on. Are you at mageuc22 by any chance? Maybe we can have a chat or you could even show me your code.

Created at 6 days ago
started
Created at 1 week ago
started
Created at 1 week ago
Generated class ProductExtension is passed on incorrectly to phpstan

@oneserv-heuser @norgeindian could you people please test #274 and report back it that works for your use-cases?

@torhoehn I might need to roll back the array extension modification, your code example looked different than reported here. Do you remember which Magento & PHP version you were using? Mind also checking if the fix in #274 works for you?

Created at 1 week ago
pull request opened
Don't use ?array type hint in ext attributes

Should fix #272

Created at 1 week ago
shochdoerfer create branch fix/ext_attr_array
Created at 1 week ago
Created at 2 weeks ago
Created at 2 weeks ago