136 Commits (6a466a120a404d1c5d492e5ca715841c491517fc)

Author SHA1 Message Date
Jordi Boggiano 6a466a120a
Enable strict types on all files 2 years ago
Jordi Boggiano 6da38f83a0
Add parameter types to all the things 2 years ago
Jordi Boggiano eda9014bef
Add return types to all code which is not being extended by open source packages 2 years ago
Jordi Boggiano a16ed3d0ed
Add return types to private/internal methods 2 years ago
Jordi Boggiano abdc6893a6
Add void types where no return statement is present 2 years ago
Jordi Boggiano 45218092b4
Merge branch '2.2' into main 2 years ago
Jordi Boggiano f808e4907c
Fix handling for non-lowercased enum keyword, fixes #10521 2 years ago
Jordi Boggiano 3446091027
Merge branch '2.2' into main 2 years ago
Jordi Boggiano db8ea45295
Fix enum parsing when the syntax is "enum foo:string {}" without space between name and type, fixes #10498 2 years ago
Niels Vanpachtenbeke 1c928466a9
Remove code blocks for php <7.2 compatibility (#10417) 2 years ago
Jordi Boggiano 0b3adc84da
Fix a few phpstan errors and add a php8+ baseline for the rest 2 years ago
Jordi Boggiano 24ce1eddbd
Add composer/pcre dependency and use it everywhere instead of preg_* 2 years ago
immeëmosol be25cf1d7a
Reaching phpstan level 6 in Composer/Autoload (refs #10159) (#10179)
Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
3 years ago
Jordi Boggiano d1c8a4d1b4
Lots of typing improvements 3 years ago
Jordi Boggiano d64d1adf61
Rewrite php file cleaning step to be less regex intensive and support extreme cases better, fixes #10106 (#10107) 3 years ago
Jordi Boggiano 8cd2d0e541
Fix scanning of classmaps in files containing invalid Unicode, fixes #10102 3 years ago
Jordi Boggiano 0761474599
Add type info to many properties/methods 3 years ago
Jordi Boggiano fc04c86f82
Add type info to Autoload namespace 3 years ago
Jordi Boggiano d8054d1d2f
Add more possessive quantifiers, unicode flag and support for more post-heredoc syntax, fix test file syntax being invalid 3 years ago
Jordi Boggiano 6ab1b6a7d2
Regex simplifications 3 years ago
Jordi Boggiano f6c446bdd7
Tweak to allow matching delimiter within the string 3 years ago
Jordi Boggiano c44be998ab
Undo new stripping code and fix regex 3 years ago
jrfnl 40bd4b03ad
ClassMapGenerator: stabilize the heredoc/nowdoc stripping
I've looked into 10067 and have come to the conclusion that using a single regex to strip the heredoc/nowdocs is always going to run into trouble as:
* Either the matching will be too greedy (issue 10067);
* Or the matching will run into backtrace limits for large heredoc/nowdocs.

We cannot solve both within a single regex.

So, I'm proposing a slightly different solution which should support both and should also improve performance for files containing large heredoc/nowdocs.

The `stripHereNowDocs()` function will find a start marker and remember the offset of the start marker.
It will then find the end marker and strip the contents between the two (replace with `null`).
The function will then recurse onto itself until all heredocs/nowdocs in a file have been removed.
3 years ago
Jordi Boggiano d3c176ec69
PHPStan Level 5 (#10070)
* Bump PHPStan to level 5

* Update seld/phar-utils to latest

* Add phpstan-setup / phpstan scripts
3 years ago
jrfnl 42c6a0d7c5 ClassMapGenerator: fix the regex
By using a look ahead assertion to match "new line - maybe whitespace - marker", the negative performance impact of the `.*` is significantly mitigated and backtracing will be severely limited.

This fixes the bug as reported in 10037.

The bug was discovered due to a PHP 8.1 "passing null to non-nullable" deprecation notice being thrown, but is not a PHP 8.1 bug.

In actual fact, this issue affected all PHP versions and could lead to incomplete classmaps when the code base contained files with huge heredocs/nowdocs.

The regex change (not completely) incidentally also fixes an issue with markers in a heredoc/nowdoc not being correctly handled. This bug could lead to "classes" being added to the class map which aren't actually classes.

Fixes 10037
3 years ago
Jordi Boggiano 3380178798
Introduce a cross-platform safe version of is_readable to support UNC / wsl$ paths on Windows (#9861) 3 years ago
Ayesh Karunaratne 228428747a
Add support for autoloading Enums
PHP 8.1 supports Enums, and [Enums follow class-semantics](https://php.watch/versions/8.1/enums#class-semantics-autoload).

Composer's class-map generator currently looks for `class`, `interface`, and `trait` keywords. If Composer is run in PHP 8.1 or later, Composer now additionally looks for `enum` keyword as well. This is similar to how Hack's `enum` support is added.

This PR also adds tests for basic enums, backed enums, namespaced enums, and an enum that implements an interface and extends a class.
3 years ago
Jordi Boggiano 07b8c23f02
Merge branch '1.10' 3 years ago
Jordi Boggiano 92313447d6
Filter out exclude-from-classmap rules to avoid generating very long regexes, fixes #9487 3 years ago
Jordi Boggiano b7d770659b
CS fixes 4 years ago
Simon Berger bae227ec2d Changed all substr calls used to compare fragments of text to strpos
Some additional code cleanups in those classes

Reverted change causing issues
4 years ago
Jordi Boggiano c8731598cc
Merge branch '1.10' 4 years ago
Graham Campbell fa799970ad Replace whitelist with allow list 4 years ago
Markus Staab 6a0e02db1b Autoload-Generator: support glob patterns in classmaps 4 years ago
Jordi Boggiano 80505e745e
Fix phpstan issues 4 years ago
Jordi Boggiano 87757de6bc
Merge branch '2.0' 4 years ago
Jordi Boggiano 86677ad172
Avoid scanning files twice when generating optimized autoloaders, fixes #8683 4 years ago
Jordi Boggiano 24a5a0dacb
Skip invalid PSR-0/4 classes from optimized autoloader, fixes #8403 4 years ago
Jordi Boggiano 8fd70d2dc4
Target ClassMapGenerator ignoring of invalid PSR classes for 2.0 4 years ago
Jordi Boggiano 3496431a6c
Fix PSR warnings for optimized autoloader, refs #8397, refs #8403 5 years ago
Jordi Boggiano d059d90ecf
Fix PSR warnings for optimized autoloader, refs #8397, refs #8403 5 years ago
Jordi Boggiano 502b68967a
Fix tests for PSR-fix in optimized autoloader, refs #8397 5 years ago
Jordi Boggiano f6b8643dcd
Change PSR-fix for optimized autoloader to only warn for now, refs #8397 5 years ago
Andriy Maletsky ec293adabc make optimized autoloader respect PSR standards 5 years ago
zakonnic 9f6e45051a Optimize template for striping non-php blocks 5 years ago
zakonnic ec96e5de64 Fix incorrect strip of non-php blocks in the file 5 years ago
Rob Bast 4ea8e48bf8 leading whitespace is optional, but newline is not 5 years ago
Rob Bast 25e3f6d4b9 expand regex and testcases 5 years ago
Rob Bast 971528916b fix regex for heredoc/nowdoc
* take into account relaxed changes introduced in php 7.3
  * see: 4887357269
* allow " as well as ', which was introduced in php 5.3

closes #8080
5 years ago
Jordi Boggiano 3b9d6769bf Fix class names in comments being parsed in short_open_tags files, fixes #7289 6 years ago