Skip to content

Port Bash scripts to PHP#1591

Merged
henriquemoody merged 4 commits into
Respect:mainfrom
henriquemoody:housekeeping/console
Jan 7, 2026
Merged

Port Bash scripts to PHP#1591
henriquemoody merged 4 commits into
Respect:mainfrom
henriquemoody:housekeeping/console

Conversation

@henriquemoody
Copy link
Copy Markdown
Member

@henriquemoody henriquemoody commented Jan 5, 2026

It makes more sense to use PHP to generate PHP code than to use Bash. I love writing Bash scripts, but I know it’s not for everyone, and they can become quite complex. Porting them to PHP code also lowers the barrier for people to change them.

While I was making those changes, I also noticed a problem with how we save the domain suffixes. We’re converting all of them to ASCII, so we’re not preserving languages such as Chinese, Thai, and Hebrew, which use non-ASCII characters.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.44%. Comparing base (905cef8) to head (f635cc7).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1591   +/-   ##
=========================================
  Coverage     97.43%   97.44%           
- Complexity      986      988    +2     
=========================================
  Files           213      213           
  Lines          2265     2273    +8     
=========================================
+ Hits           2207     2215    +8     
  Misses           58       58           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@henriquemoody
Copy link
Copy Markdown
Member Author

This code is awful, but I'm not willing to prioritize refactoring it, since it's not some critical part of the library.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes the development tooling by converting Bash scripts to PHP Symfony Console commands and refactors the Tld and PostalCode validators to load data from external files rather than hardcoded arrays. This change makes the codebase more maintainable and easier to update, as data can be regenerated without modifying class files.

Key Changes:

  • Replaced Bash scripts in bin/ with Symfony Console commands in dev/Commands/
  • Refactored Tld and PostalCode validators to load data from PHP files in data/domain/
  • Added new bin/console entry point for all development commands
  • Updated GitHub workflow to use new console commands

Reviewed changes

Copilot reviewed 14 out of 20 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
bin/console New entry point for Symfony Console application with all development commands
dev/Commands/*.php New Console commands for updating TLDs, postal codes, domain suffixes, doc links, and generating mixins
library/Validators/Tld.php Refactored to load TLD list from external data file instead of hardcoded array
library/Validators/PostalCode.php Refactored to load postal codes from external data file
data/domain/tld.php New data file containing TLD list
data/domain/postal-code.php New data file containing postal code patterns
composer.json Added symfony/console dependency and dev autoload configuration
phpcs.xml.dist Added dev/ directory to code standards checks
.github/workflows/update-regionals.yaml Updated to use new console commands
.gitattributes Restructured to use allow-list approach for exports
docs/09-list-of-validators-by-category.md Reorganized validator categories

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread library/Validators/Tld.php
Comment thread data/domain/postal-code.php Outdated
Comment thread src-dev/Commands/UpdatePostalCodesCommand.php
Comment thread src-dev/Commands/UpdateDomainToplevelCommand.php
Comment thread src-dev/Commands/UpdateDomainSuffixesCommand.php
Comment thread library/Validators/PostalCode.php
Comment thread data/domain/postal-code.php Outdated
With that change, we won't need to change the Tld validator every time
there's an update.
@henriquemoody henriquemoody changed the title Move all scripts in bin/ to Symfony Console commands Port Bash scripts to PHP Jan 6, 2026
@henriquemoody henriquemoody force-pushed the housekeeping/console branch 2 times, most recently from ec992a9 to 0a84b14 Compare January 6, 2026 09:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 72 out of 78 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

With this change, we won't need to change the `PostalCode` validator
every time there's an update. While I was moving the data, I noticed
some inefficiencies with the regular expressions, so I made some
changes.
It makes more sense to use PHP to generate PHP code than to use Bash. I
love writing Bash scripts, but I know it's not for everyone, and they
can become quite complex. Porting them to PHP code also lowers the
barrier for people to change them.

While I was making those changes, I also noticed a problem with how we
save the domain suffixes. We're converting all of them to ASCII, so we
are not preserving languages such as Chinese, Thai, and Hebrew, which
use non-ASCII characters.
@alganet
Copy link
Copy Markdown
Member

alganet commented Jan 6, 2026

Looks great!

While I was making those changes, I also noticed a problem with how we save the domain suffixes. We’re converting all of them to ASCII, so we’re not preserving languages such as Chinese, Thai, and Hebrew, which use non-ASCII characters.

Can we add a test that ensures validation for those new languages work? Just a few for the most stable international domains.

I manually run the commands that update the data we use in `Tld`,
`PostalCode`, and `PublicDomainSuffix`.
@henriquemoody henriquemoody requested review from alganet and removed request for alganet January 7, 2026 08:49
@henriquemoody henriquemoody merged commit f635cc7 into Respect:main Jan 7, 2026
5 checks passed
@henriquemoody henriquemoody deleted the housekeeping/console branch January 7, 2026 10:19
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