Skip to content

Conversation

@uuf6429
Copy link
Contributor

@uuf6429 uuf6429 commented Dec 14, 2025

This PR changes a few (somewhat unrelated) minor things.

Refer to the comments for an explanation.

Everything should be backward compatible.

if (!$readable) {
chmod($filename, 0000);
if (PHP_OS_FAMILY === 'Windows') {
exec('icacls ' . escapeshellarg($filename) . ' /deny Everyone:(F)');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Compatibility for Windows (which otherwise kinda ignores chmod()).

$output = $this->process->getErrorOutput() . $this->process->getOutput();

return trim((string) preg_replace('/ +$/m', '', $output));
return trim((string) preg_replace(['/ +$/m', '/\r\n/'], ['', "\n"], $output));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems that Behat output on windows contains \r\n sequences, which would fail some tests. This change fixes that.

self::rmdir($file);
} else {
unlink($file);
@unlink($file);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A lot of tests failed on this and the changed line below - apparently for some reason it's not able to delete files in temp. Suppressing the error makes the tests pass, leaving behind the files. Normally that's not a big deal since Windows eventually cleans that up.

Using a VFS would solve this and the chmod issue, but I suspect it wouldn't work with exec('behat vfs://...'), unless we add some convoluted extension that transmits the VFS state to behat. Or alternatively, create a temp dir in the current project folder instead of using the system temp dir.

Either way, doesn't feel like a big issue at the moment.

public function __construct(string $message, int $code = 0, ?Throwable $previous = null, mixed $needle = null, mixed $haystack = null)
{
$message .= PHP_EOL . PHP_EOL . sprintf(
$message .= "\n\n" . sprintf(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix for Windows, where PHP_EOL returns \r\n causing a string mismatch.

@@ -0,0 +1,14 @@
root = true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to ensure editors/IDEs respect formatting specifics of this project, especially "unusual" things like 2-space indents.

"sa": "vendor/bin/phpstan",
"cs": "vendor/bin/php-cs-fixer fix --dry-run --diff",
"dev": "php -S localhost:8080 -t ./features/bootstrap > build/httpd.log 2>&1",
"dev": "php -S localhost:8080 -t ./features/bootstrap",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed that for two reasons:

  1. compatibility on Windows
  2. I don't find it really useful - typically these scripts aren't run asynchronously / in-the-background, so there isn't a lot of reason to reroute the output to a file, IMO at least.

"phpstan/extension-installer": true
}
},
"process-timeout": 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Relates to the scripts above - without it they will eventually fail with a timeout (I think after 5 mins or so).

Alternatively, we may want to update the scripts with disableProcessTimeout which makes it more granular and perhaps safer - though I don't see any major disadvantages either way.

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" executionOrder="depends,defects"
beStrictAboutOutputDuringTests="true" requireCoverageMetadata="true"
displayDetailsOnTestsThatTriggerDeprecations="true" displayDetailsOnPhpunitDeprecations="true">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Split to multiple lines for readability

.vscode
.php-cs-fixer.cache
.php-cs-fixer.php
phpstan.neon
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change and renaming the original files is to allow contributors/maintainers to have their own local version of those config files. E.g. a typical case is set up phpstan output formatting to display an IDE link based on your preferred IDE.

.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php-cs-fixer.dist.php export-ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is to avoid exporting those entries when creating the composer package, resulting in a faster download/install.


I checked the indentation is consistent and correct... so that must be some sort of GitHub display defect? Ah, I guess it's because of ligatures:

Image

@uuf6429 uuf6429 marked this pull request as ready for review December 14, 2025 07:20
@uuf6429
Copy link
Contributor Author

uuf6429 commented Dec 22, 2025

@christeredvartsen I just rebased this, so I think it's ready now.

The only functional change is in src/Exception/ArrayContainsComparatorException.php - where I changed the newlines. It's not the best, but it shouldn't be a breaking change seeing as it impacts exception messages (end users should never depend on the exact exception message).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant