Skip to content

Conversation

@crazywhalecc
Copy link
Owner

What does this PR do?

  • Refactor re2c fix-item
  • Use patch for current package exclusively
  • Add libedit package build
  • Add ncurses package build
  • Allow all types of package can be built
  • Fix missing ncurses static-libs config
  • Add php-micro patch for embed mode
  • Add patch description display
  • Add missing patchPkgconfPrefix function for LibraryPackage
  • Allow package implementation using parent class functions (libxxx extends LibraryPackage)
  • Add shared extension build support
  • Correct SAPI-packages to be installed

Checklist before merging

If your PR involves the changes mentioned below and completed the action, please tick the corresponding option.
If a modification is not involved, please skip it directly.

  • If you modified *.php or *.json, run them locally to ensure your changes are valid:
    • composer cs-fix
    • composer analyse
    • composer test
    • bin/spc dev:sort-config
  • If it's an extension or dependency update, please ensure the following:
    • Add your test combination to src/globals/test-extensions.php.
    • If adding new or fixing bugs, add commit message containing extension test or test extensions to trigger full test suite.

@crazywhalecc crazywhalecc added the mixed PR This PR contains multiple updates label Dec 8, 2025
@crazywhalecc
Copy link
Owner Author

crazywhalecc commented Dec 10, 2025

@copilot Is there any changes I'm doing wrong? Just be smart and cautious, okay?

Copilot AI mentioned this pull request Dec 10, 2025
6 tasks
Copy link

Copilot AI commented Dec 10, 2025

@crazywhalecc I've opened a new pull request, #993, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

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 introduces significant architectural improvements to the static PHP build system, focusing on refactoring the registry and package loading system, adding shared extension build support, and implementing new library packages.

Key Changes

  • Registry System Refactoring: Moved loader classes (PackageLoader, DoctorLoader, ArtifactLoader) to a dedicated StaticPHP\Registry namespace and introduced RegistryException for better error handling
  • Shared Extension Build Support: Added comprehensive support for building PHP extensions as shared libraries with new stages, environment configuration, and automatic stage registration
  • Package Inheritance Pattern: Enabled package implementation classes to extend base package types (LibraryPackage, TargetPackage) for direct access to utility methods

Reviewed changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
src/globals/functions.php Updated strip_ansi_colors to accept Stringable parameter
src/StaticPHP/Util/InteractiveTerm.php Added no-ansi option support for terminal output formatting
src/StaticPHP/Registry/Registry.php Changed exception types to RegistryException and added registry validation
src/StaticPHP/Registry/PackageLoader.php Moved to Registry namespace, refactored stage handling, added validation
src/StaticPHP/Registry/DoctorLoader.php Moved to Registry namespace
src/StaticPHP/Registry/ArtifactLoader.php Moved to Registry namespace
src/StaticPHP/Package/PhpExtensionPackage.php Added shared extension build support with default stages
src/StaticPHP/Package/PackageInstaller.php Refactored package installation logic and SAPI package handling
src/StaticPHP/Package/Package.php Moved build functions from LibraryPackage, added outputs tracking
src/StaticPHP/Package/LibraryPackage.php Added patchPkgconfPrefix method for pkg-config file patching
src/StaticPHP/Exception/RegistryException.php New exception class for registry-related errors
src/StaticPHP/Exception/ExceptionHandler.php Added RegistryException handling
src/StaticPHP/DI/CallbackInvoker.php Added context hierarchy expansion for object inheritance
src/StaticPHP/DI/ApplicationContext.php Added PatchDescription attribute logging
src/StaticPHP/ConsoleApplication.php Added registry validation check on initialization
src/StaticPHP/Attribute/Package/Stage.php Changed parameter from 'name' to nullable 'function'
src/StaticPHP/Attribute/Package/BeforeStage.php Added support for callable array stage references
src/StaticPHP/Attribute/Package/AfterStage.php Added support for callable array stage references
src/Package/Target/php.php Updated to use callable stage references, added shared extension building, extended TargetPackage
src/Package/Target/micro.php New micro SAPI target implementation with embed stage patching
src/Package/Library/ncurses.php New ncurses library build implementation
src/Package/Library/libedit.php New libedit library build implementation extending LibraryPackage
config/pkg.lib.json Added static-libs configuration for ncurses
composer.json Added nette/php-generator dependency
Comments suppressed due to low confidence (1)

src/StaticPHP/Registry/PackageLoader.php:295

  • [nitpick] Inconsistent variable naming in the loop. The iteration variable $before_events is misleading since it's used in both BeforeStage and AfterStage event processing (line 295). Consider using a more generic name like $events or $stage_events for clarity.

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

}
} elseif ($package instanceof LibraryPackage && $package->getArtifact()->shouldUseBinary()) {
// install binary
} elseif ($is_to_build && $has_build_stage || $has_source && $has_build_stage) {
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

The logic condition appears incorrect. The condition should build packages that either:

  1. Are marked to build ($is_to_build) AND have a build stage, OR
  2. Have source AND have a build stage (regardless of binary availability)

However, the current condition $is_to_build && $has_build_stage || $has_source && $has_build_stage lacks parentheses and may not express the intended logic correctly due to operator precedence. Without parentheses, this evaluates as ($is_to_build && $has_build_stage) || ($has_source && $has_build_stage).

Consider adding explicit parentheses or revising the logic to make the intent clear.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@crazywhalecc crazywhalecc merged commit 7837563 into v3-dev Dec 10, 2025
1 check passed
@crazywhalecc crazywhalecc deleted the v3-feat/re2c branch December 10, 2025 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mixed PR This PR contains multiple updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants