[PHP 7.2] My fix for «Declaration of Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)»

php7
bug
bug-fix
php72
php72-declaration-must-be-compatible

(Dmitry Fedyuk) #1

Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country::getAllOptions():

Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country really inherits from Magento\Eav\Model\Entity\Attribute\Source\Table:

Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions():


[PHP 7.2] My fix for «Declaration of Magento\Customer\Model\Customer\Attribute\Source\Website::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)»
[PHP 7.2] My fix for «Declaration of Magento\Customer\Model\ResourceModel\Address\Attribute\Source\CountryWithWebsites::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions»
How to adapt Magento 2 to PHP 7.2?
[PHP 7.2] My fix for «Declaration of Magento\Directory\Model\Config\Source\Country\Full::toOptionArray($isMultiselect = false) must be compatible with Magento\Directory\Model\Config\Source\Country::toOptionArray»
[PHP 7.2] My fix for «Declaration of Magento\Eav\Model\Entity\Attribute\Source\Store::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)»
[PHP 7.2] My fix for «Declaration of Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)»
[PHP 7.2] My fix for «Declaration of Magento\Tax\Model\System\Config\Source\Tax\Country::toOptionArray($noEmpty = false) must be compatible with Magento\Directory\Model\Config\Source\Country::toOptionArray»
[PHP 7.2] My fix for «Declaration of Magento\Customer\Model\Customer\Attribute\Source\Group::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)»
[PHP 7.2] My fix for «Declaration of Magento\Customer\Model\Customer\Attribute\Source\Store::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)»
(Dmitry Fedyuk) #2

The fact that PHP < 7.2 accepted this was an unintentional side-effect.

bugs.php.net/bug.php?id=75590#1512772457


(Dmitry Fedyuk) #3

My fix

Replace the line:

with the following one:

public function getAllOptions($withEmpty = true, $defaultValues = false)

(Dmitry Fedyuk) #4

See also: