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

Fixed incorrect type-hint for parameter of type class-string. #370

Conversation

thirsch
Copy link
Collaborator

@thirsch thirsch commented Apr 4, 2024

I stumbled upon this a few times but never fixed it. Today is the day. ;-)

Copy link
Member

@thePanz thePanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
Please rebase on latest master branch and I will merge it 👍
note: this repo's config enforces a linear git history

@thirsch thirsch force-pushed the bugfix/fixed-incorrect-typehint-class-for-class-string branch from 3011b9c to 76131ab Compare April 4, 2024 20:40
@thirsch
Copy link
Collaborator Author

thirsch commented Apr 4, 2024

Thanks! Rebased. :)

@thirsch
Copy link
Collaborator Author

thirsch commented Apr 5, 2024

Thanks for both suggestions. Unfortunately, there are so many errors in the type-hints.

@thePanz
Copy link
Member

thePanz commented Apr 5, 2024

Unfortunately, there are so many errors in the type-hints.

yes, true! Thank you for taking the first steps to clean them up! 👍

@thePanz thePanz merged commit 998e779 into FriendsOfSymfony1:master Apr 5, 2024
5 checks passed
mentalstring pushed a commit to mentalstring/symfony1 that referenced this pull request Apr 12, 2024
akhumphrey added a commit to JamesAndJamesFulfilment/symfony1 that referenced this pull request Jul 1, 2024
* Add docker compose

* Add apcu for PHP 5.5+
* Disable APC on PHP 7+ as APCu 5 is not supported
* Add ability to use a custom test runtime

Co-authored-by: Thomas <[email protected]>

* Use GitHub actions for Continuous Integration tests

Remove TravisCI integration

* Fix test for /bin/ls file mimetype guessing, using application/x-pie-executable

* PHP 8.1 > internal_method_return_types
https://wiki.php.net/rfc/internal_method_return_types

PHP 8.0 added return type for abstract methods on Iterator, ArrayAccess, Countable, IteratorAggregate
PHP 8.1 made non implementation as a Deprecated Warning
PHP 9.0 (no release date at this moment) will drop the support.

Temporary Fix : adding this Attribute
Will drop the Deprecated warning.

Adding return type will break compatibility before PHP 7.4,
Return type has been added on PHP 7.0, but "mixed" special type is required, and it has been added on PHP 7.4.
In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4

Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment.

* PHP 8.1 > Serializable Phase Out
https://wiki.php.net/rfc/phase_out_serializable

PHP 7.4 add a new Serialize mecanism
PHP 8.1 made old method, "Serializable implementation" deprecated
PHP 9.0 (no release date at this moment) will drop the support.

Temporary Fix: Adding both method serialize/unserialize and __serialize/__unserialize

In order to be compatible with future PHP 9.0, once it will be release, we will have to drop the support to PHP Version before 7.4.

Currently a lot of Unix distribution in LTS are running a PHP Version older than 7.4 so moving to the final solution of "add return type" should break a lot of setup for the moment.

Each class has been serialized/unserialized and compared on PHP 8.1.2 and 5.6.30

* PHP 8.0 & 8.1 > Deprecated of null to non-nullable internal function parameters

Mainly ensure use of string instead of null / false by casting the variable into (string)
Also fix method/function arguments with default value must be at the end.

Thanks to @teymour
FriendsOfSymfony1@cba71a4

* PHP 8.1 > strftime deprecated.

2 possible workaround, use partial implementation with php date method or use IntlDateFormatter.
As symfony1 is not intended to evolve, it should not rely on currently unused PHP-Extension (nor update composer.json).

I propose a fix to replace "strftime" by "date", with a translation of format for PHP 8.1+

It will lose the ability of translating date of logs (does anybody use it ?) and it will deprecated a few strftime format (probably not used)
Performances should remains OK

I only tested it with a few formats (the default one and a few others)
If you need some missing strftime formats, please add them.

* PHP 8.1 > Unit Test

sfException> fileExcerpt file can be null, and PHP 8.1 do not allow null on is_readable()

sfBrowser> Move sf_test conf before getContext, because getContext can throw some sfException, which will raise some printStackTrace, hidden by another Exception "header already sent ..."

lime.php> some trace can have no "file" (internal methods call)
lime.php> handle_exception can handle Error/Throwable, not avaialble under php7.2: remove typing

sfTestFunctionalBase> can throw exception

Fix Select Unit test NewActivePendingExpired.
DomDocument on recent php return a list of values, not concatened ones.

Fix SessionStorage UnitTest.

sfSessionStorage could not be restarted.
Flag $sessionStarted as false when shutdown to avoid error during unit test which can start several sfSessionStorage

Storage need to be shutdown to avoid:
PHP Warning:  session_name(): Session name cannot be changed when a session is active

* Fix lime message: "An uncaught exception has been thrown" do not have "error" value

uncaught exception does not populate error field

* PHP 8.1 > uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero

* Fix ValueError: DOMDocument::loadHTML(): Argument #1 ($source) must not be empty

* PHP 8.0 > fread()/count() behavior

ValueError: fread(): Argument #2 ($length) must be greater than 0

TypeError: count(): Argument #1 ($value) must be of type Countable|array Foo Given
Use Symfony Polyfill symfony/polyfill@d330c00

TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given
Do not use Symfony pollyfill, is_array is enought

* Fix Declaration of sfPearRestTest::downloadHttp($url, $lastmodified = null, $accept = false) must be compatible with sfPearRest::downloadHttp($url, $lastmodified = null, $accept = false, $channel = false)

* PHP 8.0 > mktime update

8.0.0 	hour is no longer optional.
8.0.0 	minute, second, month, day and year are nullable now.

* Fix sfWebResponse->getContentType() return a string not an array

* Fix sfDoctrineTester, string cannot be accessed as array

* PHP 8.0 > Fix is_numeric behavior with trailing empty char
Numeric strings ending with whitespace ("42 ") will now return true. Previously, false was return instead.

Use same fix has main maintened Yaml lib :
symfony/yaml@4152e36
+ performance improvement
symfony/yaml@2b5f2ae

* PHP 8.0 > String to Number Comparison.
When $previousIndent was equal to 0, and $matches['indent'] = "    "

PHP(before 8.0)> (0 != "    ") ==> false
PHP8.0+ > (0 != "     ")  ==> true

In order to keep "false" value we avoid "0" as a valid value.

More details here why here:
https://www.php.net/manual/en/migration80.incompatible.php

* PHP 8.1 > Change support to PHP 8.1

* Fix UnitTest application/x-sharedlib

/bin/ls can be reported as:
- application/x-sharedlib
- application/x-executable
- application/x-pie-executable

* PHP 8.1 > mysqli_report revert to off
https://php.watch/versions/8.1/mysqli-error-mode

* Refactor code and apply Coding Style fixes

* PHP 8.1 > Better MYSQLI_REPORT_OFF implementations for php8.1 compat

Thanks @mentalstring

* PHP 8.1 > remove full_path from uploads added on PHP v8.1

* Fix use of null on string parameter on multiple classes

* Github Actions: enable testing on PHP v8.0 and v8.1 (for PRs too)

* test environment for php 8.2

* PHP 8.2 > Using ${var} in strings is deprecated, use {$var} instead.

* PHP 8.2 > Creation of dynamic property Class::$property is deprecated

* PHP 8.0 > Uncaught ArgumentCountError: Too few arguments to function

* PHP 8.0 > Trying to access array offset on value of type bool

* PHP 8.0 > Passing null to parameter #1 ($haystack) of type string is deprecated

* set symfony version to 1.5.15-dev

* PHP 8.0 > Class name must be a valid object or a string in case the controller does not exist.

* PHP 8.0 > Fix undefined array key

* PHP 8.1 > Fix some more null on string parameter

* Prepared release 1.5.15

* Add(changelog) Add v1.5.15 release date to Changelog file

* Add(versioning) Add v1.5.16-dev as next release

* Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate (FriendsOfSymfony1#277)

* Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate, add return types from implemented sfIMessageSource

* Add(linting) Add code linting to GitHub workflow, use php-cs-fixer

* Fix(php-cs) Fix php-cs styles according to configuration

* Add(gitattributes) Add .gitattributes to repository

* Fix: avoid creating dynamic property $options in sfViewCacheManager (FriendsOfSymfony1#290) 

Dynamic properties are deprecated since PHP8.2

* Update(github) Update github workflows, include cache for composer install

* Fix(php-cs-fixer) Fix php-cs-fixer warnings, according to new checks

* add php8.3

* Fix(php-cs-fix) fix php-cs-fix single_space_around_construct warning

* Fix(php-cs-fixer) Fix php-cs-fixer to v3.45 and apply code fixes

* Fix(deprecation) preg_match_all requires string parameter (FriendsOfSymfony1#298)

* Fix APC cache tests

- Using negative TTLs to force the immediate expiration of keys, while
  convenient in tests, doesn't work consistently with APC and is an
  undocumented feature. Using a low TTL and sleep() is what guarantees
  that it works for APC. See krakjoe/apcu#184

- The setting apc.use_request_time interferes with key expiration when
  running on the CLI. Making sure it always has a sensible value for
  running the tests. See krakjoe/apcu#392

* Add APCu support

Support for the APCu extension (through sfAPCuCache) as an alternative
to APC, which no longer works with recent versions of PHP.

* Fix sfCacheSessionStorageTest with PHP>=7.2

From PHP 7.2 onward, session functions are stricter and may not work
if output/headers have already been sent out. Using output buffering
prevents this issue.

* Remove test dependency on APC

Replace the use of sfAPCCache with sfFileCache in
sfCacheSessionStorageTest so that it doesn't depend on APC being
available.

* Fix deprecation on stropos()  usage on sfDebug::shortenFilePath (FriendsOfSymfony1#299)

Fix PHP v8.x deprecation on strpos() usage with `null` as first parameter

* Fix strpos() deprecation on sfCacheSessionStorage check for cookie

* Fix setrawcookie() deprecation on null parameter (FriendsOfSymfony1#304)

* Fix str_replace() deprecated null parameter on sfNumberFormat

* Declare $params var

* Replace default with 0

* Update README

Fix build badge, update supported PHP version and other minor tweaks.

* Fix link to GitHub pipeline badge

* fix(config) sfCacheConfigHandler: There is no fourth argument. Nice catch phpstan!

* Fix PHP8.1 sfForm - Unsupported operand types: array + null on sfForm::updateValues()

Avoid error:
Fatal error: Uncaught TypeError: Unsupported operand types: array + null in lib\form\sfForm.class.php:319

Step to reproduce :
$form = new sfForm();
$form->updateValues(array('foo' => 'value'));

PHP 5.3 coding style

May use sfForm::getValues(), but as sfForm::updateValues() is a hack, it could be used before bind ($this->isBound = true);

* fix(phpdoc) remove html code from throws phpdoc. phpstan don't like this

* fix(phpdoc) remove version tag

* PHP 8.3 deprecated errors fixed (FriendsOfSymfony1#320)

* Update min PHP requirement to v7.4 or v8.1

* Remove PHP v8.0 from CI workflow

* Updated gh workflow to use latest actions

* Backported display_errors-handling to sf1

* Set min versions of swiftmailer to 5.4.13 and 6.2.5 and updated swiftmailer submodule (FriendsOfSymfony1#331)

* Update min versions of swiftmailer to v5.4.13 or v6.2.5
* Update swiftmailer code on submodule to v5.4.13

* Sync changelog with latest releases (FriendsOfSymfony1#337)

* Sync changelog with latest releases

* Remove(legacy): Remove unsupported PHP docker images

* Remove(legacy): drop sfAPCCache cache as apc extension does not exist anymore

Please use sfAPCUCache instead

* Fix(docblock): fix typo in check_configuration.php docblock

* Update(check-config): use PHP constant for version check on check_configuration.php file

* Remove(legacy): delete checks for 'magic_quotes_gpc' and 'register_globals' ini settings, as removed on PHP v5.4

* Remove(legacy): delete EAccelerator cache, the extension is not existing for php v7.4

See: https://github.com/eaccelerator/eaccelerator, where the following
message is shown:

> This project is deprecated and does not work with anything newer than PHP 5.3.
> Please use a recent version of PHP with OPcache instead!

* Remove(legacy): drop XCache support, as the extension is not available for PHP >= 7.4

* Remove(legacy): delete check for PHP < 5.2 in tests for mime_content_type bug

* Remove(legacy): drop PHP v5.3 check for SQLite version match

* Remove(legacy): drop PHP v5.4 check and compatibility layer on sfWebRequest

* Remove(legacy): drop PHP v5.3 check on sfRoute

This removes a preliminary fix for a legacy PHP 5.3. issue with regexp excaping
PHP bug reference: http://bugs.php.net/bug.php?id=47229

* Update: Update php-cs-fixer to v3.51

Apply rule fixes

* Update: php-cs-fixer, enable short array syntax

* Update: move php-cs-fixer cache under .cache folder

* Update: run php-cs-fixer on PHP v7.4 as min supported version

* Update: GitHub actions to run php-cs-fixer only on relevant changed files

* Hotfix: Add type checking for deserialized data in sfParameterHolder and sfNamespacedParameterHolder (CVE-2024-28861)

* Update php-cs-fixer to v3.52

* Remove(legacy): drop sf*Cache implementations for APC, XCache and EAccelerator extensions

* Phpstan: fix warnings on sfAPCiCache implementation, add docblocks and returns

* Phpstan: fix warnings on sfFileCache and sfMemcache implementation, add missing returns

* Phpstan: fix missing sfTask* return statement

* [widget] fix return statement missing (FriendsOfSymfony1#349)

* [validator] fix return statement missing (FriendsOfSymfony1#352)

* [view] fix return statement missing on ParamHolder and CacheManager (FriendsOfSymfony1#350)

* [task] Fix return statement missing on some tasks (FriendsOfSymfony1#353)

* [util] fix missing return statement and docblock on sfContext class (FriendsOfSymfony1#351)

* Chore: Fix Changelog typo (FriendsOfSymfony1#361)

* Fix: update the SYMFONY_VERSION constant to the latest release number (FriendsOfSymfony1#355)

* Add: Include "test" folder to gitattribute's exclusion (FriendsOfSymfony1#368)

* Fix: Correct type-hint for parameters sfConfigCache (FriendsOfSymfony1#370)

---------

Co-authored-by: Alexandre Quercia <[email protected]>
Co-authored-by: Thomas <[email protected]>
Co-authored-by: Emanuele Panzeri <[email protected]>
Co-authored-by: Tybaze <[email protected]>
Co-authored-by: Paulo Magalhaes <[email protected]>
Co-authored-by: Thomas A. Hirsch <[email protected]>
Co-authored-by: Karoly Gossler <[email protected]>
Co-authored-by: Vincent Mariani <[email protected]>
Co-authored-by: iricketson <[email protected]>
Co-authored-by: Ian Ricketson <[email protected]>
Co-authored-by: Sergei Miami <[email protected]>
Co-authored-by: darkpills <>
Co-authored-by: ಠ_ಠ <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants