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

PHP Fatal error: strict_types declaration must be the very first statement in the script #4848

Closed
duri0214 opened this issue Dec 25, 2021 · 1 comment
Labels
type/bug Something is broken

Comments

@duri0214
Copy link

Q A
PHPUnit version 9.5.10
PHP version 7.3
Installation Method Composer / PHAR

Summary

Changing the declaration location will fix it

#!/usr/bin/env php
<?php declare(strict_types=1);

to

<?php declare(strict_types=1);
#!/usr/bin/env php
dev\ci4_batches> php batches/vendor/bin/phpunit --version
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

PS D:\OneDrive\dev\ci4_batches> php batches/vendor/bin/phpunit --list-suite 
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Usage:
  phpunit [options] UnitTest.php
  phpunit [options] <directory>

Code Coverage Options:
  --coverage-clover <file>    Generate code coverage report in Clover XML format
  --coverage-cobertura <file> Generate code coverage report in Cobertura XML format

Current behavior

dev\ci4_batches> php batches/vendor/bin/phpunit --list-suites
  PHP Fatal error:  strict_types declaration must be the very first statement in the script in D:\OneDrive\dev\ci4_batches\batches\vendor\phpunit\phpunit\phpunit on line 2

  Fatal error: strict_types declaration must be the very first statement in the script in D:\OneDrive\dev\ci4_batches\batches\vendor\phpunit\phpunit\phpunit on line 2

How to reproduce

enter the command

dev\ci4_batches> php batches/vendor/bin/phpunit --list-suites

Expected behavior

I want list available test suites.
Why is the usage output?.

composer info | sort

PS D:\OneDrive\dev\ci4_batches\batches> composer info | sort
codeigniter4/framework             v4.1.5  The CodeIgniter framework v4
doctrine/instantiator              1.4.0   A small, lightweight utility to instantiate objects in PHP wit...     
ezyang/htmlpurifier                v4.13.0 Standards compliant HTML filter written in PHP
fakerphp/faker                     v1.17.0 Faker is a PHP library that generates fake data for you.
kint-php/kint                      3.3     Kint - debugging tool for PHP developers
laminas/laminas-escaper            2.9.0   Securely and safely escape HTML, HTML attributes, JavaScript, ...     
maennchen/zipstream-php            2.1.0   ZipStream is a library for dynamically streaming dynamic zip f...     
markbaker/complex                  3.0.1   PHP Class for working with complex numbers
markbaker/matrix                   3.0.0   PHP Class for working with matrices
mikey179/vfsstream                 v1.6.10 Virtual file system to mock the real file system in unit tests.       
myclabs/deep-copy                  1.10.2  Create deep copies (clones) of your objects
myclabs/php-enum                   1.8.3   PHP Enum implementation
nikic/php-parser                   v4.13.2 A PHP parser written in PHP
phar-io/manifest                   2.0.3   Component for reading phar.io manifest information from a PHP ...     
phar-io/version                    3.1.0   Library for handling version information and constraints
phpdocumentor/reflection-common    2.2.0   Common reflection classes used by phpdocumentor to reflect the...     
phpdocumentor/reflection-docblock  5.3.0   With this component, a library can provide support for annotat...     
phpdocumentor/type-resolver        1.5.1   A PSR-5 based resolver of Class names, Types and Structural El...     
phpoffice/phpspreadsheet           1.20.0  PHPSpreadsheet - Read, Create and Write Spreadsheet documents ...     
phpspec/prophecy                   v1.15.0 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          9.2.10  Library that provides collection, processing, and rendering fu...     
phpunit/php-file-iterator          3.0.6   FilterIterator implementation that filters files based on a li...     
phpunit/php-invoker                3.1.1   Invoke callables with a timeout
phpunit/php-text-template          2.0.4   Simple template engine.
phpunit/php-timer                  5.0.3   Utility class for timing
phpunit/phpunit                    9.5.10  The PHP Unit Testing framework.
psr/container                      2.0.2   Common Container Interface (PHP FIG PSR-11)
psr/http-client                    1.0.1   Common interface for HTTP clients
psr/http-factory                   1.0.1   Common interfaces for PSR-7 HTTP message factories
psr/http-message                   1.0.1   Common interface for HTTP messages
psr/log                            1.1.4   Common interface for logging libraries
psr/simple-cache                   1.0.1   Common interfaces for simple caching
sebastian/cli-parser               1.0.1   Library for parsing CLI options
sebastian/code-unit                1.0.8   Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3   Looks up which function or method a line of code belongs to
sebastian/comparator               4.0.6   Provides the functionality to compare PHP values for equality
sebastian/complexity               2.0.2   Library for calculating the complexity of PHP code units
sebastian/diff                     4.0.4   Diff implementation
sebastian/environment              5.1.3   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 4.0.4   Provides the functionality to export PHP variables for visuali...     
sebastian/global-state             5.0.3   Snapshotting of global state
sebastian/lines-of-code            1.0.3   Library for counting the lines of code in PHP source code
sebastian/object-enumerator        4.0.4   Traverses array structures and object graphs to enumerate all ...     
sebastian/object-reflector         2.0.4   Allows reflection of object attributes, including inherited an...     
sebastian/recursion-context        4.0.4   Provides functionality to recursively process PHP variables
sebastian/resource-operations      3.0.3   Provides a list of PHP built-in functions that operate on reso...     
sebastian/type                     2.3.4   Collection of value objects that represent the types of the PH...     
sebastian/version                  3.0.2   Library that helps with managing the version number of Git-hos...     
symfony/deprecation-contracts      v2.5.0  A generic function and convention to trigger deprecation notices      
symfony/polyfill-ctype             v1.23.0 Symfony polyfill for ctype functions
symfony/polyfill-mbstring          v1.23.1 Symfony polyfill for the Mbstring extension
tecnickcom/tcpdf                   6.4.2   TCPDF is a PHP class for generating PDF documents and barcodes.       
theseer/tokenizer                  1.2.1   A small library for converting tokenized PHP source code into ...     
webmozart/assert                   1.10.0  Assertions to validate method input/output with nice error mes...     
PS D:\OneDrive\dev\ci4_batches\batches>
@duri0214 duri0214 added the type/bug Something is broken label Dec 25, 2021
@sebastianbergmann
Copy link
Owner

Duplicate of composer/composer#10387 (fixed by composer/composer@7d1ca1f and #4846).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is broken
Projects
None yet
Development

No branches or pull requests

2 participants