laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.16k stars 10.88k forks source link

Fatal error during composer update - Illuminate\Http\Request::toArray() #34660

Closed LeVadim closed 3 years ago

LeVadim commented 3 years ago

Description:

Hello! During the composer update or composer dumpautoload I am receiving the following error message:

PHP Fatal error: Declaration of Illuminate\Http\Request::toArray() must be compatible with Symfony\Component\HttpFoundation\Request::toArray(): array in vendor/laravel/framework/src/Illuminate/Http/Request.php on line 20

In Request.php line 20:

Declaration of Illuminate\Http\Request::toArray() must be compatible with S
ymfony\Component\HttpFoundation\Request::toArray(): array

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

After I added ": array" to toArray function, the error messaged disappeared.

public function toArray():array
{
    return $this->all();
}

Can you please look into this? Thanks!

Steps To Reproduce:

composer update or composer dumpautoload

LeVadim commented 3 years ago

Seems like this commit https://github.com/symfony/http-foundation/commit/af8a5353c61d7d656768cba750e35d846228ea32 was the one to raise this issue. That Symphony added "public function toArray(): array" and now Laravel might need to add it too.

Thanks!!

AegirLeet commented 3 years ago

It seems like that change to http-foundation isn't released yet, as the latest tagged version is from a week ago. How'd you get composer to update to that version?

LeVadim commented 3 years ago

I wouldn't know, I have just run composer update and it updated. This crash was confirmed on 3 different projects. I have tried re-installing whole vendor package too. Perhaps you or someone could try if same issue is coming up on their end?

Thank you!

AegirLeet commented 3 years ago

Can you post the output of composer show symfony/http-foundation?

LeVadim commented 3 years ago

Sure

name : symfony/http-foundation descrip. : Symfony HttpFoundation Component keywords : versions : * dev-master, 5.2.x-dev type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText source : [git] https://github.com/symfony/http-foundation.git af8a5353c61d7d656768cba750e35d846228ea32 dist : [zip] https://api.github.com/repos/symfony/http-foundation/zipball/af8a5353c61d7d656768cba750e35d846228ea32 af8a5353c61d7d656768cba750e35d846228ea32 names : symfony/http-foundation

autoload psr-4 Symfony\Component\HttpFoundation\ => . exclude-from-classmap

requires php >=7.2.5 symfony/deprecation-contracts ^2.1 symfony/polyfill-mbstring ~1.1 symfony/polyfill-php80 ^1.15

requires (dev) predis/predis ~1.0 symfony/cache ^4.4|^5.0 symfony/expression-language ^4.4|^5.0 symfony/mime ^4.4|^5.0

suggests symfony/mime To use the file extension guesser

AegirLeet commented 3 years ago

versions : * dev-master, 5.2.x-dev

Well that's interesting.

Could you post the output of composer why symfony/http-foundation too?

LeVadim commented 3 years ago

Sure

laravel/framework 8.x-dev requires symfony/http-foundation (^5.1)
symfony/http-kernel dev-master requires symfony/http-foundation (^4.4|^5.0)

ahinkle commented 3 years ago

What's the output of composer show -i? Looks like you are requiring many developmental versions of packages.

LeVadim commented 3 years ago

It looks like so, perhaps I can clear dev-master packages if they are impacting?

authorizenet/authorizenet dev-master cba5827 Official PHP SDK for Authorize.Net aws/aws-sdk-php 3.158.1 AWS SDK for PHP - Use Amazon Web Services in your PHP project brick/math 0.9.1 Arbitrary-precision arithmetic library clue/stream-filter v1.5.0 A simple and modern approach to stream filtering in PHP composer/package-versions-deprecated dev-master c8c9aa8 Composer plugin that provides efficient querying for installed package versions (no runtime IO) dnoegel/php-xdg-base-dir v0.1.1 implementation of xdg base directory specification for php doctrine/inflector dev-master f2b6085 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words. doctrine/instantiator dev-master 3e7a22a A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer dev-master ec953a1 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. dragonmantank/cron-expression 3.0.1 CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due edamov/pushok 0.11.2 PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key) or certificate-based authentication egulias/email-validator dev-master 68e418e A library for validating emails against several RFCs fgrosse/phpasn1 2.1.x-dev 734e1a9 A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules. fideloper/proxy 4.4.0 Set trusted proxies for Laravel fig/http-message-util dev-master 961814e Utility classes and constants for use with PSR-7 (psr/http-message) filp/whoops 2.7.3 php error handling for cool kids firebase/php-jwt v5.2.0 A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec. fzaninotto/faker dev-master 5337ce5 Faker is a PHP library that generates fake data for you. giggsey/libphonenumber-for-php dev-master 3f630e3 PHP Port of Google's libphonenumber giggsey/locale 1.9 Locale functions required by libphonenumber-for-php google/auth v1.14.0 Google Auth Library for PHP google/cloud-core v1.39.0 Google Cloud PHP shared dependency, providing functionality useful to all components. google/cloud-storage v1.23.0 Cloud Storage Client for PHP google/cloud-vision dev-master 45179df Cloud Vision Client for PHP google/common-protos 1.3 Google API Common Protos for PHP google/crc32 v0.1.0 Various CRC32 implementations google/gax 1.4.0 Google API Core for PHP google/grpc-gcp 0.1.5 gRPC GCP library for channel management google/protobuf v3.13.0 proto library for PHP graham-campbell/result-type 1.0.x-dev 82d5052 An Implementation Of The Result Type grpc/grpc 1.30.0 gRPC library for PHP guzzlehttp/guzzle 7.0.1 Guzzle is a PHP HTTP client library guzzlehttp/promises dev-master 60d379c Guzzle promises library guzzlehttp/psr7 1.x-dev 53330f4 PSR-7 message implementation that also provides common utility methods hamcrest/hamcrest-php dev-master 8c3d0a3 This is the PHP port of Hamcrest Matchers http-interop/http-factory-guzzle 1.0.0 An HTTP Factory using Guzzle PSR7 intervention/image 2.5.1 Image handling and manipulation library with support for Laravel integration irazasyed/telegram-bot-sdk v3.3.0 The Unofficial Telegram Bot API PHP SDK jean85/pretty-package-versions dev-master a917488 A wrapper for ocramius/package-versions to get pretty versions strings kreait/clock 1.0.1 A PHP 7.0 compatible clock abstraction kreait/firebase-php 5.x-dev 9cb112f Firebase Admin SDK kreait/firebase-tokens 1.10.0 A library to work with Firebase tokens kreait/laravel-firebase 2.3.1 A Laravel package for the Firebase PHP Admin SDK laravel-notification-channels/apn v3.0.1 Apple APN Push Notification Channel laravel-notification-channels/fcm 2.1.1 FCM (Firebase Cloud Messaging) Notifications Driver for Laravel laravel/framework 8.x-dev 0bdd5c6 The Laravel Framework. laravel/helpers dev-master 9a841ea Provides backwards compatibility for helpers in the latest Laravel release. laravel/tinker 2.x-dev a25e3d7 Powerful REPL for the Laravel framework. lcobucci/jwt 3.4.x-dev 63b0d8b A simple library to work with JSON Web Token and JSON Web Signature league/commonmark 1.5.x-dev 45d47d4 Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and Github-Flavored Markdown (GFM) league/event 2.2.0 Event package league/flysystem 1.x-dev 2062a94 Filesystem abstraction: Many filesystems, one API. league/flysystem-aws-s3-v3 dev-master 92067af Flysystem adapter for the AWS S3 SDK v3.x league/mime-type-detection 1.5.0 Mime-type detection for Flysystem mjaschen/phpgeo dev-master ab40cff Simple Yet Powerful Geo Library mockery/mockery dev-master 20cab67 Mockery is a simple yet flexible PHP mock object framework monolog/monolog dev-master bbe10b1 Sends your logs to files, sockets, inboxes, databases and various web services mtdowling/jmespath.php dev-master 30dfa00 Declaratively specify how to extract elements from a JSON document myclabs/deep-copy 1.x-dev 00aba97 Create deep copies (clones) of your objects namshi/jose 7.2.3 JSON Object Signing and Encryption library for PHP. nesbot/carbon dev-master 0c4aff0 An API extension for DateTime that supports 281 different languages. nikic/php-parser v4.10.2 A PHP parser written in PHP opis/closure dev-master 4531e53 A library that can be used to serialize closures (anonymous functions) and arbitrary objects. paragonie/random_compat v9.99.99.x-dev 0947f25 PHP 5.x polyfill for random_bytes() and randomint() from PHP 7 phar-io/manifest 1.0.3 Component for reading phar.io manifest information from a PHP Archive (PHAR) phar-io/version 2.0.1 Library for handling version information and constraints php-http/client-common dev-master e37e46c Common HTTP Client implementations and tools for HTTPlug php-http/discovery 1.12.0 Finds installed HTTPlug implementations and PSR-7 message factories php-http/httplug dev-master 191a0a1 HTTPlug, the HTTP client abstraction for PHP php-http/message 1.9.0 HTTP Message related tools php-http/message-factory dev-master 597f30e Factory interfaces for PSR-7 HTTP Message php-http/promise dev-master 4c4c1f9 Promise used for asynchronous HTTP requests phpdocumentor/reflection-common dev-master cf8df60 Common reflection classes used by phpdocumentor to reflect the code structure phpdocumentor/reflection-docblock dev-master 069a785 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock. phpdocumentor/type-resolver dev-master 94f3ddc A PSR-5 based resolver of Class names, Types and Structural Element Names phpoption/phpoption dev-master 994eccc Option Type for PHP phpspec/prophecy 1.12.1 Highly opinionated mocking framework for PHP 5.3+ phpunit/php-code-coverage 7.0.10 Library that provides collection, processing, and rendering functionality for PHP code coverage information. phpunit/php-file-iterator 2.0.2 FilterIterator implementation that filters files based on a list of suffixes. phpunit/php-text-template 1.2.1 Simple template engine. phpunit/php-timer 2.1.2 Utility class for timing phpunit/php-token-stream 3.1.x-dev 995192d Wrapper around PHP's tokenizer extension. phpunit/phpunit 8.5.x-dev 684ef7b The PHP Unit Testing framework. psr/cache dev-master b9aa2cd Common interface for caching libraries psr/container dev-master b1fbdff Common Container Interface (PHP FIG PSR-11) psr/event-dispatcher dev-master 3ef040d Standard interfaces for event handling. psr/http-client dev-master 22b2ef5 Common interface for HTTP clients psr/http-factory dev-master 36fa03d Common interfaces for PSR-7 HTTP message factories psr/http-message dev-master efd67d1 Common interface for HTTP messages psr/log dev-master dd738d0 Common interface for logging libraries psr/simple-cache dev-master 5a7b96b Common interfaces for simple caching psy/psysh dev-master 2e6b273 An interactive shell for modern PHP. ralouphie/getallheaders 3.0.3 A polyfill for getallheaders. ramsey/collection 1.2.x-dev 91e16d7 A PHP 7.2+ library for representing and manipulating collections. ramsey/uuid dev-master e4562b0 A PHP library for generating and working with universally unique identifiers (UUIDs). riverline/multipart-parser 2.0.8 One class library to parse multipart content with encoding and charset support. rize/uri-template 0.3.2 PHP URI Template (RFC 6570) supports both expansion & extraction sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to sebastian/comparator 3.0.2 Provides the functionality to compare PHP values for equality sebastian/diff 3.0.2 Diff implementation sebastian/environment 4.2.3 Provides functionality to handle HHVM/PHP environments sebastian/exporter 3.1.2 Provides the functionality to export PHP variables for visualization sebastian/global-state 3.0.0 Snapshotting of global state sebastian/object-enumerator 3.0.3 Traverses array structures and object graphs to enumerate all referenced objects sebastian/object-reflector 1.1.1 Allows reflection of object attributes, including inherited and non-public ones sebastian/recursion-context 3.0.0 Provides functionality to recursively process PHP variables sebastian/resource-operations 2.0.1 Provides a list of PHP built-in functions that operate on resources sebastian/type 1.1.3 Collection of value objects that represent the types of the PHP type system sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted PHP projects sentry/sdk 3.x-dev b40c12c This is a metapackage shipping sentry/sentry with a recommended HTTP client. sentry/sentry dev-master a35c6c7 A PHP SDK for Sentry (http://sentry.io) sentry/sentry-laravel 2.0.1 Laravel SDK for Sentry (https://sentry.io) spatie/enum v2.x-dev 2464947 PHP Enums spomky-labs/base64url v2.x-dev 27171c7 Base 64 URL Safe Encoding/Decoding PHP Library stripe/stripe-php v7.27.3 Stripe PHP Library swiftmailer/swiftmailer dev-master ff832c4 Swiftmailer, free feature-rich PHP mailer symfony/console dev-master 4cd6bfc Symfony Console Component symfony/css-selector dev-master 59f93b1 Symfony CssSelector Component symfony/deprecation-contracts dev-master d940483 A generic function and convention to trigger deprecation notices symfony/error-handler dev-master 8740c9e Symfony ErrorHandler Component symfony/event-dispatcher dev-master cf7666f Symfony EventDispatcher Component symfony/event-dispatcher-contracts dev-master 5e8ae4d Generic abstractions related to dispatching event symfony/finder dev-master b5f7c0d Symfony Finder Component symfony/http-client dev-master e85bb48 Symfony HttpClient component symfony/http-client-contracts dev-master 385955d Generic abstractions related to HTTP clients symfony/http-foundation dev-master af8a535 Symfony HttpFoundation Component symfony/http-kernel dev-master 517cc55 Symfony HttpKernel Component symfony/mime dev-master 8239e12 A library to manipulate MIME messages symfony/options-resolver dev-master fed2893 Symfony OptionsResolver Component symfony/polyfill-ctype dev-master 1c30264 Symfony polyfill for ctype functions symfony/polyfill-iconv dev-master 6c2f78e Symfony polyfill for the Iconv extension symfony/polyfill-intl-grapheme dev-master b740103 Symfony polyfill for intl's grapheme* functions symfony/polyfill-intl-idn dev-master 045643b Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions symfony/polyfill-intl-normalizer dev-master 37078a8 Symfony polyfill for intl's Normalizer class and related functions symfony/polyfill-mbstring dev-master 48928d4 Symfony polyfill for the Mbstring extension symfony/polyfill-php56 dev-master 13df84e Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions symfony/polyfill-php70 dev-master 0dd93f2 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions symfony/polyfill-php72 dev-master dc6ef20 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions symfony/polyfill-php73 dev-master fffa1a5 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions symfony/polyfill-php80 dev-master c3616e7 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions symfony/polyfill-util dev-master 46b910c Symfony utilities for portability of PHP codes symfony/polyfill-uuid dev-master da48e2c Symfony polyfill for uuid functions symfony/process dev-master 6beca1c Symfony Process Component symfony/property-access dev-master aa0883b Symfony PropertyAccess Component symfony/property-info dev-master feb7cf2 Symfony Property Info Component symfony/routing dev-master 72d46a4 Symfony Routing Component symfony/serializer dev-master ca1aa48 Symfony Serializer Component symfony/service-contracts dev-master 90388a3 Generic abstractions related to writing services symfony/string dev-master 4dfc0b2 Symfony String component symfony/thanks dev-master 733cc7b Encourages sending ⭐ and 💵 to fellow PHP package maintainers (not limited to Symfony components)! symfony/translation dev-master 1ee3299 Symfony Translation Component symfony/translation-contracts dev-master e2eaa60 Generic abstractions related to translation symfony/var-dumper dev-master 61d516c Symfony mechanism for exploring and dumping PHP variables theseer/tokenizer 1.2.0 A small library for converting tokenized PHP source code into XML and potentially other formats tijsverkoyen/css-to-inline-styles dev-master b43b05c CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails. twilio/sdk 5.42.2 A PHP wrapper for Twilio's API tymon/jwt-auth 1.0.x-dev b927137 JSON Web Token Authentication for Laravel and Lumen vlucas/phpdotenv dev-master fba6413 Loads environment variables from .env to getenv(), $_ENV and $_SERVER automagically. voku/portable-ascii 1.5.3 Portable ASCII library - performance optimized (ascii) string functions for php. web-token/jwt-core v2.2.x-dev 8115d84 Core component of the JWT Framework. web-token/jwt-key-mgmt v2.2.x-dev 03fafa1 Key Management component of the JWT Framework. web-token/jwt-signature v2.2.x-dev f4d83f7 Signature component of the JWT Framework. web-token/jwt-signature-algorithm-ecdsa v2.2.x-dev 3ae6e56 ECDSA Based Signature Algorithms the JWT Framework. webmozart/assert 1.9.1 Assertions to validate method input/output with nice error messages.

AegirLeet commented 3 years ago

You should definitely stick to stable versions instead of dev-*. That should solve the issue for now.

Still, I think Laravel will have to restrict symfony/http-foundation to <5.2.0 for now to prevent this from becoming a problem once they release this change as 5.2.0. I'll submit a PR.

LeVadim commented 3 years ago

How can i clear dev-*?

Thank you

AegirLeet commented 3 years ago

I'm not sure how you got those into your project in the first place. Generally speaking, you can use composer why <package name> to figure out why a package is being pulled in. So when you do composer why symfony/http-foundation and it shows you package foo/bar is pulling in dev-*, you can then do composer why foo/bar to figure out why that is being pulled in etc. - until you've found the root cause.

Try composer why -r symfony/http-foundation too. Haven't tested it, but that might show you the root cause directly.

GrahamCampbell commented 3 years ago

Please open an issue with symfony to let them know of this accidental breaking change they have made.

LeVadim commented 3 years ago

Adding dependency in composer.json fixes the problem. "symfony/http-foundation": "5.1.0"

Thank you for prompt responses!

GrahamCampbell commented 3 years ago

Will be fixed by https://github.com/symfony/symfony/pull/38403. :)

LeVadim commented 3 years ago

Perfect, thank you!