-
Notifications
You must be signed in to change notification settings - Fork 4
アノテーションを PHP 8 Attributes に移行し依存関係を更新 #24
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
base: 1.x
Are you sure you want to change the base?
Changes from all commits
4193579
d90abb9
e192dc4
d6e5bba
f4e605a
7bcb17d
67df167
47c4b50
280117b
9f408e2
677d1cb
46414e8
dfafacb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,6 @@ build | |
| vendor/ | ||
| composer.phar | ||
| composer.lock | ||
| tests/tmp/* | ||
| !tests/tmp/.placefolder | ||
| .phpunit.result.cache | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,12 @@ | ||
| build: | ||
| nodes: | ||
| analysis: | ||
| tests: | ||
| override: | ||
| - php-scrutinizer-run | ||
| environment: | ||
| php: | ||
| version: 8.2 | ||
|
|
||
| filter: | ||
| paths: ["src/*"] | ||
| tools: | ||
| external_code_coverage: true | ||
| php_code_coverage: | ||
| timeout: 1200 | ||
| php_sim: true | ||
| php_mess_detector: true | ||
| php_pdepend: true | ||
| php_analyzer: true | ||
| php_cpd: true | ||
| php_mess_detector: | ||
| enabled: true | ||
| config: | ||
| ruleset: ./phpmd.xml | ||
| php_code_sniffer: | ||
| enabled: true | ||
| config: | ||
| ruleset: ./phpcs.xml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,21 @@ | ||
| <phpunit bootstrap="tests/bootstrap.php"> | ||
| <testsuites> | ||
| <testsuite> | ||
| <testsuite name="Ray.WebFormModule Test Suite"> | ||
| <directory suffix="Test.php">tests</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
|
|
||
| <coverage> | ||
| <include> | ||
| <directory suffix=".php">src</directory> | ||
| </include> | ||
| <report> | ||
| <html outputDirectory="build/coverage"/> | ||
| <clover outputFile="build/logs/clover.xml"/> | ||
| </report> | ||
| </coverage> | ||
|
|
||
| <logging> | ||
| <log type="coverage-html" target="build/coverage"/> | ||
| <log type="coverage-clover" target="build/logs/clover.xml"/> | ||
| <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/> | ||
| <junit outputFile="build/logs/junit.xml"/> | ||
| </logging> | ||
|
|
||
| <filter> | ||
| <whitelist> | ||
| <directory suffix=".php">src</directory> | ||
| </whitelist> | ||
| </filter> | ||
| </phpunit> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,41 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||
| <?php | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| declare(strict_types=1); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * This file is part of the Ray.WebFormModule package. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @license http://opensource.org/licenses/MIT MIT | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| namespace Ray\WebFormModule; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| use ArrayIterator; | ||||||||||||||||||||||||||||||||||||||||||
| use Aura\Filter\FilterFactory; | ||||||||||||||||||||||||||||||||||||||||||
| use Aura\Filter\SubjectFilter; | ||||||||||||||||||||||||||||||||||||||||||
| use Aura\Html\HelperLocator; | ||||||||||||||||||||||||||||||||||||||||||
| use Aura\Html\HelperLocatorFactory; | ||||||||||||||||||||||||||||||||||||||||||
| use Aura\Input\AntiCsrfInterface; | ||||||||||||||||||||||||||||||||||||||||||
| use Aura\Input\BuilderInterface; | ||||||||||||||||||||||||||||||||||||||||||
| use Aura\Input\Fieldset; | ||||||||||||||||||||||||||||||||||||||||||
| use Exception; | ||||||||||||||||||||||||||||||||||||||||||
| use Ray\Di\Di\Inject; | ||||||||||||||||||||||||||||||||||||||||||
| use Ray\Di\Di\PostConstruct; | ||||||||||||||||||||||||||||||||||||||||||
| use Ray\WebFormModule\Exception\CsrfViolationException; | ||||||||||||||||||||||||||||||||||||||||||
| use Ray\WebFormModule\Exception\LogicException; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| use function trigger_error; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| abstract class AbstractForm extends Fieldset implements FormInterface | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * @var SubjectFilter | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| /** @var SubjectFilter */ | ||||||||||||||||||||||||||||||||||||||||||
| protected $filter; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * @var null | array | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| /** @var array|null */ | ||||||||||||||||||||||||||||||||||||||||||
| protected $errorMessages; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * @var HelperLocator | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| protected $helper; | ||||||||||||||||||||||||||||||||||||||||||
| protected HelperLocator $helper; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * @var AntiCsrfInterface | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| /** @var AntiCsrfInterface */ | ||||||||||||||||||||||||||||||||||||||||||
| protected $antiCsrf; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public function __construct() | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -61,58 +62,51 @@ public function __toString() | |||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return $this->toString(); | ||||||||||||||||||||||||||||||||||||||||||
| } catch (\Exception $e) { | ||||||||||||||||||||||||||||||||||||||||||
| } catch (Exception $e) { | ||||||||||||||||||||||||||||||||||||||||||
| trigger_error($e->getMessage() . PHP_EOL . $e->getTraceAsString(), E_USER_ERROR); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return ''; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return ''; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * @param BuilderInterface $builder | ||||||||||||||||||||||||||||||||||||||||||
| * @param FilterFactory $filterFactory | ||||||||||||||||||||||||||||||||||||||||||
| * @param HelperLocatorFactory $helperFactory | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @\Ray\Di\Di\Inject | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| #[Inject] | ||||||||||||||||||||||||||||||||||||||||||
| public function setBaseDependencies( | ||||||||||||||||||||||||||||||||||||||||||
| BuilderInterface $builder, | ||||||||||||||||||||||||||||||||||||||||||
| FilterFactory $filterFactory, | ||||||||||||||||||||||||||||||||||||||||||
| HelperLocatorFactory $helperFactory | ||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||
| ): void { | ||||||||||||||||||||||||||||||||||||||||||
| $this->builder = $builder; | ||||||||||||||||||||||||||||||||||||||||||
| $this->filter = $filterFactory->newSubjectFilter(); | ||||||||||||||||||||||||||||||||||||||||||
| $this->helper = $helperFactory->newInstance(); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public function setAntiCsrf(AntiCsrfInterface $antiCsrf) | ||||||||||||||||||||||||||||||||||||||||||
| public function setAntiCsrf(AntiCsrfInterface $antiCsrf): void | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| $this->antiCsrf = $antiCsrf; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * @\Ray\Di\Di\PostConstruct | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function postConstruct() | ||||||||||||||||||||||||||||||||||||||||||
| #[PostConstruct] | ||||||||||||||||||||||||||||||||||||||||||
| public function postConstruct(): void | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| $this->init(); | ||||||||||||||||||||||||||||||||||||||||||
| if ($this->antiCsrf instanceof AntiCsrfInterface) { | ||||||||||||||||||||||||||||||||||||||||||
| $this->antiCsrf->setField($this); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * {@inheritdoc} | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| /** {@inheritdoc} */ | ||||||||||||||||||||||||||||||||||||||||||
| public function input($input) | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| return $this->helper->input($this->get($input)); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * {@inheritdoc} | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function error($input) | ||||||||||||||||||||||||||||||||||||||||||
| /** {@inheritdoc} */ | ||||||||||||||||||||||||||||||||||||||||||
| public function error(string $input): string | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| if (! $this->errorMessages) { | ||||||||||||||||||||||||||||||||||||||||||
| $failure = $this->filter->getFailures(); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -131,12 +125,10 @@ public function error($input) | |||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * @param array $attr attributes for the form tag | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @throws \Aura\Html\Exception\HelperNotFound | ||||||||||||||||||||||||||||||||||||||||||
| * @throws \Aura\Input\Exception\NoSuchInput | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return string | ||||||||||||||||||||||||||||||||||||||||||
| * @throws \Aura\Html\Exception\HelperNotFound | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function form($attr = []) | ||||||||||||||||||||||||||||||||||||||||||
| public function form(array $attr = []): string | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| $form = $this->helper->form($attr); | ||||||||||||||||||||||||||||||||||||||||||
| if (isset($this->inputs['__csrf_token'])) { | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -152,14 +144,13 @@ public function form($attr = []) | |||||||||||||||||||||||||||||||||||||||||
| * @param array $data | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @throws CsrfViolationException | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return bool | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function apply(array $data) | ||||||||||||||||||||||||||||||||||||||||||
| public function apply(array $data): bool | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| if ($this->antiCsrf && ! $this->antiCsrf->isValid($data)) { | ||||||||||||||||||||||||||||||||||||||||||
| throw new CsrfViolationException; | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| $this->fill($data); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return $this->filter->apply($data); | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -168,20 +159,16 @@ public function apply(array $data) | |||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Returns all failure messages for all fields. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return array | ||||||||||||||||||||||||||||||||||||||||||
| * @return list<string> | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function getFailureMessages() | ||||||||||||||||||||||||||||||||||||||||||
| public function getFailureMessages(): array | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| return $this->filter->getFailures()->getMessages(); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
159
to
167
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's locate and examine the AbstractForm.php file
find . -name "AbstractForm.php" -type fRepository: ray-di/Ray.WebFormModule Length of output: 90 🏁 Script executed: # Check if there's a composer.json to understand dependencies
cat composer.json 2>/dev/null | head -50Repository: ray-di/Ray.WebFormModule Length of output: 1190 🏁 Script executed: # Search for references to Aura Filter in the codebase
rg "Aura\\\\Filter" --type php -A 3Repository: ray-di/Ray.WebFormModule Length of output: 732 🏁 Script executed: # Let's examine the AbstractForm.php file, particularly around lines 159-167
cat -n ./src/AbstractForm.php | sed -n '150,175p'Repository: ray-di/Ray.WebFormModule Length of output: 828 🏁 Script executed: # Also, let's see the full context of the class to understand $this->filter
head -50 ./src/AbstractForm.phpRepository: ray-di/Ray.WebFormModule Length of output: 1125 🏁 Script executed: # Search for documentation or type hints related to SubjectFilter and getFailures()
rg "getFailures|getMessages" --type php -B 2 -A 5Repository: ray-di/Ray.WebFormModule Length of output: 986 🏁 Script executed: # Let's look for the complete context where errorMessages is used to understand the structure better
cat -n ./src/AbstractForm.php | sed -n '120,150p'Repository: ray-di/Ray.WebFormModule Length of output: 1015 🏁 Script executed: # Search for vendor/aura/filter to see if we can find the actual implementation
find . -path "*/vendor/aura/filter*" -type d 2>/dev/null | head -5Repository: ray-di/Ray.WebFormModule Length of output: 50 🏁 Script executed: # Let's check if there's any test file that shows the expected return type
rg "getFailureMessages|getMessages" --type php -B 5 -A 10 tests/Repository: ray-di/Ray.WebFormModule Length of output: 50 🌐 Web query:
💡 Result: In Aura.Filter 2.x, So the effective return type of
Sources: 🌐 Web query:
💡 Result: In Aura.Filter 2.2+, Use: $success = $filter->apply($subject);
if (! $success) {
$failures = $filter->getFailures(); // FailureCollection
$messages = $failures->getMessages(); // array of messages (keyed by field)
}This is the pattern shown in the Aura.Filter docs; Citations:
Incorrect
Proposed fix- * `@return` list<string>
+ * `@return` array<string, array<string>>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Returns all the fields collection | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @return \ArrayIterator | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function getIterator() | ||||||||||||||||||||||||||||||||||||||||||
| /** Returns all the fields collection */ | ||||||||||||||||||||||||||||||||||||||||||
| public function getIterator(): ArrayIterator | ||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||
| return new \ArrayIterator($this->inputs); | ||||||||||||||||||||||||||||||||||||||||||
| return new ArrayIterator($this->inputs); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.